wildfly-8.1.0.Final Failed实例化InitialContextFactory

时间:2014-10-16 07:34:32

标签: jboss wildfly-8 initial-context

我得到以下错误

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

2 个答案:

答案 0 :(得分:1)

尝试将jboss-deployment-structure.xml添加到顶级 .ear 文件的META-INF。在jboss-deployment-structure.xml中为org.jboss.remote-namingorg.jboss.ejb-client添加依赖项。

以下是jboss-deployment-strucure.xmlClass 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>