8 Replies Latest reply on Oct 28, 2004 5:23 PM by 807567

    how to get precompiled JSPs to work?

    807567
      This simple little thing is really pissing me off - please help.

      I precompile JSPs and jar them up and add jar to web-inf/lib directory and deploy the app. I also have sun-web.xml file in web-inf directory with following contents:
      <?xml version="1.0" encoding="UTF-8"?>
      <!DOCTYPE sun-web-app PUBLIC '-//Sun Microsystems,
      Inc.//DTD Sun ONE Web Server 6.1 Servlet 2.3//EN'
      'http://www.sun.com/software/dtd/webserver/sun-web-app_2_3-1.dtd'>
      
      <sun-web-app>
           <jsp-config>
                 <property name="reload-interval" value="-1" />
           </jsp-config>
      </sun-web-app>
      I get this in error log confirming that it picked up the sun-web.xml parameter (cara is the app i'm deploying):
      [28/Jun/2004:14:43:24] fine ( 3448): jsp-config property for [/cara] is [reload-interval] = [-1]
      I try to access the app and it starts compiling JSPs instead of loading them from jsp.jar file which is included in lib directory as you can see in the compile classpath:
      [28/Jun/2004:14:43:40] info ( 3448): for host xxx.xxx.xxx.xxx trying to GET /cara/login.jsp, service-j2ee reports: WEB2798: [] ServletContext.log(): WEB4070: Compiling with: -encoding UTF8 -classpath C:/Tools/Sun/WebServer6.1/https-halo/webapps/https-halo/cara/WEB-INF/classes;C:/Tools/Sun/WebServer6.1/https-halo/webapps/https-halo/cara/WEB-INF/lib/cglib2.jar;C:/Tools/Sun/WebServer6.1/https-halo/webapps/https-halo/cara/WEB-INF/lib/classes12.jar;C:/Tools/Sun/WebServer6.1/https-halo/webapps/https-halo/cara/WEB-INF/lib/commons-collections.jar;C:/Tools/Sun/WebServer6.1/https-halo/webapps/https-halo/cara/WEB-INF/lib/commons-logging.jar;C:/Tools/Sun/WebServer6.1/https-halo/webapps/https-halo/cara/WEB-INF/lib/dom4j.jar;C:/Tools/Sun/WebServer6.1/https-halo/webapps/https-halo/cara/WEB-INF/lib/ehcache.jar;C:/Tools/Sun/WebServer6.1/https-halo/webapps/https-halo/cara/WEB-INF/lib/hibernate2.jar;C:/Tools/Sun/WebServer6.1/https-halo/webapps/https-halo/cara/WEB-INF/lib/jdbc2_0-stdext.jar;C:/Tools/Sun/WebServer6.1/https-halo/webapps/https-halo/cara/WEB-INF/lib/jsp.jar;C:/Tools/Sun/WebServer6.1/https-halo/webapps/https-halo/cara/WEB-INF/lib/jta.jar;C:/Tools/Sun/WebServer6.1/https-halo/webapps/https-halo/cara/WEB-INF/lib/log4j-1.2.8.jar;C:/Tools/Sun/WebServer6.1/https-halo/webapps/https-halo/cara/WEB-INF/lib/odmg.jar;C:/Tools/Sun/WebServer6.1/https-halo/webapps/https-halo/cara/WEB-INF/lib/proxool-0.8.3.jar;C:/Tools/Sun/WebServer6.1/https-halo/webapps/https-halo/cara/WEB-INF/lib/xalan.jar;C:/Tools/Sun/WebServer6.1/https-halo/webapps/https-halo/cara/WEB-INF/lib/xerces.jar;C:/Tools/Sun/WebServer6.1/https-halo/webapps/https-halo/cara/WEB-INF/lib/xml-apis.jar;/C:/Tools/Sun/WebServer6.1/bin/https/jar/webserv-rt.jar;/C:/Tools/Sun/WebServer6.1/bin/https/jdk/lib/tools.jar;/C:/Tools/Sun/WebServer6.1/bin/https/jar/webserv-ext.jar;/C:/Tools/Sun/WebServer6.1/bin/https/jar/webserv-jstl.jar;/C:/Tools/Sun/WebServer6.1/bin/https/jar/ktsearch.jar;/C:/Tools/Sun/WebServer6.1/https-halo/config/;/C:/Tools/Sun/WebServer6.1/https-halo/config/;/C:/Tools/Sun/WebServer6.1/bin/https/jdk/jre/lib/ext/dnsns.jar;/C:/Tools/Sun/WebServer6.1/bin/https/jdk/jre/lib/ext/ldapsec.jar;/C:/Tools/Sun/WebServer6.1/bin/https/jdk/jre/lib/ext/localedata.jar;/C:/Tools/Sun/WebServer6.1/bin/https/jdk/jre/lib/ext/sunjce_provider.jar;c:/tools/sun/WebServer6.1/bin/https/jar/webserv-rt.jar;c:/tools/sun/WebServer6.1/bin/https/jdk/lib/tools.jar;c:/tools/sun/WebServer6.1/bin/https/jar/webserv-ext.jar;c:/tools/sun/WebServer6.1/bin/https/jar/webserv-jstl.jar;c:/tools/sun/WebServer6.1/bin/https/jar/ktsearch.jar;; -d c:\tools\sun\WebServer6.1\https-halo\ClassCache\https-halo\cara c:\tools\sun\WebServer6.1\https-halo\ClassCache\https-halo\cara\_jsps\_login_jsp.java 
      What else do I need to do to get the server to use my precompiled JSPs and where the heck is that additional bit documented???
        • 1. Re: how to get precompiled JSPs to work?
          807567
          Were you ever able to figure out this problem? I am having the exact same experience using Sun ONE 6.1

          One thing I did notice is that despite the fact that the JSPs are still being compiled by the app server the classes are indeed being loaded from my jar of precompiled JSPs. I was able to figure this out by making a small change to the JSP file but not migrating that change over to the jar file.

          The bottom line is that precompiling the JSPs and putting them in a jar file is of little use if the server is still going to compile the residual JSP files.

          Does anyone have a suggestion to fix this?
          • 2. Re: how to get precompiled JSPs to work?
            807567
            Unfortunately I found another big issue with this release and decided not to use it altogether.

            http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6057385

            It says it's fixed wih sp3 release, they might have fixed the JSP pre-compilation too. I'll have to check it out.
            • 3. Re: how to get precompiled JSPs to work?
              807567
              I've figured this out with only a little help from Sun One support.

              One solution is to remove the physical JSP files after you have precompiled them. This will absolutely prevent the web server from recompiling them when first accessed.

              Another option is to make a servlet mapping for each precompiled JSP and put it into your web.xml file. Fortunately the jspc command has a switch -webinc that will output a file with all the servlet mappings already generated for you. The down side is that you will need to cut the mappings from this generated file and paste them into your web.xml file.

              For my situation the latter solution wasn't maintainable. I used the former solution with a twist. I am not precompiling the JSPs from the web server's doc root. Instead I am precompiling them from my source tree and deploying them to my webserver in a jar file which then gets placed in /WEB-INF/lib

              For the record I still believe that there is a bug in the Sun One Web Server. The documentation clearly states that you can precompile the JSP files from the web server's doc root. It also clearly states that you can tell the web server to not try to precompile JSPs the first time they are loaded. Unfortunately Sun One Web Server still does try to precompile them.

              The bottom line is that as long as the actual JSP files are not on the web server then you should be OK with just running them out of a jar file.

              Hope this helps and please reply if you have questions.
              • 4. Re: how to get precompiled JSPs to work?
                807567
                One of the developers here reported that the "repload-interval" property wouldn't take unless there was a <description> tag inside that <property> tag. So your sun-web.xml file would need to look like this...

                <?xml version="1.0" encoding="UTF-8"?>
                <!DOCTYPE sun-web-app PUBLIC '-//Sun Microsystems,
                Inc.//DTD Sun ONE Web Server 6.1 Servlet 2.3//EN'
                'http://www.sun.com/software/dtd/webserver/sun-web-app_2_3-1.dtd'>

                <sun-web-app>
                     <jsp-config>
                          <property name="reload-interval" value="-1">
                               <description>Disable automatic reload and rebuild of new or updated JSP files</description>
                          </property>
                     </jsp-config>
                </sun-web-app>
                • 5. Re: how to get precompiled JSPs to work?
                  807567
                  I finally got a response from Sun. As it turns out, you have to map all the JSP class files in web.xml. So run the jspc with one of the following options to generate the mapping:

                  -webinc or -webxml

                  I am still waiting for sun to see if there's a way to make it work like the 6.0 server (without mapping all jsps). If I get any solution, i'll update this thread.
                  • 6. Re: how to get precompiled JSPs to work?
                    807567
                    Actually I did get a response from Sun on this problem. Here's what you need to know...

                    First of all they are correct that creating a mapping for each JSP will stop the web server from compiling your already pre-compiled JSPs. BUT this is not the only way to stop it.

                    The most simple way to stop the web server from compiling your JSPs is to not ship the JSPs. The web server will be quite happy to load the pre-compiled JSPs without having the actual JSPs in the file system. To get this to work you may need to have reload-interval set to -1 in the sun-web.xml file. YMMV.

                    If those two solutions aren't good enough for you there is hope. I was able to get Sun to admit that their web server does not function according to the documentation. They sent me a beta bug fix that stopped the web server from compiling JSPs when the reload-interval is set to -1. This was working pretty well, but aparently my bug report got someone at Sun thinking. They later sent me a beta patch that uses a new "use precompiled JSPs" parameter in the sun-web.xml file.

                    It looks like Sun might finally be interested in getting this problem fixed. Since this was all a bunch of beta patch releases don't expect to see anything for a while. I was told that IF these bug fixes see the light of day it won't be until after the next service pack.
                    • 7. Re: how to get precompiled JSPs to work?
                      807567
                      I had already tried your second solution on 6.1 sp3 but it didn't work for me. Thanks for the update.
                      • 8. Re: how to get precompiled JSPs to work?
                        807567
                        The second solution (not including the actual JSPs) is the one I am using. It works without any of the beta patches. If you can't get it to work email me directly and we can figure it out.