英文:
GlassFish 6.2.1 throws 'java.lang.ClassNotFoundException: org.glassfish.jakartaee.jakarta.servlet.ServletContainer' while deploying JAX-RS web service
问题
我使用 Jakarta EE 9、GlassFish 6.2.1 服务器和 NetBeans 14 创建了一个 RESTful Web 服务。无法部署,因为在 GlassFish 服务器的日志文件中出现了一些错误。错误如下:
" [2023-06-01T14:16:12.835+0530] [glassfish 6.2] [WARNING] [] [org.glassfish.jersey.servlet.init.JerseyServletContainerInitializer] [tid: _ThreadID=55 _ThreadName=admin-listener(1)] [timeMillis: 1685609172835] [levelValue: 900] [[
映射冲突。存在与 Jersey Servlet 应用具有相同映射的 Servlet 注册,名称为 com.ayush1.server.MyApplication,位于 Servlet 映射 /api/*。]]"
"[2023-06-01T14:16:12.840+0530] [glassfish 6.2] [INFO] [] [jakarta.enterprise.web] [tid: _ThreadID=55 _ThreadName=admin-listener(1)] [timeMillis: 1685609172840] [levelValue: 800] [[
WebModule[/rest2] ServletContext.log(): 将 Servlet jakarta-servlet 标记为不可用。]]"
"[2023-06-01T14:16:12.841+0530] [glassfish 6.2] [SEVERE] [] [jakarta.enterprise.web] [tid: _ThreadID=55 _ThreadName=admin-listener(1)] [timeMillis: 1685609172841] [levelValue: 1000] [[
WebModule[/rest2] 错误加载 WebappClassLoader(delegate=true; repositories=WEB-INF/classes/)org.glassfish.jakartaee.jakarta.servlet.ServletContainer
java.lang.ClassNotFoundException: org.glassfish.jakartaee.jakarta.servlet.ServletContainer
""
"[2023-06-01T14:16:12.843+0530] [glassfish 6.2] [SEVERE] [] [jakarta.enterprise.web] [tid: _ThreadID=55 _ThreadName=admin-listener(1)] [timeMillis: 1685609172843] [levelValue: 1000] [[
WebModule[/rest2]Servlet /rest2 threw load() exception
java.lang.ClassNotFoundException: org.glassfish.jakartaee.jakarta.servlet.ServletContainer""
"[2023-06-01T14:16:12.852+0530] [glassfish 6.2] [SEVERE] [AS-WEB-CORE-00108] [jakarta.enterprise.web.core] [tid: _ThreadID=55 _ThreadName=admin-listener(1)] [timeMillis: 1685609172852] [levelValue: 1000] [[
ContainerBase.addChild: start:
org.apache.catalina.LifecycleException: org.apache.catalina.LifecycleException: java.lang.ClassNotFoundException: org.glassfish.jakartaee.jakarta.servlet.ServletContainer
""
英文:
I used Jakarta EE 9, glassfish 6.2.1 server and NetBeans 14 to create a restful web service.
Couldn't deploy it as got some errors in the log file of Glassfish server.
The error was :
" [2023-06-01T14:16:12.835+0530] [glassfish 6.2] [WARNING] [] [org.glassfish.jersey.servlet.init.JerseyServletContainerInitializer] [tid: _ThreadID=55 _ThreadName=admin-listener(1)] [timeMillis: 1685609172835] [levelValue: 900] [[
Mapping conflict. A Servlet registration exists with same mapping as the Jersey servlet application, named com.ayush1.server.MyApplication, at the servlet mapping, /api/*.]]
[2023-06-01T14:16:12.840+0530] [glassfish 6.2] [INFO] [] [jakarta.enterprise.web] [tid: _ThreadID=55 _ThreadName=admin-listener(1)] [timeMillis: 1685609172840] [levelValue: 800] [[
WebModule[/rest2] ServletContext.log():Marking servlet jakarta-servlet as unavailable]]
[2023-06-01T14:16:12.841+0530] [glassfish 6.2] [SEVERE] [] [jakarta.enterprise.web] [tid: _ThreadID=55 _ThreadName=admin-listener(1)] [timeMillis: 1685609172841] [levelValue: 1000] [[
WebModule[/rest2]Error loading WebappClassLoader (delegate=true; repositories=WEB-INF/classes/) org.glassfish.jakartaee.jakarta.servlet.ServletContainer
java.lang.ClassNotFoundException: org.glassfish.jakartaee.jakarta.servlet.ServletContainer
"
"[2023-06-01T14:16:12.843+0530] [glassfish 6.2] [SEVERE] [] [jakarta.enterprise.web] [tid: _ThreadID=55 _ThreadName=admin-listener(1)] [timeMillis: 1685609172843] [levelValue: 1000] [[
WebModule[/rest2]Servlet /rest2 threw load() exception
java.lang.ClassNotFoundException: org.glassfish.jakartaee.jakarta.servlet.ServletContainer"
"
[2023-06-01T14:16:12.852+0530] [glassfish 6.2] [SEVERE] [AS-WEB-CORE-00108] [jakarta.enterprise.web.core] [tid: _ThreadID=55 _ThreadName=admin-listener(1)] [timeMillis: 1685609172852] [levelValue: 1000] [[
ContainerBase.addChild: start:
org.apache.catalina.LifecycleException: org.apache.catalina.LifecycleException: java.lang.ClassNotFoundException: org.glassfish.jakartaee.jakarta.servlet.ServletContainer
"
1: https://i.stack.imgur.com/cdMMM.png
答案1
得分: 1
从您的web.xml文件中删除servlet
和servlet-mapping
元素。它们与GlassFish在部署您的应用程序时创建的REST servlet存在冲突。
英文:
Remove the servlet
and servlet-mapping
elements from your web.xml file. They conflict with the REST servlet created by GlassFish when your app is deployed.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论