I need to implementing a stateful Session Bean. So, I took the Cart-example
and added the following thinks to look the values of a stateful bean who
shall be in the container (because by first call of this program, I added
some beans).
But, all Beans are destroyed. I can't see the STATEFUL beans of the
last program-call!
Why there not persistent?
Client:
--------
// init Contextejb-jar.xml
java.util.Properties p = new java.util.Properties();
p.put(Context.INITIAL_CONTEXT_FACTORY,"com.evermind.server.ApplicationClientInitialContextFactory");
p.put(Context.PROVIDER_URL,"ormi://localhost/caddie");
p.put(Context.SECURITY_PRINCIPAL,"admin");
p.put(Context.SECURITY_CREDENTIALS,"metrocine");
Context context = new InitialContext(p);// get Cart bean
Object homeObject = context.lookup("java:comp/env/Cart");
CartHome home = (CartHome)PortableRemoteObject.narrow(homeObject, CartHome.class);
Cart cart = (Cart)PortableRemoteObject.narrow(home.create("kuno"), Cart.class);// print-out of all item stored in the stateful bean
java.util.Collection items = cart.getItems();
java.util.Iterator iterator = items.iterator();while(iterator.hasNext()){
System.out.println((String)iterator.next());
}// Add some new items to the Cart.
cart.add("Milk");
cart.add("Apples");
cart.add("Pizza");
----------
<ejb-jar>
<display-name>Caddie for the shop of Metrocine</display-name>
<description>prototype v1.0</description>
<enterprise-beans>
<session>
<display-name>Shopping Cart</display-name>
<description>A simple shopping cart.</description>
<ejb-name>Cart</ejb-name>
<home>metrocine.caddie.interfaces.CartHome</home>
<remote>metrocine.caddie.interfaces.Cart</remote>
<ejb-class>metrocine.caddie.ejb.CartEJB</ejb-class>
<session-type>Stateful</session-type>
<transaction-type>Container</transaction-type>
</session>
</enterprise-beans>
<assembly-descriptor/>
</ejb-jar>
--
------------------------------------------------------------------------
-- http://zap.to/kuno - Homepage - http://www.eif.ch --
-- 026/ 494.19.56 - Telefon - 026/ 429.66.11 --
-- [EMAIL PROTECTED] - eMail - [EMAIL PROTECTED] --
------------------------------------------------------------------------
