You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@velocity.apache.org by kuku <ku...@yahoo.com> on 2007/08/02 07:00:19 UTC

JSP + Velocity + Resin........ java.lang.NullPointerException

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


Re: JSP + Velocity + Resin........ java.lang.NullPointerException

Posted by Will Glass-Husain <wg...@gmail.com>.
Hi Kuku,

Does your server run under high volume?

We have discovered several race conditions (which may sometimes throw a NPE
under load) and have fixed them in Velocity 1.5.

WILL

On 8/1/07, kuku <ku...@yahoo.com> wrote:
>
>
> 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
>
>


-- 
Forio Business Simulations

Will Glass-Husain
wglass@forio.com
www.forio.com