Jboss EAP 7.0.0 - java.lang.ClassNotFoundException: org.jboss.naming.remote.client.InitialContextFactory
Jboss EAP 7.0.0 - java.lang.ClassNotFoundException: org.jboss.naming.remote.client.InitialContextFactory
我正在将一项服务从 Jboss 5.1 迁移到 Jboss EAP 7.0.0。
它使用 Maven 3.9.9 在 jdk 1.8 中成功构建,并在 jboss EAP 7.0.0.
中成功部署
在部署期间显示 java.lang.ClassNotFoundException
。此服务仅包含本地 ejb,不包含远程 ejb。
EJb 查找 class -
String contextFactory = SysConfigUtil.getJndiFactory();
String ejbLocalJndi = SysConfigUtil.getTimerEjbLocalJndi();
Properties environment = new Properties();
environment.put(Context.INITIAL_CONTEXT_FACTORY, contextFactory);
Context ctx;
environment.put(Context.URL_PKG_PREFIXES, "org.jboss.ejb.client.naming");
environment.put("jboss.naming.client.ejb.context", new Boolean(true));
ctx = new InitialContext(environment);
logger.info("************ before lookup");
ejb = (ISystemConfigurationTimerLocal) ctx.lookup(ejbLocalJndi);
logger.info("************ after lookup");
堆栈跟踪 -
javax.naming.NamingException: WFLYNAM0027: Failed instantiate InitialContextFactory org.jboss.naming.remote.client.InitialContextFactory from classloader ModuleClassLoader f
or Module "deployment.SystemConfiguration.ear.system-configuration-lifecycle.sar:main" from Service Module Loader [Root exception is java.lang.ClassNotFoundException: org.jb
oss.naming.remote.client.InitialContextFactory from [Module "deployment.SystemConfiguration.ear.system-configuration-lifecycle.sar:main" from Service Module Loader]]
org.jboss.as.naming.InitialContext.getDefaultInitCtx(InitialContext.java:118)
org.jboss.as.naming.InitialContext.init(InitialContext.java:99)
javax.naming.ldap.InitialLdapContext.<init>(InitialLdapContext.java:154)
org.jboss.as.naming.InitialContext.<init>(InitialContext.java:89)
org.jboss.as.naming.InitialContextFactory.getInitialContext(InitialContextFactory.java:43)
javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:684)
javax.naming.InitialContext.getDefaultInitCtx(InitialContext.java:313)
javax.naming.InitialContext.init(InitialContext.java:244)
javax.naming.InitialContext.<init>(InitialContext.java:216)
com.abcd.services.core.systemconfiguration.conn.impl.SystemConfigurationTimerEjbExecutor.getSystemConfigurationTimerEJB(SystemConfigurationTimerEjbExecutor.java:96)
com.abcd.services.core.systemconfiguration.conn.impl.SystemConfigurationTimerEjbExecutor.startScheduler(SystemConfigurationTimerEjbExecutor.java:56)
com.abcd.services.core.systemconfiguration.conn.impl.SystemConfigurationAppLifeCycle.start(SystemConfigurationAppLifeCycle.java:65)
org.jboss.as.service.AbstractService.invokeLifecycleMethod(AbstractService.java:76)
org.jboss.as.service.StartStopService.run(StartStopService.java:61)
java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
java.util.concurrent.FutureTask.run(FutureTask.java:266)
java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
java.lang.Thread.run(Thread.java:745)
org.jboss.threads.JBossThread.run(JBossThread.java:320)
Caused by: java.lang.ClassNotFoundException: org.jboss.naming.remote.client.InitialContextFactory from [Module "deployment.SystemConfiguration.ear.system-configuration-lifec
ycle.sar:main" from Service Module Loader]
org.jboss.modules.ModuleClassLoader.findClass(ModuleClassLoader.java:198)
org.jboss.modules.ConcurrentClassLoader.performLoadClassUnchecked(ConcurrentClassLoader.java:363)
org.jboss.modules.ConcurrentClassLoader.performLoadClass(ConcurrentClassLoader.java:351)
org.jboss.modules.ConcurrentClassLoader.loadClass(ConcurrentClassLoader.java:93)
java.lang.Class.forName0(Native Method)
java.lang.Class.forName(Class.java:348)
org.jboss.as.naming.InitialContext.getDefaultInitCtx(InitialContext.java:113)
在任何版本的 JBossAS 或 WildFly 中查找本地对象时,您永远不需要向 new InitialContext()
提供环境属性。
Context ctx = new InitialContext();
ejb = (ISystemConfigurationTimerLocal) ctx.lookup(ejbLocalJndi);
应有尽有。
FWIW,您提供的 属性 配置是针对远程独立客户端的,即使对于服务器 -> 服务器调用也是不正确的。
我正在将一项服务从 Jboss 5.1 迁移到 Jboss EAP 7.0.0。 它使用 Maven 3.9.9 在 jdk 1.8 中成功构建,并在 jboss EAP 7.0.0.
中成功部署在部署期间显示 java.lang.ClassNotFoundException
。此服务仅包含本地 ejb,不包含远程 ejb。
EJb 查找 class -
String contextFactory = SysConfigUtil.getJndiFactory();
String ejbLocalJndi = SysConfigUtil.getTimerEjbLocalJndi();
Properties environment = new Properties();
environment.put(Context.INITIAL_CONTEXT_FACTORY, contextFactory);
Context ctx;
environment.put(Context.URL_PKG_PREFIXES, "org.jboss.ejb.client.naming");
environment.put("jboss.naming.client.ejb.context", new Boolean(true));
ctx = new InitialContext(environment);
logger.info("************ before lookup");
ejb = (ISystemConfigurationTimerLocal) ctx.lookup(ejbLocalJndi);
logger.info("************ after lookup");
堆栈跟踪 -
javax.naming.NamingException: WFLYNAM0027: Failed instantiate InitialContextFactory org.jboss.naming.remote.client.InitialContextFactory from classloader ModuleClassLoader f
or Module "deployment.SystemConfiguration.ear.system-configuration-lifecycle.sar:main" from Service Module Loader [Root exception is java.lang.ClassNotFoundException: org.jb
oss.naming.remote.client.InitialContextFactory from [Module "deployment.SystemConfiguration.ear.system-configuration-lifecycle.sar:main" from Service Module Loader]]
org.jboss.as.naming.InitialContext.getDefaultInitCtx(InitialContext.java:118)
org.jboss.as.naming.InitialContext.init(InitialContext.java:99)
javax.naming.ldap.InitialLdapContext.<init>(InitialLdapContext.java:154)
org.jboss.as.naming.InitialContext.<init>(InitialContext.java:89)
org.jboss.as.naming.InitialContextFactory.getInitialContext(InitialContextFactory.java:43)
javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:684)
javax.naming.InitialContext.getDefaultInitCtx(InitialContext.java:313)
javax.naming.InitialContext.init(InitialContext.java:244)
javax.naming.InitialContext.<init>(InitialContext.java:216)
com.abcd.services.core.systemconfiguration.conn.impl.SystemConfigurationTimerEjbExecutor.getSystemConfigurationTimerEJB(SystemConfigurationTimerEjbExecutor.java:96)
com.abcd.services.core.systemconfiguration.conn.impl.SystemConfigurationTimerEjbExecutor.startScheduler(SystemConfigurationTimerEjbExecutor.java:56)
com.abcd.services.core.systemconfiguration.conn.impl.SystemConfigurationAppLifeCycle.start(SystemConfigurationAppLifeCycle.java:65)
org.jboss.as.service.AbstractService.invokeLifecycleMethod(AbstractService.java:76)
org.jboss.as.service.StartStopService.run(StartStopService.java:61)
java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
java.util.concurrent.FutureTask.run(FutureTask.java:266)
java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
java.lang.Thread.run(Thread.java:745)
org.jboss.threads.JBossThread.run(JBossThread.java:320)
Caused by: java.lang.ClassNotFoundException: org.jboss.naming.remote.client.InitialContextFactory from [Module "deployment.SystemConfiguration.ear.system-configuration-lifec
ycle.sar:main" from Service Module Loader]
org.jboss.modules.ModuleClassLoader.findClass(ModuleClassLoader.java:198)
org.jboss.modules.ConcurrentClassLoader.performLoadClassUnchecked(ConcurrentClassLoader.java:363)
org.jboss.modules.ConcurrentClassLoader.performLoadClass(ConcurrentClassLoader.java:351)
org.jboss.modules.ConcurrentClassLoader.loadClass(ConcurrentClassLoader.java:93)
java.lang.Class.forName0(Native Method)
java.lang.Class.forName(Class.java:348)
org.jboss.as.naming.InitialContext.getDefaultInitCtx(InitialContext.java:113)
在任何版本的 JBossAS 或 WildFly 中查找本地对象时,您永远不需要向 new InitialContext()
提供环境属性。
Context ctx = new InitialContext();
ejb = (ISystemConfigurationTimerLocal) ctx.lookup(ejbLocalJndi);
应有尽有。
FWIW,您提供的 属性 配置是针对远程独立客户端的,即使对于服务器 -> 服务器调用也是不正确的。