我得到以下错误
**ERROR:**
2014-10-07 16:33:46,692 ERROR [stderr] (default task-1) javax.naming.NamingException:
JBAS011843: **Failed instantiate** **InitialContextFactory
org.jboss.naming.remote.client.InitialContextFactory** from classloader
ModuleClassLoader for Module "deployment.wildfly8.1.ear.wildfly8.1-war.war:main"
from Service Module Loader [Root exception is java.lang.ClassNotFoundException:
org.jboss.naming.remote.client.InitialContextFactory from [Module
"deployment.wildfly8.1.ear.wildfly8.1-war.war:main" from Service Module Loader]]
代码:
final Properties env = new Properties();
env.put(Context.INITIAL_CONTEXT_FACTORY, "org.jboss.naming.remote.client.InitialContextFactory");
env.put(Context.PROVIDER_URL, "127.0.0.1");
//OR env.put(Context.PROVIDER_URL, "http-remoting://127.0.0.1");
env.put(Context.SECURITY_PRINCIPAL, "admin");
env.put(Context.SECURITY_CREDENTIALS, "password");
context = new InitialContext(env);
答案 0 :(得分:1)
尝试将jboss-deployment-structure.xml
添加到顶级 .ear 文件的META-INF
。在jboss-deployment-structure.xml
中为org.jboss.remote-naming
和org.jboss.ejb-client
添加依赖项。
以下是jboss-deployment-strucure.xml
:Class Loading in WildFly
其他有用的链接:
EJB invocations from a remote server instance
ejb-multi-server: EJB Communication Across Servers
答案 1 :(得分:0)
您需要在war / WEB-INF / lib目录中包含远程客户端的所有依赖项:
<dependency>
<groupId>org.wildfly</groupId>
<artifactId>wildfly-jms-client-bom</artifactId>
<version>${version.wildfly}</version>
<type>pom</type>
</dependency>