Bug 68035 - Deploying a directory from Host appBase fails
Summary: Deploying a directory from Host appBase fails
Status: RESOLVED FIXED
Alias: None
Product: Tomcat 10
Classification: Unclassified
Component: Manager (show other bugs)
Version: 10.1.15
Hardware: PC All
: P2 normal (vote)
Target Milestone: ------
Assignee: Tomcat Developers Mailing List
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2023-10-31 18:33 UTC by brandgutz
Modified: 2023-12-12 12:29 UTC (History)
0 users



Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description brandgutz 2023-10-31 18:33:24 UTC
I have a webapp directory "my-webapp" in apache-tomcat/webapps. A .war file does NOT exist. 

Executing the GET request http://localhost:8080/manager/text/deploy?war=/my-webapp fails with the message "FAIL - Failed to deploy application at context path [/my-webapp]"

Stack Trace:
31-Oct-2023 11:31:09.887 SEVERE [http-nio-8080-exec-7] org.apache.catalina.startup.ExpandWar.copy Error copying [my-webapp] to [apache-tomcat\webapps\my-webapp]
        java.io.FileNotFoundException: my-webapp (The system cannot find the file specified)
                at java.base/java.io.FileInputStream.open0(Native Method)
                at java.base/java.io.FileInputStream.open(FileInputStream.java:216)
                at java.base/java.io.FileInputStream.<init>(FileInputStream.java:157)
                at org.apache.catalina.startup.ExpandWar.copy(ExpandWar.java:270)
                at org.apache.catalina.manager.ManagerServlet.deploy(ManagerServlet.java:954)
                at org.apache.catalina.manager.ManagerServlet.doGet(ManagerServlet.java:334)
                at jakarta.servlet.http.HttpServlet.service(HttpServlet.java:564)
                at jakarta.servlet.http.HttpServlet.service(HttpServlet.java:658)
                at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:205)
                at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:149)
                at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:51)
                at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:174)
                at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:149)
                at org.apache.catalina.filters.CorsFilter.handleNonCORS(CorsFilter.java:331)
                at org.apache.catalina.filters.CorsFilter.doFilter(CorsFilter.java:158)
                at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:174)
                at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:149)
                at org.apache.catalina.filters.HttpHeaderSecurityFilter.doFilter(HttpHeaderSecurityFilter.java:129)
                at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:174)
                at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:149)
                at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:167)
                at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:90)
                at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:597)
                at org.apache.catalina.valves.RequestFilterValve.process(RequestFilterValve.java:355)
                at org.apache.catalina.valves.RemoteAddrValve.invoke(RemoteAddrValve.java:54)
                at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:115)
                at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:93)
                at org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:673)
                at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:74)
                at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:340)
                at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:391)
                at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:63)
                at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:896)
                at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1744)
                at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:52)
                at org.apache.tomcat.util.threads.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1191)
                at org.apache.tomcat.util.threads.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:659)
                at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
                at java.base/java.lang.Thread.run(Thread.java:833)


Documentation I am reading is here.
https://tomcat.apache.org/tomcat-10.1-doc/manager-howto.html#Deploy_a_Directory_or_War_from_the_Host_appBase
Comment 1 brandgutz 2023-11-02 02:55:40 UTC
Another note. I have autoDeploy="false" in server.xml.
Comment 2 Remy Maucherat 2023-11-02 10:27:24 UTC
The deploy command is designed to copy from somewhere. So here, you simply want to deploy a webapp from its regular spot, without autodeploy.
Although it is possible to handle it by not copying anything when the final path is already the origin (hence the change to an enhancement), you should be able to deploy a descriptor instead (the "config" parameter) which could also be useful to you thanks to the extra configuration it gives you access to.
Comment 3 Mark Thomas 2023-11-06 17:58:28 UTC
Changing this back to a bug as it is documented to work and it has worked in previous versions. It looks like it was broken by this commit:

https://github.com/apache/tomcat/commit/1f9b47ed2a9ad9039b8a83fa77f2b5ca836f4480

which doesn't consider the src == dest case
Comment 4 Mark Thomas 2023-11-06 19:53:40 UTC
Fixed in:
- 11.0.x for 11.0.0-M14 onwards
- 10.1.x for 10.1.16 onwards
-  9.0.x for  9.0.83 onwards

Note 8.5.x was not affected
Comment 5 brandgutz 2023-12-11 17:49:51 UTC
Tested this again in 10.1.16

Still seeing an issue. Seems like it is trying to deploy the webapp from apache-tomcat/bin rather than appBase.

https://github.com/apache/tomcat/blob/a0d5005d00719ff387408d1379ba4a2b88795cbc/java/org/apache/catalina/manager/ManagerServlet.java#L954

I added some debug statements and here are the logs from manager.

11-Dec-2023 09:40:24.702 INFO [http-nio-8080-exec-1] org.apache.catalina.core.ApplicationContext.log Manager: install: Installing web application '/my-webapp' from 'my-webapp'
11-Dec-2023 09:40:24.704 INFO [http-nio-8080-exec-1] org.apache.catalina.core.ApplicationContext.log Manager: file: 'C:\Users\brandon.gutzmann\Downloads\apache-tomcat-10.1.16-windows-x64\apache-tomcat-10.1.16\bin\my-webapp' local: 'C:\Users\brandon.gutzmann\Downloads\apache-tomcat-10.1.16-windows-x64\apache-tomcat-10.1.16\webapps\my-webapp'
11-Dec-2023 09:40:24.705 INFO [http-nio-8080-exec-1] org.apache.catalina.core.ApplicationContext.log Manager: not equal

And the same error as before

11-Dec-2023 09:40:24.708 SEVERE [http-nio-8080-exec-1] org.apache.catalina.startup.ExpandWar.copy Error copying [my-webapp] to [C:\Users\brandon.gutzmann\Downloads\apache-tomcat-10.1.16-windows-x64\apache-tomcat-10.1.16\webapps\my-webapp]
	java.io.FileNotFoundException: my-webapp (The system cannot find the file specified)
Comment 6 Mark Thomas 2023-12-12 11:43:39 UTC
The original report used ...war=/my-webapp. This is going to try and deploy the directory my-webapp located at the root of the file system which isn't what is required.

The current code will work if you use the full path to the directory in the appBase.

I'll expand the previous fix so ...war=my-webapp also works as documented.
Comment 7 Mark Thomas 2023-12-12 12:29:23 UTC
Fixed in:
- 11.0.x for 11.0.0-M16 onwards
- 10.1.x for 10.1.18 onwards
-  9.0.x for  9.0.85 onwards