Listeners' requestDestoyed() method not called in exception cases

2015-05-15 Thread Pilkington, Simon
We recently ran into an issue where the requestDestroyed() method of listeners 
were not being called when exceptions were propagated out of our application.

Looking into the code, it seems related to this[1]. Is this the expected 
behavior for listeners and we can’t rely on the requestDestroyed() method 
always being called for a request? 

One option we have considered is migrating to exclusively using filters and 
handling the exceptional use case explicitly there. Is there a recommended 
approach for this use case?

-Simon



[1] 
http://grepcode.com/file/repo1.maven.org/maven2/org.apache.tomcat.embed/tomcat-embed-core/7.0.59/org/apache/catalina/core/ApplicationDispatcher.java#486

[Tomcat8] What happened to WebappLoader.addRepository()?

2015-03-17 Thread Pilkington, Simon
Hey tomcat users,

The javadoc for WebappLoader still tells me to use addRepository(), but that 
method no longer exists. My team has implemented an extension of WebappLoader 
that looked like this:

https://tomcat.apache.org/tomcat-7.0-doc/api/org/apache/catalina/loader/WebappLoader.html
https://tomcat.apache.org/tomcat-8.0-doc/api/org/apache/catalina/loader/WebappLoader.html

   @Override
   protected void startInternal() throws LifecycleException {
   // validate the context, which is used for debugging messages
   Context context;
   {
   Container container = getContainer();
   if (container == null) {
   throw new LifecycleException(Container is null?!);
   }
   if (!(container instanceof Context)) {
   throw new LifecycleException(Container is not an instance of 
Context?!);
   }
   context = (Context) container;
   }

   if (ENVIRONMENT_ROOT != null  ENVIRONMENT_ROOT.length()  0) {
   // validate targetPackage
   if (null == targetPackage) {
   throw new LifecycleException(
   Missing required Loader attribute \targetPackage\ in 
Context configuration  +
   context.getConfigFile());
   }

   try {
   // Excluded jars are those already pulled in by tomcat.
   SetString allExcludedJars = getAllExcludedJars();
   SetString reallyExcludedJars = new HashSetString();
   // add JARs from target package as repositories
   // getPackageClasspath finds the list of jars I want to include 
for this webapp.
   for (String jar : getPackageClasspath(targetPackage)) {
   File file = new File(ENVIRONMENT_ROOT, jar);
   // skip bad and unwanted JARs
   if (allExcludedJars.contains(jar) || isBadJar(file)) {
   reallyExcludedJars.add(jar);
   } else {
   // TODO: HOW TO FIX ME??
   addRepository(file.toURI().toString());
   }
   }
   log.info(Context path \ + context.getPath() + \ excluding 
JARs:  + reallyExcludedJars);
   } catch (IOException e) {
   throw new LifecycleException(
   Problem setting classpath for context path \ + 
context.getPath() + \,
   e);
   }

   // getRepositoriesString() has been renamed to 
getLoaderRepositoriesString()...
   log.info(Context path \ + context.getPath() + \ using 
classpath:  + getRepositoriesString());
   } else {
   log.warning(MyWebappLoader seems to be used outside of my 
environment. Delegating to parent.);
   }

   super.startInternal();
   }

Can the community help me figure out how to upgrade this for tomcat 8?