3 Replies Latest reply on Mar 10, 2008 5:05 PM by Peter Johnson

    5.0 beta3, war class scoping problem

    Peter Johnson Master

      JBossAS 5.0 beta3 has changed the scoping of classes within war files. Previously (as in 4.x.x, and even in beta3 as of last September), if a class in some other archive (such as an ear) attempted to instantiate a class packaged in a war, I got a exception. With beta3 (and beta4 pulled today after Adrian's classloader change - JBAS-5119), the class is successfully instantiated.

      At first I thought that the "useJBossWebLoader" property might now default to true, but is is still false.

      Is this new behavior intended, or are the new class loaders broke?

        • 1. Re: 5.0 beta3, war class scoping problem
          Dimitris Andreadis Master

          Peter, can you create a very simple example to demonstrate this?

          Any classloader changes made to AS5 were mostly to satisfy TCK requirements, however, we do use scoped deployments in the ear deployer in that particular setup.

           <property name="isolated">true</property>
           <property name="callByValue">true</property>

          • 2. Re: 5.0 beta3, war class scoping problem
            Peter Johnson Master

            Here are the test files:


            package peter.scope;
            import java.io.*;
            import javax.servlet.ServletException;
            import javax.servlet.http.*;
            public class RouteServlet extends HttpServlet {
             protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException,
             IOException {
             InEar ie = new InEar();
             String result = ie.route();
             PrintWriter out = resp.getWriter();
             out.print("<html><body><h2>" + result + "</h2></body></html>");
             protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException,
             IOException {
             doGet(req, resp);

            package peter.scope;
            public class InWar {
             public String route() {
             return "oops";

            package peter.scope;
            public class InEar {
             public String route() {
             String result = null;
             try {
             result = callInWar();
             } catch (Throwable e) {
             result = "exception when calling InWar: " + e;
             return result;
             private String callInWar() {
             InWar id = new InWar();
             return id.route();


            <?xml version="1.0" encoding="UTF-8"?>
            <web-app xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
             xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"

            Compile the three Java source files together. Then package the files as follows:

            inear.jar should contain:

            inear.ear should contain:

            route.war should contain:

            Deploy inear.ear and route.war, point a browser at http://localhost:8080/route.

            When I do this on 5.0.0.Beta3, the browser displays:

            When I do this on 4.2.2.GA, the browser displays:
            exception when calling InWar: java.lang.NoClassDefFoundError: peter/scope/InWar

            • 3. Re: 5.0 beta3, war class scoping problem
              Peter Johnson Master

              This problem appears to have gotten worse - in beta4 class loader repository declarations are being ignored, making it impossible to do scoping. Or are class loader repositories going away, and if so, what is the replacement mechanism?