Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Accessing a datasource from outside JBoss

 
Jean-Marie Galliot
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 75
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please post the part of the code that you are using to lookup the datasource. Also which datasource is that ?

Regards,
Meka Toka
 
Jean-Marie Galliot
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 91
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic