java – maven-tomcat7-plugin生成损坏的可执行JAR

前端之家收集整理的这篇文章主要介绍了java – maven-tomcat7-plugin生成损坏的可执行JAR前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我使用Maven Tomcat7插件生成带有嵌入式Tomcat7实例的JAR存档时遇到问题.这是我的pom.xml片段:
<plugin>
            <groupId>org.apache.tomcat.maven</groupId>
            <artifactId>tomcat7-maven-plugin</artifactId>
            <version>2.2</version>
            <configuration>
                <path>/${project.artifactId}</path>
            </configuration>
            <executions>
                <execution>
                    <phase>package</phase>
                    <goals>
                        <goal>exec-war</goal>
                    </goals>
                </execution>
            </executions>
        </plugin>

我的项目使用战争包装.生成包含项目的WAR存档的Tomcat的JAR文件,但是当我尝试运行它时,我收到错误

java.io.FileNotFoundException: /home/rafal.wrzeszcz/workspace/Mailer/.extract/webapps/mailer.war
    at java.util.zip.ZipFile.open(Native Method)
    at java.util.zip.ZipFile.<init>(ZipFile.java:214)
    at java.util.zip.ZipFile.<init>(ZipFile.java:144)
    at java.util.jar.JarFile.<init>(JarFile.java:153)
    at java.util.jar.JarFile.<init>(JarFile.java:90)
    at sun.net.www.protocol.jar.URLJarFile.<init>(URLJarFile.java:93)
    at sun.net.www.protocol.jar.URLJarFile.getJarFile(URLJarFile.java:69)
    at sun.net.www.protocol.jar.JarFileFactory.get(JarFileFactory.java:88)
    at sun.net.www.protocol.jar.JarURLConnection.connect(JarURLConnection.java:122)
    at sun.net.www.protocol.jar.JarURLConnection.getJarFile(JarURLConnection.java:89)
    at org.apache.catalina.startup.ExpandWar.expand(ExpandWar.java:113)
    at org.apache.catalina.startup.ContextConfig.fixDocBase(ContextConfig.java:722)
    at org.apache.catalina.startup.ContextConfig.init(ContextConfig.java:843)
    at org.apache.catalina.startup.ContextConfig.lifecycleEvent(ContextConfig.java:387)
    at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:119)
    at org.apache.catalina.util.LifecycleBase.fireLifecycleEvent(LifecycleBase.java:90)
    at org.apache.catalina.util.LifecycleBase.setStateInternal(LifecycleBase.java:402)
    at org.apache.catalina.util.LifecycleBase.init(LifecycleBase.java:110)
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:139)
    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)

我试过插件版本2.1 – 相同的结果.

这是通过执行JAR提取的目录树:

$ls -AR .extract
.extract:
conf  logs  temp  webapps  work

.extract/conf:

.extract/logs:
access_log.2014-03-07

.extract/temp:

.extract/webapps:

.extract/work:
Tomcat

.extract/work/Tomcat:
localhost

.extract/work/Tomcat/localhost:
mailer

.extract/work/Tomcat/localhost/mailer:

(你可以看到没有复制的文件)

解决方法

从配置中删除路径.并使用2.1版本的tomcat插件.在我的pom文件中进行这两项更改为我修复了类似的问题. 我还在重新运行之前清理了$M2_REPO / org / apache文件夹.
原文链接:https://www.f2er.com/java/125375.html

猜你在找的Java相关文章