6 Replies Latest reply on Sep 8, 2003 9:03 AM by gmoore1

    Working around jsps recompiling all the time

    pascalpt

      Hi,
      Under JBoss-3.2.1, by default, the JSPs recompile every time an application is redeployed or JBoss is restarted.

      Now, this is REALLY annoying when you're under development (should this really be the default behavior?) Anyway, to work around the problem I set the scratchdir parameter in jbossweb-tomcat.sar/web.xml to a fixed absolute directory which effectively prevents them from being deleted on redeploy. With one web app, it works perfectly.

      Add a second web application though and you start hitting major problems because the generated files are in the exact same place for all deployed applications. The login.jsp or index.jsp from the application that got compiled last will be used for both (or all) applications.

      Does anybody know a way around this????

      Thanks

      Pascal

        • 1. Re: Working around jsps recompiling all the time

          You could delete the jsp-servlet from the default config, but then You have to remember it in every app-config. (web.xml for each app)

          • 2. Re: Working around jsps recompiling all the time
            pascalpt

            I'm not sure I understand your reply. What do you mean by delete the jsp-servlet from the default config?

            • 3. Re: Working around jsps recompiling all the time

              In the jbossweb-tomcat.sar/web.xml there is a servlet-config for handling requests to JSP-files (the servlet-config where you set scratch-dir parameter).

              You can comment out this config completly in this file, and include it in the web.xml for your app. But you will have to include it in all the apps that uses JSP's, otherwise those won't get compiled...

              • 4. Re: Working around jsps recompiling all the time

                I have tested a bit more, and found one easier way..

                In the WEB.XML for your app, you create a servlet like this :


                <servlet-name>jsp2</servlet-name>
                <servlet-class>org.apache.jasper.servlet.JspServlet</servlet-class>
                <init-param>
                <param-name>logVerbosityLevel</param-name>
                <param-value>WARNING</param-value>
                </init-param>
                <init-param>
                <param-name>scratchdir</param-name>
                <param-value>(Your path)</param-value>
                </init-param>
                <load-on-startup>3</load-on-startup>



                and map it like this :

                <servlet-mapping>
                <servlet-name>jsp2</servlet-name>
                <url-pattern>*.jsp</url-pattern>
                </servlet-mapping>


                Note that you cannot name it JSP, since this servlet-name is already taken, but you can specify the same mapping, and this mapping will override the default one...

                • 5. Re: Working around jsps recompiling all the time
                  pascalpt

                  It works fine. Thanks.

                  I didn't like having to hard-code a path in the web.xml because it's better to not have to edit the web.xml file every time you go to a different machine. It turns out that a relative path will start you in the bin directory of jboss so putting "../temp/app_name" gives me a nice place to put the file that's machine (and OS) independent.

                  Though my problem is solved, it still feel kludgy to have to do it that way. It would be nicer to have one of the following solutions:
                  1. A way to tell jboss not to delete compiled jsps on redeploy
                  2. Prepend the application name in the temp directory. Is there one example where that would break anything? Jasper should be smart enough to isolate the applications without me having to do it manually.

                  The current approach will do for now, thanks again for your help.

                  Pascal

                  • 6. Re: Working around jsps recompiling all the time
                    gmoore1

                    I am confused on this issue as well. There is an attribute that can be set in the <server-dir>/deploy/jbossweb-tomcat.sar/META-INF/jboss-service.xml that prevents the tmp deployments from being deleted. This is where the compiled JSP servlets are generated. When not present (the default) the value defaults to true

                    The attribute to set
                    false

                    has no effect????

                    Is this a bug, or am I missing something???