gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-11-28 22:02:58 25 4
gpt4 key购买 nike

我正在尝试设置 Maven 以将我的应用程序部署到 Tomcat 以适应不同的环境。当我部署到本地主机时一切正常,但是当我尝试部署到开发服务器时,它部署失败。但是,如果我告诉 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 文件中的 modeboth 更改为 war。)一切正常并加载应用程序。

谢谢。

最佳答案

抱歉,由于 Tomcat 的限制,不可能。上下文文件必须在服务器上。

关于java - 远程服务器上的 tomcat7-maven-plugin contextFile,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21052186/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com