You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by "Berneburg, Cris J. - US" <cb...@caci.com.INVALID> on 2021/05/05 19:04:48 UTC

temp folder?

Hi Folks

Sometimes we get strange errors after deployments to our test server.  We just "solved" some weirdness by manually cleaning out the TC temp folder(s) - again.

Googling confirms what I thought about the TC work versus temp folder:
* "work stores compiled JSPs and other assets".
* "temp is used to store files created using the Java File API for creating temporary files".

Looking in our TC temp folder, I see subfolders that match all the webapps (some names changed to protect the not-so-innocent):
* 0-app1
* 1-app2
* 2-app3
* 3-app4
* 4-docs
* 5-manager
* 6-trap

Looking in a subfolder, like temp/3-app4, it appears to be an exact copy of everything in the webapps/app4 folder, which is just the extracted app4.war file.  (The webapps folder has a copy of app4.war.)  The temp/app4 folder does not seem to contain temporary files, like output files for Excel reports, etc.  Same for the other subfolders.  Is that normal?

Some technical specifics:
* TC 8.5.63
* Java 1.8.0_291
* AWS EC2 instance.
* Windows Server 2016.
* Instance started as Windows Service.
* -Dcatalina.home=D:\Tomcat8_1
* -Dcatalina.base=D:\Tomcat8_1
* -Djava.io.tmpdir=D:\Tomcat8_1\temp
* There are other TC instances on the same server.
* Each TC instance has multiple apps.

I see references to the temp folder in tomcat8-stdout.x.log  Below are some excerpts.  Why is it trying to access files in the temp subfolder instead of the webapps subfolder?  (Looks like I have some app debugging to do?)

* 2021-05-05 07:03:38,383 DEBUG [localhost-startStop-1] (?:?) - Attempting to obtain an input stream to file:/D:/Tomcat8_1/temp/0-app1/WEB-INF/classes/action.properties.

* 2021-05-05 07:04:52,426 localhost-startStop-1 DEBUG Apache Log4j Core 2.12.1 initializing configuration XmlConfiguration[location=D:\Tomcat8_1\temp\1-app2\WEB-INF\classes\log4j2.xml]

* 07:04:53.990 [localhost-startStop-1] DEBUG org.springframework.context.annotation.ClassPathBeanDefinitionScanner - Identified candidate component class: file [D:\Tomcat8_1\temp\1-app2\WEB-INF\classes\app\HelloWorld.class]

* 2021-05-05 07:05:10,007 DEBUG [localhost-startStop-1] (?:?) - Attempting to obtain an input stream to file:/D:/Tomcat8_1/temp/2-app3/WEB-INF/classes/action.properties.

--
Cris Berneburg
CACI Senior Software Engineer


________________________________

This electronic message contains information from CACI International Inc or subsidiary companies, which may be company sensitive, proprietary, privileged or otherwise protected from disclosure. The information is intended to be used solely by the recipient(s) named above. If you are not an intended recipient, be aware that any review, disclosure, copying, distribution or use of this transmission or its contents is prohibited. If you have received this transmission in error, please notify the sender immediately.

Re: temp folder?

