users@glassfish.java.net

How Can I access a Stateful Session Bean with a WebService ?

From: <glassfish_at_javadesktop.org>
Date: Sun, 17 Jun 2007 16:39:04 PDT

Hello,

Here is my problem: I need to access my session bean with a web service endpoint, but I need to keep track of my session bean instance each time I call my Web Service.
As I can only use annotation @WebService with a Stateless bean (@Stateless) as an example I tried something like that:
 [code]
@WebService()
public class NewWebService {
 
@EJB
private NewSessionLocal newSessionBean;
/**
* Web service operation
*/
@WebMethod
public String operation() {
return newSessionBean.hello();
}
}

@Stateful
public class NewSessionBean {
 
private String message;
 
/** Creates a new instance of NewSessionBean */
public NewSessionBean() {
message = "";
}
public String hello(){
return message += "hello";
}
}

 [code]

 which should append hello string every time I call my web Service. However it only works if I remove annotation @EJB and @Stateful. Otherwis I get an
EJB5070: Exception creating stateless session bean : [{0}]

If someone could tell me how I can do with this issue it would be very nice.

Thank you.
[Message sent by forum member 'bastral1' (bastral1)]

http://forums.java.net/jive/thread.jspa?messageID=222626