4 Replies Latest reply on Sep 24, 2002 1:58 AM by tsangcn

    Problems in JBoss with Jetty and Tomcat

    tsangcn Newbie

      Hello

      After testing with JBoss 3.0.2 for nearly 2 months. I still have some very basic problem not yet solved. Can anyone help me?

      (1) JBoss with Jetty
      I still got the problem of recompilation of JSP whenever I redploy my application or restart JBoss. On average, every JSP compilation needs 15 to 20 seconds. This is very unacceptable especially in my development and testing cycle.

      (2) JBoss with Tomcat
      The recompilation of JSP can be subpressed by putting the following in tomcat4-service.xml

      false

      On average, the compilation of JSP in Tomcat is faster than Jetty (about 15 seconds each).
      But I got another problem.

      (2a) The method getServletContext().getRealPath("/") in my servlet always return NULL.
      (In Jetty, it return my real path if WAR is run unpacked, and returns NULL if WAR is run packed)
      I have checked with javadoc and I think the Jetty behaviour is corrected. Is this a bug in Tomcat ?

      (2b) After starting JBoss, and my User.class has been instantiated the first time, and then redeploy my EAR file, I always get the following exception

      java.lang.LinkageError: Class com/nsl/framework/security/beans/User violates loader constraints

      I have defined my loader-repository in jboss-app.xml already. (This never happened in JBoss with Jetty).


      So I am in the mist. Both JBoss with Jetty and JBoss with Tomcat have problem in my application. Please help me.
      My runtime platform is Windows 2000, JDK is 1.4.0_01

      Thanks
      CN

        • 1. Re: Problems in JBoss with Jetty and Tomcat
          Julian Gosnell Expert

          Re: Jetty.

          You should be able to prevent the cache of your compiled JSPs from being removed between deployments by telling Jasper not to do so. This is detailed in the FAQ :

          http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/jboss/contrib/jetty/FAQ?rev=HEAD&content-type=text/vnd.viewcvs-markup

          Look at the item entitled:

          "Don't delete JSP compilation results between JBoss instances."
          I think you may also have to move the JSP compilation cache outside of the Jetty temporary dir, which will probably be deleted on redeployment. If there is not enough information for you here - ask on jetty-support@yahoogroups.com.

          If you work it out, please post your solution back to the forum and I will update the FAQ accordingly.

          If you simply symbolically linked your app unpacked into the JBoss deployment directory, you should be able to edit JSPs within the deployed app. Jasper should spot JSPs that have been modified and rebuild them the next time that they are hit. This would mean that you would never have to redeploy your app - alos resolving the problem above.

          Finally, to speed up development, toggle the Java2ClassLoadingCompliance (also mentioned in the FAQ)
          flag in your /deploy/jbossweb/META-INF/jboss-service.xml. This will result in calls to your EJB tier no longer being optimised (since the calls will cross classloaders), but classloading (a bottleneck with JSPs) will be much faster since it will use Jetty's classloader, which is much simpler and therefore faster than the JBoss UCL.

          Try all of this and see how you get on and persevere with Jetty !

          Good luck,


          Jules

          • 2. Re: Problems in JBoss with Jetty and Tomcat
            tsangcn Newbie

            Hello Jules,

            I think I found something maybe a bug in Jetty or Jasper ?

            First, the results of your suggestions.
            (1) "Don't delete JSP compilations results between JBoss instances"
            the remarks in the webdefault.xml says the "keepgenerated" parameter is to control whether to keep the generated Java source code for each page, but not the compiled Java class.
            And its default value is true.
            I have tested keepgenerated as true and also false in webdefault.xml, and found that it only affects the generated Java source code.
            So it does not help to my problem.

            (2) the Java2ClassLoadingCompliance parameter in jboss-service.xml is originally true.
            I have try setting to false, as you suggested. But the result get worse.
            I got the exception
            java.lang.ClassCastException: org.firebirdsql.jdbc.FBDataSource
            when it execute the statement
            DataSource ds = (DataSource)jndiContext.lookup("java:comp/env/jdbc/AppDS");
            But it is OK when the parameter is true.

            ------

            I have try to look at the source code of Jasper, it determines the location for generated stuff by
            - first using scratchdir in webdefault.xml
            - or, using javax.servlet.context.tempdir in servlet context, default is $TEMP/Jetty____
            - or, using java.io.tmpdir in System property, default is $TEMP

            only javax.servlet.context.tempdir does contains port and context, the other two not.
            So if I specified scratchdir in webdefault.xml but I deploy 2 EAR with similar structure, the 2 JSPs will MESS up.
            Is this a bug or a design purpose?

            ------

            My main problem still have not solved.
            I have the following discovery.
            I have set scratchdir to a directory say /work
            I have set keepgenerated to true
            I look at the files in /work every time I restart JBoss.
            I found that the last modification date of the files in /work always changes to the time when I invoke the JSP.
            ==> Jasper always recompile JSP after JBoss restart

            Please help to solve.

            Thanks
            CN

            • 3. Re: Problems in JBoss with Jetty and Tomcat
              tsangcn Newbie

              Hello Jules,

              I think I found something maybe a bug in Jetty or Jasper ?

              First, the results of your suggestions.
              (1) "Don't delete JSP compilations results between JBoss instances"
              the remarks in the webdefault.xml says the "keepgenerated" parameter is to control whether to keep the generated Java source code for each page, but not the compiled Java class.
              And its default value is true.
              I have tested keepgenerated as true and also false in webdefault.xml, and found that it only affects the generated Java source code.
              So it does not help to my problem.

              (2) the Java2ClassLoadingCompliance parameter in jboss-service.xml is originally true.
              I have try setting to false, as you suggested. But the result get worse.
              I got the exception
              java.lang.ClassCastException: org.firebirdsql.jdbc.FBDataSource
              when it execute the statement
              DataSource ds = (DataSource)jndiContext.lookup("java:comp/env/jdbc/AppDS");
              But it is OK when the parameter is true.

              ------

              I have try to look at the source code of Jasper, it determines the location for generated stuff by
              - first using scratchdir in webdefault.xml
              - or, using javax.servlet.context.tempdir in servlet context, default is $TEMP/Jetty____
              - or, using java.io.tmpdir in System property, default is $TEMP

              only javax.servlet.context.tempdir does contains port and context, the other two not.
              So if I specified scratchdir in webdefault.xml but I deploy 2 EAR with similar structure, the 2 JSPs will MESS up.
              Is this a bug or a design purpose?

              ------

              My main problem still have not solved.
              I have the following discovery.
              I have set scratchdir to a directory say /work
              I have set keepgenerated to true
              I look at the files in /work every time I restart JBoss.
              I found that the last modification date of the files in /work always changes to the time when I invoke the JSP.
              ==> Jasper always recompile JSP after JBoss restart

              Please help to solve.

              Thanks
              CN

              • 4. Re: Problems in JBoss with Jetty and Tomcat
                tsangcn Newbie

                Hello,

                I found something which I have discussed about in

                http://www.jboss.org/modules/bb/index.html?module=bb&op=viewtopic&t=forums/ EAR is deployed, the EAR is unpacked in $JBOSS_HOME/server/default/tmp/delploy/server/default/deploy/...
                and the WAR within the EAR is unpacked to $TEMP/Jetty_____/webapp

                But the last modified date of the unpacked files are touched to the current date.
                Although I have specified "keepgenerated" and "scratchdir" in webdefault.xml,
                the JSP are always more current than the generated stuff after unpacked,
                so this causes the recompilation of JSP everytime the EAR is deployed.

                I have tested and prove that if JSP is unpacked with date unmodifed, JSP recompilation will not occur, provided scratchdir is not default.

                In JBoss 2.4.4, the JSP are unpacked with the date unchanged.
                Why in JBoss 3.0.2, the JSP are unpacked and touched to the current date?

                Is is possible for JBoss 3.0.2, and after, to unpacked JSP untouched so that JSP recompilation will not be happen?

                Thanks
                CN