Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 326456

Summary: tomcat restarts even when editing an html, css, js, etc
Product: [WebTools] WTP Java EE Tools Reporter: aash
Component: jst.j2eeAssignee: Rob Stryker <stryker>
Status: RESOLVED FIXED QA Contact: Chuck Bridgham <cbridgha>
Severity: major    
Priority: P3 CC: ahfeel+eclipse, andrey.melentyev, ccc, jasonpet, larryisaacs, stryker, thatnitind
Version: 3.2Flags: cbridgha: review+
Target Milestone: 3.2.3   
Hardware: Macintosh   
OS: Mac OS X - Carbon (unsup.)   
Whiteboard:
Attachments:
Description Flags
Patch to restore checking to avoid perpetually modified manifests none

Description aash CLA 2010-09-28 15:23:58 EDT
Build Identifier: 20100917-0705

once a file is saved in WebContent, be it .html, .html, .css, .js, etc, it gets published correctly, then tomcat restarts, although it shouldn't.  going back to galileo prevents this from happening.  i tried deleting and recreating the server.

Reproducible: Always

Steps to Reproduce:
1.  create and start a tomcat Server
2.  edit a tml, css, etc file in WebContent, and save
3.  watch tomcat restart
Comment 1 Larry Isaacs CLA 2010-09-30 11:14:01 EDT
Do you really mean Tomcat server restarts, or does Tomcat just reload the affected webapp?  If just reloading, try creating a new Dynamic Web Project and sprinkle a few HTML, CSS, and JS files in it.  Then see if this "test" project exhibits the same behavior.  There may be a utility project dependency of your web project that is always rebuilding its jar during publishing.  This could trigger Tomcat's auto-reload feature.
Comment 2 aash CLA 2010-09-30 12:03:49 EDT
(In reply to comment #1)
> Do you really mean Tomcat server restarts, or does Tomcat just reload the
> affected webapp?  If just reloading, try creating a new Dynamic Web Project and
> sprinkle a few HTML, CSS, and JS files in it.  Then see if this "test" project
> exhibits the same behavior.  There may be a utility project dependency of your
> web project that is always rebuilding its jar during publishing.  This could
> trigger Tomcat's auto-reload feature.

Yes, I meant reload the webapp instead of restarting.  Sorry for not being precise.

I created a new project, and everything worked as it should.  Then I added a dependent project "common" to the build path, and to the Deployment Assembly (Project -> then selected project common).  Now when I edit a css, etc, the context reloads:

{{
Sep 30, 2010 11:57:26 AM org.apache.catalina.core.StandardContext reload
INFO: Reloading this Context has started
Hello servlet loaded.

}}
Comment 3 Larry Isaacs CLA 2010-09-30 12:48:03 EDT
There was a problem in the past where some Java EE handling was "monkeying" with the MANIFEST.MF that was going into the jar built for the utility project (see Bug 251262 for details).  It made the utility project appear to be perpetually modified.  It's possible a new version of this issue is the source of this behavior.  Can you check the published jar's MANIFEST.MF and any MANIFEST.MF in your "common" project to see if they are different, especially the Classpath attribute.
Comment 4 aash CLA 2010-09-30 12:58:16 EDT
(In reply to comment #3)
> There was a problem in the past where some Java EE handling was "monkeying"
> with the MANIFEST.MF that was going into the jar built for the utility project
> (see Bug 251262 for details).  It made the utility project appear to be
> perpetually modified.  It's possible a new version of this issue is the source
> of this behavior.  Can you check the published jar's MANIFEST.MF and any
> MANIFEST.MF in your "common" project to see if they are different, especially
> the Classpath attribute.

I don't have a MANIFEST.MF in my project, but the one created by eclipse is:

Manifest-Version: 1.0
Class-Path: commons-codec-1.3.jar commons-httpclient-3.1.jar commons-l
 ogging-1.1.1.jar httpcore-4.0.jar httpcore-nio-4.0.jar servlet.jar pe
 rsistence-api-1.0.jar xercesImpl.jar mysql-connector-java-5.1.8-bin.j
 ar jakarta-oro-2.0.8.jar gson-1.3.jar
Comment 5 Larry Isaacs CLA 2010-09-30 13:09:03 EDT
I'm not sure how the absence of a MANIFEST.MF in your project might affect the behavior of the code added for Bug 251262.  Try creating a META-INF folder in your Java source folder and add a MAINIFEST.MF there with the default content of:

Manifest-Version: 1.0
Class-Path:

Then see if the jar stops rebuilding.  Hopefully, it will rebuild one more time after this change, then stop rebuilding for future publishes.  Note you don't have to have Tomcat running to test the rebuilding.  Just do a publish and see if timestamp on the jar changes (assuming at least a minute has passed).
Comment 6 aash CLA 2010-09-30 14:02:53 EDT
(In reply to comment #5)
> I'm not sure how the absence of a MANIFEST.MF in your project might affect the
> behavior of the code added for Bug 251262.  Try creating a META-INF folder in
> your Java source folder and add a MAINIFEST.MF there with the default content
> of:
> 
> Manifest-Version: 1.0
> Class-Path:
> 
> Then see if the jar stops rebuilding.  Hopefully, it will rebuild one more time
> after this change, then stop rebuilding for future publishes.  Note you don't
> have to have Tomcat running to test the rebuilding.  Just do a publish and see
> if timestamp on the jar changes (assuming at least a minute has passed).

Ok, so I added a META-INF to my java src dir, and put in it a MANIFEST.MF and a mytest.xml... when i look in build/classes i see a META-INF dir, and in that META-INF is MANIFEST.MF and mytest.xml, as expected.  However, when eclipse rebuilds the common.jar ('common' is the project), the mytest.xml is in the jar, but the MANIFEST.MF isn't the same!  It seems like eclipse is rebuilding that MANIFEST.MF.  I copied the exact MANIFEST.MF that eclipse creates over to it, and it still causes the restarts.  (of course, you can't tell if eclipse was recreating it, or just using it)  So then, I then added Main-Class: com.company.util.Test to the MANIFEST.MF, and it gets copied to build/classes, but still doesn't make it into the common.jar that wst sees.

(I also tried several iterations of trying to make the Deployment Assembly and Java Build Path entries do the work for me, but to no avail.)

So it seems like the issue is that eclipse is always creating a new MANIFEST.MF?
Comment 7 Larry Isaacs CLA 2010-09-30 14:07:58 EDT
Inspecting source code, it appears the code to address Bug 251262 was removed in revision 1.2 of the org.eclipse.jst.common.internal.modulecore.util.ManifestUtilities.java file.
In answer to the comment in revision 1.1, 

* TODO: why do we check if the file already exists? We should just output to 
* the file and get rid of this manifestClasspaths map. 

Utility projects appear perpetually modified with out it, which causes the the behavior in this bug.  Sorry for not noticing this regression sooner.  Updating product and component.
Comment 8 Carl Anderson CLA 2010-10-04 11:45:01 EDT
Larry, it would appear the Rob was unfamiliar with the reason for the checking of the MANIFEST.MF's existance/changes.  Can you add the check back in?
Comment 9 Larry Isaacs CLA 2010-10-04 13:17:57 EDT
Created attachment 180185 [details]
Patch to restore checking to avoid perpetually modified manifests
Comment 10 Larry Isaacs CLA 2010-10-04 13:22:22 EDT
Since I don't think I have commit privileges for this code, redirecting back to relevant component.
Comment 11 Larry Isaacs CLA 2010-10-04 13:26:01 EDT
Opps, I mean assign it someone who can commit the code, i.e. Rob.  I included comment this time to make it clearer why this checking is present.  Rob, if you think of a better what to accomplish this, feel free to try something different.
Comment 12 Larry Isaacs CLA 2010-10-04 13:27:42 EDT
Correction: /what/way/
Comment 13 Rob Stryker CLA 2010-10-04 23:51:45 EDT
The patch doesn't look offensive to me. I'd be glad to commit after permission
Comment 14 Chuck Bridgham CLA 2010-10-08 15:14:58 EDT
approved
Comment 15 Rob Stryker CLA 2010-10-12 02:35:26 EDT
Committed this to both streams
Comment 16 Larry Isaacs CLA 2010-10-12 13:56:09 EDT
*** Bug 327431 has been marked as a duplicate of this bug. ***
Comment 17 Larry Isaacs CLA 2011-04-07 13:08:03 EDT
*** Bug 328685 has been marked as a duplicate of this bug. ***