GlassFish 6.2.1 throws 'java.lang.ClassNotFoundException: org.glassfish.jakartaee.jakarta.servlet.ServletContainer' while deploying JAX-RS web service

huangapple go评论50阅读模式
英文:

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 &#x2f&#x3b;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
""

java class

Myapplication class

web.xml

英文:

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&#x3b; 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 &#x2f&#x3b;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

java class

Myapplication class

web.xml

答案1

得分: 1

从您的web.xml文件中删除servletservlet-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.

huangapple
  • 本文由 发表于 2023年6月1日 18:01:15
  • 转载请务必保留本文链接:https://go.coder-hub.com/76380750.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定