Posted by Mark Thomas <ma...@apache.org>.
On 07/05/2021 21:09, Christopher Schultz wrote:
> Cris,
> 
> On 5/7/21 14:29, Berneburg, Cris J. - US wrote:
>> Hi Mark
>>
>> Thanks for getting back with me.  :-)
>>
>> markt> What is the setting for unpackWARs for Host?
>>
>> These are the host settings in server.xml:
>>
>> name="localhost"
>> appBase="webapps"
>> unpackWARs="true"
>> autoDeploy="true"
>> deployOnStartup="false"
>>
>> markt> Running directly from a WAR (with unpackWARs="false"
>> markt> file will impact performance. It looks as if something
>> markt> is unpacking the WAR to the temp directory.
>>
>> Where is it supposed to unpack the WAR files to?  I would have
>> thought the work folder.
> webapps/
> 
> (Well... "appBase")

To add to what Chris said, abc.war unpacks to abc (if unpackWARs is 
true) and then the filename is used to derive the context path.

The reason for this is the file names have to be unique so (given how 
file names are converted to context paths) it is guaranteed that context 
paths are unique.

It looks like your WARs are unpacking into appBase (webapps in your 
case) as expected.

>> markt> Tomcat does provide the org.apache.catalina.webresources.
>> markt> ExtractingRoot resources implementation to help alleviate
>> markt> performance issues in this case but that should only
>> markt> extract the JARs in WEB-INF/lib and location they are
>> markt> extracted to should be under the work directory and include
>> markt> "application-jars" in the path.
>>
>> OK good to know that at least for JAR's the "normal" place is the
>> work  folder and *not* the temp folder.
>>
>> markt> Maybe some custom "unpack to temp" code?
>>
>> That's what I'm afraid of.  :-\  What's weird(er) is that the default
>> TC apps like docs and manager are copied to the temp folder too.
>> Also, the subfolders start with a number, like "0-app1", "4-docs",
>> and "5-manager".  Does that provide a clue, or is that just normal?
> I think it points to a process outside of Tomcat's control.

+1.

That apps are trying to access resources from temp suggests at least one 
app is aware of what is going on here.

That manager, docs etc are also in temp is strange. That suggests 
configuration at Host level or above.

The Manager app does have a little used feature (tags) that does store 
apps in temp but if I am reading the code correctly they still get 
deployed to appBase.

>> Could the destination for unpacking the WAR files be changed from
>> default with a setting or an environment variable?
> You can change the appBase on the <Host> but then you have to move your 
> WAR files, too.

You could try making temp read only for the Tomcat user. You might need 
to do that after Tomcat starts as I think it checks it can write. 
Hopefully you'll get an error when something tries to write there.

Mark

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: temp folder?

Posted by Christopher Schultz <ch...@christopherschultz.net>.
Cris,

On 5/7/21 14:29, Berneburg, Cris J. - US wrote:
> Hi Mark
> 
> Thanks for getting back with me.  :-)
> 
> markt> What is the setting for unpackWARs for Host?
> 
> These are the host settings in server.xml:
> 
> name="localhost"
> appBase="webapps"
> unpackWARs="true"
> autoDeploy="true"
> deployOnStartup="false"
> 
> markt> Running directly from a WAR (with unpackWARs="false"
> markt> file will impact performance. It looks as if something
> markt> is unpacking the WAR to the temp directory.
> 
> Where is it supposed to unpack the WAR files to?  I would have
> thought the work folder.
webapps/

(Well... "appBase")

> markt> Tomcat does provide the org.apache.catalina.webresources.
> markt> ExtractingRoot resources implementation to help alleviate
> markt> performance issues in this case but that should only
> markt> extract the JARs in WEB-INF/lib and location they are
> markt> extracted to should be under the work directory and include
> markt> "application-jars" in the path.
> 
> OK good to know that at least for JAR's the "normal" place is the
> work  folder and *not* the temp folder.
> 
> markt> Maybe some custom "unpack to temp" code?
> 
> That's what I'm afraid of.  :-\  What's weird(er) is that the default
> TC apps like docs and manager are copied to the temp folder too.
> Also, the subfolders start with a number, like "0-app1", "4-docs",
> and "5-manager".  Does that provide a clue, or is that just normal?
I think it points to a process outside of Tomcat's control.

> Could the destination for unpacking the WAR files be changed from
> default with a setting or an environment variable?
You can change the appBase on the <Host> but then you have to move your 
WAR files, too.

Hope that helps,
-chris

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


RE: temp folder?

Posted by "Berneburg, Cris J. - US" <cb...@caci.com.INVALID>.
Hi Mark

Thanks for getting back with me.  :-)

markt> What is the setting for unpackWARs for Host?

These are the host settings in server.xml:

name="localhost"
appBase="webapps"
unpackWARs="true"
autoDeploy="true"
deployOnStartup="false"

