The test case here (and its backports to TC 8, 7) broke configuration of Eclipse IDE for Tomcat 7/8/9, with the following error:
The declared package "org.apache.tomcat" does not match the expected package "webapp-3.0.WEB-INF.classes.org.apache.tomcat" Bug58096.java /tomcat-7.0.x/test/webapp-3.0/WEB-INF/classes/org/apache/tomcat line 17 Java Problem The .classpath file of Eclipse currently has <classpathentry kind="src" path="test"/> There are two possible solutions here: 1) Reconfigure Eclipse classpath, so that non-java subdirectories are excluded from compilation classpath. For Tomcat 8 and 9 the above classpath line becomes <classpathentry excluding="deployment/|tld/|webapp*/|webresources/" kind="src" path="test"/> I have not reviewed the Ant build file nor Netbeans configuration. 2) Move java source files into a subdirectory and reconfigure classpath accordingly. "2)" will be more long term solution, but it needs a follow-up to fix tests that will be broken by such move (I mean lines like "new File("test/webapp/WEB-INF/classes");" below). So I opt for 1) for now. Best regards, Konstantin Kolinko 2015-07-06 12:29 GMT+03:00 <ma...@apache.org>: > Author: markt > Date: Mon Jul 6 09:29:44 2015 > New Revision: 1689346 > > URL: http://svn.apache.org/r1689346 > Log: > Fix https://issues.apache.org/bugzilla/show_bug.cgi?id=58096 > Ensure that the correct codeBase is returned for classes loaded from > WEB-INF/classes > > Added: > tomcat/trunk/test/org/apache/catalina/webresources/TestFileResource.java > (with props) > tomcat/trunk/test/webapp/WEB-INF/classes/org/ > tomcat/trunk/test/webapp/WEB-INF/classes/org/apache/ > tomcat/trunk/test/webapp/WEB-INF/classes/org/apache/tomcat/ > tomcat/trunk/test/webapp/WEB-INF/classes/org/apache/tomcat/Bug58096.class > (with props) > tomcat/trunk/test/webapp/WEB-INF/classes/org/apache/tomcat/Bug58096.java > (with props) > tomcat/trunk/test/webapp/bug5nnnn/bug58096.jsp (with props) > Modified: > tomcat/trunk/java/org/apache/catalina/webresources/FileResource.java > > Modified: tomcat/trunk/java/org/apache/catalina/webresources/FileResource.java > URL: > http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/webresources/FileResource.java?rev=1689346&r1=1689345&r2=1689346&view=diff > ============================================================================== > --- tomcat/trunk/java/org/apache/catalina/webresources/FileResource.java > (original) > +++ tomcat/trunk/java/org/apache/catalina/webresources/FileResource.java Mon > Jul 6 09:29:44 2015 > @@ -210,7 +210,11 @@ public class FileResource extends Abstra > > @Override > public URL getCodeBase() { > - return getURL(); > + if (getWebappPath().startsWith("/WEB-INF/classes/") && > name.endsWith(".class")) { > + return > getWebResourceRoot().getResource("/WEB-INF/classes/").getURL(); > + } else { > + return getURL(); > + } > } > > @Override > > Added: > tomcat/trunk/test/org/apache/catalina/webresources/TestFileResource.java > URL: > http://svn.apache.org/viewvc/tomcat/trunk/test/org/apache/catalina/webresources/TestFileResource.java?rev=1689346&view=auto > ============================================================================== > --- tomcat/trunk/test/org/apache/catalina/webresources/TestFileResource.java > (added) > +++ tomcat/trunk/test/org/apache/catalina/webresources/TestFileResource.java > Mon Jul 6 09:29:44 2015 > @@ -0,0 +1,45 @@ > +/* > + * Licensed to the Apache Software Foundation (ASF) under one or more > + * contributor license agreements. See the NOTICE file distributed with > + * this work for additional information regarding copyright ownership. > + * The ASF licenses this file to You under the Apache License, Version 2.0 > + * (the "License"); you may not use this file except in compliance with > + * the License. You may obtain a copy of the License at > + * > + * http://www.apache.org/licenses/LICENSE-2.0 > + * > + * Unless required by applicable law or agreed to in writing, software > + * distributed under the License is distributed on an "AS IS" BASIS, > + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. > + * See the License for the specific language governing permissions and > + * limitations under the License. > + */ > +package org.apache.catalina.webresources; > + > +import java.io.File; > + > +import javax.servlet.http.HttpServletResponse; > + > +import org.junit.Assert; > +import org.junit.Test; > + > +import org.apache.catalina.startup.TomcatBaseTest; > +import org.apache.tomcat.util.buf.ByteChunk; > + > +public class TestFileResource extends TomcatBaseTest { > + > + @Test > + public void doIt() throws Exception { > + getTomcatInstanceTestWebapp(false, true); > + > + ByteChunk out = new ByteChunk(); > + > + int rc = getUrl("http://localhost:" + getPort() + > "/test/bug5nnnn/bug58096.jsp", out, null); > + > + Assert.assertEquals(HttpServletResponse.SC_OK, rc); > + > + // Build the expected location the same way the webapp base dir is > built > + File f = new File("test/webapp/WEB-INF/classes"); > + Assert.assertEquals(f.toURI().toURL().toString(), > out.toString().trim()); > + } > +} > > Propchange: > tomcat/trunk/test/org/apache/catalina/webresources/TestFileResource.java > ------------------------------------------------------------------------------ > svn:eol-style = native > > Added: > tomcat/trunk/test/webapp/WEB-INF/classes/org/apache/tomcat/Bug58096.class > URL: > http://svn.apache.org/viewvc/tomcat/trunk/test/webapp/WEB-INF/classes/org/apache/tomcat/Bug58096.class?rev=1689346&view=auto > ============================================================================== > Binary file - no diff available. > > Propchange: > tomcat/trunk/test/webapp/WEB-INF/classes/org/apache/tomcat/Bug58096.class > ------------------------------------------------------------------------------ > svn:mime-type = application/octet-stream > > Added: > tomcat/trunk/test/webapp/WEB-INF/classes/org/apache/tomcat/Bug58096.java > URL: > http://svn.apache.org/viewvc/tomcat/trunk/test/webapp/WEB-INF/classes/org/apache/tomcat/Bug58096.java?rev=1689346&view=auto > ============================================================================== > --- tomcat/trunk/test/webapp/WEB-INF/classes/org/apache/tomcat/Bug58096.java > (added) > +++ tomcat/trunk/test/webapp/WEB-INF/classes/org/apache/tomcat/Bug58096.java > Mon Jul 6 09:29:44 2015 > @@ -0,0 +1,24 @@ > +/* > + * Licensed to the Apache Software Foundation (ASF) under one or more > + * contributor license agreements. See the NOTICE file distributed with > + * this work for additional information regarding copyright ownership. > + * The ASF licenses this file to You under the Apache License, Version 2.0 > + * (the "License"); you may not use this file except in compliance with > + * the License. You may obtain a copy of the License at > + * > + * http://www.apache.org/licenses/LICENSE-2.0 > + * > + * Unless required by applicable law or agreed to in writing, software > + * distributed under the License is distributed on an "AS IS" BASIS, > + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. > + * See the License for the specific language governing permissions and > + * limitations under the License. > + */ > +package org.apache.tomcat; > + > +/** > + * Contains no functionality since it is only used tp test the code source > + * assigned to the class. > + */ > +public class Bug58096 { > +} > > Propchange: > tomcat/trunk/test/webapp/WEB-INF/classes/org/apache/tomcat/Bug58096.java > ------------------------------------------------------------------------------ > svn:eol-style = native > > Added: tomcat/trunk/test/webapp/bug5nnnn/bug58096.jsp > URL: > http://svn.apache.org/viewvc/tomcat/trunk/test/webapp/bug5nnnn/bug58096.jsp?rev=1689346&view=auto > ============================================================================== > --- tomcat/trunk/test/webapp/bug5nnnn/bug58096.jsp (added) > +++ tomcat/trunk/test/webapp/bug5nnnn/bug58096.jsp Mon Jul 6 09:29:44 2015 > @@ -0,0 +1,17 @@ > +<%-- > + Licensed to the Apache Software Foundation (ASF) under one or more > + contributor license agreements. See the NOTICE file distributed with > + this work for additional information regarding copyright ownership. > + The ASF licenses this file to You under the Apache License, Version 2.0 > + (the "License"); you may not use this file except in compliance with > + the License. You may obtain a copy of the License at > + > + http://www.apache.org/licenses/LICENSE-2.0 > + > + Unless required by applicable law or agreed to in writing, software > + distributed under the License is distributed on an "AS IS" BASIS, > + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. > + See the License for the specific language governing permissions and > + limitations under the License. > +--%> > +<%= > org.apache.tomcat.Bug58096.class.getProtectionDomain().getCodeSource().getLocation() > %> > \ No newline at end of file > > Propchange: tomcat/trunk/test/webapp/bug5nnnn/bug58096.jsp > ------------------------------------------------------------------------------ > svn:eol-style = native > > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org > For additional commands, e-mail: dev-h...@tomcat.apache.org > --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org For additional commands, e-mail: dev-h...@tomcat.apache.org