• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Problem with execAndWait interceptor

 
Ranch Hand
Posts: 53
Android Eclipse IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi All

my xml file looks like this.



after executing its giving me null pointer exception.

if i remove this wait part its running fine.
 
Author
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
...

"its giving me null pointer exception" is not helpful on its own. *What* is giving you the NPE?
 
Bilal A. Siddiqui
Ranch Hand
Posts: 53
Android Eclipse IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The action on which i am applying this execAndWait interceptor is doing 2 things

1. Its validating username and passowrd

2. If validation succeeds it fetches some data corresponding to the user, puts that data in a list and save that list in session.


without execAndWait its running fine, as soon as i include execAndWait it gives me NPE.
 
David Newton
Author
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
...

How could anyone possibly diagnose an NPE if we don't know where the NPE is occurring? Is it in S2 code? XWork code? Your code? Third-party library code? Zimbabwe? Stack traces are provided for a reason.
 
Bilal A. Siddiqui
Ranch Hand
Posts: 53
Android Eclipse IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi David,

java.lang.NullPointerException
at com.apt.action.Login.execute(Login.java:152)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at com.opensymphony.xwork2.DefaultActionInvocation.invokeAction(DefaultActionInvocation.java:404)
at com.opensymphony.xwork2.DefaultActionInvocation.invokeActionOnly(DefaultActionInvocation.java:267)
at org.apache.struts2.interceptor.BackgroundProcess$1.run(BackgroundProcess.java:56)
at java.lang.Thread.run(Thread.java:595)

the line on which this error is really pin pointing is



and this is excatly what i am doing after username validation




 
David Newton
Author
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Your session is getting lost?! Can you confirm that somehow?
 
Bilal A. Siddiqui
Ranch Hand
Posts: 53
Android Eclipse IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi David,

You were right. The session is getting lost.

when i am calling this line


this method is being called



now in this method if don't execute the query
i mean this line


session is maintained, but if i execute session is getting lost.

Now how should i maintain this session?


 
David Newton
Author
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I don't see how that code could make the session go away; it's not related to session handling at all. I think something else is wrong.

In any case, it doesn't seem to be a Struts issue.

Btw, BeanUtils.copyProperties().
 
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
execAndWait Interceptor?

the exec and wait interceptor is declaired in your struts.xml file like

its my understanding that the wait page is called from a bkground thread, which makes me wonder
if this newly created (temporary) thread would have access to the session of the original thread (I'm unsure).

perhaps this is why the success page (called from/with original thread) can get stuff from the session just fine?
If this is true it looks like a slight hack might be necessary?

above code from http://struts.apache.org/2.0.6/docs/execute-and-wait-interceptor.html
 
J Owens
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Important: Because the action will be running in a seperate thread, you can't use ActionContext because it is a ThreadLocal.
This means if you need to access, for example, session data, you need to implement
SessionAware rather than calling ActionContext.getSesion().

from: http://struts.apache.org/2.0.6/docs/execute-and-wait-interceptor.html
 
reply
    Bookmark Topic Watch Topic
  • New Topic