Results 1 to 1 of 1
Thread: A problem with stateful EJB
- 11-24-2010, 09:52 AM #1
Member
- Join Date
- Nov 2009
- Location
- Russia
- Posts
- 9
- Rep Power
- 0
A problem with stateful EJB
My application is assumed to increment a property in a stateful EJB,
but it does not work. Sum=0 all the time. If I change it to Stateless it works.
As I understood a Stateful EJB is created one per a client, but in my case it is like one per a request.
Remote interface
import javax.ejb.Remote;
@Remote
public interface AddInterface {
int getSum();
}
Stateful EJB
import javax.ejb.Stateful;
@Stateful
public class SumBean implements AddInterface {
private int summa;
@Override
public int getSum() {
return summa++;
}
}
JSP client (summa.jsp)
<%
InitialContext ctx = new InitialContext();
AddInterface myBean = (AddInterface)
ctx.lookup(AddInterface.class.getName());
out.println(myBean.getSum());
%>
<form action="summa.jsp">
<input type="submit" value="Send" />
</form>
Similar Threads
-
EJB 3 Stateful Application
By mohiit in forum Enterprise JavaBeans (EJB)Replies: 2Last Post: 05-11-2008, 02:44 AM -
Stateful Session Bean
By Java Tip in forum Java TipReplies: 0Last Post: 11-29-2007, 12:39 PM -
Calling a Stateful Session bean in NetBeans
By JavaForums in forum NetBeansReplies: 0Last Post: 07-31-2007, 09:21 AM -
Introduction to Stateful Session Bean In NetBeans
By JavaForums in forum NetBeansReplies: 0Last Post: 07-31-2007, 09:21 AM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks