0

我得到以下错误

**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);
4

2 回答 2

1

尝试jboss-deployment-structure.xmlMETA-INF顶级.ear文件中添加一个。在为andjboss-deployment-structure.xml添加依赖项。org.jboss.remote-namingorg.jboss.ejb-client

这里有一些文档jboss-deployment-strucure.xmlWildFly 中的类加载

其他有用的链接:

来自远程服务器实例的 EJB 调用
ejb-multi-server:跨服务器的 EJB 通信

于 2014-10-16T20:19:12.127 回答
0

您需要在您的 war/WEB-INF/lib 目录中包含远程客户端的所有依赖项:

    <dependency>
        <groupId>org.wildfly</groupId>
        <artifactId>wildfly-jms-client-bom</artifactId>
        <version>${version.wildfly}</version>
        <type>pom</type>
    </dependency>
于 2014-10-16T07:43:26.037 回答