markt> Running directly from a WAR (with unpackWARs="false"
markt> file will impact performance. It looks as if something
markt> is unpacking the WAR to the temp directory.

Where is it supposed to unpack the WAR files to?  I would have thought the work folder.

markt> Tomcat does provide the org.apache.catalina.webresources.
markt> ExtractingRoot resources implementation to help alleviate
markt> performance issues in this case but that should only
markt> extract the JARs in WEB-INF/lib and location they are
markt> extracted to should be under the work directory and include
markt> "application-jars" in the path.

OK good to know that at least for JAR's the "normal" place is the work folder and *not* the temp folder.

markt> Maybe some custom "unpack to temp" code?

That's what I'm afraid of.  :-\  What's weird(er) is that the default TC apps like docs and manager are copied to the temp folder too.  Also, the subfolders start with a number, like "0-app1", "4-docs", and "5-manager".  Does that provide a clue, or is that just normal?

Could the destination for unpacking the WAR files be changed from default with a setting or an environment variable?

--
Cris Berneburg
CACI Senior Software Engineer

-----Original Message-----

cb> Sometimes we get strange errors after deployments to our
cb> test server.  We just "solved" some weirdness by manually
cb> cleaning out the TC temp folder(s) - again.

cb> Looking in our TC temp folder, I see subfolders that match
cb> all the webapps [...] Looking in a subfolder, like temp/
cb> 3-app4, it appears to be an exact copy of everything in the
cb> webapps/app4 folder, which is just the extracted app4.war
cb> file. [...] The temp/app4 folder does not seem to contain
cb> temporary files, like output files for Excel reports, etc.
cb> Same for the other subfolders.  Is that normal?

cb> I see references to the temp folder in tomcat8-stdout.x.log
cb> [...] Why is it trying to access files in the temp subfolder
cb> instead of the webapps subfolder?  (Looks like I have some
cb> app debugging to do?)


________________________________

This electronic message contains information from CACI International Inc or subsidiary companies, which may be company sensitive, proprietary, privileged or otherwise protected from disclosure. The information is intended to be used solely by the recipient(s) named above. If you are not an intended recipient, be aware that any review, disclosure, copying, distribution or use of this transmission or its contents is prohibited. If you have received this transmission in error, please notify the sender immediately.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: temp folder?

Posted by Mark Thomas <ma...@apache.org>.
What is the setting for unpackWARs for Host?

Running directly from a WAR (with unpackWARs="false" file will impact 
performance. It looks as if something is unpacking the WAR to the temp 
directory.

Tomcat does provide the org.apache.catalina.webresources.ExtractingRoot 
resources implementation to help alleviate performance issues in this 
case but that should only extract the JARs in WEB-INF/lib and location 
they are extracted to should be under the work directory and include 
"application-jars" in the path.

Maybe some custom "unpack to temp" code?

Mark


On 05/05/2021 20:04, Berneburg, Cris J. - US wrote:
> Hi Folks
> 
> Sometimes we get strange errors after deployments to our test server.  We just "solved" some weirdness by manually cleaning out the TC temp folder(s) - again.
> 
> Googling confirms what I thought about the TC work versus temp folder:
> * "work stores compiled JSPs and other assets".
> * "temp is used to store files created using the Java File API for creating temporary files".
> 
> Looking in our TC temp folder, I see subfolders that match all the webapps (some names changed to protect the not-so-innocent):
> * 0-app1
> * 1-app2
> * 2-app3
> * 3-app4
> * 4-docs
> * 5-manager
> * 6-trap
> 
> Looking in a subfolder, like temp/3-app4, it appears to be an exact copy of everything in the webapps/app4 folder, which is just the extracted app4.war file.  (The webapps folder has a copy of app4.war.)  The temp/app4 folder does not seem to contain temporary files, like output files for Excel reports, etc.  Same for the other subfolders.  Is that normal?
> 
> Some technical specifics:
> * TC 8.5.63
> * Java 1.8.0_291
> * AWS EC2 instance.
> * Windows Server 2016.
> * Instance started as Windows Service.
> * -Dcatalina.home=D:\Tomcat8_1
> * -Dcatalina.base=D:\Tomcat8_1
> * -Djava.io.tmpdir=D:\Tomcat8_1\temp
> * There are other TC instances on the same server.
> * Each TC instance has multiple apps.
> 
> I see references to the temp folder in tomcat8-stdout.x.log  Below are some excerpts.  Why is it trying to access files in the temp subfolder instead of the webapps subfolder?  (Looks like I have some app debugging to do?)
> 
> * 2021-05-05 07:03:38,383 DEBUG [localhost-startStop-1] (?:?) - Attempting to obtain an input stream to file:/D:/Tomcat8_1/temp/0-app1/WEB-INF/classes/action.properties.
> 
> * 2021-05-05 07:04:52,426 localhost-startStop-1 DEBUG Apache Log4j Core 2.12.1 initializing configuration XmlConfiguration[location=D:\Tomcat8_1\temp\1-app2\WEB-INF\classes\log4j2.xml]
> 
> * 07:04:53.990 [localhost-startStop-1] DEBUG org.springframework.context.annotation.ClassPathBeanDefinitionScanner - Identified candidate component class: file [D:\Tomcat8_1\temp\1-app2\WEB-INF\classes\app\HelloWorld.class]
> 
> * 2021-05-05 07:05:10,007 DEBUG [localhost-startStop-1] (?:?) - Attempting to obtain an input stream to file:/D:/Tomcat8_1/temp/2-app3/WEB-INF/classes/action.properties.
> 
> --
> Cris Berneburg
> CACI Senior Software Engineer
> 
> 
> ________________________________
> 
> This electronic message contains information from CACI International Inc or subsidiary companies, which may be company sensitive, proprietary, privileged or otherwise protected from disclosure. The information is intended to be used solely by the recipient(s) named above. If you are not an intended recipient, be aware that any review, disclosure, copying, distribution or use of this transmission or its contents is prohibited. If you have received this transmission in error, please notify the sender immediately.
> 


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org