gpt4 book ai didi

javax.naming.NameNotFoundException : CDIExtension

转载 作者:行者123 更新时间:2023-11-30 06:51:04 29 4
gpt4 key购买 nike

我使用 com.sun.jersey.spi.spring.container.servlet.SpringServlet 创建了两个 Jersey servlet 项目。我使用 Jersey 1.19.1 jar 。这两个项目的 lib 文件夹中都有依赖的 jar。我将这两个项目部署在 liberty 9 服务器中。
当我尝试访问端点时,一个项目工作正常,但另一个项目工作正常。如果第二个项目不起作用,我在控制台中出现以下异常。如果我单独重新启动该项目(而不是服务器),它就可以工作。我不知道为什么,我尝试找到永久解决方案。

SRVE0271E: Uncaught init() exception created by servlet [jersey-servlet] in application [secondproject]: java.lang.RuntimeException: javax.naming.NameNotFoundException: CDIExtension

SRVE0315E: An exception occurred: java.lang.Throwable: javax.servlet.ServletException: SRVE0207E: Uncaught initialization exception created by servlet

如果第一个项目不起作用,我会在控制台中看到以下异常。

SRVE0271E:应用程序 [firstproject] 中的 servlet [jersey-servlet] 创建的未捕获 init() 异常:java.lang.ClassCastException:com.sun.jersey.server.impl.cdi.CDIExtension 与 com.sun.jersey 不兼容.server.impl.cdi.CDIExtension

SRVE0276E:初始化 Servlet [jersey-servlet] 时出错:javax.servlet.ServletException:SRVE0207E:Servlet 创建的未捕获初始化异常

更新完整堆栈:

    java.lang.RuntimeException: javax.naming.NameNotFoundException: CDIExtension
at com.sun.jersey.server.impl.cdi.CDIExtension.getInitializedExtension(CDIExtension.java:183)
at com.sun.jersey.server.impl.cdi.CDIComponentProviderFactory.<init>(CDIComponentProviderFactory.java:95)
at com.sun.jersey.server.impl.cdi.CDIComponentProviderFactoryInitializer.initialize(CDIComponentProviderFactoryInitializer.java:76)
at com.sun.jersey.spi.container.servlet.WebComponent.configure(WebComponent.java:572)
at com.sun.jersey.spi.container.servlet.ServletContainer$InternalWebComponent.configure(ServletContainer.java:332)
at com.sun.jersey.spi.container.servlet.WebComponent.load(WebComponent.java:604)
at com.sun.jersey.spi.container.servlet.WebComponent.init(WebComponent.java:207)
at com.sun.jersey.spi.container.servlet.ServletContainer.init(ServletContainer.java:394)
at com.sun.jersey.spi.container.servlet.ServletContainer.init(ServletContainer.java:577)
at javax.servlet.GenericServlet.init(GenericServlet.java:244)
at com.ibm.ws.webcontainer.servlet.ServletWrapper.init(ServletWrapper.java:332)
at com.ibm.ws.webcontainer.servlet.ServletWrapper.loadOnStartupCheck(ServletWrapper.java:1428)
at com.ibm.ws.webcontainer.webapp.WebApp.doLoadOnStartupActions(WebApp.java:1181)
at com.ibm.ws.webcontainer.webapp.WebApp.commonInitializationFinally(WebApp.java:1149)
at com.ibm.ws.webcontainer.webapp.WebApp.initialize(WebApp.java:1055)
at com.ibm.ws.webcontainer.webapp.WebApp.initialize(WebApp.java:6499)
at com.ibm.ws.webcontainer.osgi.DynamicVirtualHost.startWebApp(DynamicVirtualHost.java:446)
at com.ibm.ws.webcontainer.osgi.DynamicVirtualHost.createRunnableHandler(DynamicVirtualHost.java:248)
at com.ibm.ws.webcontainer.osgi.DynamicVirtualHost.createRunnableHandler(DynamicVirtualHost.java:313)
at com.ibm.ws.http.internal.VirtualHostImpl.discriminate(VirtualHostImpl.java:251)
at com.ibm.ws.http.dispatcher.internal.channel.HttpDispatcherLink.ready(HttpDispatcherLink.java:300)
at com.ibm.ws.http.channel.internal.inbound.HttpInboundLink.handleDiscrimination(HttpInboundLink.java:471)
at com.ibm.ws.http.channel.internal.inbound.HttpInboundLink.handleNewRequest(HttpInboundLink.java:405)
at com.ibm.ws.http.channel.internal.inbound.HttpInboundLink.processRequest(HttpInboundLink.java:285)
at com.ibm.ws.http.channel.internal.inbound.HttpInboundLink.ready(HttpInboundLink.java:256)
at com.ibm.ws.tcpchannel.internal.NewConnectionInitialReadCallback.sendToDiscriminators(NewConnectionInitialReadCallback.java:174)
at com.ibm.ws.tcpchannel.internal.NewConnectionInitialReadCallback.complete(NewConnectionInitialReadCallback.java:83)
at com.ibm.ws.tcpchannel.internal.WorkQueueManager.requestComplete(WorkQueueManager.java:504)
at com.ibm.ws.tcpchannel.internal.WorkQueueManager.attemptIO(WorkQueueManager.java:574)
at com.ibm.ws.tcpchannel.internal.WorkQueueManager.workerRun(WorkQueueManager.java:929)
at com.ibm.ws.tcpchannel.internal.WorkQueueManager$Worker.run(WorkQueueManager.java:1018)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1153)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
at java.lang.Thread.run(Thread.java:785)
Caused by: javax.naming.NameNotFoundException: CDIExtension
at com.ibm.ws.jndi.internal.ContextNode.lookup(ContextNode.java:218)
at com.ibm.ws.jndi.internal.WSContext.lookup(WSContext.java:297)
at com.ibm.ws.jndi.WSContextBase.lookup(WSContextBase.java:62)
at com.sun.jersey.server.impl.cdi.CDIExtension.getInitializedExtension(CDIExtension.java:181)
... 33 more




