-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 5 posts ] 
Author Message
 Post subject: Hibernate JNDI failure...
PostPosted: Tue Jan 09, 2007 7:22 am 
Newbie

Joined: Fri Dec 22, 2006 2:32 pm
Posts: 16
Hello,

I am trying to set up a web application that uses Spring and Hibernate on JBoss 4.0.5. The Hibernate classes are placed inside a .HAR inside the .EAR, and referenced in jboss-app.xml.

I have placed jboss-service.xml inside the HAR:

Code:
<?xml version="1.0" encoding="UTF-8"?>
<server>
   <mbean code="org.jboss.hibernate.jmx.Hibernate" name="jboss.har:service=Hibernate">
      <depends>jboss:service=Naming</depends>
      <attribute name="DatasourceName">java:/MyDS</attribute>
      <attribute name="Dialect">org.hibernate.dialect.OracleDialect</attribute>
      <attribute name="SessionFactoryName">java:hibernate/BMSessionFactory</attribute>
      <attribute name="CacheProviderClass">org.hibernate.cache.HashtableCacheProvider</attribute>
      <attribute name="ShowSqlEnabled">true</attribute>
      <attribute name="ScanForMappingsEnabled">true</attribute>
   </mbean>
</server>               


and the following inside spring-web.xml:

Code:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "http://www.springframework.org/dtd/spring-beans.dtd">
<beans>
   <bean id="mySessionFactory" class="org.springframework.jndi.JndiObjectFactoryBean">
      <property name="jndiName" value="java:hibernate/BMSessionFactory"/>
   </bean>
   
   <bean id="svinnDao" class="com.svinn.SvinnDao">
      <property name="sessionFactory"><ref local="mySessionFactory"/></property>
   </bean>   

</beans>


When I deploy to JBoss, I get the following (important lines marked in bold):

Code:
09:49:30,533 INFO  [Configuration] Searching for mapping documents in jar: tmp28513bm.ear-1.0-SNAPSHOT.ear
09:49:30,534 INFO  [Configuration] Searching for mapping documents in jar: bm-hibernate.har
09:49:30,534 INFO  [Configuration] Searching for mapping documents in jar: bm.ejb-1.0-SNAPSHOT.jar
09:49:30,536 INFO  [NamingHelper] JNDI InitialContext properties:{}
09:49:30,539 INFO  [DatasourceConnectionProvider] Using datasource: java:/MyDS
09:49:30,539 INFO  [SettingsFactory] RDBMS: Oracle, version: Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - 64bit Production
With the Partitioning, OLAP and Data Mining options
09:49:30,539 INFO  [SettingsFactory] JDBC driver: Oracle JDBC driver, version: 10.2.0.1.0
09:49:30,540 INFO  [Dialect] Using dialect: org.hibernate.dialect.OracleDialect
09:49:30,542 INFO  [TransactionFactoryFactory] Transaction strategy: org.hibernate.transaction.JTATransactionFactory
09:49:30,543 INFO  [NamingHelper] JNDI InitialContext properties:{}
09:49:30,543 INFO  [TransactionManagerLookupFactory] instantiating TransactionManagerLookup: org.hibernate.transaction.JBossTransactionManagerLookup
09:49:30,543 INFO  [TransactionManagerLookupFactory] instantiated TransactionManagerLookup
09:49:30,543 INFO  [TransactionManagerLookupFactory] instantiating TransactionManagerLookup: org.hibernate.transaction.JBossTransactionManagerLookup
09:49:30,543 INFO  [TransactionManagerLookupFactory] instantiated TransactionManagerLookup
09:49:30,543 INFO  [SettingsFactory] Automatic flush during beforeCompletion(): enabled
09:49:30,543 INFO  [SettingsFactory] Automatic session close at end of transaction: enabled
09:49:30,543 INFO  [SettingsFactory] JDBC batch size: 15
09:49:30,543 INFO  [SettingsFactory] JDBC batch updates for versioned data: disabled
09:49:30,544 INFO  [SettingsFactory] Scrollable result sets: enabled
09:49:30,544 INFO  [SettingsFactory] JDBC3 getGeneratedKeys(): disabled
09:49:30,544 INFO  [SettingsFactory] Connection release mode: after_statement
09:49:30,544 INFO  [SettingsFactory] Default batch fetch size: 1
09:49:30,544 INFO  [SettingsFactory] Generate SQL with comments: disabled
09:49:30,544 INFO  [SettingsFactory] Order SQL updates by primary key: disabled
09:49:30,544 INFO  [SettingsFactory] Query translator: org.hibernate.hql.ast.ASTQueryTranslatorFactory
09:49:30,544 INFO  [ASTQueryTranslatorFactory] Using ASTQueryTranslatorFactory
09:49:30,544 INFO  [SettingsFactory] Query language substitutions: {}
09:49:30,544 INFO  [SettingsFactory] JPA-QL strict compliance: disabled
09:49:30,544 INFO  [SettingsFactory] Second-level cache: enabled
09:49:30,544 INFO  [SettingsFactory] Query cache: disabled
09:49:30,544 INFO  [SettingsFactory] Cache provider: org.hibernate.cache.HashtableCacheProvider
09:49:30,544 INFO  [SettingsFactory] Optimize cache for minimal puts: disabled
09:49:30,545 INFO  [SettingsFactory] Structured second-level cache entries: disabled
09:49:30,545 INFO  [SettingsFactory] Echoing all SQL to stdout
09:49:30,545 INFO  [SettingsFactory] Statistics: disabled
09:49:30,545 INFO  [SettingsFactory] Deleted entity synthetic identifier rollback: disabled
09:49:30,545 INFO  [SettingsFactory] Default entity-mode: pojo
09:49:30,549 INFO  [SessionFactoryImpl] building session factory
[b]09:49:30,549 INFO  [SessionFactoryObjectFactory] Not binding factory to JNDI, no JNDI name configured[/b]
09:49:30,549 INFO  [NamingHelper] JNDI InitialContext properties:{}
[b]09:49:30,550 INFO  [Hibernate] SessionFactory successfully built and bound into JNDI [java:hibernate/BMSessionFactory][/b]


