You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Arup Vidyerthy <li...@yahoo.co.uk> on 2005/08/09 13:58:49 UTC
RE: OutOfMemoryError & WebappClassLoader.openJARs(WebappClassLoader.java:1544)
Dear all,
I am just reopening this thread here.
Just to give you guys some more info on this OutOfMemoryError issue.
We always see this problem on a single page. Our application uses Velocity
and in one of the pages we do some special character escaping. If you look
at the following stack trace you will notice an arrow:
java.lang.OutOfMemoryError
java.util.zip.ZipFile.open(Native Method)
java.util.zip.ZipFile.<init>(ZipFile.java:112)
java.util.jar.JarFile.<init>(JarFile.java:127)
java.util.jar.JarFile.<init>(JarFile.java:92)
org.apache.catalina.loader.WebappClassLoader.openJARs(WebappClassLoader.java
:1544)
org.apache.catalina.loader.WebappClassLoader.findResourceInternal(WebappClas
sLoader.java:1763)
org.apache.catalina.loader.WebappClassLoader.findClassInternal(WebappClassLo
ader.java:1570)
org.apache.catalina.loader.WebappClassLoader.findClass(WebappClassLoader.jav
a:850)
org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.jav
a:1299)
org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.jav
a:1181)
java.lang.ClassLoader.loadClassInternal(ClassLoader.java:302)
-->
org.apache.velocity.runtime.parser.Parser.Escape(Parser.java:378)
org.apache.velocity.runtime.parser.Parser.Statement(Parser.java:316)
org.apache.velocity.runtime.parser.Parser.process(Parser.java:258)
org.apache.velocity.runtime.parser.Parser.parse(Parser.java:104)
org.apache.velocity.runtime.RuntimeInstance.parse(RuntimeInstance.java:776)
org.apache.velocity.runtime.RuntimeInstance.parse(RuntimeInstance.java:720)
org.apache.velocity.Template.process(Template.java:123)
org.apache.velocity.runtime.resource.ResourceManagerImpl.loadResource(Resour
ceManagerImpl.java:423)
org.apache.velocity.runtime.resource.ResourceManagerImpl.getResource(Resourc
eManagerImpl.java:341)
org.apache.velocity.runtime.RuntimeInstance.getTemplate(RuntimeInstance.java
:831)
org.apache.velocity.runtime.RuntimeInstance.getTemplate(RuntimeInstance.java
:813)
org.apache.velocity.runtime.RuntimeSingleton.getTemplate(RuntimeSingleton.ja
va:285)
org.apache.velocity.tools.view.servlet.VelocityViewServlet.getTemplate(Veloc
ityViewServlet.java:540)
Whenever we see the OutOfMemoryError, it is always from a specific
page/specific action. The arrow points to the line that is present in all of
our stack traces. The page in question has some javascript that contains few
back slashes.
function setImageTag() {
if(outOfSync) {
if(!confirm("Image is out of sync.\nAre you
sure you want to save?")) return false;
}
arr = new Array();
arr["src"] =
document.getElementById("preview").src;
arr["width"] =
document.getElementById("preview").width;
arr["height"] =
document.getElementById("preview").height;
arr["alt"] = document.scaleForm.caption.value;
arr["align"] = document.scaleForm.align.value;
arr["class"] =
document.scaleForm.classification.value;
arr["title"] =
document.scaleForm.showcaption.checked ? document.scaleForm.caption.value :
"";
var attributes = "";
for (var attrib in arr) {
// Right...
// Because the imageTag string will be
wrapped in single quotes when it is returned
// from the backend we need to escape all '
and \
//
if (attrib == "alt" || attrib == "title") {
arr[attrib] =
arr[attrib].replace(new RegExp("\\\\", "g"), "\\\\");
arr[attrib] =
arr[attrib].replace(new RegExp("'", "g"), "\\\'");
}
attributes += " " + attrib + "=\"" +
arr[attrib] + "\"";
}
var imageTag = "<img" + attributes + "/>";
document.getElementById("imageTag").value =
imageTag;
return true;
}
This is the only page where we do this kind of thing. Looking at Velocity
(1.4) source it is evident that org.apache.velocity.runtime.parser.Parser
class is trying to escape these nasty back slashes (when it intially parses
the page). It has an object pool of bunch of parsers. Size of this pool can
be controlled from the velocity.properties config file. My guess is the
velocity RuntimeInstance is running out memory (or some other OS related
weird stuff) and as a result an OOME is thrown.
To resolve this, we have taken out the java script function out of the
velocity page so that the Velocity RunTime doesn't have to parse these
backslashes. Hopefully this will cure the problem.
I just thought I will post this just in case some of you are seeing similar
problems in your app.
Good luck.
Arup
-----Original Message-----
From: Caldarale, Charles R [mailto:Chuck.Caldarale@unisys.com]
Sent: 20 July 2005 17:45
To: Tomcat Users List; like_donuts@yahoo.co.uk
Subject: RE: OutOfMemoryError &
WebappClassLoader.openJARs(WebappClassLoader.java:1544)
> From: Arup Vidyerthy [mailto:like_donuts@yahoo.co.uk]
> Subject: RE: OutOfMemoryError &
> WebappClassLoader.openJARs(WebappClassLoader.java:1544)
>
> Any pointers in terms of how I should approach this problem...?
I'd raise the limit on the number of open file descriptors and see what
happens.
- Chuck
THIS COMMUNICATION MAY CONTAIN CONFIDENTIAL AND/OR OTHERWISE PROPRIETARY
MATERIAL and is thus for use only by the intended recipient. If you received
this in error, please contact the sender and delete the e-mail and its
attachments from all computers.
---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org
___________________________________________________________
To help you stay safe and secure online, we've developed the all new Yahoo! Security Centre. http://uk.security.yahoo.com
---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org