Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGreg Wilkins2015-11-26 23:38:43 +0000
committerGreg Wilkins2015-11-26 23:39:52 +0000
commitcea05f17d9ae016ed41f8038462b46a06986ef3e (patch)
treec340d09d2df737745c5b44aca905686e4dc52615
parent81b2a6a4de22ebb3d3e1c857e686bccbfd636c4d (diff)
downloadorg.eclipse.jetty.project-cea05f17d9ae016ed41f8038462b46a06986ef3e.tar.gz
org.eclipse.jetty.project-cea05f17d9ae016ed41f8038462b46a06986ef3e.tar.xz
org.eclipse.jetty.project-cea05f17d9ae016ed41f8038462b46a06986ef3e.zip
483119 - CachingWebAppClassLoader breaks JSP
Cleaned up debugging and impl. No fix for JSP problem
-rw-r--r--examples/embedded/src/main/java/org/eclipse/jetty/embedded/OneWebAppWithJsp.java3
-rw-r--r--jetty-servlet/pom.xml6
-rw-r--r--jetty-servlet/src/main/java/org/eclipse/jetty/servlet/ServletHolder.java11
-rw-r--r--jetty-util/src/main/java/org/eclipse/jetty/util/Loader.java40
-rw-r--r--jetty-webapp/src/main/java/org/eclipse/jetty/webapp/CachingWebAppClassLoader.java39
-rw-r--r--jetty-webapp/src/main/java/org/eclipse/jetty/webapp/WebAppClassLoader.java11
-rw-r--r--tests/test-webapps/test-jetty-webapp/src/main/config/demo-base/webapps/test.xml2
7 files changed, 40 insertions, 72 deletions
diff --git a/examples/embedded/src/main/java/org/eclipse/jetty/embedded/OneWebAppWithJsp.java b/examples/embedded/src/main/java/org/eclipse/jetty/embedded/OneWebAppWithJsp.java
index f391be7e02..58c177a59f 100644
--- a/examples/embedded/src/main/java/org/eclipse/jetty/embedded/OneWebAppWithJsp.java
+++ b/examples/embedded/src/main/java/org/eclipse/jetty/embedded/OneWebAppWithJsp.java
@@ -62,6 +62,7 @@ public class OneWebAppWithJsp
+ warFile.getAbsolutePath() );
}
webapp.setWar( warFile.getAbsolutePath() );
+ webapp.setExtractWAR(true);
// This webapp will use jsps and jstl. We need to enable the
// AnnotationConfiguration in order to correctly
@@ -100,6 +101,8 @@ public class OneWebAppWithJsp
// Start things up!
server.start();
+
+ server.dumpStdErr();
// The use of server.join() the will make the current thread join and
// wait until the server is done executing.
diff --git a/jetty-servlet/pom.xml b/jetty-servlet/pom.xml
index b3db655a84..cc6fb60911 100644
--- a/jetty-servlet/pom.xml
+++ b/jetty-servlet/pom.xml
@@ -49,6 +49,12 @@
<optional>true</optional>
</dependency>
<dependency>
+ <groupId>org.eclipse.jetty</groupId>
+ <artifactId>apache-jsp</artifactId>
+ <version>${project.version}</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
<groupId>org.eclipse.jetty.toolchain</groupId>
<artifactId>jetty-test-helper</artifactId>
<scope>test</scope>
diff --git a/jetty-servlet/src/main/java/org/eclipse/jetty/servlet/ServletHolder.java b/jetty-servlet/src/main/java/org/eclipse/jetty/servlet/ServletHolder.java
index 0bae106bb4..0fed318d8b 100644
--- a/jetty-servlet/src/main/java/org/eclipse/jetty/servlet/ServletHolder.java
+++ b/jetty-servlet/src/main/java/org/eclipse/jetty/servlet/ServletHolder.java
@@ -598,8 +598,6 @@ public class ServletHolder extends Holder<Servlet> implements UserIdentity.Scope
if (_config==null)
_config=new Config();
-
-
// Handle run as
if (_identityService!=null)
{
@@ -612,14 +610,11 @@ public class ServletHolder extends Holder<Servlet> implements UserIdentity.Scope
initJspServlet();
detectJspContainer();
}
+ else if (_forcedPath != null)
+ detectJspContainer();
initMultiPart();
- if (_forcedPath != null && _jspContainer == null)
- {
- detectJspContainer();
- }
-
if (LOG.isDebugEnabled())
LOG.debug("Servlet.init {} for {}",_servlet,getName());
_servlet.init(_config);
@@ -665,6 +660,8 @@ public class ServletHolder extends Holder<Servlet> implements UserIdentity.Scope
/* Set the webapp's classpath for Jasper */
ch.setAttribute("org.apache.catalina.jsp_classpath", ch.getClassPath());
+ System.err.println("JSP ("+ch+","+getName()+") CP="+ch.getClassPath());
+
/* Set up other classpath attribute */
if ("?".equals(getInitParameter("classpath")))
{
diff --git a/jetty-util/src/main/java/org/eclipse/jetty/util/Loader.java b/jetty-util/src/main/java/org/eclipse/jetty/util/Loader.java
index 0280686a2a..885551ffd3 100644
--- a/jetty-util/src/main/java/org/eclipse/jetty/util/Loader.java
+++ b/jetty-util/src/main/java/org/eclipse/jetty/util/Loader.java
@@ -18,15 +18,11 @@
package org.eclipse.jetty.util;
-import java.io.File;
import java.net.URL;
-import java.net.URLClassLoader;
import java.util.Locale;
import java.util.MissingResourceException;
import java.util.ResourceBundle;
-import org.eclipse.jetty.util.resource.Resource;
-
/* ------------------------------------------------------------ */
/** ClassLoader Helper.
* This helper class allows classes to be loaded either from the
@@ -86,7 +82,6 @@ public class Loader
return loadClass(name);
}
-
/* ------------------------------------------------------------ */
public static ResourceBundle getResourceBundle(String name,boolean checkParents,Locale locale)
throws MissingResourceException
@@ -94,40 +89,5 @@ public class Loader
ClassLoader loader=Thread.currentThread().getContextClassLoader();
return loader==null ? ResourceBundle.getBundle(name, locale) : ResourceBundle.getBundle(name, locale, loader);
}
-
- /* ------------------------------------------------------------ */
- /**
- * Generate the classpath (as a string) of all classloaders
- * above the given classloader.
- *
- * This is primarily used for jasper.
- * @param loader the classloader to use
- * @return the system class path
- * @throws Exception if unable to generate the classpath from the resource references
- */
- public static String getClassPath(ClassLoader loader) throws Exception
- {
- StringBuilder classpath=new StringBuilder();
- while (loader != null && (loader instanceof URLClassLoader))
- {
- URL[] urls = ((URLClassLoader)loader).getURLs();
- if (urls != null)
- {
- for (int i=0;i<urls.length;i++)
- {
- Resource resource = Resource.newResource(urls[i]);
- File file=resource.getFile();
- if (file!=null && file.exists())
- {
- if (classpath.length()>0)
- classpath.append(File.pathSeparatorChar);
- classpath.append(file.getAbsolutePath());
- }
- }
- }
- loader = loader.getParent();
- }
- return classpath.toString();
- }
}
diff --git a/jetty-webapp/src/main/java/org/eclipse/jetty/webapp/CachingWebAppClassLoader.java b/jetty-webapp/src/main/java/org/eclipse/jetty/webapp/CachingWebAppClassLoader.java
index b099a34810..dd31a6162b 100644
--- a/jetty-webapp/src/main/java/org/eclipse/jetty/webapp/CachingWebAppClassLoader.java
+++ b/jetty-webapp/src/main/java/org/eclipse/jetty/webapp/CachingWebAppClassLoader.java
@@ -25,6 +25,8 @@ import java.util.concurrent.ConcurrentHashMap;
import org.eclipse.jetty.util.ConcurrentHashSet;
import org.eclipse.jetty.util.annotation.ManagedObject;
import org.eclipse.jetty.util.annotation.ManagedOperation;
+import org.eclipse.jetty.util.log.Log;
+import org.eclipse.jetty.util.log.Logger;
/**
@@ -36,6 +38,8 @@ import org.eclipse.jetty.util.annotation.ManagedOperation;
@ManagedObject
public class CachingWebAppClassLoader extends WebAppClassLoader
{
+ private static final Logger LOG = Log.getLogger(CachingWebAppClassLoader.class);
+
private final ConcurrentHashSet<String> _notFound = new ConcurrentHashSet<>();
private final ConcurrentHashMap<String,URL> _cache = new ConcurrentHashMap<>();
@@ -53,7 +57,11 @@ public class CachingWebAppClassLoader extends WebAppClassLoader
public URL getResource(String name)
{
if (_notFound.contains(name))
+ {
+ if (LOG.isDebugEnabled())
+ LOG.debug("Not found cache hit resource {}",name);
return null;
+ }
URL url = _cache.get(name);
@@ -63,6 +71,8 @@ public class CachingWebAppClassLoader extends WebAppClassLoader
if (url==null)
{
+ if (LOG.isDebugEnabled())
+ LOG.debug("Caching not found resource {}",name);
_notFound.add(name);
}
else
@@ -75,33 +85,26 @@ public class CachingWebAppClassLoader extends WebAppClassLoader
}
@Override
- protected Class<?> loadClass(String name, boolean resolve) throws ClassNotFoundException
+ public Class<?> loadClass(String name) throws ClassNotFoundException
{
if (_notFound.contains(name))
- throw new ClassNotFoundException(name+": in notfound cache");
- try
- {
- return super.loadClass(name,resolve);
- }
- catch (ClassNotFoundException nfe)
{
- _notFound.add(name);
- throw nfe;
- }
- }
-
- @Override
- protected Class<?> findClass(String name) throws ClassNotFoundException
- {
- if (_notFound.contains(name))
+ if (LOG.isDebugEnabled())
+ LOG.debug("Not found cache hit resource {}",name);
throw new ClassNotFoundException(name+": in notfound cache");
+ }
try
{
- return super.findClass(name);
+ return super.loadClass(name);
}
catch (ClassNotFoundException nfe)
{
- _notFound.add(name);
+ if (_notFound.add(name))
+ if (LOG.isDebugEnabled())
+ {
+ LOG.debug("Caching not found {}",name);
+ LOG.debug(nfe);
+ }
throw nfe;
}
}
diff --git a/jetty-webapp/src/main/java/org/eclipse/jetty/webapp/WebAppClassLoader.java b/jetty-webapp/src/main/java/org/eclipse/jetty/webapp/WebAppClassLoader.java
index 67241f3ff0..7fbd1aae09 100644
--- a/jetty-webapp/src/main/java/org/eclipse/jetty/webapp/WebAppClassLoader.java
+++ b/jetty-webapp/src/main/java/org/eclipse/jetty/webapp/WebAppClassLoader.java
@@ -452,13 +452,6 @@ public class WebAppClassLoader extends URLClassLoader
/* ------------------------------------------------------------ */
@Override
- public Class<?> loadClass(String name) throws ClassNotFoundException
- {
- return loadClass(name, false);
- }
-
- /* ------------------------------------------------------------ */
- @Override
protected Class<?> loadClass(String name, boolean resolve) throws ClassNotFoundException
{
synchronized (getClassLoadingLock(name))
@@ -526,7 +519,11 @@ public class WebAppClassLoader extends URLClassLoader
LOG.debug("loadedClass({})=={} from={} tried_parent={}",name,c,source,tried_parent);
if (resolve)
+ {
resolveClass(c);
+ if (LOG.isDebugEnabled())
+ LOG.debug("resolved({})=={} from={} tried_parent={}",name,c,source,tried_parent);
+ }
return c;
}
diff --git a/tests/test-webapps/test-jetty-webapp/src/main/config/demo-base/webapps/test.xml b/tests/test-webapps/test-jetty-webapp/src/main/config/demo-base/webapps/test.xml
index d5a5f4bf4c..fc42f03a8f 100644
--- a/tests/test-webapps/test-jetty-webapp/src/main/config/demo-base/webapps/test.xml
+++ b/tests/test-webapps/test-jetty-webapp/src/main/config/demo-base/webapps/test.xml
@@ -42,11 +42,13 @@ detected.
</Set>
<!-- Set Caching Classloader that improves performance on resource searching webapps -->
+ <!--
<Set name="classLoader">
<New class="org.eclipse.jetty.webapp.CachingWebAppClassLoader">
<Arg><Ref refid="testWebapp"/></Arg>
</New>
</Set>
+ -->
<!-- Enable symlinks
<Call name="addAliasCheck">

Back to the top