It's not a secret anymore!
The moose likes EJB and other Java EE Technologies and the fly likes Annotation @Stateful in EJB 3.0 Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » EJB and other Java EE Technologies
Bookmark "Annotation @Stateful in EJB 3.0" Watch "Annotation @Stateful in EJB 3.0" New topic

Annotation @Stateful in EJB 3.0

Jagadeesan Sampath

Joined: Sep 05, 2007
Posts: 1
Hi I am new bie,

The stateful bean and Interface are as follows.
package business;

import java.util.Collection;
import javax.ejb.Remote;

public interface Cart {
public void addItem(String item);
public void removeItem(String item);
public Collection getItems();
public void listItem(Collection stuff);
package business;

import java.util.ArrayList;
import java.util.Collection;
import javax.annotation.PostConstruct;
import javax.ejb.Stateful;
import javax.ejb.Remote;
import java.util.Iterator;

public class CartBean implements Cart {
private ArrayList items;
private Collection stuff;
public void initialize() {
items = new ArrayList();

public void addItem(String item) {

public void removeItem(String item) {

public void listItem(Collection stuff) {
for (Iterator i = items.iterator(); i.hasNext() {
String item = (String);
System.out.println(" " + item);

public Collection getItems() {
return items;

The jar built with these 2 is succesfully deployed in JBoss

When a standalone client tried to access the CartBean with the mappedname attribute it gives the below exception

javax.naming.NameNotFoundException: CartEJB#Cart not bound
at org.jnp.server.NamingServer.getBinding(
at org.jnp.server.NamingServer.getBinding(
at org.jnp.server.NamingServer.getObject(
at org.jnp.server.NamingServer.lookup(
at org.jnp.server.NamingServer.lookup(
at sun.reflect.GeneratedMethodAccessor88.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(
at java.lang.reflect.Method.invoke(
at sun.rmi.server.UnicastServerRef.dispatch(
at sun.rmi.transport.Transport$
at Method)
at sun.rmi.transport.Transport.serviceCall(
at sun.rmi.transport.tcp.TCPTransport.handleMessages(
at sun.rmi.transport.tcp.TCPTransport$
at sun.rmi.transport.StreamRemoteCall.exceptionReceivedFromServer(
at sun.rmi.transport.StreamRemoteCall.executeCall(
at sun.rmi.server.UnicastRef.invoke(
at org.jnp.server.NamingServer_Stub.lookup(Unknown Source)
at org.jnp.interfaces.NamingContext.lookup(
at org.jnp.interfaces.NamingContext.lookup(
at javax.naming.InitialContext.lookup(
at CartClient.main(

I am using lookup like this

ctx.lookup (CartEJB#Cart)

Not sure if I have to make the request in JBoss forum. Please advice

[ September 05, 2007: Message edited by: Jagadeesan Sampath ]
I agree. Here's the link:
subject: Annotation @Stateful in EJB 3.0
It's not a secret anymore!