Hi,

I would like to declare a datasource and retrieve it from one of my EJB. the 
EJB 1.1 recommends to reference a datasource from "jbdc/myDatasource" in the 
deployment file of the EJB and then get the datasource from 
"java:comp/env/jdbc/Datasource".

Since now, I didn't succeed to respect this recommendation with JBoss (I'm 
more familiarize with Weblogic); I catch a NamingException when I call the 
lookup method with "java:comp/env/jdbc/myDataSource" as parameter (it works 
when I call the lookup method with "java:/myDataSource", but I break the EJB 
recommendation).

I trie to get some information from the JBoss documentation 
(http://www.jboss.org/documentation/HTML/ch06.html), or some examples, but I 
didn't find anything that can help me.

Could you please, give me a simple example with some simple jboss.jcml, 
ejb-jar.xml, jboss.xml and myBean.java files ?

Thanks,


Daniel



P.S.: Here my files are!

 ejb-jar.xml:
 ------------
 (...)
   <enterprise-beans>
     <session>
       <ejb-name>myEJB</ejb-name>
       <home>com.infusio.gamezilla.ejb.bean.util.myEJBHome</home>
       <remote>com.infusio.gamezilla.ejb.bean.util.myEJB</remote>
       <ejb-class>com.infusio.gamezilla.ejb.bean.util.myEJBBean</ejb-class>
       <session-type>Stateless</session-type>
       <transaction-type>Container</transaction-type>

       <resource-ref>
         <res-ref-name>jdbc/myDataSource</res-ref-name>
         <res-type>javax.sql.DataSource</res-type>
         <res-auth>Container</res-auth>
       </resource-ref>
     </session>
   </enterprise-beans>
 (...)


 jboss.xml:
 ----------
   <enterprise-beans>
     <session>
       <ejb-name>myEJB</ejb-name>
       <jndi-name>ejb/myEJB</jndi-name>

       <resource-ref>
         <res-ref-name>jdbc/myDataSource</res-ref-name>
         <resource-name>myDataSource</resource-name>
         <res-auth>Container</res-auth>
       </resource-ref>
     </session>

     <resource-managers>
       <resource-manager>
         <res-name>myDataSource</res-name>
         <res-jndi-name>java:/myDataSource</res-jndi-name>
       </resource-manager>
     </resource-managers>
   </enterprise-beans>


 jboss.jcml:
 -----------
 <mbean code="org.jboss.jdbc.XADataSourceLoader"
 name="DefaultDomain:service=XADataSource,name=myDataSource">
   <attribute name="PoolName">myDataSource</attribute>
   (...)
 </mbean>


 myEJB.java:
 ------------
 DataSource dataSource = (DataSource)
 initialContext.lookup("java:comp/env/jdbc/myDataSource");


 JBoss' log:
 ------
 (...)
 [myDataSource] XA Connection pool myDataSource bound to
 java:/myDataSource
 (...)

_______________________________________________
Jboss-development mailing list
[EMAIL PROTECTED]
http://lists.sourceforge.net/lists/listinfo/jboss-development

Reply via email to