1 Reply Latest reply on Oct 28, 2001 1:41 AM by Dan Christopherson

    JSP and Servlet in same war get different classpaths?

    James DuPlain Newbie

      Hi,

      I am using the tomcat intergrated version of JBoss 2.4.3. I have a servlet and a jsp in the same war that seem to end up with different classpaths? I'm not sure why and any help would be appreciated. Here are the contents of my ear and war

      MyEAR.ear
      META-INF/MANIFEST.MF
      META-INF/application.xml
      org/mycomp/util/MyUtils.class
      MyWar.war
      META-INF/MANIFEST.MF
      WEB-INF/web.xml
      WEB-INF/classes/org/mycomp/servlets/MyServlet.class
      MyJSP.jsp

      In the MyWar.war:META-INF/MANIFEST.MF I have the following line so that the org tree in the ear will be available to the war
      Class-Path: ./

      The problem: MyUtils.class is available to MyServlet when I run it but not MyJSP.jsp. If I put MyUtils in the MyWar.war/WEB-INF/classes tree, the jsp can then access it.

      There has to be a better way. If I've got EJBs, JSPs and Servlets that all need access to the same utility classes, it seems that I'll have to include the same class in 3+ jar files (one or more ejb.jar files, the web.war, and the app.ear)? Has anybody got a good solution to this process problem? Having multiple copies of the same class file seems pretty dangerous to me.

      Thanks.

        • 1. Re: JSP and Servlet in same war get different classpaths?
          Dan Christopherson Newbie


          > MyEAR.ear
          > META-INF/MANIFEST.MF
          > META-INF/application.xml
          > org/mycomp/util/MyUtils.class

          So that class is sitting naked in your .ear? Personally, I'd put it in a jar first, but that won't solve your problem.

          > There has to be a better way. If I've got EJBs, JSPs
          > and Servlets that all need access to the same utility
          > classes, it seems that I'll have to include the same
          > class in 3+ jar files (one or more ejb.jar files, the
          > web.war, and the app.ear)? Has anybody got a good
          > solution to this process problem? Having multiple
          > copies of the same class file seems pretty dangerous
          > to me.


          Yep, blecherous. Why would you put it in your ear, though?

          Try pre-compiling the JSP. When I've seen this problem it's been when the JSP is compiled - it should go away if you precompile the JSP so that it's just a servlet that gets run.