在Tomcat服务器8.0上部署基于Java的Webservice时出错

时间:2015-08-19 16:16:00

标签: java xml web-services tomcat servlets

我目前正在尝试使用Apache Tomcat服务器8.0部署基于Java的Web服务。当我尝试部署时,我收到以下错误:

SEVERE: Error configuring application listener of class  org.springframework.web.context.ContextLoaderListener
java.lang.NoClassDefFoundError: javax/servlet/ServletContextListener

由于错误是有两个映射的servlet [AxisServlet]和[CXF],我试图在web.xml文件(WEB-INF / web.xml)中注释掉一个并部署,新的错误是:< / p>

<?xml version="1.0" encoding="UTF-8"?>
<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>beA_WS</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>
     <display-name>Apache-Axis Servlet</display-name>
     <servlet-name>AxisServlet</servlet-name>
     <servlet-class>org.apache.axis.transport.http.AxisServlet</servlet-class>
   </servlet>
   <servlet-mapping>
     <servlet-name>AxisServlet</servlet-name>
     <url-pattern>/servlet/AxisServlet</url-pattern>
    </servlet-mapping>
  <servlet-mapping>
     <servlet-name>AxisServlet</servlet-name>
     <url-pattern>*.jws</url-pattern>
  </servlet-mapping>
  <servlet-mapping>
     <servlet-name>AxisServlet</servlet-name>
     <url-pattern>/services/*</url-pattern>
     </servlet-mapping>
  <servlet>
    <display-name>Axis Admin Servlet</display-name>
    <servlet-name>AdminServlet</servlet-name>
    <servlet-class>org.apache.axis.transport.http.AdminServlet</servlet-class>
    <load-on-startup>100</load-on-startup>
  </servlet>
  <servlet-mapping>
    <servlet-name>AdminServlet</servlet-name>
    <url-pattern>/servlet/AdminServlet</url-pattern>
  </servlet-mapping>
  <servlet>
     <description>Apache CXF Endpoint</description>
     <display-name>cxf</display-name>
     <servlet-name>cxf</servlet-name>
     <servlet-class>org.apache.cxf.transport.servlet.CXFServlet</servlet-class>
     <load-on-startup>1</load-on-startup>
  </servlet>
  <servlet-mapping>
    <servlet-name>cxf</servlet-name>
    <url-pattern>/services/*</url-pattern>
    </servlet-mapping>
  <session-config>
     <session-timeout>60</session-timeout>
  </session-config>
  <context-param>
    <param-name>contextConfigLocation</param-name>
    <param-value>WEB-INF/cxf-beans.xml</param-value>
   </context-param>
   <listener>
     <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>

我不知道我是否遗漏了一些东西,请在这方面帮助我。

我的web.xml如下:

item.error || item.available

1 个答案:

答案 0 :(得分:0)

Servlet AdminServlet有一个servlet AxisServlet所涵盖的路径,您需要将AdminServlet的路径更改为其他内容,例如/_admin_servlet

你得到的第二个错误是因为库初始化,我不是Spring专家也不是粉丝。只检查是否为所有内容设置了所有依赖项,有时库a依赖于lib b,其中遗漏了b,以及加载lib a的异常

好的做法是,如果可以,将容器隔离/专用于一个特定的业务/项目,并且只需将所有库放在库指定的文件夹下(lib大多数时间)