PDA

View Full Version : JNDI Lookup Broken


gigsvoo
May 4th, 2006, 05:14 AM
Hi there,

I had deployed HAR using JBoss MBean approach and it works properly. The problem now is when I uses WEB-IND\applicationContext.xml to point the JNDI registered, then error bounced.

Here is the applicationContext.xml snipplet:

<!-- JCA connector configuration -->
<bean id="sessionFactory" class="org.springframework.jndi.JndiObjectFactoryBean">
<property name="jndiName" value="java:/hibernate/SessionFactory"/>
<!--<property name="lookupOnStartup" value="false"/>
<property name="cache" value="true"/>
<property name="proxyInterface" value="javax.sql.DataSource"/>-->
</bean>

This is the stack trade that shows JNDI being registered and being destroyed once Spring lookup thru web container:

2006-05-04 16:54:03,109 INFO [org.jboss.hibernate.jmx.Hibernate] SessionFactory successfully built and bound into JNDI [java:/hibernate/SessionFactory]
2006-05-04 16:54:03,109 DEBUG [org.jboss.hibernate.jmx.Hibernate] Started jboss.har:service=Hibernate
...
2006-05-04 16:54:07,234 DEBUG [org.springframework.beans.factory.support.DefaultL istableBeanFactory] Eagerly caching bean with name 'sessionFactory' to allow for resolving potential circular references
2006-05-04 16:54:07,234 DEBUG [org.springframework.beans.factory.support.DefaultL istableBeanFactory] Not autowiring property 'jndiEnvironment' of bean 'sessionFactory' by name: no matching bean found
2006-05-04 16:54:07,234 DEBUG [org.springframework.beans.factory.support.DefaultL istableBeanFactory] Not autowiring property 'jndiTemplate' of bean 'sessionFactory' by name: no matching bean found
2006-05-04 16:54:07,234 DEBUG [org.springframework.beans.BeanWrapperImpl] About to invoke write method [public void org.springframework.jndi.JndiObjectLocator.setJndi Name(java.lang.String)] on object of class [org.springframework.jndi.JndiObjectFactoryBean]
2006-05-04 16:54:07,234 DEBUG [org.springframework.beans.BeanWrapperImpl] Invoked write method [public void org.springframework.jndi.JndiObjectLocator.setJndi Name(java.lang.String)] with value of type [java.lang.String]
2006-05-04 16:54:07,234 DEBUG [org.springframework.beans.factory.support.DefaultL istableBeanFactory] Invoking BeanPostProcessors before initialization of bean 'sessionFactory'
2006-05-04 16:54:07,234 DEBUG [org.springframework.beans.factory.support.DefaultL istableBeanFactory] Invoking afterPropertiesSet() on bean with name 'sessionFactory'
2006-05-04 16:54:07,234 DEBUG [org.springframework.jndi.JndiTemplate] Looking up JNDI object with name [java:/hibernate/SessionFactory]
2006-05-04 16:54:07,265 DEBUG [org.hibernate.impl.SessionFactoryObjectFactory] initializing class SessionFactoryObjectFactory
2006-05-04 16:54:07,265 DEBUG [org.hibernate.impl.SessionFactoryObjectFactory] JNDI lookup: hibernate/SessionFactory
2006-05-04 16:54:07,265 DEBUG [org.hibernate.impl.SessionFactoryObjectFactory] lookup: uid=8a82813c0afe9a2a010afe9a90550000
2006-05-04 16:54:07,265 WARN [org.hibernate.impl.SessionFactoryObjectFactory] Not found: 8a82813c0afe9a2a010afe9a90550000
2006-05-04 16:54:07,265 DEBUG [org.hibernate.impl.SessionFactoryObjectFactory] {}
2006-05-04 16:54:07,265 DEBUG [org.springframework.beans.factory.support.DefaultL istableBeanFactory] Retrieving dependent beans for bean 'sessionFactory'
2006-05-04 16:54:07,265 INFO [org.springframework.beans.factory.support.DefaultL istableBeanFactory] Destroying singletons in factory {org.springframework.beans.factory.support.Default ListableBeanFactory defining beans [sessionFactory,gov.mohr.ems.core.entity.logic.Defa ultQueryMethod,gov.mohr.ems.core.entity.logic.ORME ngine]; root of BeanFactory hierarchy}
2006-05-04 16:54:07,281 ERROR [org.springframework.web.context.ContextLoader] Context initialization failed
org.springframework.beans.factory.BeanCreationExce ption: Error creating bean with name 'sessionFactory' defined in ServletContext resource [/WEB-INF/applicationcontext.xml]: Initialization of bean failed; nested exception is javax.naming.NamingException: JNDI object with [java:/hibernate/SessionFactory] not found: JNDI implementation returned null
javax.naming.NamingException: JNDI object with [java:/hibernate/SessionFactory] not found: JNDI implementation returned null
at org.springframework.jndi.JndiTemplate$1.doInContex t(JndiTemplate.java:125)
at org.springframework.jndi.JndiTemplate.execute(Jndi Template.java:85)
at org.springframework.jndi.JndiTemplate.lookup(JndiT emplate.java:121)
at org.springframework.jndi.JndiTemplate.lookup(JndiT emplate.java:146)

Please help, me now is near due date.

Costin Leau
May 6th, 2006, 02:46 PM
The message can be misleading - the context is closed before the error is displayed (in a finally block). Make sure the hibernate SF is really under java:/hibernate/SessionFactory - you can verify this with the jmx console under jboss.
Then make sure that the jndi template is looking at that address and does not append com/env to it - this has/is the source of a lot of problems when working with jndi - turn on logging to see what exactly is going on.

gigsvoo
May 17th, 2006, 03:40 AM
The problem has been solved by placing the right HAR file in the application.xml of EAR file. Thanks alot.

chikaiwang
May 17th, 2006, 07:55 AM
I encountered the same problem, would you give me your detail configuration right HAR file in the application.xml of EAR file?

gigsvoo
May 17th, 2006, 07:59 AM
under your EAR file META-INF\application.xml, you need to have the entry of:


...
<module>
<java>entity.har</java>
</module>
...