• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

help with Jboss datasource lookup with springs

 
kaarthik asokkumar
Greenhorn
Posts: 29
  • Mark post as helpful
  • send pies
  • 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>
 
Mark Spritzler
ranger
Sheriff
Posts: 17278
6
IntelliJ IDE Mac Spring
  • Mark post as helpful
  • send pies
  • 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
  • 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
 
Wirianto Djunaidi
Ranch Hand
Posts: 210
Ruby Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Maybe try java:comp/env/devpfmdb or devfmdb as the jndi name value.
 
Mark Spritzler
ranger
Sheriff
Posts: 17278
6
IntelliJ IDE Mac Spring
  • Mark post as helpful
  • send pies
  • 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
  • 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
Sheriff
Posts: 17278
6
IntelliJ IDE Mac Spring
  • Mark post as helpful
  • send pies
  • 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
  • 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
Sheriff
Posts: 17278
6
IntelliJ IDE Mac Spring
  • Mark post as helpful
  • send pies
  • 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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic