Feb 13 2011

Still using Jetty for the J2EE container, but now we are running Hibernate against Oracle instead of Hibernate's HQLDB.

At first,I could not get the hibernate.cfg.xml to work with a schema name/password other than the default (xwiki).  The config file is read, but the username and password properties are not honored for DDL statements (like those run on first XWiki startup when the XWiki database schema is empty).

If I used xwiki for the Oracle schema username, Hibernate persistence works as expected.  If I used another schema name, i.e. wiki27, stdout and the client web browser show Java Exceptions like: 

java.sql.SQLSyntaxErrorException: ORA-00942: table or view does not exist
java.sql.SQLSyntaxErrorException: ORA-01031: insufficient privileges

Examination of xwiki.log revealed the root cause:

2011-02-21 10:19:33,419 [http://localhost:8080/xwiki/bin/import/XWiki/XWikiPreferences] ERROR store.XWikiHibernateBaseStore   - Failed updating schema while executing query [create table xwiki.activitystream_events (ase_eventid varchar2(255 char) not null, ase_requestid varchar2(2000 char), ase_stream varchar2(255 char), ase_date timestamp, ase_priority number(10,0), ase_type varchar2(255 char), ase_application varchar2(255 char), ase_user varchar2(255 char), ase_wiki varchar2(255 char), ase_space varchar2(255 char), ase_page varchar2(255 char), ase_url varchar2(2000 char), ase_title varchar2(2000 char), ase_body varchar2(2000 char), ase_version varchar2(30 char), ase_param1 varchar2(2000 char), ase_param2 varchar2(2000 char), ase_param3 varchar2(2000 char), ase_param4 varchar2(2000 char), ase_param5 varchar2(2000 char), primary key (ase_eventid))]
java.sql.SQLSyntaxErrorException: ORA-01918: user 'XWIKI' does not exist

It turns out some XWiki persistence component, possibly related to the virtual wiki support, specifies fully-qualified schema.table names in DDL statements and is hardcoded to xwiki for the schema name.  The username property in the Oracle section of hibernate.cfg is honored for logging in to the database, but not for subsequent DDL.  So the XWiki database session is trying to create a table in another user's schema.


The workaround is to force the schema name in the xwiki.cfg file.  E.g. to use a oracle schema name of xwiki27:

#-# [Since 1.6M1]

#-# Force the database name for the main wiki in virtual mode and for the wiki itself in non virtual mode.

# xwiki.db=xwiki


Created by Quentin Conner on 08/01/2013
This website content is not licensed to you. All rights reserved.
XWiki Enterprise 9.11.1 - Documentation