- 
        1. Re: javax.sql.DataSource JNDI nameclmich Jan 27, 2002 9:49 AM (in response to sealbb)Hi, 
 I experienced the same problem as yours, at the same time... I finally got the lookup working using a jboss.xml to have the datasource registered with the bean java:comp/env namespace.
 In short, two options:
 1) lookup the datasource as "java:/rwdev" and it should work, but the portability to other servers would not be ideal...
 2) use a jboss.xml file in addition to your ejb-jar.xml:
 <enterprise-beans>
 <ejb-name>YourBean</ejb-name>
 <resource-ref>
 <res-ref-name>jdbc/rwdev</res-ref-name>
 <resource-name>rwdevDS</resource-name>
 </resource-ref>
 </enterprise-beans>
 <resource-managers>
 <resource-manager res-class="org.jboss.jdbc.XADataSourceLoader">
 <res-name>rwdevDS</res-name>
 <res-jndi-name>java:/rwdev</res-jndi-name>
 </resource-manager>
 </resource-managers>
 Hope it will help...
- 
        2. Re: javax.sql.DataSource JNDI namejaniprashant Feb 5, 2002 4:39 AM (in response to sealbb)well 
 how do i get the DataSource from a java client not an EJB.
 I have failed to get the lookup of the DS.
 Is there any example or code available.
 greetz
 Jani
- 
        3. Re: javax.sql.DataSource JNDI namedavidjencks Feb 5, 2002 10:44 AM (in response to sealbb)you can't access datasources outside the jboss vm. IMHO it is also a very bad idea architecturally, weblogic's implementation notwithstanding. 
- 
        4. Re: javax.sql.DataSource JNDI namegudujarlson Feb 5, 2002 1:12 PM (in response to sealbb)Why is the implementation specific jboss.xml file necessary to achieve behavior as defined in the EJB spec? Or do I not understand the EJB spec? 
 Is it possible to configure jboss to put JDBC datasources under java:comp by default and thus avoid putting a jboss.xml file in the EJB jar?
- 
        5. Re: javax.sql.DataSource JNDI nameluckystar_007 Mar 8, 2002 1:27 AM (in response to sealbb)But if I use the joss+tomcat as my J2EE environment, I want to use a servlet program to lookup a Datasource registered in JBoss (I use JBoss-2.4.3_Tomcat-3.2.3),Can I say that the servlet and JBoss are in same JVM? If so,to lookup a datasource from Jboss might not be a bad idea, OK? 
- 
        6. Re: javax.sql.DataSource JNDI namedavidjencks Mar 8, 2002 8:20 AM (in response to sealbb)yes, in the same vm it is (performance-wise) ok, whether it is architecturally wise is another question. For instance, it ties your app to running tomcat + jboss in the same vm, and distributes data access code over several layers. 
- 
        7. Re: javax.sql.DataSource JNDI namejaywright00 Mar 8, 2002 4:24 PM (in response to sealbb)
 What if you have multiple ejbs that all use the same resource reference? Is there any way, in either the ejb-jar.xml or jboss.xml file to manage this without one entry per ejb?
 Jay
- 
        8. Re: javax.sql.DataSource JNDI namedavidjencks Mar 8, 2002 4:38 PM (in response to sealbb)With cmp, you can specify the default datasource in the defaults section of jbosscmp-jdbc.xml. 
 With bmp, if you are willing to throw out portability, don't use a resource ref at all and just hardcode the global jndi name. If you want portability, since the local environment is per-bean, you have to set it up in each bean.
