aspose file tools*
The moose likes Other Application Frameworks and the fly likes help with Jboss datasource lookup with springs Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Other Application Frameworks
Bookmark "help with Jboss datasource lookup with springs" Watch "help with Jboss datasource lookup with springs" New topic
Author

help with Jboss datasource lookup with springs

kaarthik asokkumar
Greenhorn

Joined: Jan 21, 2005
Posts: 29
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>


SCJP 1.4, SCWCD 1.4,SCBCD 1.3.
Mark Spritzler
ranger
Sheriff

Joined: Feb 05, 2001
Posts: 17259
    
    6

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


Perfect World Programming, LLC - Two Laptop Bag - Tube Organizer
How to Ask Questions the Smart Way FAQ
kaarthik asokkumar
Greenhorn

Joined: Jan 21, 2005
Posts: 29
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

Joined: Mar 20, 2001
Posts: 210

Maybe try java:comp/env/devpfmdb or devfmdb as the jndi name value.
Mark Spritzler
ranger
Sheriff

Joined: Feb 05, 2001
Posts: 17259
    
    6

Or better yet, use the jmx-console in JBoss and let JBoss just tell you the jndi location String.

Mark
kaarthik asokkumar
Greenhorn

Joined: Jan 21, 2005
Posts: 29
I am stuck at this point. i tried jmx console and used the same name but in vain..
Mark Spritzler
ranger
Sheriff

Joined: Feb 05, 2001
Posts: 17259
    
    6

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

Joined: Jan 21, 2005
Posts: 29
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

Joined: Feb 05, 2001
Posts: 17259
    
    6

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
 
 
subject: help with Jboss datasource lookup with springs