全部,
我正在尝试从远程独立程序调用 EJB。 EJB 已正确部署在 JBOSS 7.0 上。我正在使用以下代码进行查找:
Properties jndiProps = new Properties();
jndiProps.put(Context.INITIAL_CONTEXT_FACTORY, "org.jboss.naming.remote.client.InitialContextFactory");
jndiProps.put(Context.URL_PKG_PREFIXES, "org.jboss.ejb.client.naming");
jndiProps.put(Context.PROVIDER_URL, "http-remoting://localhost:8080");
jndiProps.put(Context.SECURITY_PRINCIPAL, "user1");
jndiProps.put(Context.SECURITY_CREDENTIALS, "password@123?");
jndiProps.put("jboss.naming.client.ejb.context", true);
try {
Context ctx = new InitialContext(jndiProps);
HelloWorld d= (HelloWorld) ctx.lookup("HelloWorldSessionBean/HelloWorldBean!com.ibytecode.business.HelloWorld");
// String s=d.sayHello();
// System.out.println(s);
}
catch(Exception ne) {
ne.printStackTrace();
}
但我遇到以下异常,无法进一步继续。谁能告诉我我缺少什么:
Failed to connect to any server. Servers tried: [http-remoting://localhost:8080]
javax.naming.NamingException: Failed to connect to any server. Servers tried: [http-remoting://localhost:8080]
我的服务器已启动并正在运行,并且我正在使用standalone-full.xml 文件
最佳答案
我认为 http-remoting:
协议(protocol)在您的 JBoss 版本 (AS 7) 中不可用。
更改您的提供商 URL
jndiProps.put(Context.PROVIDER_URL, "http-remoting://localhost:8080");
到
jndiProps.put(Context.PROVIDER_URL, "remote://localhost:4447");
此外,请确保客户端的类路径中具有所有必需的 JBoss EJB 远程处理项目库。
关于java - JBOSS 7.0 - 无法使用 http 远程协议(protocol)连接到服务器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41881375/