This week's book giveaways are in the Refactoring and Agile forums.
We're giving away four copies each of Re-engineering Legacy Software and Docker in Action and have the authors on-line!
See this thread and this one for details.
Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Unable to lookup JNDI name - hibernate 4.1.5 , Spring 3.1.1 , JBoss 5

 
suresh pandey
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I am getting the error "nested exception is org.hibernate.service.jndi.JndiException: Unable to lookup JNDI name" while using hibernate with spring for jboss.

hibernate -config is

<hibernate-configuration>

<session-factory >
<property name="connection.pool_size">10</property>
<property name="hibernate.dialect">org.hibernate.dialect.MySQLDialect</property>
<property name="connection.datasource">ScionDS</property>
<property name="show_sql">true</property>
<property name="hbm2ddl.auto">create</property>

<mapping class="com.tms.efc.configuratoradmin.entity.Employee" />

</session-factory>


</hibernate-configuration>


application-context is

<bean id="sessionFactory" class="org.springframework.orm.hibernate4.LocalSessionFactoryBean">
<property name="configLocation" value="classpath:config/hibernate-config.xml"/>
</bean>


I have configured the data soucre on jboss.

Thanks
 
Bill Gorder
Bartender
Posts: 1682
7
Android IntelliJ IDE Linux Mac OS X Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please UseCodeTags when posting code or configuration.

I am going to move this to the Spring forum as it appears to be a Spring configuration issue.

Where is your datasource configured in your application context?
 
suresh pandey
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well the problem has been solved, data source is configure on JBoss server. Actually JBoss internally append 'java:' with the JNDI name so if you have configured JNDI name as 'ScioDS' you need to access it using 'java:ScionDS'.


Thanks
 
Bill Gorder
Bartender
Posts: 1682
7
Android IntelliJ IDE Linux Mac OS X Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
OK that was my mistake I missed that you had set this property.



Yeah they all have to be different with the jndi binding

The more typical is java:comp/env/

With the code you are currently having it may not be portable to other major application servers. This may or may not be an issue for you.

You might find this useful:
https://community.jboss.org/thread/121272?tstart=0#4084585

Thanks for posting back with your solution.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic