【问题标题】:wildfly-8.1.0.Final Failed instantiate InitialContextFactorywildfly-8.1.0.Final 失败实例化 InitialContextFactory
【发布时间】:2014-12-11 11:33:40
【问题描述】:

我得到以下错误

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

【问题讨论】:

    标签: jboss wildfly-8 initial-context


    【解决方案1】:

    尝试将jboss-deployment-structure.xml 添加到顶级.ear 文件的META-INF。在jboss-deployment-structure.xml 中添加org.jboss.remote-namingorg.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

    【讨论】:

      【解决方案2】:

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

          <dependency>
              <groupId>org.wildfly</groupId>
              <artifactId>wildfly-jms-client-bom</artifactId>
              <version>${version.wildfly}</version>
              <type>pom</type>
          </dependency>
      

      【讨论】:

      • 谢谢。但我不想在战争中添加库。只有服务器本身。那么远程库需要在服务器中添加什么?
      • 下载 bom:mvn org.apache.maven.plugins:maven-dependency-plugin:2.6:get -Dartifact=org.wildfly:wildfly-jms-client-bom:${version.wildfly}:pom -Ddest=. -U 转到 dependencies 部分并查看
      猜你喜欢
      • 1970-01-01
      • 2014-09-21
      • 2015-12-03
      • 2014-10-11
      • 2014-11-17
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多