Link to home
Start Free TrialLog in
Avatar of integrosys
integrosys

asked on

Force re-compile of JSP

When I changed a JSP file in our WebLogic 8.1 server (Solaris), the JSP will not get compiled immediately when accessed. I have to re-start the server to force it to recompile. If I change the file again, I have to restart the server again. From what I found, the pageCheckSeconds parameter in weblogic.xml is used to control the compiling. If it is absent or set to 1, JSPs should be compiled when changed. But in both cases, it does not work. What else can I do?
Avatar of ECollin
ECollin

Hi,

the jsp will be compiled before the first access by a client.
You can use 2 different tools for compiling your jsp : weblogic.appc and weblogic.jspc

These links will give you details about these products :
.http://e-docs.bea.com/wls/docs81/ejb/appc_ejbc.html
.http://e-docs.bea.com/wls/docs81/jsp/reference.html

good read
Emmanuel
hey you can actually go to the admin console and redeploy the application from the deployments link that will force the jsps to recompile

it could be a good idea, but this will stop the application during redeployement.
Emmanuel
Avatar of integrosys

ASKER

>> the jsp will be compiled before the first access by a client.

I know. But after I change the JSP again, WebLogic will not re-compile it.

If I use appc to compile, do I need to redeploy the application?

Why doesn't the pageCheckSeconds work? Is it a bug in WebLogic 8.1?

It is just not practical if we need to compile manually, then redeploy the application everytime that we change the JSP.
ASKER CERTIFIED SOLUTION
Avatar of ECollin
ECollin

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Weblogic should automatically be recompiling that JSP page when a user requests the page and the server detects that the page has changed.  

So if you say you have to restart the server for it to compile, I am going to assume you're putting the JSP page in the right place (weblogic copies deployed apps to the server's staging folder, by default, and serves all pages from below that folder structure, so if you need to make a quick patch or update to a JSP in a running application putting it in the correct folder under the staging folder should auto-compile it next time the page is requested).

So assuming it's in the right place.... there must be some setting that's missing?  All my apps automatically work this way, with Weblogic's default settings.  So I'm thinking you changed something in either a config file (web.xml) or in weblogic's server or deployments settings.

So I did a search on the internet.  BEA says that "WebLogic Server automatically compiles JSPs if the servlet class file is not present or is older than the JSP source file" ... but I didn't see any mention of if there's a way to turn that on an off, so I could find if perhaps you had accidentally turned it off.  Even the Servlet spec says the appserver needs to recompile modified JSPs on demand.

Some more searching on BEA's site produced the text below.  Can you check and be sure you're NOT using JSPClassServlet?

-------
http://edocs.bea.com/wls/docs81/jsp/reference.html

Another way to prevent your JSPs from recompiling is to use the JSPClassServlet in place of JSPServlet and to place your precompiled JSPs into the WEB-INF/classes directory. This will remove any possibility of the JSPs being recompiled, as the server will not look at the source code. The server will not note any changes to the JSPs and recompile them if you choose this option. This option allows you to completely remove the JSP source code from your application after precompiling.

This is an example of how to add the JSPClassServlet to your Web Application's web.xml file.

<servlet>
   <servlet-name>JSPClassServlet</servlet-name>
   <servlet-class>weblogic.servlet.JSPClassServlet</servlet-class>
</servlet>

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

The only thing I can think of is that maybe my initial assumption is wrong?  Are you sure you're putting the modified JSP in Weblgic's staging location (the actual location Weblogic should be looking for changes to the JSPs)?
As far as I know, the only parameter that tells WebLogic to whether to re-compile JSP is pageCheckSeconds. If I don't specify (this is the default), it will always re-compile if the file is changed. But somehow it is not re-compiling.

I don't have the JSPClassServlet as you mentioned, and my JSPs are all in the correct locations since I am able to access them without problems.
hi,

is your domain in production mode ?

is your application deployed as an exploded directory structure ?

Emmanuel
It's not about whether or not you can access the JSP, it's about whether or not Weblogic is copying the web application files to its staging location on the server that serves the application.  If and when you make a change to a JSP you must make it under the staging folder of the appserver and not the original deployed location (which only gets looked at upon redeploy).

Make sure you're editing the JSPs in both the original deployed location AND copying the changed JSP to the correct location under the appserver's staging folder.

-B
>> is your domain in production mode ?

No.

>> is your application deployed as an exploded directory structure ?

Yes. The files are copied individually over.

>> Make sure you're editing the JSPs in both the original deployed location AND copying the changed JSP to the correct location under the appserver's staging folder.

Where is this staging folder?
If you're in dev mode and are using all the defaults, and ou're not using Weblogic Workshop for development (which uses the split directory strucutre), your staging folder will be:

BEA\user_projects\domains\<your domain name>\<your server name - usually the admin server in dev>\staging\

If you can't find it do a search for a directory called "staging" under the BEA folder.

Once you find it, in the staging folder, you should see a folder name that corresponds to your web application name. Find the old JSP and copy the new JSP over it.  That's the folder Weblogic looks at to detect changes in the JSP for automatic recompilation
I can't find the staging folder in either Windows or Solaris environment. For your information, my problem is confined to Solaris only. On Windows, WebLogic will automatically re-compile the JSP if it has been changed.
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
I think you have some good solutions here, even though the questioner didn't follow up.  There are a few issues that get explained:  1) How to precompile JSPs,  2) How BEA handles staging mode and where files are stored when serving from staging mode, and 3) Clearing up possible confusion about  when BEA automatically compiles JSPs.

For those reasons, at least, this question shouldn't be deleted.
First thing to be checked in this case is the value of the parameter "JSPPage Check Secs" at weblogic console.
This will be visible on weblogic console when u navigate to ur application deployed on server and then click on the Descriptor tab.
If this is "-1" here then it will be overwritten as written in ur weblogic.xml.
I faced the same issue and was successful on correcting this at console.