• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Paul Clapham
  • Ron McLeod
Sheriffs:
  • Jeanne Boyarsky
  • Liutauras Vilda
Saloon Keepers:
  • Tim Holloway
  • Carey Brown
  • Roland Mueller
  • Piet Souris
Bartenders:

help with Jboss datasource lookup with springs

 
Greenhorn
Posts: 29
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi all
I am trying to use springs JndiObjectFactoryBean to get a datasource connection through Jboss connection pool. When ever i do so i get an error java: not bound on starting my application. When i remove the the spring initialization server starts up fine and binds my data source correctly. My thought was spring is loaded before Jboss binds the datasource to a JNDI. Any help would really be appreciated.

Below are some of my configs
jboss-web.xml
<resource-ref>
<description>DB Connection</description>
<res-ref-name>devpfmdb</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<jndi-name>java evpfmdb</jndi-name>
<res-auth>Container</res-auth>
</resource-ref>
web.xml
<resource-ref>
<description>DB Connection</description>
<res-ref-name>devpfmdb</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<res-auth>Container</res-auth>
</resource-ref>
Bean config
<bean id="datasource" class ="org.springframework.jndi.JndiObjectFactoryBean">
<property name="jndiName">
<value>java evpfmdb</value>
</property>
</bean>
 
ranger
Posts: 17347
11
Mac IntelliJ IDE Spring
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Data sources are loaded before war files in JBoss. My question is whether your jndi string to look it up is correct or not? The best way to see is to check in the jmx-console, find the datasouce and go into it to see the jndi path, and use that string.

Mark
 
kaarthik asokkumar
Greenhorn
Posts: 29
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
When i dont use spring config below code line works
DataSource envCtx = (DataSource) initCtx.lookup("java:/devpfmdb");

however if i use the spring config below it throw an exception at start up.

<bean id="datasource" class =org.springframework.jndi.JndiObjectFactoryBean>
<property name="jndiName">
<value>java:/devpfmdb</value>
</property>
</bean>
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'datasource' defined in ServletContext resource [/WEB-INF/applicationContext.xml]: Invocation of init method failed; nested exception is javax.naming.NameNotFoundException: java: not bound
 
Ranch Hand
Posts: 218
VI Editor Ruby Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Maybe try java:comp/env/devpfmdb or devfmdb as the jndi name value.
 
Mark Spritzler
ranger
Posts: 17347
11
Mac IntelliJ IDE Spring
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Or better yet, use the jmx-console in JBoss and let JBoss just tell you the jndi location String.

Mark
 
kaarthik asokkumar
Greenhorn
Posts: 29
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am stuck at this point. i tried jmx console and used the same name but in vain..
 
Mark Spritzler
ranger
Posts: 17347
11
Mac IntelliJ IDE Spring
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yep it looks like this



Where you just have to make sure that the value for the jndiName is what you copied from the jndi-name property you got from the jmx-console.

Are there any typos anywhere in your configuration? or in the definition of the DataSource? Missing capitalization?

Mark
 
kaarthik asokkumar
Greenhorn
Posts: 29
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
thanks mark i think i found the issue. The property that was giving a problem was <value> java:/devpfmdb</value> changed it to value>java:/devpfmdb</value>
it worked. An extra space cost an extra day.
 
Mark Spritzler
ranger
Posts: 17347
11
Mac IntelliJ IDE Spring
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by kaarthik asokkumar:
thanks mark i think i found the issue. The property that was giving a problem was <value> java:/devpfmdb</value> changed it to value>java:/devpfmdb</value>
it worked. An extra space cost an extra day.



Yep, we didn't see the extra space either.

Mark
reply
    Bookmark Topic Watch Topic
  • New Topic