[jboss-user] [EJB 3.0] - lookup datasource from ejb3 sessionbean (jboss 4.2.3)

woongiap do-not-reply at jboss.com
Wed Oct 15 06:57:07 EDT 2008


I have a requirement to setup 2 instances of same application (one for live and one for testing) running on jboss 4.2.3.GA. I don't want to run multiple instances of Jboss server since it requires changing all the listening ports, so i decided to move the "hard-coded" actual jndi name from my ejb3 sessionbean (I'm using @javax.annotation.Resource injection currently), i tried and failed to lookup the datasource using:

(in sessionbean)
Context ic = new InitialContext();
ds = (DataSource) ic.lookup("java:comp/env/jdbc/ds_name");
(ejb-jar.xml)
<enterprise-beans>
      
         <ejb-name>AdmResourceFacade</ejb-name>
         com.tims.ac.service.AdmResourceFacade         <ejb-class>com.tims.ac.service.AdmResourceFacadeImpl</ejb-class>
         <session-type>Stateless</session-type>
         <transaction-type>Container</transaction-type>
         <resource-ref>
             <res-ref-name>jdbc/ds_name</res-ref-name>
             <res-type>javax.sql.DataSource</res-type>
             <res-auth>Container</res-auth>
         </resource-ref>
      
   </enterprise-beans>
(in jboss.xml)
<enterprise-beans>

            <ejb-name>AdmResourceFacade</ejb-name>
            <resource-ref>
                <res-ref-name>jdbc/ds_name</res-ref-name>
                <jndi-name>java:/actual_ds_name</jndi-name>
            </resource-ref>
        
    </enterprise-beans>

i get javax.naming.NameNotFoundException: jdbc not bound when looking up the datasource, please help.

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

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



More information about the jboss-user mailing list