• 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 stateful service

 
Ranch Hand
Posts: 399
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi, I was trying an example from Ivan Krizsan tutorial to maintain stateful session between requests, but HttpServletRequest is always null when I try to extract it from MessageContext.
This is client :


This is service :




and unfortunately the exception stack trace :


Why I cannot retrieve the HttpServletRequest object ?
 
Ranch Hand
Posts: 2198
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi!
There is indeed an error in the example in the study notes, but somehow you seem to have figured it out anyway.
The error is that the printNumber() method in the service endpoint implementation class is annotated with @Oneway. This way, the HTTP response will be closed before the printNumber method is entered and thus no HTTP session will be created (exception will occur).

To make sure that the operation becomes a request-response operation, you can add "throws Exception" to the method declaration.

Also note that the example says that you also are supposed to call the printHTTPSessionID() method from the add() method - this to see that invocations of different operations happens within one and the same session.
Hope this solves your problems!
 
Goran Markovic
Ranch Hand
Posts: 399
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yes, however thanks on yours suggestions about this issue.
 
Ivan Krizsan
Ranch Hand
Posts: 2198
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi!
I just want to add that I used the exact code that you posted above, developing the web service and client. Then I deployed the web service to GlassFish 2.1 and everything worked as it is supposed to.
If you still have problems, what are you deploying the web service to? Have you made any modifications to the default configuration of the container?
Best wishes!
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic