velocity-user mailing list archives

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

Hi.....

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="api.abc.com" root-directory="/www/sw/api">
      <web-app id="/" document-directory="/www/sw/api">
        <servlet-mapping url-pattern="/servlet/*" servlet-name="invoker"/>
      </web-app>
 </host>


>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 {
            logger.info("Velocity File Resource
Loaded:"+Velocity.FILE_RESOURCE_LOADER_PATH);
 
            VelocityContext myVelocityContext = null;
            Velocity.setProperty(Velocity.FILE_RESOURCE_LOADER  _PATH,
velpath);
            Velocity.init();
            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);
            pageContext.getOut().print(myStringWriter);
 
            return EVAL_PAGE;
        }
        catch (Exception e) {
            e.printStackTrace();
 
            throw new JspException("Exception; TEMPLATE_CLASSPATH;
exception="
                    + 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: http://www.nabble.com/JSP-%2B-Velocity-%2B-Resin........-java.lang.NullPointerException-tf4204125.html#a11958420
Sent from the Velocity - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@velocity.apache.org
For additional commands, e-mail: user-help@velocity.apache.org


Mime
View raw message