远程服务器上的tomcat7-maven-plugin contextFile

时间:2014-01-10 18:55:10

标签: java maven tomcat tomcat7 maven-tomcat-plugin

我正在尝试设置maven以将我的应用程序部署到Tomcat以用于不同的环境。当我部署到localhost时,一切正常,但是当尝试部署到开发服务器时,它无法部署。但是,如果我告诉tomcat7-maven-plugin不要部署context.xml文件,一切正常。

的pom.xml

...
<profiles>
    <profile>
        <id>local</id>
        <build>
            <plugins>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-war-plugin</artifactId>
                    <version>2.4</version>
                    <configuration>
                        <webXml>src\main\webapp\WEB-INF\web.xml</webXml>
                    </configuration>
                </plugin>
                <plugin>
                    <groupId>org.apache.tomcat.maven</groupId>
                    <artifactId>tomcat7-maven-plugin</artifactId>
                    <version>2.2</version>
                    <configuration>
                        <url>http://localhost:8888/manager/text</url>
                        <username>admin</username>
                        <password>admin</password>
                        <mode>both</mode>
                        <contextFile>${project.build.directory}/${project.build.finalName}/META-INF/local/context.xml</contextFile>
                    </configuration>
                </plugin>
            </plugins>
        </build>
    </profile>
    <profile>
        <id>dve</id>
        <build>
            <plugins>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-war-plugin</artifactId>
                    <version>2.4</version>
                    <configuration>
                        <webXml>src\main\webapp\WEB-INF\web.xml</webXml>
                    </configuration>
                </plugin>
                <plugin>
                    <groupId>org.apache.tomcat.maven</groupId>
                    <artifactId>tomcat7-maven-plugin</artifactId>
                    <version>2.2</version>
                    <configuration>
                        <url>http://devserver.mycompany.com:8083/manager/text</url>
                        <username>myusername</username>
                        <password>mypassword</password>
                        <mode>both</mode>
                        <warFile>${project.build.directory}/${project.build.finalName}.war</warFile>
                        <contextFile>${project.build.directory}/${project.build.finalName}/META-INF/dve/context.xml</contextFile>
                    </configuration>
                </plugin>
            </plugins>
        </build>
    </profile>
</profiles>
...

这是maven在运行 mvn tomcat7时告诉我的:redeploy -Pdve

...
[INFO] Deploying war and context to http://devserver.mycompany:8083/myProject
[DEBUG] No server specified for authentication - using defaults
[INFO] OK - Undeployed application at context path /eDiscovery
[INFO] FAIL - Failed to deploy application at context path /eDiscovery
...

这是来自“devserver”的catalina.out

Jan 10, 2014 1:34:00 PM org.apache.catalina.core.ApplicationContext log
INFO: Manager: install: Installing context configuration at 'file:/C:/Users/MyLocalUserName/git/myProject/target/myProject-0.0.1/META-INF/dve/context.xml' from 'file:/C:/Users/MyLocalUserName/git/myProject/target/myProject-0.0.1.war'
Jan 10, 2014 1:34:00 PM org.apache.catalina.core.ApplicationContext log
INFO: Manager: undeploy: Undeploying web application at '/myProject'
Jan 10, 2014 1:34:01 PM org.apache.catalina.startup.HostConfig checkResources
INFO: Undeploying context [/myProject]
java.io.FileNotFoundException: /C:/Users/MyLocalUserName/git/myProject/target/myProject-0.0.1/META-INF/dve/context.xml (No such file or directory)
    at java.io.FileInputStream.open(Native Method)
    at java.io.FileInputStream.<init>(FileInputStream.java:120)
    at org.apache.catalina.manager.ManagerServlet.copyInternal(ManagerServlet.java:1652)
    at org.apache.catalina.manager.ManagerServlet.copy(ManagerServlet.java:1613)
    at org.apache.catalina.manager.ManagerServlet.deploy(ManagerServlet.java:843)
    at org.apache.catalina.manager.ManagerServlet.doGet(ManagerServlet.java:353)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:621)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
    at org.apache.catalina.filters.SetCharacterEncodingFilter.doFilter(SetCharacterEncodingFilter.java:108)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:224)
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:169)
    at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:581)
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:168)
    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:98)
    at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:927)
    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:407)
    at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:987)
    at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:579)
    at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:307)
    at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
    at java.lang.Thread.run(Thread.java:662)
java.io.FileNotFoundException: /C:/Users/MyLocalUserName/git/myProject/target/myProject-0.0.1.war (No such file or directory)
    at java.io.FileInputStream.open(Native Method)
    at java.io.FileInputStream.<init>(FileInputStream.java:120)
    at org.apache.catalina.manager.ManagerServlet.copyInternal(ManagerServlet.java:1652)
    at org.apache.catalina.manager.ManagerServlet.copy(ManagerServlet.java:1613)
    at org.apache.catalina.manager.ManagerServlet.deploy(ManagerServlet.java:848)
    at org.apache.catalina.manager.ManagerServlet.doGet(ManagerServlet.java:353)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:621)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
    at org.apache.catalina.filters.SetCharacterEncodingFilter.doFilter(SetCharacterEncodingFilter.java:108)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:224)
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:169)
    at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:581)
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:168)
    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:98)
    at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:927)
    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:407)
    at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:987)
    at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:579)
    at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:307)
    at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
    at java.lang.Thread.run(Thread.java:662)

看起来服务器正在尝试从我的本地路径加载context.xml文件,它无权访问。有谁知道如何解决这一问题?如果我关闭了context.xml的加载(通过将模式两者更改为pom文件中的 war )。一切正常和应用程序加载。

感谢。

1 个答案:

答案 0 :(得分:0)

由于Tomcat限制,很抱歉。 上下文文件必须位于服务器上。