[jboss-user] [JNDI/Naming/Network] - Problem getting Datasource vi JNDI
mjais
do-not-reply at jboss.com
Fri Jan 12 07:51:24 EST 2007
hello
I am trying to get the Quartz scheduler running:
I have a local jboss (4.0.3) running on my machine and configured the Quartz datasource.
via the JBoss JMX console I can see that the datasource is bound:
java: Namespace
+- jaas (class: javax.naming.Context)
.............
+- jdbc (class: org.jnp.interfaces.NamingContext)
| +- QuartzDS (class: org.jboss.resource.adapter.jdbc.WrapperDataSource)
| +- QuartzNoTxDS (class: org.jboss.resource.adapter.jdbc.WrapperDataSource)
..............
I wrote the following client programme to access the datasource:
class ContextTest {
public static DataSource getDataSource(String dataSourceJndiName) {
DataSource dataSource = null;
Properties prop = new Properties();
prop.put(Context.INITIAL_CONTEXT_FACTORY, "org.jnp.interfaces.NamingContextFactory");
prop.put(Context.URL_PKG_PREFIXES, "jboss.naming:org.jnp.interfaces");
prop.put(Context.PROVIDER_URL, "jnp://localhost:1099");
try {
Context ctx = new InitialContext(prop);
dataSource = (DataSource) ctx.lookup(dataSourceJndiName);
} catch (ClassCastException cce) {
cce.printStackTrace();
} catch (NamingException ne) {
ne.printStackTrace();
}
return dataSource;
}
public static void main(String[] args) {
DataSource ds = getDataSource("java:comp/env/jdbc/QuartzDS");
System.out.println(ds.toString());
}
}
and I get this error:
javax.naming.NameNotFoundException: comp not bound
at org.jnp.server.NamingServer.getBinding(NamingServer.java:514)
at org.jnp.server.NamingServer.getBinding(NamingServer.java:522)
at org.jnp.server.NamingServer.getObject(NamingServer.java:528)
at org.jnp.server.NamingServer.lookup(NamingServer.java:252)
I also tried many other combinations for the JNDI Name, but I never managed
to get the Datasource.
calling the code from within a JSF application (deployed on the JBoss where the
Quartz datasource is) doesn't work either.
any idea what's wrong here ?
Markus
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4000890#4000890
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4000890
More information about the jboss-user
mailing list