473,396 Members | 1,783 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

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
Expand|Select|Wrap|Line Numbers
  1.  
  2. <host id="api.abc.com" root-directory="/www/sw/api">
  3.       <web-app id="/" document-directory="/www/sw/api">
  4.         <servlet-mapping url-pattern="/servlet/*" servlet-name="invoker"/>
  5.       </web-app>
  6.  </host>
  7.  
From the error message in stdout.log, we found the java null pointer throw from velocity. The coding area is somewhere like below:

Expand|Select|Wrap|Line Numbers
  1. public int doEndTag() throws JspException {
  2.         try {
  3.             logger.info("Velocity File Resource Loaded:"+Velocity.FILE_RESOURCE_LOADER_PATH);
  4.  
  5.             VelocityContext myVelocityContext = null;
  6.             Velocity.setProperty(Velocity.FILE_RESOURCE_LOADER_PATH, velpath);
  7.             Velocity.init();
  8.             if (ctx == null) {
  9.                 myVelocityContext = new VelocityContext();
  10.             }
  11.             else {
  12.                 myVelocityContext = ctx;
  13.             }
  14.  
  15.             Template template = null;
  16.             template = Velocity.getTemplate(veltemplate, "UTF-8");
  17.             StringWriter myStringWriter = new StringWriter();
  18.  
  19.             template.merge(myVelocityContext, myStringWriter);
  20.             pageContext.getOut().print(myStringWriter);
  21.  
  22.             return EVAL_PAGE;
  23.         }
  24.         catch (Exception e) {
  25.             e.printStackTrace();
  26.  
  27.             throw new JspException("Exception; TEMPLATE_CLASSPATH; exception="
  28.                     + e.getMessage());
  29.         }
  30.     }
  31.  
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...
Aug 2 '07 #1
0 1414

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Jens Mueller | last post by:
Hi there, this is a Java-XML Question, so I am not sure whether this is the right place, haven't found anything better .... I try to convert a Java object to XML via SAX and let the FOP...
2
by: Tim Murray | last post by:
First of all, I don't know much about Java, even its naming and version numbering nomenclature, and second, if there is a better group to ask this in, please let me know. System is Mac with...
0
by: gezkk | last post by:
hi, i m using http proxy service to get proxy and host to applet, its working fine with jdk1.5 but getting java.lang.NullPointerException in jdk1.6 And the following is mseeage contains java...
0
by: ycinar | last post by:
hey all, i am working on a Java project using JBuilder.. when i build my code its fine, but when comes to run, it doesnt run and displays the following logs.. i think there is JDK conflict.. ...
1
by: ketand1 | last post by:
import java.awt.*; import java.awt.event.*; import java.io.*; import java.util.*; import java.sql.*; import java.lang.*; class DbAwt extends Frame implements ActionListener { private...
2
by: sokeefe | last post by:
I am trying to edit the GUI of a project in Netbeans. In particular, I am trying to add new JButtons. I get a NullPointerException when I try to add an Event to any given JButton (even ones that...
1
by: sokeefe | last post by:
I am trying to edit the GUI of a project in Netbeans. In particular, I am trying to add new JButtons. I get a NullPointerException when I try to add an Event to any given JButton (even ones that...
3
by: ohadr | last post by:
hi, i get Exception in thread "main" java.lang.NullPointerException when i run my application. the exact error is: "Exception in thread "main" java.lang.NullPointerException at...
1
by: r035198x | last post by:
This exception occurs often enough in practice to warrant its own article. It is a very silly exception to get because it's one of the easiest exceptions to avoid in programming. Yet we've all got it...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.