-
1. Re: JBoss3.0.4 Datasource lookup
juhalindfors Feb 19, 2003 7:27 AM (in response to p661121)You should lookup from the private ENC java:comp/env/<jdbc/YourDSName> and map that to the in-VM java: name for the DS
that is the J2EE compat. way to do it -
2. Re: JBoss3.0.4 Datasource lookup
ctaggart Feb 24, 2003 5:42 PM (in response to p661121)I've been trying to bind a MySQL database connection for a couple of days now without any luck. I had a working Tomcat web application, and I'm trying to port it over to JBoss v3.0.6 with Jetty and I can't seem to bind/access the MySQL database connection.
I used the example mysql-service.xml and changed all the name references to be jdbc/PeopleFinderDB, e.g.
jdbc/PeopleFinderDB
The server.log reports this when I deploy the mysql-service.xml mbean:
2003-02-24 14:26:32,506 INFO [org.jboss.resource.adapter.jdbc.local.LocalManagedConnectionFactory.jdbc/PeopleFinderDB] Bound connection factory for resource adapter 'JBoss LocalTransaction JDBC Wrapper' to JNDI name 'java:/jdbc/PeopleFinderDB'
2003-02-24 14:26:32,516 INFO [org.jboss.resource.connectionmanager.LocalTxConnectionManager] Started
2003-02-24 14:26:32,516 INFO [org.jboss.deployment.MainDeployer] Deployed package: file:/C:/java/jboss-3.0.6/server/default/deploy/mysql-service.xml
My jboss-web.xml contains this:
<resource-ref>
<res-ref-name>jdbc/PeopleFinderDB</res-ref-name>
<!--<jndi-name>java:/jdbc/PeopleFinderDB</jndi-name>-->
<jndi-name>jdbc/PeopleFinderDB</jndi-name>
</resource-ref>
My web.xml contains this:
<resource-ref>
<res-ref-name>jdbc/PeopleFinderDB</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<res-auth>Container</res-auth>
</resource-ref>
Then in a JSP page, I recursively print the context tree starting with the initial context and the datasource isn't listed.
Please help!
Thanks,
Cameron -
3. Re: JBoss3.0.4 Datasource lookup
joey75205 Feb 24, 2003 6:02 PM (in response to p661121)I have a similar problem doing this with EJBs. For some reason, jBoss only binds the DefaultDS to my resource-ref rather than the ref I defined in the jboss.xml file. I have not been able to get an answer to my own post so I thought I'd piggy back here. Have you guys had any luck doing this in a web application?
I can see the java:comp/env naming context in the JNDI view but it doesn't point to my deployed datasources.
Thanks,
Joey -
4. Re: JBoss3.0.4 Datasource lookup
fubao Mar 11, 2003 3:22 PM (in response to p661121)You have to do the mapping in jboss.xml.
To map your java:/yourDS to java:comp/env/jdbc/aDs, besides give <resource-ref> in your ejb-jar.xml as:
<ejb-name>youEjb</ejb-name>
...
<resource-ref>
<res-ref-name>jdbc/aDs</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<res-auth>Container</res-auth>
</resource-ref>
In jboss.xml, you should give:
<enterprise-beans>
<ejb-name>yourEjb</ejb-name>
<resource-ref>
<res-ref-name>jdbc/aDs</res-ref-name>
<jndi-name>java:/yoursDS</jndi-name>
</resource-ref>
</enterprise-beans>
This way, you can lookup you DS by "java:comp/env/jdbc/aDs". It works fine for me.