Then, further down I get this Exception:

Code:
[b]09:49:31,102 ERROR [ContextLoader] Context initialization failed
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'mySessionFactory' defined in ServletContext resource [/WEB-INF/spring-web.xml]: Initialization of bean failed; nested exception is javax.naming.NamingException: JNDI object with [java:hibernate/BMSessionFactory] not found: JNDI implementation returned null
[/b]javax.naming.NamingException: JNDI object with [java:hibernate/BMSessionFactory] 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)
...
...


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jan 09, 2007 9:48 am 
Regular
Regular

Joined: Thu Aug 17, 2006 4:50 am
Posts: 55
Location: Mallorca
check you do not need an JndiName attribute in you MBean.

Code:
<attribute name="JndiName">java:hibernate/BMSessionFactory</attribute>


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jan 09, 2007 9:56 am 
Newbie

Joined: Fri Dec 22, 2006 2:32 pm
Posts: 16
Thank you for your reply!

Adding this, I get the following error:

Code:
14:53:52,835 INFO  [ServiceConfigurator] Problem configuring service jboss.har:service=Hibernate
org.jboss.deployment.DeploymentException: No Attribute found with name: jndiName


I treid with JndiName and JNDIName as well...

dominicus wrote:
check you do not need an JndiName attribute in you MBean.

Code:
<attribute name="JndiName">java:hibernate/BMSessionFactory</attribute>


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jan 09, 2007 10:02 am 
Regular
Regular

Joined: Thu Aug 17, 2006 4:50 am
Posts: 55
Location: Mallorca
yes .... jndi name was for the previous JBoss release...

try changing the jndi name from

Code:
java:hibernate/BMSessionFactory


to

Code:
java:[b]/[/b]hibernate/BMSessionFactory


both in the mbean and in the spring definition. Maybe the first one is not legal...


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jan 09, 2007 10:16 am 
Newbie

Joined: Fri Dec 22, 2006 2:32 pm
Posts: 16
Thanks for your reply!

I have tried any possible combinations of

java:/hibernate/BMSessionFactory
java:/hibernate/SessionFactory
hibernate/BMSessionFactory
hibernate/SessionFactory
java:BMSessionFactory
java:/BMSessionFactory
...
etc.

I am totally confused, as the log does state that the SessionFactory is bound, but that doesnt appear to be so...

dominicus wrote:
yes .... jndi name was for the previous JBoss release...

try changing the jndi name from

Code:
java:hibernate/BMSessionFactory


to

Code:
java:[b]/[/b]hibernate/BMSessionFactory


both in the mbean and in the spring definition. Maybe the first one is not legal...


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 5 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.