Prashant Kumar
Prashant Kumar

Reputation: 1

Why Stateful bean is showing the opposite behavior

I am getting different instances (on clicking Test then going back and repeating) of the Demo. I was expecting the same instance. Can someone explain what I am missing here?

Bean

@Stateful
@LocalBean
public class Demo {
    public Demo() {
    }
}

Service

@Path("/")
public class Services {
    @EJB
    Demo demo;

    @POST
    @Produces(MediaType.APPLICATION_JSON)
    @Path("Testing")
    public Response testing(){
        return Response.ok(demo.hashCode()).build();
    }
}

Upvotes: 0

Views: 32

Answers (0)

Related Questions