As a postlude to Consuming an EJB question. I have created an ejb on JBOSS AS 6.0 and am consuming it in a java client using the following code.
private ServiceLocator(String host, String principal, String creadentials) throws NamingException {
Properties env = new Properties();
env.put(Context.INITIAL_CONTEXT_FACTORY,
"org.jnp.interfaces.NamingContextFactory");
env.put(Context.URL_PKG_PREFIXES,
"org.jboss.naming:org.jnp.interfaces");
env.put(Context.PROVIDER_URL, "jnp://" + host);
System.out.println("jnp://" + host);
env.put(Context.SECURITY_PRINCIPAL, principal);
env.put(Context.SECURITY_CREDENTIALS, creadentials);
env.setProperty(Context.INITIAL_CONTEXT_FACTORY,
"org.jboss.security.jndi.JndiLoginInitialContextFactory");
InitialContext ct = new InitialContext(env);
cachedStructSpeechRemote = (StructSpeechRemote) ct.lookup("eCWServicesEAR/StructSpeechService/remote-com.ecw.ejb.StructSpeechRemote");
}
The consumer uses JBOSS-all-client.jar present in开发者_如何学Python client folder of JBoss AS6.0. I am not able to use the same code with JDK1.4 because the jar is not JDK 1.4 compatible. I have also tried to get the jar file form the older distribution of JBoss AS but than it does not work with the newer distribution of the server:( Is there a way to write an EJB consumer which is JDK version independent (May be also vendor independent!) and can work in all JDKs ranging from 1.4 to 6?
In your case I would expose the EJB on JBoss as a web service to be able to call it from any jvm. Otherwise you can try to find more info here: https://issues.jboss.org/browse/EJBTHREE-1029?focusedCommentId=12371962
精彩评论