WFLYNAM0027:ClassNotFoundException:org.jboss.naming.remote.client.InitialContextFactory [英] WFLYNAM0027 : ClassNotFoundException: org.jboss.naming.remote.client.InitialContextFactory

查看:2407
本文介绍了WFLYNAM0027:ClassNotFoundException:org.jboss.naming.remote.client.InitialContextFactory的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Enviornment- wildfly-9.0.2.Final,EJB 3.0

Enviornment- wildfly-9.0.2.Final, EJB 3.0

尝试连接Test.java类时(以wildfly-9.0部署为模块)发生以下错误。 2.Final@machine-A)到机器B(291.861.301.732)上的EJB部署在EJB上。

Following error occurred while trying to connect Test.java class(deployed as module at wildfly-9.0.2.Final@machine-A) to EJB whilch is deployed on jboss at machine-B(291.861.301.732).

17:02:46,666 ERROR [stderr] (default task-1) javax.naming.NamingException: WFLYNAM0027: Failed instantiate InitialContextFactory org.jboss.naming.remote.client.InitialContextFactory from classloader ModuleClassLoader for Module "deployment.test.ear.test.war:main" from Service Module Loader [Root exception is java.lang.ClassNotFoundException: org.jboss.naming.remote.client.InitialContextFactory from [Module "deployment.test.ear.test.war:main" from Service Module Loader]]
17:02:46,667 ERROR [stderr] (default task-1)    at org.jboss.as.naming.InitialContext.getDefaultInitCtx(InitialContext.java:118)
17:02:46,667 ERROR [stderr] (default task-1)    at org.jboss.as.naming.InitialContext.init(InitialContext.java:99)
17:02:46,670 ERROR [stderr] (default task-1)    at javax.naming.ldap.InitialLdapContext.<init>(InitialLdapContext.java:154)
17:02:46,670 ERROR [stderr] (default task-1)    at org.jboss.as.naming.InitialContext.<init>(InitialContext.java:89)
17:02:46,670 ERROR [stderr] (default task-1)    at org.jboss.as.naming.InitialContextFactory.getInitialContext(InitialContextFactory.java:43)
17:02:46,687 ERROR [stderr] (default task-1) Caused by: java.lang.ClassNotFoundException: org.jboss.naming.remote.client.InitialContextFactory from [Module "deployment.test.ear.test.war:main" from Service Module Loader]
17:02:46,688 ERROR [stderr] (default task-1)    at org.jboss.modules.ModuleClassLoader.findClass(ModuleClassLoader.java:205)
17:02:46,688 ERROR [stderr] (default task-1)    at org.jboss.modules.ConcurrentClassLoader.performLoadClassUnchecked(ConcurrentClassLoader.java:455)
17:02:46,688 ERROR [stderr] (default task-1)    at org.jboss.modules.ConcurrentClassLoader.performLoadClassChecked(ConcurrentClassLoader.java:404)
17:02:46,688 ERROR [stderr] (default task-1)    at org.jboss.modules.ConcurrentClassLoader.performLoadClass(ConcurrentClassLoader.java:385)
17:02:46,688 ERROR [stderr] (default task-1)    at org.jboss.modules.ConcurrentClassLoader.loadClass(ConcurrentClassLoader.java:130)

Test.java类中存在Test.java类testclient.jar已经被deplyed作为模块使用命令

Test.java class is present in testclient.jar & testclient.jar has been deplyed as a module using command

module add --name=testclient --resources=/Downloads/lib/test/client/testclient.jar --dependencies=javax.api

Test.java类



Test.java class

package com.testmodule.pojo;

import java.util.Properties;
import javax.naming.Context;
import javax.naming.InitialContext;

public class Test { 
public void getDbConnection(){
    try{
        Properties jndiProps = new Properties();
        jndiProps.put(Context.INITIAL_CONTEXT_FACTORY,"org.jboss.naming.remote.client.InitialContextFactory");
        jndiProps.put(Context.PROVIDER_URL,"remote://291.861.301.732:4447");
        jndiProps.put(Context.SECURITY_PRINCIPAL, "testuser");
        jndiProps.put(Context.SECURITY_CREDENTIALS, "testpassword");
        jndiProps.put("jboss.naming.client.ejb.context", true);
        Context context = new InitialContext(jndiProps);
    }
    catch(Exception e){e.printStackTrace();}
}}

为什么这个错误已经发生了,为了可见性的org.jboss.naming.remote.client.InitialContextFactory到testclient.jar,我必须要添加更多的依赖项(目前只有javax。 api),同时将testclient.jar部署为模块?或任何其他导致错误的问题? $ wilDFLY_HOME / bin / client / jboss-client.jar中的org.jboss.naming.remote.client.InitialContextFactory类也存在

