7 Replies Latest reply on Jun 27, 2003 4:06 AM by Jon Barnett

    jsp examples problem

    Linn Kubler Newbie

      Hi,

      Real newbee here so please bear with me. My developer is getting a new workstation, currently working in Windows 2000 Pro. New system will be the same.

      I'm trying to replicate the jboss/tomcat env. on the new computer. I believe I have it working for the most part but can't seem to get any jsp pages to work.

      Running Jakarta-Tomcat version 3.2.1 and Jboss 2.1. I can get to the Tomcat home page and examples but when I try to run the jsp examples I get the following error:

      Error: 500

      Location: /examples/jsp/dates/date.jsp
      Internal Servlet Error:

      javax.servlet.ServletException: sun/tools/javac/Main
      at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:399)
      at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
      at org.apache.tomcat.core.ServletWrapper.doService(ServletWrapper.java:404)
      at org.apache.tomcat.core.Handler.service(Handler.java:286)
      at org.apache.tomcat.core.ServletWrapper.service(ServletWrapper.java:372)
      at org.apache.tomcat.core.ContextManager.internalService(ContextManager.java:797)
      at org.apache.tomcat.core.ContextManager.service(ContextManager.java:743)
      at org.apache.tomcat.service.http.HttpConnectionHandler.processConnection(HttpConnectionHandler.java:210)
      at org.apache.tomcat.service.TcpWorkerThread.runIt(PoolTcpEndpoint.java:416)
      at org.apache.tomcat.util.ThreadPool$ControlRunnable.run(ThreadPool.java:498)
      at java.lang.Thread.run(Unknown Source)

      Root cause:
      java.lang.NoClassDefFoundError: sun/tools/javac/Main
      at org.apache.jasper.compiler.SunJavaCompiler.compile(SunJavaCompiler.java:128)
      at org.apache.jasper.compiler.Compiler.compile(Compiler.java:245)
      at org.apache.jasper.servlet.JspServlet.doLoadJSP(JspServlet.java:462)
      at org.apache.jasper.servlet.JasperLoader12.loadJSP(JasperLoader12.java:146)
      at org.apache.jasper.servlet.JspServlet.loadJSP(JspServlet.java:433)
      at org.apache.jasper.servlet.JspServlet$JspServletWrapper.loadIfNecessary(JspServlet.java:152)
      at org.apache.jasper.servlet.JspServlet$JspServletWrapper.service(JspServlet.java:164)
      at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:318)
      at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:391)
      at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
      at org.apache.tomcat.core.ServletWrapper.doService(ServletWrapper.java:404)
      at org.apache.tomcat.core.Handler.service(Handler.java:286)
      at org.apache.tomcat.core.ServletWrapper.service(ServletWrapper.java:372)
      at org.apache.tomcat.core.ContextManager.internalService(ContextManager.java:797)
      at org.apache.tomcat.core.ContextManager.service(ContextManager.java:743)
      at org.apache.tomcat.service.http.HttpConnectionHandler.processConnection(HttpConnectionHandler.java:210)
      at org.apache.tomcat.service.TcpWorkerThread.runIt(PoolTcpEndpoint.java:416)
      at org.apache.tomcat.util.ThreadPool$ControlRunnable.run(ThreadPool.java:498)
      at java.lang.Thread.run(Unknown Source)

      I copied all the config files over from my developers current computer which works fine. So I thought I had all the configuration licked but I guess not.

      Any suggestions? Did I miss something in the setup?

      Any help is greatly appreciated.

      Thanks in advance,
      Linn


        • 1. Re: jsp examples problem
          Jon Barnett Master

          Java pages need access to the Java compiler libraries in order to create the Java class files from your JSP source (via an intermediate stage of turning your JSP into servlet Java source code). In order to do that, it needs access to a valid tools.jar (located in lib/tools.jar of your JDK distribution).

          When you execute the run.bat, you need JAVA_HOME to be set to the topmost directory of your JDK distribution. Normally, this should be in a directory path with no spaces in it (the Sun JDK does not like spaces, particularly when it is dealing with RMI, JNDI and so on and this in turn breaks JBoss). So for example, I have JDK 1.4.1_01 in c:\java\j2sdk1.4.1_01. Set JAVA_HOME to c:\java\j2sdk1.4.1 (in this example).

          The output from your batch file should then be:
          ===============================================================================
          .
          JBoss Bootstrap Environment
          .
          JBOSS_HOME: C:\Java\JBoss-3.2.0\bin\\..
          .
          JAVA: C:\Java\j2sdk1.4.1\\bin\java
          .
          JAVA_OPTS: -server -Dprogram.name=run.bat -Xms16m -Xmx50m
          .
          CLASSPATH: ;C:\Java\j2sdk1.4.1\\lib\tools.jar;C:\Java\JBoss-3.2.0\bin\\run.jar

          .
          ===============================================================================

          Note the classpath.

          Hope that helps.

          • 2. Re: jsp examples problem
            Jon Barnett Master

            BTW, ignore the -Xms ... options, I added those in for some local testing on my Win2K startup. Unless you modify JAVA_OPTS, you wouldn't normally see these.

            • 3. Re: jsp examples problem
              Linn Kubler Newbie

              Ah yes, that's it. Found a typo in my classpath environment variable. Now the examples seem to work.

              However, our application doesn't seem to run correctly all the time. On some of our pages I get the following error:

              Error: 500
              Location: /ecw/infopackagesc.jsp.deployed
              Internal Servlet Error:

              org.apache.jasper.JasperException: Unable to compile class for JSPThe compiler has run out of memory. Consider using the "-J-mx" command line option to increase the maximum heap size.

              Being very new at this just where do I apply the "-J-mx" command line option? Do I leave it in place all the time or do I just use it once.

              Oh, do I pass it as a parameter to the run.bat file??

              Thanks again,
              Linn

              • 4. Re: jsp examples problem
                Jon Barnett Master

                Just modify your run.bat. The JAVA_OPTS variable is the place to add it. You should see something like -Dprogram.name=run.jar. Add your -Xms.., etc to that line.

                • 5. Re: jsp examples problem
                  Jon Barnett Master

                  For example, the existing line:
                  set JAVA_OPTS=%JAVA_OPTS% -Dprogram.name=%PROGNAME%

                  Is replaced by:

                  set JAVA_OPTS=%JAVA_OPTS% -server -Dprogram.name=%PROGNAME% -Xms16m -Xmx50m

                  • 6. Re: jsp examples problem
                    Linn Kubler Newbie

                    I looked in my run.bat and there is no JAVA_OPTS variable. However, there is a SET CLASSPATH=%CLASSPATH%;run.jar line. I presume that's where you are refering.

                    I noticed in your example you use the form -Xmx50m, is there some documentation you can refer me to that will help me understand what this command does and how to use it?

                    I really appreciate the help, I'm learning as I go here.

                    Thanks,
                    Linn

                    • 7. Re: jsp examples problem
                      Jon Barnett Master

                      Just checked a clean JBoss Jetty 3.2.1 package rather than one of my hacked configurations. The file still retains the JAVA_OPTS in run.bat. I've included some further lines to make it easier to identify in the file.

                      rem Include the JDK javac compiler for JSP pages. The default is for a Sun JDK
                      rem compatible distribution to which JAVA_HOME points

                      set JAVAC_JAR=%JAVA_HOME%\lib\tools.jar
                      set JBOSS_CLASSPATH=%JBOSS_CLASSPATH%;%JAVAC_JAR%;%RUNJAR%

                      rem Setup JBoss specific properties
                      set JAVA_OPTS=%JAVA_OPTS% -Dprogram.name=%PROGNAME%
                      set JBOSS_HOME=%DIRNAME%\..

                      The second last line is the one you want. If not, get a clean run.bat from a distribution - the batch file doesn't vary between Tomcat or Jetty distributions.

                      If you run your java at the command line, it should tell you all the supported -X parameters. Like so:
                      c:\> java -X

                      -Xmixed mixed mode execution (default)
                      -Xint interpreted mode execution only
                      -Xbootclasspath:<directories and zip/jar files separated by ;>
                      set search path for bootstrap classes and resources
                      -Xbootclasspath/a:<directories and zip/jar files separated by ;>
                      append to end of bootstrap class path
                      -Xbootclasspath/p:<directories and zip/jar files separated by ;>
                      prepend in front of bootstrap class path
                      -Xnoclassgc disable class garbage collection
                      -Xincgc enable incremental garbage collection
                      -Xloggc: log GC status to a file with time stamps
                      -Xbatch disable background compilation
                      -Xms set initial Java heap size
                      -Xmx set maximum Java heap size
                      -Xss set java thread stack size
                      -Xprof output cpu profiling data
                      -Xrunhprof[:help]|[:=, ...]
                      perform JVMPI heap, cpu, or monitor profiling
                      -Xdebug enable remote debugging
                      -Xfuture enable strictest checks, anticipating future default
                      -Xrs reduce use of OS signals by Java/VM (see documentation)
                      -Xcheck:jni perform additional checks for JNI functions

                      -Xmx and -Xms are the important ones for applications that generate a lot of beans, materialise a lot of BLOBs or large BLOBs from a database, or otherwise have a heavy memory footprint. You tune this so you don't steal too much memory from the OS while making sure you don't get "out of memory" errors from JBoss.