• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Jeanne Boyarsky
  • Liutauras Vilda
Sheriffs:
  • Rob Spoor
  • Bear Bibeault
  • Tim Cooke
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Piet Souris
Bartenders:
  • Frits Walraven
  • Himai Minh

Accessing a datasource from outside JBoss

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Ranch Hand
Posts: 75
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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();
}
}
 
Ranch Hand
Posts: 91
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic