gpt4 book ai didi

java - Jboss EAP 7.0.0 - java.lang.ClassNotFoundException : org. jboss.naming.remote.client.InitialContextFactory

转载 作者:行者123 更新时间:2023-12-02 13:36:54 25 4
gpt4 key购买 nike

我正在将服务从 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 查找类 -

        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$1.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,您提供的属性配置适用于远程独立客户端,即使对于服务器 -> 服务器调用也是不正确的。

关于java - Jboss EAP 7.0.0 - java.lang.ClassNotFoundException : org. jboss.naming.remote.client.InitialContextFactory,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42944706/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com