- 
        9. Re: javax.sql.DataSource JNDI namejaywright00 Mar 8, 2002 4:58 PM (in response to sealbb)
 Yes, using BMP. Is there any issue using a JNDI name such as "jaguar/dataSource"? I'm still having problems accessing the datasource.
 In my ejb-jar.xml file I include:
 <resource-ref>
 <res-ref-name>jaguarDS</res-ref-name>
 <res-type>javax.sql.DataSource</res-type>
 <res-auth>Container</res-auth>
 </resource-ref>
 In my jboss.xml I include:
 <resource-ref>
 <res-ref-name>jaguarDS</res-ref-name>
 <resource-name>jaguar/dataSource</resource-name>
 </resource-ref>
 with each bean and:
 <resource-managers>
 <resource-manager res-class="org.jboss.jdbc.XADataSourceLoader">
 <res-name>jaguarDS</res-name>
 <res-jndi-name>java:/jaguar/dataSource</res-jndi-name>
 </resource-manager>
 </resource-managers>
 my (truncated) mbean from jboss.jcml:
 jaguar/dataSource
 org.jboss.pool.jdbc.xa.wrapper.XADataSourceImpl
 ...
- 
        10. Re: javax.sql.DataSource JNDI namedavidjencks Mar 8, 2002 5:13 PM (in response to sealbb)I think you don't specify res-class in resource-manager (you already specified it in ejb-jar.xml), and anyway the class you specify is wrong. 
 I think the resource-ref resource-name and resource-manager res-name have to match up
 <resource-managers>
 <resource-manager">
 <res-name>jaguar/dataSource</res-name>
 <res-jndi-name>java:/jaguar/dataSource</res-jndi-name>
 </resource-manager>
 </resource-managers>
 There's a pretty good explanation of this in the dtd.
- 
        11. Re: javax.sql.DataSource JNDI namejaywright00 Mar 8, 2002 7:07 PM (in response to sealbb)
 Maybe it's just friday afternoon, but this is just plain not working for me. Where is the DTD for jboss.xml?
 Does anyone have an example of a properly configured OracleDriver DataSource with Connection Pooling?
 Jay
