permaculture playing cards*
The moose likes Spring and the fly likes Unable to lookup JNDI name - hibernate 4.1.5 , Spring 3.1.1 , JBoss 5 Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Frameworks » Spring
Bookmark "Unable to lookup JNDI name - hibernate 4.1.5 , Spring 3.1.1 , JBoss 5" Watch "Unable to lookup JNDI name - hibernate 4.1.5 , Spring 3.1.1 , JBoss 5" New topic
Author

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

suresh pandey
Greenhorn

Joined: Jul 23, 2012
Posts: 6
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

Joined: Mar 07, 2010
Posts: 1646
    
    7

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?


[How To Ask Questions][Read before you PM me]
suresh pandey
Greenhorn

Joined: Jul 23, 2012
Posts: 6
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

Joined: Mar 07, 2010
Posts: 1646
    
    7

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.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Unable to lookup JNDI name - hibernate 4.1.5 , Spring 3.1.1 , JBoss 5
 
Similar Threads
JBoss AS5 with Hibernate 3 annotations
Not able to find the added record in table.
glassfish vs. Hibernate: JNDI configuration
Tomcat application won't start with MySQL Connection Pooling
Hibernate using weblogic 10.3 Datasource