This week's book giveaway is in the Java 8 forum.
We're giving away four copies of Java 8 in Action and have Raoul-Gabriel Urma, Mario Fusco, and Alan Mycroft on-line!
See this thread for details.
The moose likes Other JSE/JEE APIs and the fly likes Struts2 Null Pointer Exception at Session Scope Level Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Java » Other JSE/JEE APIs
Bookmark "Struts2 Null Pointer Exception at Session Scope Level" Watch "Struts2 Null Pointer Exception at Session Scope Level" New topic

Struts2 Null Pointer Exception at Session Scope Level

Monica Salvador

Joined: Feb 24, 2011
Posts: 23
I have a problem with my struts2 action. It says that I have a null session scope attribute when it's printing out the code fine.. Here's where the code gets the error (this is actually line 48)..

Here's the output on the Server Log..

But after printing out the output, here's the error I get...

WTH's goin on with Java?
Rob Spoor

Joined: Oct 27, 2005
Posts: 19552

If you check out that stack trace, you see that the top level exception is a JSONException (line 2). That's caused by an InvocationTargetException (line 70). That in turn is caused by a NullPointerException (line 77). That's what you should focus on.

This tells you that the NullPointerException is thrown by method execute of class com.cashmate.struts.Release_EditVouchers, on line 48 of file That's now the number one piece of code to focus on. Why don't you post that line here; if it's not too long the entire execute method.

How To Ask Questions How To Answer Questions
I agree. Here's the link:
subject: Struts2 Null Pointer Exception at Session Scope Level
Similar Threads
LazyInitializationException [spring + struts2]
Can use validator classes within action's validation methods?
Could not initialize class thats under WEB-INF
HibernateDaoSupport not compatible with JSON
Struts2 java.lang.reflect.InvocationTargetException (Struts2 with Hibernate)