4 Replies Latest reply on Jan 12, 2006 4:46 PM by reinerka

    Servlet Exception with Jboss

    sjb1973

      I have got a simple servlet which outputs an HTML form.
      I get the following error when I call it:

      13:35:35,359 ERROR [[MyServlet]] Servlet.service() for servlet MyServlet threw exception
      java.lang.NoClassDefFoundError: java/io/PrintWriter

      The java.io.PrinterWriter import is included at the top of the java file and Eclipse is showing no errors.
      I am using WindowsXP / jboss-4.0.3SP1, JBossIDE-1.5RC2-Bundle-win32, Sun J2EE 1.4.02 JDK (downloaded as a bundle from Sun including J2SE 5).

      Any suggestions about how to resolve this will be appreciated.

        • 1. Re: Servlet Exception with Jboss
          starksm64

          To not be able to find a core jdk class such as java.io.PrinterWriter, the runtime classpath of the servlet has to be completely screwed up. The Sun J2EE jdk should not be used with ecplise when using jboss. Only the J2SE jdk that is bundled with eclipse is needed.

          • 2. Re: Servlet Exception with Jboss
            sjb1973

            I need a reference to the J2EE JDK so that I can write EJBs.

            I do not know exactly what caused the problem, but your reply got me looking in the right place.

            I changed the build classpath order, which caused Eclipse to recompile everything. I then changed it back to the way that it was to start with and it recompiled everything again. I then restarted the JBoss server and redeployed the application and it wirked.

            Thanks for your help,

            Stephen.

            • 3. Re: Servlet Exception with Jboss
              starksm64

              You don't need the j2ee sdk to compile ejbs. Every app server will includes its own implementation of the j2ee classes. The jboss classes are located in one of:

              servlet-api.jar
              jboss-j2ee.jar
              jboss-jaxrpc.jar

              depending on which components you are using.

              • 4. Re: Servlet Exception with Jboss
                reinerka

                I just got the same problem in the following environment:

                - Eclipse 3.1.1 with JBossIDE 1.5
                - Fedora Core 4 Linux
                - JDK 1.5.0_06
                - JBoss 4.0.3SP1 (installer used with install everything)

                I've been trying to follow the EJB3 Trailblaizer demo with my own Classes and when running the Servlet I get the same error NoClassDefFaundException for java.io.PrintWriter.

                I created a Debug instance for 4.0.3SP1 (using the JDK5) - I'm also starting Eclipse with Java5.

                Seems very strange since this is such a basic functionality that it should work.

                Reiner