why this error has been occurred, For visiblity of 'org.jboss.naming.remote.client.InitialContextFactory' to testclient.jar, should i have to add more dependencies(currently only javax.api) while deploying testclient.jar as a module? or any other issue which is causing error? Class 'org.jboss.naming.remote.client.InitialContextFactory' is also present in $WILDFLY_HOME/bin/client/jboss-client.jar

注 - 291.861.301.732是远程系统ip,其中ejb部署在jboss上。 ,这个ejb是使用JNDI从Test.java(远程客户端)调用的。

Note - 291.861.301.732 is the remote system ip, on which ejb is deployed at jboss. ,This ejb is invoking from Test.java(remote client) using JNDI.

在wildfly-9.0.2.Final中没有jnp(在JBOSS 5中) x),所以我将属性org.jnp.interfaces.NamingContextFactory替换为值org.jboss.naming.remote.client.InitialContextFactory,为什么还会出现错误?

There is no jnp in wildfly-9.0.2.Final(which was in JBOSS 5.x), so i replaced property "org.jnp.interfaces.NamingContextFactory" to value org.jboss.naming.remote.client.InitialContextFactory". why still error is occurred?

接收到评论后添加以下内容尝试将jboss-client.jar放在运行时路径中,作为WEB-INF / lib的一部分,或许可以通过Sampada Wagde

我无法理解,在这个场景中,test.jsp(在test.ear - > test.war - > test.jsp中)文件正在调用Test.java的函数getDbConnection文件Test.java文件存在于testclient.jar中,此testclient.jar已经被部署为一个模块
根据你的建议,当我将'jboss-client.jar'放在test.ear - > test.war - > WEB-INF - > lib,问题解决了,现在正在访问
应用程序'org.jboss.naming.remote.client.InitialContextFactory'ClassNotF ound异常没有发生... 但我的问题是有多个war的文件(Eg..test.war,test1.war,test2.war),每个war文件正在访问Test.java文件(存在于testclient.jar),所以我必须将'jboss-client.jar'文件放在每个war档案的WEB-INF / lib文件中。这对我来说非常复杂,有没有其他方法可用?其次,将'jboss-client.jar'放入WEB-INF / lib目录中,这个问题是通过'org.jboss.naming'来解决的。 remote.client.InitialContextFactory'存在于testclient.jar(不在test.ear - > test.war中)

I am not able to understand, In this scenarion test.jsp (present in test.ear-->test.war-->test.jsp) file is calling function getDbConnection of Test.java file. Test.java file is present in testclient.jar and this testclient.jar has been deployed as a module. As per your suggestion, when i put 'jboss-client.jar' in test.ear-->test.war-->WEB-INF-->lib, problem was solved, now while accessing application 'org.jboss.naming.remote.client.InitialContextFactory' ClassNotFound exception was not occurred...But my problem is that there are multiple war's files(Eg..test.war,test1.war,test2.war) and each war file is accessing Test.java file(present in testclient.jar), so i have to put 'jboss-client.jar' file in WEB-INF/lib of each war archive. which will be very complex for me, is there any other approach available? and secondly how this problem is solved by putting 'jboss-client.jar' into WEB-INF/lib direcory as 'org.jboss.naming.remote.client.InitialContextFactory' is present in testclient.jar(Not in test.ear-->test.war).

