wood burning stoves 2.0*
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


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Products » JBoss/WildFly
Bookmark "Accessing a datasource from outside JBoss" Watch "Accessing a datasource from outside JBoss" New topic
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.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Accessing a datasource from outside JBoss
 
Similar Threads
getting org.jboss.resource.adapter.jdbc.WrapperDataSource cannot be cast to javax.sql.XADataSource
UNmanaged JBoss Connection Pool wanted!
java:comp/env issue in JBOSS
Using Hibernate with DataSource or connection pool
Connect DS with JNDI in JBoss AS