Caused by: java.lang.ClassCastException: com.sun.jersey.server.impl.cdi.CDIExtension incompatible with com.sun.jersey.server.impl.cdi.CDIExtension
at com.sun.jersey.server.impl.cdi.CDIExtension.getInitializedExtension(CDIExtension.java:181)
at com.sun.jersey.server.impl.cdi.CDIComponentProviderFactory.<init>(CDIComponentProviderFactory.java:95)
at com.sun.jersey.server.impl.cdi.CDIComponentProviderFactoryInitializer.initialize(CDIComponentProviderFactoryInitializer.java:76)
at com.sun.jersey.spi.container.servlet.WebComponent.configure(WebComponent.java:572)
at com.sun.jersey.spi.container.servlet.ServletContainer$InternalWebComponent.configure(ServletContainer.java:332)
at com.sun.jersey.spi.container.servlet.WebComponent.load(WebComponent.java:604)
at com.sun.jersey.spi.container.servlet.WebComponent.init(WebComponent.java:207)
at com.sun.jersey.spi.container.servlet.ServletContainer.init(ServletContainer.java:394)
at com.sun.jersey.spi.container.servlet.ServletContainer.init(ServletContainer.java:577)
at javax.servlet.GenericServlet.init(GenericServlet.java:244)
at com.ibm.ws.webcontainer.servlet.ServletWrapper.init(ServletWrapper.java:332)
... 1 more

最佳答案

请查看this link ,这对我很有帮助。

设置system-property即可解决问题com.sun.jersey.server.impl.cdi.lookupExtensionInBeanManager=true

这可以通过 GlassFish 服务器控制台完成。

  1. 选择节点 -> 配置 -> 服务器配置 -> JVM 设置更改为“JVM 选项”选项卡
  2. 添加新条目

    -Dcom.sun.jersey.server.impl.cdi.lookupExtensionInBeanManager=true

  3. 重新启动服务器

关于javax.naming.NameNotFoundException : CDIExtension,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40540110/

29 4 0