接收后添加以下内容在运行时,服务器需要回复'jboss-client.jar''''Sampada Wagde'

我还尝试了以下步骤
1.将'jboss-deployment-structure.xml'放在test.ear中 - > META-INF - > jboss-deployment-structure.xml

I also tried following steps 1. By putting 'jboss-deployment-structure.xml' in test.ear-->META-INF-->jboss-deployment-structure.xml

<?xml version="1.0"?>
<jboss-deployment-structure xmlns="urn:jboss:deployment-structure:1.1">
<deployment>
    <dependencies>
        <module name="testclient" export="true" />
        <module name="jboss-client" export="true" />
    </dependencies>
</deployment>


  1. 将模块名称部署为

  1. Deploying module name as

module add --name=jboss-client --resources=/Downloads/wildfly-9.0.2.Final/bin/client/jboss-client.jar


但仍然出现以下错误。

14:14:34,376 WARN  [org.jboss.modules] (default task-1) Failed to define class org.jboss.naming.remote.client.InitialContextFactory in Module "jboss-client:main" from local module loader @707f7052 (finder: local module finder @11028347 (roots: /Downloads/wildfly-9.0.2.Final/modules,/Downloads/wildfly-9.0.2.Final/modules/system/layers/base)): java.lang.LinkageError: Failed to link org/jboss/naming/remote/client/InitialContextFactory (Module "jboss-client:main" from local module loader @707f7052 (finder: local module finder @11028347 (roots: /Downloads/wildfly-9.0.2.Final/modules,/Downloads/wildfly-9.0.2.Final/modules/system/layers/base)))
at org.jboss.modules.ModuleClassLoader.defineClass(ModuleClassLoader.java:437)
at org.jboss.modules.ModuleClassLoader.loadClassLocal(ModuleClassLoader.java:269)
at org.jboss.modules.ModuleClassLoader$1.loadClassLocal(ModuleClassLoader.java:77)
at org.jboss.modules.Module.loadModuleClass(Module.java:560)
at org.jboss.modules.ModuleClassLoader.findClass(ModuleClassLoader.java:197)
Caused by: java.lang.NoClassDefFoundError: javax/naming/spi/InitialContextFactory
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:760)
at org.jboss.modules.ModuleClassLoader.doDefineOrLoadClass(ModuleClassLoader.java:353)
at org.jboss.modules.ModuleClassLoader.defineClass(ModuleClassLoader.java:432)
Caused by: java.lang.ClassNotFoundException: javax.naming.spi.InitialContextFactory from [Module "jboss-client:main" from local module loader @707f7052 (finder: local module finder @11028347 (roots: /Downloads/wildfly-9.0.2.Final/modules,/Downloads/wildfly-9.0.2.Final/modules/system/layers/base))]
at org.jboss.modules.ModuleClassLoader.findClass(ModuleClassLoader.java:205)
at org.jboss.modules.ConcurrentClassLoader.performLoadClassUnchecked(ConcurrentClassLoader.java:455)
at org.jboss.modules.ConcurrentClassLoader.performLoadClassChecked(ConcurrentClassLoader.java:404)
at org.jboss.modules.ConcurrentClassLoader.performLoadClass(ConcurrentClassLoader.java:385)
14:14:34,391 ERROR [io.undertow.request] (default task-1) UT005023: Exception handling request to /test/test.jsp: javax.servlet.ServletException: java.lang.LinkageError: Failed to link org/jboss/naming/remote/client/InitialContextFactory (Module "jboss-client:main" from local module loader @707f7052 (finder: local module finder @11028347 (roots: /Downloads/wildfly-9.0.2.Final/modules,/Downloads/wildfly-9.0.2.Final/modules/system/layers/base)))
at org.apache.jasper.runtime.PageContextImpl.doHandlePageException(PageContextImpl.java:848)
at org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:777)
at org.apache.jsp.test_jsp._jspService(test_jsp.java:85)
at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:69)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:790)
Caused by: java.lang.LinkageError: Failed to link org/jboss/naming/remote/client/InitialContextFactory (Module "jboss-client:main" from local module loader @707f7052 (finder: local module finder @11028347 (roots: /Downloads/wildfly-9.0.2.Final/modules,/Downloads/wildfly-9.0.2.Final/modules/system/layers/base)))
at org.jboss.modules.ModuleClassLoader.defineClass(ModuleClassLoader.java:437)
at org.jboss.modules.ModuleClassLoader.loadClassLocal(ModuleClassLoader.java:269)
at org.jboss.modules.ModuleClassLoader$1.loadClassLocal(ModuleClassLoader.java:77)
at org.jboss.modules.Module.loadModuleClass(Module.java:560)
at org.jboss.modules.ModuleClassLoader.findClass(ModuleClassLoader.java:197)
Caused by: java.lang.NoClassDefFoundError: javax/naming/spi/InitialContextFactory
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:760)
at org.jboss.modules.ModuleClassLoader.doDefineOrLoadClass(ModuleClassLoader.java:353)
at org.jboss.modules.ModuleClassLoader.defineClass(ModuleClassLoader.java:432)
Caused by: java.lang.ClassNotFoundException: javax.naming.spi.InitialContextFactory from [Module "jboss-client:main" from local module loader @707f7052 (finder: local module finder @11028347 (roots: /Downloads/wildfly-9.0.2.Final/modules,/Downloads/wildfly-9.0.2.Final/modules/system/layers/base))]
at org.jboss.modules.ModuleClassLoader.findClass(ModuleClassLoader.java:205)
at org.jboss.modules.ConcurrentClassLoader.performLoadClassUnchecked(ConcurrentClassLoader.java:455)
at org.jboss.modules.ConcurrentClassLoader.performLoadClassChecked(ConcurrentClassLoader.java:404)
at org.jboss.modules.ConcurrentClassLoader.performLoadClass(ConcurrentClassLoader.java:385)


推荐答案

您需要使自己的模块依赖于不仅包含jboss-client jar的模块,还包含jboss-client的所有依赖关系可能只是其他的模块,也可能是其他罐子。关于丢失的第一个类是javax / naming / spi / InitialContextFactory,因此编辑jboss-client模块的module.xml以依赖于javax.api

You need to make your own module depend on a module that contains not only the jboss-client jar, but also all the dependencies of jboss-client, this might just be other modules or possibly other jars too. The first class it's moaning about being missing is javax/naming/spi/InitialContextFactory so edit the module.xml for the jboss-client module to depend on javax.api

这篇关于WFLYNAM0027:ClassNotFoundException:org.jboss.naming.remote.client.InitialContextFactory的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