File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes JBoss/WildFly and the fly likes Accessing a datasource from outside JBoss Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Products » JBoss/WildFly
Bookmark "Accessing a datasource from outside JBoss" Watch "Accessing a datasource from outside JBoss" New topic

Accessing a datasource from outside JBoss

Jean-Marie Galliot

Joined: Apr 20, 2003
Posts: 2
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 ?
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 ?

Meka Toka

Thanks<br />MekaToka<br />SCJP 1.4
Jean-Marie Galliot

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();
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) {
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 .
I hope this will help.

Arun Sahni<br />SCJP2,SWCD,<br />BEA Certified Specialist: Server <br />JCert Enterprise Developer for BEA.
I agree. Here's the link:
subject: Accessing a datasource from outside JBoss
It's not a secret anymore!