| Author |
Accessing a datasource from outside JBoss
|
Jean-Marie Galliot
Greenhorn
Joined: Apr 20, 2003
Posts: 2
|
|
Hi, Is it possible to configure a datasource in JBoss, such a way that it becomes available from a standalone application outside JBoss, using JNDI, to get connection from it. At the moment, it seems that my datasource is accessible only from code running in JBoss VM. I can see the JNDI name in JNDI view but when I try to "lookup" the name from outside, I get a "not bound" error. Is it a question of security settings or is it a general policy not to allow external code to use JBoss datasources ? Tks
|
 |
meka toka
Ranch Hand
Joined: Dec 11, 2002
Posts: 75
|
|
Please post the part of the code that you are using to lookup the datasource. Also which datasource is that ? Regards, Meka Toka
|
Thanks<br />MekaToka<br />SCJP 1.4
|
 |
Jean-Marie Galliot
Greenhorn
Joined: Apr 20, 2003
Posts: 2
|
|
This is the client code : public static final String JBOSS_CONTEXT_FACTORY = "org.jnp.interfaces.NamingContextFactory"; public static final String JBOSS_PROVIDER_URL = "jnp://localhost:1099"; public static final String JBOSS_URL_PKG_PREFIXES = "org.jboss.naming rg.jnp.interfaces"; public static void main( String args[] ) { Properties prop = new Properties(); prop.put( Context.INITIAL_CONTEXT_FACTORY, JBOSS_CONTEXT_FACTORY ); prop.put( Context.PROVIDER_URL, JBOSS_PROVIDER_URL ); prop.put( Context.URL_PKG_PREFIXES, JBOSS_URL_PKG_PREFIXES ); try { InitialContext jbossContext = new InitialContext( prop ); Context obj = (Context)jbossContext.lookup("java:/sage"); .... // I tried to lookup different names like // in the JNDIVIEW I can perfectly see the datasource in the java: Namespace // but it looks like anything under java:/ is not accessible from outside JBoss Context obj = (Context)jbossContext.lookup("java:comp/sage"); Context obj = (Context)jbossContext.lookup("sage"); } catch (NamingException ne) { ne.printStackTrace(); } }
|
 |
arun sahni
Ranch Hand
Joined: Jan 16, 2002
Posts: 91
|
|
The datasource is bind in java local name and can not access outside its JVM. You can search JBoss forum for info. I have checked sometime back in thread http://JBoss.org/forums/thread.jsp?forum=144&thread=19891&message=3736850&q=gobal%2Bjndi%2Bnamespace . I hope this will help.
|
Arun Sahni<br />SCJP2,SWCD,<br />BEA Certified Specialist: Server <br />JCert Enterprise Developer for BEA.
|
 |
 |
|
|
subject: Accessing a datasource from outside JBoss
|
|
|