Summary: | Tomcat messes up when a class has the same name as a package | ||
---|---|---|---|
Product: | Tomcat 5 | Reporter: | Paul Hamer <paul> |
Component: | Servlet & JSP API | Assignee: | Tomcat Developers Mailing List <dev> |
Status: | RESOLVED DUPLICATE | ||
Severity: | major | ||
Priority: | P2 | ||
Version: | 5.5.17 | ||
Target Milestone: | --- | ||
Hardware: | PC | ||
OS: | Windows XP | ||
Attachments: |
TC webapp to test this yourselves
New test-it-yourself TC webapp sorry, previous zip did not contain the sources |
Description
Paul Hamer
2006-03-24 08:50:42 UTC
Created attachment 17966 [details]
TC webapp to test this yourselves
Thanks for the test case. It makes looking at bugs like this so much quicker. My environment: Windows Home SP2 + all patches Java 1.5.0_04 Tomcat 5.5.HEAD and 5.5.15 I can't reproduce this. I confirmed the suspect code was present in the JSP by reviewing the source code generated in the work directory. The JSP was compilied with the Eclipse 3.1.2 compilier. This looks like a problem with your environment. I've finally been able to narrow down this problem. It appears that it occurs
ONLY when the classes are in the Java classpath, and NOT (as in most cases) in
the WEB-INF/classes directory. I'll attach a new ZIP in a minute.
Meanwhile, I've also migrated to Tomcat 5.5.17, but the problem remains.
Just unpack the zip (mytest2.zip) into your tomcat/webapps directory. The
index.jsp will now compile fine, just to prove it actually works :-)
Now, here we go:
- Stop Tomcat
- Rename the mytest/WEB-INF/classes dir to mytest/WEB-INF/klasses .
This will prevent Tomcat from picking it up.
- Now add the mytest/WEB-INF/klasses dir to the Java classpath. My new
classpath then is:
C:\Program Files\Tomcat5.5\bin\bootstrap.jar;C:\Program Files\Tomcat5.5
\webapps\mytest\WEB-INF\klasses
- Restart Tomcat
- Make sure you "touch" index.jsp to force re-compilation.
- Visit index.jsp
et voila... there you have it:
> gui.editor cannot be resolved to a type
When I then (keep Tomcat running) delete the WEB-INF/klasses/gui/Editor.class
file, and re-visit the index.jsp, it suddenly compiles!
Go figure :-)
My environment:
Windows XP Pro SP2 + all patches
Java 1.5.0_04
Tomcat 5.5.16 + 5.5.17
Hope this helps to finally locate this bug. Would help me a lot. I've already
got many applications out in the field using these classes, so renaming them is
not really an option :-(
Thanx!
Paul Hamer
Created attachment 18378 [details]
New test-it-yourself TC webapp
Goes with my reply above
Created attachment 18379 [details]
sorry, previous zip did not contain the sources
If you mess with the classpath like this you are asking for trouble and are on your own. See http://tomcat.apache.org/tomcat-5.5-doc/class-loader-howto.html for an explanation of why it isn't as simple as justing adding stuff to your classpath. Also, be aware that the Tomcat startup scripts may over-write your classpath anyway. In Tomcat 6.0.20, I cannot reproduce this issue as is (by deploying the web application from attachment 18379 [details]), but I can if I move the class files from WEB-INF/classes into ${catalina.home}/lib Thus, the issue does exist, but is not observed with web applications, because different class loaders behave differently. My environment: - Windows XP Prof. SP3 - JRE 1.6.0_13-b03 - Tomcat 6.0.20 A workaround is to pack the classes into a jar file. *** This bug has been marked as a duplicate of bug 47323 *** |