[jboss-user] [Installation, Configuration & DEPLOYMENT] - Re: 5.0 beta3, war class scoping problem

PeterJ do-not-reply at jboss.com
Thu Jan 10 17:05:58 EST 2008


Here are the test files:

RouteServlet.java
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);
  |   }
  | }

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

InEar.java
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();
  |   }
  | }

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:
anonymous wrote : oops

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


View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4118858#4118858

Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4118858



More information about the jboss-user mailing list