我的应用程序上下文被定义为my/path/to/Tomcat/conf/Catalina/localhost/my-app.xml
中的XML文件。
<Context docBase='/my/path/to/myApp/myAppWarFile.war'>
<Environment name='my_config_dir' value='/my/path/to/myApp' type='java.lang.String'/>
</Context>
/my/path/to/myApp
包含WAR文件myAppWarFile.war以及Spring读取的许多外部化属性。
Tomcat配置为关闭autoDeploy。当我启动Tomcat时,它会创建my/path/to/Tomcat/conf/webapps/my-app/
并且WAR文件会按预期解压缩到此位置,并且应用程序可以按预期运行。
当我想在不重启Tomcat的情况下部署新版本时,我按如下方式运行undeploy命令:
curl http://localhost:8080/manager/text/undeploy?path=/my-app --user my-username:my-password
......这很有效。但是当我指示Tomcat使用以下curl语句进行部署时,我遇到了失败。
curl http://localhost:8080/manager/text/deploy?config=file:/my/path/to/Tomcat/conf/Catalina/localhost/my-app.xml --user my-username:my-password
# Tomcat response
FAIL - Invalid context path null was specified
添加路径没有多大帮助,我仍然失败了。
curl http://localhost:8080/manager/text/deploy?config=file:/my/path/to/Tomcat/conf/Catalina/localhost/my-app.xml\&path=/my-app --user my-username:my-password
# Tomcat response
FAIL - Failed to deploy application at context path /my-app
最糟糕的是拖尾catalina.out并没有产生任何洞察力。最重要的是,Tomcat删除了应用程序上下文XML文件my/path/to/Tomcat/conf/Catalina/localhost/my-app.xml
!
当然我已经查看了Tomcat文档(https://tomcat.apache.org/tomcat-8.0-doc/manager-howto.html#Deploy_using_a_Context_configuration_%22.xml%22_file),我已经用Google搜索了一整天来解决这个问题,但是我没有找到任何可以帮助我完成这一特定配置的内容。
感觉好像是选择:
/my/path/to/myApp/
将导致Tomcat热部署应用程序。是否有人使用此配置完成此工作?
编辑:
我开始登录Catalina。当我运行没有路径的第一个deploy命令时,我得到这组日志条目:
FINE: Start processing with input [config=file:/my/apth/to/tomcat/conf/Catalina/localhost/my-app.xml]
Oct 13, 2015 10:04:53 AM org.apache.coyote.AbstractProtocol$AbstractConnectionHandler process
FINE: Socket: [org.apache.tomcat.util.net.SocketWrapper@189651c1:Socket[addr=/0:0:0:0:0:0:0:1,port=45415,localport=8080]], Status in: [OPEN_READ], State out: [OPEN]
Oct 13, 2015 10:04:53 AM org.apache.coyote.http11.AbstractHttp11Processor process
FINE: Error parsing HTTP request header
java.io.EOFException: Unexpected EOF read on the socket
at org.apache.coyote.http11.Http11Processor.setRequestLineReadTimeout(Http11Processor.java:168)
at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:982)
at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:611)
at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:316)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
at java.lang.Thread.run(Thread.java:744)
Oct 13, 2015 10:04:53 AM org.apache.coyote.AbstractProtocol$AbstractConnectionHandler process
FINE: Socket: [org.apache.tomcat.util.net.SocketWrapper@189651c1:Socket[addr=/0:0:0:0:0:0:0:1,port=45415,localport=8080]], Status in: [OPEN_READ], State out: [CLOSED]
Oct 13, 2015 10:04:53 AM org.apache.tomcat.util.threads.LimitLatch countDown
FINE: Counting down[http-bio-8080-exec-16] latch=1
答案 0 :(得分:1)
你试过了吗?
curl --upload-file /my/path/to/my-app.war http://localhost:8080/manager/text/deploy?path=/my-app --user my-username:my-password