Sunday, February 15, 2009

GlassFish and Java memory allocation

Last week I was very confused and bewildered when all of a sudden I could no longer find my compiled JSPs.
We are using GlassFish application server and normally one can find the compiled JSPs in the generated folder.
Anyway after the amusement passed I realised that something must have changed and remembered one of my mottos "Remember the solution!"
Basically what happened was that the server Java JDK was upgraded to 1.6
One of the features of 1.6 is memory allocation. Thus JSPs are compiled and stored in memory. The benefits are obvious, performance! That's where the JSPs have gone!
Anyway, GlassFish has a setting, keepGenerated. Prior version 1.6 this setting is set to true. In 1.6 the default is false. If you are using 1.6 and want to debug the compiled JSPs change keepgenerated (found in default-web.xml and sun-web.xml) to false.
Remember the solution!

3 comments:

  1. How about the generated .class files that are generated from the generated .jsp->java files? They don't seem to be there even when keepgenerated=true

    ReplyDelete
  2. Same thing but normally you want to look at the compiled xxx_JSP.java file to fix runtime errors.

    ReplyDelete
  3. I'd like to run FindBugs on the generated .class files to Find Bugs. But with keep generated, the only files in the generated/ directories are .java files.

    ReplyDelete