如何在jboss之外通过jndi访问在其中的datasource

03-11-02 Jagie
代码大致如下

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();

}

}

可是总是报"OracleDS not bound"的错误

难道jboss真的不能让远程VM访问其datasource?

文章出处:http://saloon.javaranch.com/cgi-bin/ubb/ultimatebb.cgi?ubb=get_topic&f=63&t=000198

大家指点我一下吧。我就是想这样远程访问一下

浆糊
2004-03-04 14:50
Jboss不支持在不同的虚拟机中访问DataSource

猜你喜欢