8 Replies Latest reply on Jun 9, 2009 10:22 AM by Stefan Henz

    Unable to compile class for JSP

    Stefan Henz Newbie

      Dear all.
      I've the followinp problem.

      I'm using annotation attributes and no ejb-jar.xml

      General things: in the ear there is available

      META-INF/application.xml
      META-INF/MANIFEST.MF
      Shop.jar
      Shop.war

      In Shop.jar all entities and sessions beans are available.

      Shop.war contains
      META-INF/MANIFEST.MF
      and a directory calles web

      In this subdirectory "web" the index.jsp file is available as well as the helper classes of objects which are create in the jsp, e.g. the class "Basket"


      With JBOSS 4.2.2.GA as well as JBOSS 4.2.3.GA everything worked well, i.e. the deploying as well as the calling of the index.jsp
      But with JBOSS 5.1.0.GA after having deployed the EAR file and calling the according jsp, I get error messages like:

      org.apache.jasper.JasperException: Unable to compile class for JSP:

      An error occurred at line: 74 in the jsp file: /web/index.jsp
      Login cannot be resolved to a type
      72: wsr = (WebShopRemote)
      73: session.getAttribute("WebShopBean");
      74: Basket basket = new Basket();
      75: basket.getPage(request, out, session, response, wsr);
      76: }

      ...

      Does somebody has an idea what might be the problem? Or does somebody has a small EJB example in connnection with a war file and a jsp?

      Thx,
      Jim

        • 1. Re: Unable to compile class for JSP
          Wolfgang Knauf Master

          Hi Jim,

          does your "Show.war" contain a file META-INF\Manifest.mf with this content?

          Manifest-Version: 1.0
          Class-Path: Shop.jar


          Best regards

          Wolfgang

          • 2. Re: Unable to compile class for JSP
            Stefan Henz Newbie

            Hi Wolfgang,

            the Show.war contains a file META/MANIFEST.MF, but has the following content:

            Manifest-Version: 1.0
            Ant-Version: Apache Ant 1.7.0
            Created-By: 11.2-b01 (Sun Microsystems Inc.)

            It's the same content for both, working with JBOSS 4.2.2.GA as well as with JBOSS 5.1.0.GA

            With JBOSS 4.2.2.GA a can call the index.jsp and Java classes called within this JSP are found and the JSP is compiled, but with JBOSS 5.1.0.GA I get the above mentioned error messages

            org.apache.jasper.JasperException: Unable to compile class for JSP:

            ... cannot resolve to a type ..

            Is there a way to get rid of tihis problems. Something important seeemed to be changed from JBOSS 4.2.2.GA to JBOSS 5.1.0.GA

            Best wishes,
            Jim

            • 3. Re: Unable to compile class for JSP
              Wolfgang Knauf Master

              Hi Jim,

              add the "Class-Path" to manifest.mf, as shown in my previous post:

              Manifest-Version: 1.0
              Class-Path: Shop.jar

              This is required for JBoss to resolve Shop.jar

              Hope this helps

              Wolfgang

              • 4. Re: Unable to compile class for JSP
                Stefan Henz Newbie

                Hi Wolfgang

                tyes this solves the problem, but because I've the according java classes which are called by the jsp I have to put in the MANIFEST.FM

                Class-Path: Shop.war

                Thx a lot!

                Jim

                • 5. Re: Unable to compile class for JSP
                  Wolfgang Knauf Master

                  Hi Jim,

                  this sounds strange. You mean you have to add "Shop.war" to the ClassPath of its own Manifest.mf?

                  Where do the classes in Shop.war reside? Normally, they should be in "WEB-INF\classes\".

                  Best regards

                  Wolfgang

                  • 6. Re: Unable to compile class for JSP
                    Stefan Henz Newbie

                    Hi Wolfgang,

                    yes I had to add "Shop.war", because the helper classes which are called from the index.jsp are located unter web/

                    i.e. the war file contains 2 directories

                    META-INF/
                    and
                    web/

                    and under web these helper classes are located.

                    Surely, the war file is packed in an EAR file named

                    Shop.ear which contains
                    it's own META-INF subdirectory, namely
                    META-INF/MANIFEST.MF
                    and
                    META-INF/application.xml


                    and the above mentioned war file Shop.war as well as a jar file Shop.jar where the entities and session beans are packed.

                    Best wishes,
                    Jim
                    WebShop.jar WebShop.war

                    • 7. Re: Unable to compile class for JSP
                      Wolfgang Knauf Master

                      Hi Jim,

                      it seems your app is not bundled according to the JavaEE spec.

                      It should be (taken your sample):

                      Shop.ear
                      |---META-INF\application.xml (this file is not required)
                      |---Shop.jar
                       |--META-INF\manifest.mf
                       |--META-INF\ejb-jar.xml (optional)
                       |--EJB classes and interfaces
                      |---Shop.war
                       |--META-INF\manifest.mf
                       |--WEB-INF\web.xml
                       |--WEB-INF\lib\yourlibraries.jar
                       |--WEB-INF\classes\....
                       |--web\some.jsp

                      The "Shop.war" must not contain any classes which are already contained in "Shop.jar".
                      Seems the classes in your WAR are in the wrong location.

                      Hope this helps

                      Wolfgang

                      • 8. Re: Unable to compile class for JSP
                        Stefan Henz Newbie

                        H i Wolfgang,

                        thx. I'll try to adapt the right file and directory structure.

                        Many thanks for the hints which helped me.

                        Best,
                        Jim