EDITED: after believing this is a NetBeans 7.0 editor bug. It still compiles and is deployable.
I want to convert my webservice which is @WebService;@Stateless implementation into a @Singleton bean but when I replace the @WebService with @Singleton annotation... I get the image below in my IDE Editor
of course when I do something silly like having both @WebService and @Stateless and deploy in glassfish I get:
severe error: Annotations processing failed for...
"Singleton session beans offer similar functionality to stateless session beans but differ from them in that there is only one singleton session bean per application, as opposed to a pool of stateless session beans, any of which may respond to a client request. Like stateless session beans, singleton session beans can implement web service endpoints."
INFO: Closing Metro monitoring root:
amx:pp=/mon/server-mon[server],type=WSEndpoint,name=soco.ws.bb.bearBearWS-BearBearImplPort
INFO: Portable JNDI names for EJB StateBean :
[java:global/BearBearService/StateBean!soco.ws.bb.StateBean,
java:global/BearBearService/StateBean] INFO: Metro monitoring rootname
successfully set to:
amx:pp=/mon/server-mon[server],type=WSEndpoint,name=soco.ws.bb.bearBearWS-BearBearImplPort
WARNING: Container org.glassfish.webservices.JAXWSContainer@249ef1e
doesn't support class com.sun.xml.ws.api.server.Module INFO: Portable
JNDI names for EJB BearBearImpl :
[java:global/BearBearService/BearBearImpl!soco.ws.bb.BearBearWS,
java:global/BearBearService/BearBearImpl] INFO: WS00019: EJB Endpoint
deployed
INFO: Metro monitoring rooname successfully set to:
amx:pp=/mon/server-mon[server], type=WSEndpoint,
name=AppleImplService-AppleImplPort WARNING: Container
org.glassfish.webservices.JAXWSContainer@191f81e doesn't support class
com.sun.xml.ws.api.server.Module INFO: Portable JNDI names for EJB
AppleImpl "
[java:global/AppleService/AppleImpl!com.ws.srv.MyService,java:global/AppleService/AppleImpl]
INFO: WS00019: EJB Endpoint deployed AppleService listening at
address at http://localhost:8080/AppleImplService/AppleImpl INFO:
AppleService was successfully deployed in 438 milliseconds
This is a bug in NetBeans 7.0 editor. I was able to build and deploy a WS using both @WebService, @Singleton even though the service name was underlined in red to indicate a compile error. Just ran a test to verify that the spec bean works as advertised. I will provide code below and snapshot of my test ui.
Thanks to @home, @bkali and @Preston for contributing.
Submitted to netbeans as a bug: http://netbeans.org/bugzilla/show_bug.cgi?id=200911
Notice below the instance state does to timeout and change from 50 to 0 after the timeout period (10 minutes) when I redeploy the service as a Singleton instead of a stateless.
Web Service Test Code:
import javax.ejb.EJB;
import javax.ejb.Singleton;
import javax.jws.WebService;
import javax.jws.WebParam;
import javax.ejb.Stateless;
@WebService(serviceName = "soco.ws.bb.bearBearWS")
@Singleton
//@Stateless
public class BearBearImpl implements BearBearWS {
int state = 0;
static int staticState = 0;
@EJB StateBean sb = new StateBean();
@Override
public String hello(@WebParam(name = "name") String txt) {
return "Hello " + txt + " !";
}
@Override
public void setAllState(int in) {
System.out.println("setting instance state from "+state+" to "+in);
state = in;
System.out.println("setting static state from "+staticState+" to "+in);
staticState = in;
System.out.println("setting singleton state from "+sb.state+" to "+in);
sb.state = in;
}
@Override
public int getInstanceState() {
System.out.println("returning instance state "+state);
return state;
}
@Override
public int getStaticState() {
System.out.println("returning static state "+staticState);
return staticState;
}
@Override
public int getSingletonState() {
System.out.println("returning singleton state "+sb.state);
return sb.state;
}
}