[jboss-user] [Persistence, JBoss/CMP, Hibernate, Database] - Re: Referenced datasource not found with JBoss 5.0 (Beta4)

jaikiran do-not-reply at jboss.com
Sat Apr 12 10:58:12 EDT 2008

I think what "depryf" is trying to do is, define a resource-ref named "app-specific/datasource" for the "java:/app/datasource" datasource and then use java:comp/env/app-specific/datasource as the jndi-name for looking up the datasource.


Going by the exception stacktrace, i guess this is what is happening:
anonymous wrote : 
  |  at $Proxy109.getDbColumnInfo(Unknown Source)
  |         at com.imsweb.seerdms.shared.util.PropertyMappingsUtils.initialize(PropertyMappingsUtils.jav
  | a:139)
  |         at com.imsweb.seerdms.shared.util.PropertyMappingsUtils.initialize(PropertyMappingsUtils.jav
  | a:111)
  |         at com.imsweb.seerdms.web.shared.configuration.ConfigurationServlet.init(ConfigurationServle
  | t.java:158)
  |         at javax.servlet.GenericServlet.init(GenericServlet.java:212)

anonymous wrote :  at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:629)
  |         at javax.naming.InitialContext.lookup(InitialContext.java:392)
  |         at com.imsweb.seerdms.shared.api.ServiceLocator.lookup(ServiceLocator.java:631)
  |         at com.imsweb.seerdms.shared.api.ServiceLocator.getConnection(ServiceLocator.java:597)
  |         at com.imsweb.seerdms.app.shared.dao.hibernate.HibernateCommonDataDAO.getDbColumnInfo(Hibern
  | ateCommonDataDAO.java:97)

You have a resource-ref defined in your web component, in which you have a startup servlet. This startup servlet will then have access to the java:comp/env/app-specific/datasource datasource. Based on the exception stacktrace, i can see that in the init method of your startup servlet you are looking up an EJB and invoking an method on the EJB. The EJB then (i guess through a DAO) tries to lookup the datasource using java:comp/env/app-specific/datasource jndi-name. This is not going to work because, the EJB has its own java:comp/env namespace. Since you have specified the resource-ref for your web component and not the EJB component, the java:comp/env namespace will be empty for the EJB and hence the lookup fails.

Just to verify this, you can lookup the datasource "java:comp/env/app-specific/datasource" directly in the init method of the startup servlet. I believe you should be able to successfully get the datasource. 

If you want the datasource to be available at java:comp/env namespace of the EJB, then you will have to define a resource-ref through the ejb-jar.xml and jboss.xml for the EJB.

View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4143648#4143648

Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4143648

More information about the jboss-user mailing list