• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Bear Bibeault
  • Tim Cooke
  • Junilu Lacar
Sheriffs:
  • Paul Clapham
  • Devaka Cooray
  • Knute Snortum
Saloon Keepers:
  • Ron McLeod
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Frits Walraven
Bartenders:
  • Carey Brown
  • salvin francis
  • Claude Moore

Annotation @Stateful in EJB 3.0  RSS feed

 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi I am new bie,

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

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

@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;

@Stateful(mappedName="CartEJB")
@Remote(Cart.class)
public class CartBean implements Cart {
private ArrayList items;
private Collection stuff;
@PostConstruct
public void initialize() {
items = new ArrayList();
}

public void addItem(String item) {
items.add(item);
}

public void removeItem(String item) {
items.remove(item);
}

public void listItem(Collection stuff) {
for (Iterator i = items.iterator(); i.hasNext() {
String item = (String) i.next();
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(NamingServer.java:529)
at org.jnp.server.NamingServer.getBinding(NamingServer.java:537)
at org.jnp.server.NamingServer.getObject(NamingServer.java:543)
at org.jnp.server.NamingServer.lookup(NamingServer.java:296)
at org.jnp.server.NamingServer.lookup(NamingServer.java:270)
at sun.reflect.GeneratedMethodAccessor88.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:294)
at sun.rmi.transport.Transport$1.run(Transport.java:153)
at java.security.AccessController.doPrivileged(Native Method)
at sun.rmi.transport.Transport.serviceCall(Transport.java:149)
at sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:460)
at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:701)
at java.lang.Thread.run(Thread.java:595)
at sun.rmi.transport.StreamRemoteCall.exceptionReceivedFromServer(StreamRemoteCall.java:247)
at sun.rmi.transport.StreamRemoteCall.executeCall(StreamRemoteCall.java:223)
at sun.rmi.server.UnicastRef.invoke(UnicastRef.java:126)
at org.jnp.server.NamingServer_Stub.lookup(Unknown Source)
at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:625)
at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:587)
at javax.naming.InitialContext.lookup(InitialContext.java:351)
at CartClient.main(CartClient.java:31)

I am using lookup like this

ctx.lookup (CartEJB#Cart)

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

Rgds
JS
[ September 05, 2007: Message edited by: Jagadeesan Sampath ]
 
God is a comedian playing for an audience that is afraid to laugh - Voltair. tiny ad:
Create Edit Print & Convert PDF Using Free API with Java
https://coderanch.com/wiki/703735/Create-Convert-PDF-Free-Spire
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!