- 
        12. Re: javax.sql.DataSource JNDI namecbradley2 Mar 26, 2002 9:03 PM (in response to sealbb)I got mine to work in the following manner: 
 (This is an incomplete, in process doc, but thought it might help!)
 Instructions for setting up Jboss/Tomcat/Ant
 1. Download Ant v1.4
 http://jakarta.apache.org/builds/jakarta-ant/release/v1.4.1/bin/
 2. Install Ant
 http://www.jboss.org/online-manual/HTML/ch01s05.html
 3. Download JBoss
 4. Install JBoss and run it to test install
 http://www.jboss.org/online-manual/HTML/ch01s06.html
 *** Note: Instead of typing in ‘run’, type in ‘run_with_catalina.bat’
 (It’s a good idea to read the pages between the previous URL and the next URL)
 5. Run the examples…
 a. Build the server and deploy it
 http://www.jboss.org/online-manual/HTML/ch01s14.html
 b. Build the client and run it
 http://www.jboss.org/online-manual/HTML/ch01s15.html
 6. Install the Oracle Drivers
 Note: You can retrieve classes12.zip(The Oracle JDBC Thin Driver) from:
 1.) Your computer, if you have the Oracle client installed, in the following directory:
 C:\oracle\ora81\jdbc\lib
 (or similar)
 2.) You can download it from technet.oracle.com
 Put jdbc driver (in this case classes12.zip) in jboss_home/lib/ext -->
 7. Test the Oracle Data Source and Connection Pool by modifying the example Session Bean:
 (In all of the below, the bold code[stuff between and ] is the stuff to insert)
 (Also, anywhere there is a your****, you should replace that text with the appropriate stuff for your stuff)
 a. Put the following lines in the “InterestBean” class of the JBOSS_DIST/examples dir.
 …
 //
 import javax.sql.*;
 import javax.naming.*;
 //
 …
 ….
 public double calculateCompoundInterest(double principle,
 double rate, double periods)
 {
 System.out.println("Someone called `calculateCompoundInterest!'");
 //
 // put this code into this method at this spot
 try {
 Context initial = new InitialContext();
 DataSource dataSource = (DataSource)initial.lookup("java:/OracleDS");
 System.out.println("It Worked!");
 System.out.println(dataSource);
 } catch (Exception ex) {
 ex.printStackTrace();
 }
 // end inserted code
 //
 return principle * Math.pow(1+rate, periods) - principle;
 b. Put the following in jboss.jcml
 <!-- ==================================================================== -->
 <!-- JDBC -->
 <!-- ==================================================================== -->
 <!-->
 oracle.jdbc.driver.OracleDriver
 jdbc/OracleDS
 org.opentools.minerva.jdbc.xa.wrapper.XADataSourceImpl
 jdbc:oracle:thin:@yourIPAddress:1521:yourSID
 yourUSERNAME
 yourPASSWORD
 <!-->
 <!-- ==================================================================== -->
 <!-- JBoss Server Management -->
 <!-- ==================================================================== -->
 c. Put the following in the ejb-jar.xml file:
 <transaction-type>Bean</transaction-type>
 </enterprise-beans>
 <!-->
 <resource-managers>
 <resource-manager res-class="org.jboss.jdbc.XADataSourceLoader">
 <res-name>OracleDS</res-name>
 <res-jndi-name>java:/OracleDS</res-jndi-name>
 </resource-manager>
 </resource-managers>
 <!-->
 </ejb-jar>
 d. Put the following in the jboss.xml file:
 <jndi-name>interest/Interest</jndi-name>
 <!-->
 <resource-ref>
 <res-ref-name>OracleDS</res-ref-name>
 <resource-name>java/OracleDS</resource-name>
 </resource-ref>
 <!-->
 </enterprise-beans>
 <!-->
 <resource-managers>
 <resource-manager res-class="org.jboss.jdbc.XADataSourceLoader">
 <res-name>OracleDS</res-name>
 <res-jndi-name>java:/OracleDS</res-jndi-name>
 </resource-manager>
 </resource-managers>
 <!-->
 e. re-build the ejb
 http://www.jboss.org/online-manual/HTML/ch01s14.html
 In the build dir:
 ant intro-interest-jar
 ant intro-interest-deploy
 f. re-run the client
 http://www.jboss.org/online-manual/HTML/ch01s15.html
 In the bulid dir:
 ant intro-interest-client
 You should see:
 [INFO,Default] Someone called `calculateCompoundInterest!'
 [INFO,Default] It Worked!
 [INFO,Default] org.jboss.pool.jdbc.xa.XAPoolDataSource@639bf1
 Disclaimer: Works on my machine!!
- 
        13. Re: javax.sql.DataSource JNDI namebartmann_d Mar 27, 2002 4:24 AM (in response to sealbb)I haven't tested this, but there are two things which I think are not right: 
 1. Your ejb-jar.xml does not conform to neither the ejb-jar.dtd nor to the ejb-jar_2_0.dtd. I think it should look something like this:
 ...
 <transaction-type>Bean</transaction-type>
 <resource-ref>
 <res-ref-name>OracleDS</res-ref-name>
 <res-type>javax.sql.XADataSource</res-type>
 <res-auth>Container</res-auth>
 </resource-ref>
 I'm not really sure, but perhaps you would have to use javax.sql.DataSource instead of javax.sql.XADataSource.
 2. I think davidjencks is right (indeed I think he always is right) concerning the specification of the res-class. However I've seen two different versions of jboss_2_4.dtd: one with the res-class attribute (required!) with the resource-manager element and one without such an attribute. I think the second one is the one you should use. Hence the jboss.xml file should look something like this:
 <enterprise-beans>
 ...
 <resource-ref>
 <res-ref-name>OracleDS</res-ref-name>
 <resource-name>myTestOracleDS</resource-name>
 </resource-ref>
 </enterprise-beans>
 <resource-managers>
 <resource-manager>
 <res-name>myTestOracleDS</res-name>
 <res-jndi-name>java:/OracleDS</res-jndi-name>
 </resource-manager>
 </resource-managers>
 
     
     
     
     
     
     
     
    