Web应用程序[/ firstws]中的Servlet [cxf]抛出了load()异常。 java.lang.ClassNotFoundException:org.apache.cxf.transport.servlet.CXFServlet

时间:2017-06-07 23:26:43

标签: java web-services maven tomcat servlets

我试图在localhost上的tomcat服务器上运行一个Web服务。任何人都可以帮帮我。

Maven clean和Maven安装成功。但是在启动Tomcat服务器时会弹出错误。错误消息是:

战争文件在目标目录中生成cxf-rt-transports-http-3.0.2jar存在于目录中。

尝试删除服务器并重新启动服务器。 此文件中有一条警告,说" src / main / webapp / services not found "

的index.jsp

storage :fog

的pom.xml:

 <html>
   <body>
       <!--the warning is below line at href attribute--!>
       <h2>Hello World! <a href="/services"> available services </a>
      </h2>
   </body>
    </html>

的web.xml:

<project xmlns="http://maven.apache.org/POM/4.0.0" 
            xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
            xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 
            http://maven.apache.org/maven-v4_0_0.xsd">
           <modelVersion>4.0.0</modelVersion>
           <groupId>com.vasu.sample</groupId>
           <artifactId>firstws</artifactId>
           <packaging>war</packaging>
           <version>1.0</version>
           <name>firstws Maven Webapp</name>
           <url>http://maven.apache.org</url>



             <build>
            <plugins>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-compiler-plugin</artifactId>
                    <version>3.2</version>
                    <configuration>
                        <source>1.8</source>
                        <target>1.8</target>
                    </configuration>
                </plugin>
                <plugin>
                    <artifactId>maven-war-plugin</artifactId>
                    <version>2.1</version>
                    <configuration>
                        <webXml>src/main/webapp/WEB-INF/web.xml</webXml>

                    </configuration>
                </plugin>
                <plugin>
                    <groupId>org.apache.cxf</groupId>
                    <artifactId>cxf-codegen-plugin</artifactId>
                    <version>3.0.2</version>

                    <executions>
                        <execution>
                            <id>generate-sources</id>
                            <phase>generate-sources</phase>
                            <configuration>
                                <sourceRoot>${basedir}/src/generated</sourceRoot>
                                <wsdlOptions>                                   
                                    <wsdlOption>
                <wsdl>${basedir}/src/main/webapp/WEB-
                                   INF/wsdl/CustomerOrders.wsdl</wsdl>
                                    </wsdlOption>
                                </wsdlOptions>
                            </configuration>
                            <goals>
                                <goal>wsdl2java</goal>
                            </goals>
                        </execution>
                    </executions>

                </plugin>

            </plugins>

            <finalName>firstws</finalName>
        </build>

        <dependencies>
            <dependency>
                <groupId>org.apache.cxf</groupId>
                <artifactId>cxf-rt-frontend-jaxws</artifactId>
                <version>3.0.2</version>
            </dependency>

            <!-- Jetty is needed if you're are not using the CXFServlet -->
            <dependency>
                <groupId>org.apache.cxf</groupId>
                <artifactId>cxf-rt-transports-http-jetty</artifactId>
                <version>3.0.2</version>
            </dependency>
            <dependency>
                <groupId>org.springframework</groupId>
                <artifactId>spring-core</artifactId>
                <version>3.2.0.RELEASE</version>
            </dependency>

            <dependency>
                <groupId>org.springframework</groupId>
                <artifactId>spring-context</artifactId>
                <version>3.2.0.RELEASE</version>
            </dependency>

            <dependency>
                <groupId>org.springframework</groupId>
                <artifactId>spring-tx</artifactId>
                <version>3.2.0.RELEASE</version>
            </dependency>

            <dependency>
                <groupId>org.springframework</groupId>
                <artifactId>spring-orm</artifactId>
                <version>3.2.0.RELEASE</version>
            </dependency>

            <dependency>
                <groupId>org.springframework</groupId>
                <artifactId>spring-web</artifactId>
                <version>3.2.0.RELEASE</version>
            </dependency>

            <dependency>
                <groupId>org.springframework</groupId>
                <artifactId>spring-webmvc</artifactId>
                <version>3.2.0.RELEASE</version>
            </dependency>

            <dependency>
                <groupId>org.apache.cxf</groupId>
                <artifactId>cxf-rt-ws-security</artifactId>
                <version>3.0.2</version>
            </dependency>
            <dependency>
                <groupId>org.apache.cxf</groupId>
                <artifactId>cxf-rt-transports-http</artifactId>
                <version>3.0.2</version>
            </dependency>

            <dependency>
                <groupId>commons-httpclient</groupId>
                <artifactId>commons-httpclient</artifactId>
                <version>3.1</version>
            </dependency>

        </dependencies>

    </project>

的cxf-servlet.xml中:

 <?xml version="1.0" encoding="UTF-8"?>

      <web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
     xmlns="http://java.sun.com/xml/ns/javaee"
     xsi:schemaLocation="http://java.sun.com/xml/ns/javaee 
     http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
       version="2.5">
   <display-name>cxf</display-name>
     <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>
 </web-app>

0 个答案:

没有答案