【问题标题】:Servlet mapping not found error while deploying JAX RS application to web sphere 8.5将 JAX RS 应用程序部署到 Web Sphere 8.5 时未找到 Servlet 映射错误
【发布时间】:2021-08-16 18:31:08
【问题描述】:

我是网络服务的新手。已经使用 Eclipse 在 java 中开发了一个简单的 rest web svc,Tomcat 遵循这个link。应用程序在 Tomcat 上成功运行,但是当我将它部署到 IBM WebSphere 8.5.5 时。它部署成功,但无法启动。我知道它与我的 Web.xml 相关,因此我将其添加以进行整改。尝试this,但无济于事。

<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://xmlns.jcp.org/xml/ns/javaee" xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd" version="3.1">
  <display-name>wstest</display-name>
  <welcome-file-list>
    <welcome-file>index.html</welcome-file>
    <welcome-file>index.htm</welcome-file>
    <welcome-file>index.jsp</welcome-file>
    <welcome-file>default.html</welcome-file>
    <welcome-file>default.htm</welcome-file>
    <welcome-file>default.jsp</welcome-file>
  </welcome-file-list>
 
  <servlet>
    <servlet-name>Java WS</servlet-name>
    <servlet-class>org.glassfish.jersey.servlet.ServletContainer</servlet-class>
    
  
  <init-param>
  <param-name>jersey.config.server.provider.packages</param-name>
  <param-value>book</param-value>
  </init-param>
   <load-on-startup>3</load-on-startup>
   </servlet>
  
  <servlet-mapping>
  <servlet-name>Java WS</servlet-name>
  <url-pattern>/*</url-pattern>
  
  
  </servlet-mapping>
</web-app> 

当我尝试启动应用程序时生成的WebSphere日志是:-

0000112c ApplicationMg A   WSVR0204I: Application: TestWS_war  Application build level: Unknown
0000112c webapp        E com.ibm.ws.wswebcontainer.webapp.WebAppConfigurationHelper 
constructServletMappings SRVE0303E: Servlet name for the servlet mapping /* could not be found.
0000112c DeployedAppli W   WSVR0206E: Module, TestWS.war, of application, TestWS_war.ear/deployments/TestWS_war, 
failed to start
0000112c ApplicationMg W   WSVR0101W: An error occurred starting, TestWS_war
0000112c ApplicationMg A   WSVR0217I: Stopping application: TestWS_war
0000112c ApplicationMg A   WSVR0220I: Application stopped: TestWS_war
0000112c CompositionUn E   WSVR0194E: Composition unit WebSphere:cuname=TestWS_war in BLA 
WebSphere:blaname=TestWS_war failed to start.
0000112c MBeanHelper   E   Could not invoke an operation on object: 
WebSphere:name=ApplicationManager,process=server1,platform=proxy,node=svrNode01,
version=8.5.5.0,type=ApplicationManager,mbeanIdentifier=ApplicationManager,
cell=svrNode01Cell,spec=1.0 
because of an mbean exception: com.ibm.ws.exception.RuntimeWarning: 
SRVE0303E: Servlet name for the servlet mapping /* could not be found.

我已经尝试了类加载选项 Parent First 和 Parent Last 但无济于事。

【问题讨论】:

  • 你能edit你的问题并提供任何相关服务器日志错误的文本吗?
  • @andrewjames 先生请添加日志。

标签: java eclipse rest web-services websphere


【解决方案1】:

它给出了类路径中缺少“org.glassfish.jersey.servlet.ServletContainer”的错误。因此应用程序没有启动。

查看与 WAS 8.5.5 兼容的 Jersey 版本吗? (我认为是泽西 1.x)。需要用到对应的库。

<servlet>
    <servlet-name>javax.ws.rs.core.Application</servlet-name>
</servlet>
<servlet-mapping>
  <servlet-name>javax.ws.rs.core.Application</servlet-name>
  <url-pattern>/rest/*</url-pattern>
</servlet-mapping>

【讨论】:

  • 我查过了。但是没有默认应用程序,我停止了所有已安装的应用程序并将上下文根更改为 testWS,然后我在 book.ws 和 web.xml 中创建了另一个包,将 /* 更改为 /ws/*。但是,它抛出了同样的错误,即找不到 servlet 映射 /ws/*。
  • 转到管理控制台并查看 web 应用程序的上下文根 (Test_ws)
  • 先生,我已经检查了它的 TESTWS
  • 已更新答案,这不是由于 DefaultWebApplication。这是因为在 Tomcat 中有效但在 WAS 中无效的 servlet 类不正确
  • 我使用 web.xml 从你的答案将 url 模式更改为 /book/* 但应用程序没有在 tomcat 上的开发环境中运行。
猜你喜欢
  • 2016-08-19
  • 2016-12-06
  • 1970-01-01
  • 2013-02-15
  • 1970-01-01
  • 1970-01-01
  • 2017-09-25
  • 2011-01-05
相关资源
最近更新 更多