velocity-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kuku <>
Subject JSP + Velocity + Resin........ java.lang.NullPointerException
Date Thu, 02 Aug 2007 05:00:19 GMT


We are using velocity1.4 to implement templating in our system. The system
is running fine since deploy. Recently, there is a serious problem that
causing the web panel down. We did setup multiple host in resin to point to
different panel. When the error happen, only the host having the problem
down but others are ok.

Host Setting in resin.conf

Code: ( text )
<host id="" root-directory="/www/sw/api">
      <web-app id="/" document-directory="/www/sw/api">
        <servlet-mapping url-pattern="/servlet/*" servlet-name="invoker"/>

>From the error message in stdout.log, we found the java null pointer throw
from velocity. The coding area is somewhere like below:

Code: ( text )
public int doEndTag() throws JspException {
        try {
  "Velocity File Resource
            VelocityContext myVelocityContext = null;
            Velocity.setProperty(Velocity.FILE_RESOURCE_LOADER  _PATH,
            if (ctx == null) {
                myVelocityContext = new VelocityContext();
            else {
                myVelocityContext = ctx;
            Template template = null;
            template = Velocity.getTemplate(veltemplate, "UTF-8");
            StringWriter myStringWriter = new StringWriter();
            template.merge(myVelocityContext, myStringWriter);
            return EVAL_PAGE;
        catch (Exception e) {
            throw new JspException("Exception; TEMPLATE_CLASSPATH;
                    + e.getMessage());

We are sure that the Velocity.FILE_RESOURCE_LOADER_PATH, velpath, and
veltemplate are always holding correct value. But, just don't know why it
throwing null pointer. Until now, we still can't find out the PATTERN to
simulate the problem. The error might happen any time, after server running
3 days, 4 days.... anytime(even not peak hour) then suddenly throw error.
Now, we still dont know what is the root cause.... totally not idea..... 

Please help...

View this message in context:
Sent from the Velocity - User mailing list archive at

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message