This content has been marked as final.
Show 3 replies
-
1. Re: 5.0 beta3, war class scoping problem
dimitris Jan 10, 2008 3:26 PM (in response to peterj)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
peterj Jan 10, 2008 5:05 PM (in response to peterj)Here are the test files:
RouteServlet.javapackage 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); } }
InWar.javapackage peter.scope; public class InWar { public String route() { return "oops"; } }
InEar.javapackage 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(); } }
application.xml<application> <display-name>Route</display-name> <module> <java>inear.jar</java> </module> </application>
web.xml<?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" version="2.5" > <servlet> <servlet-name>Route</servlet-name> <servlet-class>peter.scope.RouteServlet</servlet-class> </servlet> <servlet-mapping> <servlet-name>Route</servlet-name> <url-pattern>/route</url-pattern> </servlet-mapping> <welcome-file-list> <welcome-file>route</welcome-file> </welcome-file-list> </web-app>
Compile the three Java source files together. Then package the files as follows:
inear.jar should contain:
peter/scope/InEar.class
inear.ear should contain:
inear.jar
META-INF/application.xml
route.war should contain:
WEB-INF/web.xml
WEB-INF/classes/peter/scope/InWar.class
WEB-INF/classes/peter/scope/RouteServlet.class
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:oops
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
peterj Mar 10, 2008 5:05 PM (in response to peterj)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?