2

我在 Tomcat 上创建了 Maven Web 服务。它成功地与 Netbeans 一起运行。我尝试使用本教程将我的 Web 服务部署到 heroku:https ://devcenter.heroku.com/articles/java-webapp-runner 。但我得到这些错误:

 ekcdr@ekcdr-EasyNote-RS65-M-001TK:~/NetBeansProjects/webserviceHeroku_tc2$ java -jar target/endorsed/webapp-runner.jar target/*.war
Adding Context / for target/webserviceHeroku_tc2-1.0-SNAPSHOT.war
Haz 04, 2013 12:03:51 PM org.apache.coyote.AbstractProtocol init
INFO: Initializing ProtocolHandler ["http-nio-8080"]
Haz 04, 2013 12:03:51 PM org.apache.tomcat.util.net.NioSelectorPool getSharedSelector
INFO: Using a shared selector for servlet write/read
Haz 04, 2013 12:03:51 PM org.apache.catalina.core.StandardService startInternal
INFO: Starting service Tomcat
Haz 04, 2013 12:03:51 PM org.apache.catalina.core.StandardEngine startInternal
INFO: Starting Servlet Engine: Apache Tomcat/7.0.34
Haz 04, 2013 12:03:51 PM org.apache.catalina.startup.ContextConfig getDefaultWebXmlFragment
INFO: No global web.xml found
Haz 04, 2013 12:03:53 PM org.apache.catalina.core.StandardContext listenerStart
SEVERE: Error configuring application listener of class com.sun.xml.ws.transport.http.servlet.WSServletContextListener
java.lang.ClassNotFoundException: com.sun.xml.ws.transport.http.servlet.WSServletContextListener
    at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1714)
    at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1559)
    at org.apache.catalina.core.DefaultInstanceManager.loadClass(DefaultInstanceManager.java:532)
    at org.apache.catalina.core.DefaultInstanceManager.loadClassMaybePrivileged(DefaultInstanceManager.java:514)
    at org.apache.catalina.core.DefaultInstanceManager.newInstance(DefaultInstanceManager.java:133)
    at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4727)
    at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5285)
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
    at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1559)
    at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1549)
    at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:334)
    at java.util.concurrent.FutureTask.run(FutureTask.java:166)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
    at java.lang.Thread.run(Thread.java:722)

Haz 04, 2013 12:03:53 PM org.apache.catalina.core.StandardContext listenerStart
SEVERE: Skipped installing application listeners due to previous error(s)
Haz 04, 2013 12:03:53 PM org.apache.catalina.core.StandardContext startInternal
SEVERE: Error listenerStart
Haz 04, 2013 12:03:53 PM org.apache.catalina.core.StandardContext startInternal
SEVERE: Context [/] startup failed due to previous errors
SEVERE: Context [/] failed in [org.apache.catalina.core.StandardContext] lifecycle. Allowing Tomcat to shutdown.
Haz 04, 2013 12:03:53 PM org.apache.coyote.AbstractProtocol start
INFO: Starting ProtocolHandler ["http-nio-8080"]

pom.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/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <groupId>com.mycompany</groupId>
    <artifactId>webserviceHeroku_tc2</artifactId>
    <version>1.0-SNAPSHOT</version>
    <packaging>war</packaging>

    <name>webserviceHeroku_tc2</name>

    <properties>
        <endorsed.dir>${project.build.directory}/endorsed</endorsed.dir>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    </properties>

    <dependencies>
        <dependency>
            <groupId>javax</groupId>
            <artifactId>javaee-web-api</artifactId>
            <version>6.0</version>
            <scope>provided</scope>
        </dependency>
    </dependencies>

    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>2.3.2</version>
                <configuration>
                    <source>1.6</source>
                    <target>1.6</target>
                    <compilerArguments>
                        <endorseddirs>${endorsed.dir}</endorseddirs>
                    </compilerArguments>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-war-plugin</artifactId>
                <version>2.1.1</version>
                <configuration>
                    <failOnMissingWebXml>false</failOnMissingWebXml>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-dependency-plugin</artifactId>
                <version>2.1</version>
                <executions>
                    <execution>
                        <phase>validate</phase>
                        <goals>
                            <goal>copy</goal>
                        </goals>
                        <configuration>
                            <outputDirectory>${endorsed.dir}</outputDirectory>
                            <silent>true</silent>
                            <artifactItems>
                                <artifactItem>
                                    <groupId>javax</groupId>
                                    <artifactId>javaee-endorsed-api</artifactId>
                                    <version>6.0</version>
                                    <type>jar</type>
                                </artifactItem>
                                <artifactItem>
                                    <groupId>com.github.jsimone</groupId>
                                    <artifactId>webapp-runner</artifactId>
                                    <version>7.0.34.0</version>
                                    <destFileName>webapp-runner.jar</destFileName>
                                </artifactItem>
                            </artifactItems>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>

</project>

问题是什么?

4

2 回答 2

3

看来您没有com.sun.xml.ws.transport.http.servlet.WSServletContextListenerpom.xml.
添加以下存储库(如果已添加,请忽略)和依赖项pom.xml

<repository>
    <id>deprecated</id>
    <name>JBoss Deprecated</name>
    <url>https://repository.jboss.org/nexus/content/repositories/‌​deprecated</url>
</repository>

<dependency>
   <groupId>com.sun.xml</groupId>
   <artifactId>jaxws-rt</artifactId>
   <version>2.0EA3</version>
</dependency>  

现在,打包您的应用程序并进行部署。

注意:
问题的根本原因是jar运行应用程序所需的文件在您的netbeans classpath(因此,它可以成功运行)中可用,而application.war在使用 maven 构建时它没有添加到您的(WEB-INF/lib)中。

希望能帮助到你。快乐学习。

于 2013-06-04T09:25:50.960 回答
0

我们必须从 jax-ws lib 文件夹中复制一些 jar 文件并粘贴到 tomcat/lib 文件夹中

于 2020-02-07T05:09:22.260 回答