I have a .jsp page calling a bean using a datasource configured with MySQL.
I get this 'Agency not bound' error when trying to do a jndi lookup. I have no idea why this is not working. This is the error I get in the .jsp page.
Error exception:
java.rmi.ServerException: Bean exception. Notify the application administrator; nested exception is:
javax.ejb.EJBException: AgencyBean: Error connecting to java:/comp/env/jdbc/Agency:
javax.naming.NameNotFoundException: Agency not bound; CausedByException is:
Agency not bound
at org.jboss.ejb.plugins.LogInterceptor.handleException(LogInterceptor.java:212)
This is the pertinent sections I see in the jmx-console.
jmx-console info:
Operation list Results
Back to Agent View
Back to MBean View
--------------------------------------------------------------------------------
Ejb Module: file%/C%/JBoss/server/default/tmp/deploy/server/default/deploy/agency.ear/80.agency.ear-contents/agency.jar
java:comp namespace of the Agency bean:
+- UserTransaction (class: javax.transaction.UserTransaction)
+- env (class: org.jnp.interfaces.NamingContext)
| +- jdbc (class: org.jnp.interfaces.NamingContext)
| | +- agencyDS[link -> java:/agencyDS] (class: javax.naming.LinkRef)
java: Namespace
+- DefaultDS (class: org.jboss.resource.adapter.jdbc.local.LocalDataSource)
+- agencyDS (class: org.jboss.resource.adapter.jdbc.local.LocalDataSource)
This is the code in my bean that I am using to do the lookup.
In bean code:
dataSource = (DataSource)ic1.lookup("java:/comp/env/jdbc/Agency");
Thanks
Am i missing something but this
| | +- agencyDS[link -> java:/agencyDS] (class: javax.naming.LinkRef
is not
java:/comp/env/jdbc/Agency
Or am i stupid