This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Web Services and the fly likes problem with stateful service Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Web Services
Bookmark "problem with stateful service" Watch "problem with stateful service" New topic
Author

problem with stateful service

Goran Markovic
Ranch Hand

Joined: Sep 26, 2008
Posts: 399
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 ?
Ivan Krizsan
Ranch Hand

Joined: Oct 04, 2006
Posts: 2198
    
    1
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

Joined: Sep 26, 2008
Posts: 399
Yes, however thanks on yours suggestions about this issue.
Ivan Krizsan
Ranch Hand

Joined: Oct 04, 2006
Posts: 2198
    
    1
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!
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: problem with stateful service
 
Similar Threads
Clients of Stateful Web Services on Ivan A Krizsan's notes
javax.xml.ws.WebServiceException: java.io.IOException: Stream is closed
java.net.BindException: Address already in use: bind in JDK1.6
Client problem for my JAX-WS web service
Calculator example