Lookup datasource from client application problem
f94-mgi Feb 26, 2005 10:20 AMGaah! I'm tearing my hair turning bold... :-[ please help!
I have read documentation and searched this forum and the rest of the 'net ... have found some help but never really the same scenario as mine. I'm stuck!
This is the case: I wan't to do a lookup for a datasource registered in my JBoss AS. I have created a EAR with a JAR in it, representing the server component of my client application. The thing is I don't have anything in it but the META-INF/application-client.xml and jboss-client.xml. In all examples I have seen the lookup is for an EJB, not a datasource... is it not possible?
Anyway, this is my code:
mysql-ds.xml
<datasources> <local-tx-datasource> <jndi-name>jdbc/WpDB</jndi-name> <connection-url>jdbc:mysql://localhost:3306/wp</connection-url> <driver-class>com.mysql.jdbc.Driver</driver-class> <user-name>wpuser</user-name> <password>wp</password> </local-tx-datasource> </datasources>
application.xml
<application> <display-name>WP</display-name> <description /> <module> <java>client.jar</java> </module> </application>
application-client.xml
<application-client ...> <display-name>WP client</display-name> <resource-ref> <res-ref-name>jdbc/WpDB</res-ref-name> <res-type>javax.sql.DataSource</res-type> <res-auth>Container</res-auth> </resource-ref> </application-client>
jboss-client.xml:
<jboss-client> <jndi-name>wp-client</jndi-name> <resource-ref> <res-ref-name>jdbc/WpDB</res-ref-name> <jndi-name>java:jdbc/WpDB</jndi-name> </resource-ref> </jboss-client>
When I start JBoss AS I get the following about my bound datasource:
16:06:19,734 INFO [WrapperDataSourceService] Bound connection factory for resource adapter for ConnectionManager 'jboss.jca:name=jdbc/WpDB,service=DataSourceBinding to JNDI name 'java:jdbc/WpDB'
I start my client with the following command:
java -cp .;./lib/jbossall-client.jar -Djava.naming.factory.initial=org.jnp.interfaces.NamingContextFactory -Djava.naming.provider.url=jnp://localhost:1099 -Djava.naming.factory.url.pkgs=org.jboss.naming.client -Dj2ee.clientName=wp-client wp.client.Main
I get the following exception:
javax.naming.NamingException: Could not dereference object [Root exception is javax.naming.NamingException: Name not found java:jdbc/WpDB]
If I change the inner "jndi-name" in my jboss-client.xml to for example "hey baberiba" I would get the exception "... Name not found hey baberiba" so this is where the error lays.
If I check in the JMX web I can see this about the datasource:
JndiName: jdbc/WpDB
BindName: java:jdbc/WpDB
Someone have a clue?