Hi, I need some help configuring Glassfish-managed DataSource for XWiki Enterprise (stable 2.1.1).
In short, does anyone know how to tweak WEB-INF/hibernate.cfg.xml so that Hibernate uses a JNDI resource that has been configured in Glassfish? (for instance, i've defined jdbc/xwiki in Glassfish and would like Hibernate to use it instead of the settings provided inside WEB-INF/hibernate.cfg.xml). The long version: I'm trying to do a manual installation (as in: http://platform.xwiki.org/xwiki/bin/view/AdminGuide/Installation#HInstallingtheXWikiWARmanually ) on a Glassfish v3 app server, and would like to use a Glassfish managed datasource (let's say using JNDI jdbc/xwiki as javax.sql.DataSource). I haven't found explicit details on how to do this, so i started by commenting out line xwiki.store.hibernate.path=/WEB-INF/hibernate.cfg.xml inside file WEB-INF/xwiki.cfg and uncommenting the following inside WEB-INF/web.xml so that it's used instead: <resource-ref> <description>DB Connection</description> <res-ref-name>jdbc/xwiki</res-ref-name> <res-type>javax.sql.DataSource</res-type> <res-auth>Container</res-auth> </resource-ref> But this gave me the following error when, after deploying to Glassfish, i tried to go to http://localhost:8080/xwiki/bin/view/Main/ >HTTP Status 500 - >type Exception report > >message > >descriptionThe server encountered an internal error () that prevented >it from fulfilling this request. > >exception > >javax.servlet.ServletException: com.xpn.xwiki.XWikiException: Error number 3 >in 0: Could not initialize main XWiki context >Wrapped Exception: Error number 3001 in 3: Cannot load class >com.xpn.xwiki.store.migration.hibernate.XWikiHibernateMigrationManager from >param xwiki.store.migration.manager.class >Wrapped Exception: Error number 0 in 3: Exception while hibernate execute >Wrapped Exception: Hibernate Dialect must be explicitly set > >root cause > >com.xpn.xwiki.XWikiException: Error number 3 in 0: Could not initialize main >XWiki context >Wrapped Exception: Error number 3001 in 3: Cannot load class >com.xpn.xwiki.store.migration.hibernate.XWikiHibernateMigrationManager from >param xwiki.store.migration.manager.class >Wrapped Exception: Error number 0 in 3: Exception while hibernate execute >Wrapped Exception: Hibernate Dialect must be explicitly set Glassfish logs contain the following two logs of this error: >53:44,236 [http://localhost:8080/xwiki/bin/view/Main/] WARN >UserSuppliedConnectionProvider - No connection properties specified - >the user must supply JDBC connections and also >53:44,269 [http://localhost:8080/xwiki/bin/view/Main/] WARN >action.RequestProcessor - Unhandled Exception thrown: class >com.xpn.xwiki.XWikiException They seem to show that i need to use WEB-INF/hibernate.xml.cfg to set up the proper vendor Dialect So i modified WEB-INF/xwiki.cfg so to use the line: xwiki.store.hibernate.path=/WEB-INF/hibernate.cfg.xml Then, inside WEB-INF/hibernate.cfg.xml i ONLY uncommented the line <property name="dialect">org.hibernate.dialect.MySQLDialect</property> keeping all others (connection.username, connection.password ...) commented so to check that the ones provided by Glassfish are being used instead. After undeploying previous and deploying this modified version i get a different error when trying to visit http://localhost:8080/xwiki/bin/view/Main >HTTP Status 500 - >type Exception report >message > >descriptionThe server encountered an internal error () that prevented >it from fulfilling this request. > >exception > >javax.servlet.ServletException: com.xpn.xwiki.XWikiException: Error number 3 >in 0: Could not initialize main XWiki context >Wrapped Exception: Error number 3001 in 3: Cannot load class >com.xpn.xwiki.store.migration.hibernate.XWikiHibernateMigrationManager from >param xwiki.store.migration.manager.class >Wrapped Exception: Error number 0 in 3: Exception while hibernate execute >Wrapped Exception: Errors in named queries: listGroupsForUser, >getSpaceDocsName, getAllUsers, getAllDocuments, getSpaces, >getAllPublicDocuments, getAllSpaceDocuments > >root cause > >com.xpn.xwiki.XWikiException: Error number 3 in 0: Could not initialize main >XWiki context >Wrapped Exception: Error number 3001 in 3: Cannot load class >com.xpn.xwiki.store.migration.hibernate.XWikiHibernateMigrationManager from >param xwiki.store.migration.manager.class >Wrapped Exception: Error number 0 in 3: Exception while hibernate execute >Wrapped Exception: Errors in named queries: listGroupsForUser, >getSpaceDocsName, getAllUsers, getAllDocuments, getSpaces, >getAllPublicDocuments, getAllSpaceDocuments > And in Glassfish logs: >19:04,638 [http://localhost:8080/xwiki/bin/view/Main/] WARN >UserSuppliedConnectionProvider - No connection properties specified - >the user must supply JDBC connections and seven more like this one (i truncated the whole stack) that match the errors in named queries reported above (listGroupsForUser, getSpaceDocsName,getAllUsers,getAllDocuments,getSpaces,getAllPublicDocuments and getAllSpaceDocuments) : >19:05,013 [http://localhost:8080/xwiki/bin/view/Main/] ERROR >impl.SessionFactoryImpl - Error in named query: listGroupsForUser >org.hibernate.hql.ast.QuerySyntaxException: XWikiDocument is not mapped >[ select distinct doc.fullName from XWikiDocument as doc, BaseObject as >obj, StringProperty as prop where obj.name = doc.fullName and >obj.className='XWiki.XWikiGroups' and obj.id = prop.id.id and >prop.id.name='member' and (prop.value=:username or >prop.value=:shortname or prop.value=:veryshortname) ] This time the errors seem related to the searches themselves... I think that what might be happening is that Hibernate is not really configured to be using Glassfish datasource, but instead it expects to use the connection.username, connection.password, connection.driver_class, connection.pool_size ... properties defined in WEB-INF/hibernate.cfg.xml that i've commented out because i'd like to use Glassfish-configured datasource. I need help, so as to keep the properties that Hibernate reads from WEB-INF/hibernate.cfg.xml to a minimum and pointing it to Glassfish-defined JNDI resource instead. Thank you very much ! Guillem Plasencia _______________________________________________ devs mailing list [email protected] http://lists.xwiki.org/mailman/listinfo/devs

