Hibernate version: Hibernate 2.1.8
Sun JDK version: 1.5.0_04
JBoss version: 4.0.5
Spring version: 2.0.3
JBoss Deployer version: hibernate2-deployer.zip from
http://wiki.jboss.org/wiki/Wiki.jsp?pag ... eSwitching
I have an application with EJB 2.1, Spring 2.0.3 and hibernate 2.1.8, that I must port from JBoss 3.1.X to JBoss 4.0.5 due clustering improvement.
The problem that is annoying me is that, despite of several deployment alternatives tried, I always got a null SessionFactory reference from JBoss JNDI retrieval even with the Hibernate MBean visible on JBoss-Console.
In this task I have followed the JBoss Wiki entries (above), the recomendations from JBOss 4 Official Book and a series of posts here regarding JBoss 4.0.2 and 4.0.5.
Actually I have the following structure:
Code:
deploy
-app.ear
--META-INF
---application.xml
---jboss-app.xml
--app.war
---WEB-INF
----web.xml
----jboss-web.xml
--app.jar
---META-INF
----ejb-jar.xml
----jboss.xml
-app-hib.har
--META-INF
---hibernate-service.xml
-app-ds.xml
In current version de HAR app-hib.har is jared. Other structures are exploded. I already tried an har deployment inside app.ear without success.
I used <resource-ref> settings in all descriptors, canonical ones and JBoss proprietary ones.
Regarding jboss-hibernate.deployer, I remount it with the last versions of hibernate and CGLIB.
Follow the configuration files, the SessionFactory initialization and JNDI retrieve logs. Any help will be a lot appreciate.
hibernate-service.xmlCode:
<?xml version="1.0" encoding="ISO-8859-1"?>
<server>
<loader-repository>
com.example:loader=unique-archive-name
<loader-repository-config>java2ParentDelegation=false</loader-repository-config>
</loader-repository>
<mbean code="org.jboss.hibernate.jmx.Hibernate" name="jboss.har:service=Hibernate">
<depends>jboss:service=Naming</depends>
<depends>jboss:service=TransactionManager</depends>
<attribute name="DatasourceName">java:/IntranetDS</attribute>
<attribute name="Dialect">net.sf.hibernate.dialect.OracleDialect</attribute>
<attribute name="SessionFactoryName">java:/hibernate/SessionFactory</attribute>
<attribute name="CacheProviderClass">net.sf.hibernate.cache.HashtableCacheProvider</attribute>
<attribute name="QuerySubstitutions">true=1, false=0</attribute>
</mbean>
</server>
Spring JNDI retrieve declaration:Code:
<bean id="sessionFactory" class="org.springframework.jndi.JndiObjectFactoryBean">
<property name="resourceRef" value="true"/>
<property name="cache" value="false"/>
<property name="jndiName" value="java:/hibernate/SessionFactory"/>
<property name="lookupOnStartup" value="false"/>
<property name="proxyInterface" value="net.sf.hibernate.SessionFactory"/>
</bean>
MBean instantiation seams ok:Code:
2007-04-10 21:32:43,359 INFO [net.sf.hibernate.dialect.Dialect] Using dialect: net.sf.hibernate.dialect.OracleDialect
2007-04-10 21:32:43,375 INFO [net.sf.hibernate.cfg.SettingsFactory] Use outer join fetching: true
2007-04-10 21:32:43,390 INFO [net.sf.hibernate.util.NamingHelper] JNDI InitialContext properties:{}
2007-04-10 21:32:43,390 INFO [net.sf.hibernate.connection.DatasourceConnectionProvider] Using datasource: java:/IntranetDS
2007-04-10 21:32:43,390 INFO [net.sf.hibernate.transaction.TransactionFactoryFactory] Transaction strategy: net.sf.hibernate.transaction.JTATransactionFactory
2007-04-10 21:32:43,390 INFO [net.sf.hibernate.util.NamingHelper] JNDI InitialContext properties:{}
2007-04-10 21:32:43,390 INFO [net.sf.hibernate.transaction.TransactionManagerLookupFactory] instantiating TransactionManagerLookup: net.sf.hibernate.transaction.JBossTransactionManagerLookup
2007-04-10 21:32:43,390 INFO [net.sf.hibernate.transaction.TransactionManagerLookupFactory] instantiated TransactionManagerLookup
2007-04-10 21:32:43,390 INFO [net.sf.hibernate.util.NamingHelper] JNDI InitialContext properties:{}
2007-04-10 21:32:43,390 INFO [net.sf.hibernate.transaction.TransactionManagerLookupFactory] instantiating TransactionManagerLookup: net.sf.hibernate.transaction.JBossTransactionManagerLookup
2007-04-10 21:32:43,406 INFO [net.sf.hibernate.transaction.TransactionManagerLookupFactory] instantiated TransactionManagerLookup
2007-04-10 21:32:44,078 INFO [net.sf.hibernate.cfg.SettingsFactory] Use scrollable result sets: true
2007-04-10 21:32:44,078 INFO [net.sf.hibernate.cfg.SettingsFactory] Use JDBC3 getGeneratedKeys(): false
2007-04-10 21:32:44,078 INFO [net.sf.hibernate.cfg.SettingsFactory] Optimize cache for minimal puts: false
2007-04-10 21:32:44,078 INFO [net.sf.hibernate.cfg.SettingsFactory] Query language substitutions: {true=1, false=0}
2007-04-10 21:32:44,078 INFO [net.sf.hibernate.cfg.SettingsFactory] cache provider: net.sf.hibernate.cache.HashtableCacheProvider
2007-04-10 21:32:44,078 INFO [net.sf.hibernate.cfg.Configuration] instantiating and configuring caches
2007-04-10 21:32:44,250 INFO [net.sf.hibernate.impl.SessionFactoryImpl] building session factory
2007-04-10 21:32:51,468 DEBUG [net.sf.hibernate.impl.SessionFactoryObjectFactory] initializing class SessionFactoryObjectFactory
2007-04-10 21:32:51,468 DEBUG [net.sf.hibernate.impl.SessionFactoryObjectFactory] registered: 2c90841c11de0e800111de0e9d0c0000 (java:/hibernate/SessionFactory)
2007-04-10 21:32:51,468 INFO [net.sf.hibernate.impl.SessionFactoryObjectFactory] Factory name: java:/hibernate/SessionFactory
2007-04-10 21:32:51,468 INFO [net.sf.hibernate.util.NamingHelper] JNDI InitialContext properties:{}
2007-04-10 21:32:51,468 INFO [net.sf.hibernate.util.NamingHelper] Creating subcontext: hibernate
2007-04-10 21:32:51,468 INFO [net.sf.hibernate.impl.SessionFactoryObjectFactory] Bound factory to JNDI name: java:/hibernate/SessionFactory
2007-04-10 21:32:51,468 WARN [net.sf.hibernate.impl.SessionFactoryObjectFactory] InitialContext did not implement EventContext
2007-04-10 21:32:51,468 INFO [net.sf.hibernate.util.NamingHelper] JNDI InitialContext properties:{}
But I got Problems on Session Factory JNDI Lookup: Code:
2007-04-10 21:33:31,203 DEBUG [net.sf.hibernate.impl.SessionFactoryObjectFactory] initializing class SessionFactoryObjectFactory
2007-04-10 21:33:31,218 DEBUG [net.sf.hibernate.impl.SessionFactoryObjectFactory] JNDI lookup: hibernate/SessionFactory
2007-04-10 21:33:31,218 DEBUG [net.sf.hibernate.impl.SessionFactoryObjectFactory] lookup: uid=2c90841c11de0e800111de0e9d0c0000
2007-04-10 21:33:31,218 WARN [net.sf.hibernate.impl.SessionFactoryObjectFactory] Not found: 2c90841c11de0e800111de0e9d0c0000
2007-04-10 21:33:31,218 DEBUG [net.sf.hibernate.impl.SessionFactoryObjectFactory] {}
2007-04-10 21:33:31,218 ERROR [org.apache.catalina.core.ContainerBase.[jboss.web].[localhost].[/intranet].[login]] Servlet.service() for servlet login threw exception
org.springframework.jndi.JndiLookupFailureException: JndiObjectTargetSource failed to obtain new target object; nested exception is javax.naming.NameNotFoundException: JNDI object with [java:/hibernate/SessionFactory] not found: JNDI implementation returned null
Caused by:
javax.naming.NameNotFoundException: JNDI object with [java:/hibernate/SessionFactory] not found: JNDI implementation returned null
at org.springframework.jndi.JndiTemplate$1.doInContext(JndiTemplate.java:125)
at org.springframework.jndi.JndiTemplate.execute(JndiTemplate.java:85)
at org.springframework.jndi.JndiTemplate.lookup(JndiTemplate.java:121)
at org.springframework.jndi.JndiTemplate.lookup(JndiTemplate.java:146)
at org.springframework.jndi.JndiLocatorSupport.lookup(JndiLocatorSupport.java:91)
at org.springframework.jndi.JndiObjectLocator.lookup(JndiObjectLocator.java:105)
at org.springframework.jndi.JndiObjectTargetSource.getTarget(JndiObjectTargetSource.java:118)
at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:182)
at $Proxy283.openSession(Unknown Source)
at org.springframework.orm.hibernate.SessionFactoryUtils.getSession(SessionFactoryUtils.java:282)
at org.springframework.orm.hibernate.SessionFactoryUtils.getSession(SessionFactoryUtils.java:194)
at org.springframework.orm.hibernate.support.OpenSessionInViewFilter.openSession(OpenSessionInViewFilter.java:252)
at org.springframework.orm.hibernate.support.OpenSessionInViewFilter.getSession(OpenSessionInViewFilter.java:234)
at com.hoepers.intranet.util.spring.SessionFilter.getSession(SessionFilter.java:13)
at org.springframework.orm.hibernate.support.OpenSessionInViewFilter.doFilterInternal(OpenSessionInViewFilter.java:157)
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:77)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)
at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:175)
at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:74)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
at org.jboss.web.tomcat.tc5.jca.CachedConnectionValve.invoke(CachedConnectionValve.java:156)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:869)
at org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:664)
at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527)
at org.apache.tomcat.util.net.MasterSlaveWorkerThread.run(MasterSlaveWorkerThread.java:112)
at java.lang.Thread.run(Thread.java:595)
Thank you in advance.