1 Reply Latest reply on May 11, 2003 11:33 AM by Raja

    Struts Exception on undeploy

    Raja Master

      I have a basic app that uses Struts 1.1RC1 , everything works well when the app is deployed. When i try to undeploy the app, i get a stack trace that a resource is not found.
      When i looked at the struts code, this is what i have.

      if (log.isTraceEnabled()) {
      log.trace(" Loading resource '" + name + "'");
      ClassLoader classLoader =
      if (classLoader == null) {
      classLoader = this.getClass().getClassLoader();
      is = classLoader.getResourceAsStream(name);

      The "name" thats loaded is org/apache/struts/action/ActionResources.properties which is a standard properties file that comes along with Struts. The interesting part is this is getting loaded during initialization but fails only during undeployment.
      This is the Stack Trace that i get from jboss.
      at org.apache.naming.resources.WARDirContext.treeLookup(WARDirContext.java:842)
      at org.apache.naming.resources.WARDirContext.getAttributes(WARDirContext.java:493)
      at org.apache.naming.resources.WARDirContext.getAttributes(WARDirContext.java:474)
      at org.apache.naming.resources.BaseDirContext.getAttributes(BaseDirContext.java:789)
      at org.apache.naming.resources.ProxyDirContext.cacheLoad(ProxyDirContext.java:1426)
      at org.apache.naming.resources.ProxyDirContext.cacheLookup(ProxyDirContext.java:1350)
      at org.apache.naming.resources.ProxyDirContext.lookup(ProxyDirContext.java:257)
      at org.apache.catalina.loader.WebappClassLoader.findResourceInternal(WebappClassLoader.java:1691)
      at org.apache.catalina.loader.WebappClassLoader.findResource(WebappClassLoader.java:999)
      at org.apache.catalina.loader.WebappClassLoader.getResourceAsStream(WebappClassLoader.java:1203)
      at org.apache.struts.util.PropertyMessageResources.loadLocale(PropertyMessageResources.java:294)
      at org.apache.struts.util.PropertyMessageResources.getMessage(PropertyMessageResources.java:192)

      Shoudnt the classloader be able to find this resource given that its a part of the struts distribution?


        • 1. Re: Struts Exception on undeploy
          Raja Master

          Did a little more research on the AbstractwebContainer.java that does the start/stop for web apps.
          Shouldnt the stop set the contextclass loader before it calls performUndeploy(). The code in performDeploy is something like

          Thread thread = Thread.currentThread();
          ClassLoader appClassLoader = thread.getContextClassLoader();
          // Create a classloader for the war to ensure a unique ENC
          URL[] empty = {};
          URLClassLoader warLoader = URLClassLoader.newInstance(empty, di.ucl);

          but the stop method just does a performUndeploy which means its operating on the appclassloader rather than the thread contextclassloader.
          since struts depends on the threadcontextclassloader to get some resources, the undeploy operation fails.

          Is this a bug in Jboss or am i wrong in my conclusion above?
          I will post this in Tomcat forum also.

          One other thing i did was move all the struts libraries to the default/lib directory and in this case i did *NOT* have any issues as the appclassloader does find these classes and loads the resources.