Hi folks!
That's my environment:
App.Server: JBoss 3.0
Deployment-Tool: deploytool from J2EE 1.3
Database: Oracle 8.0i
I got 4 different objects according to a customer: the customer-obj himself, address, bankAccount and contact.
When I try to create for ex. an Address with my client like this:
Object ref = jndiContext.lookup("AddressBean");
AddressHome home = (AddressHome) PortableRemoteObject.narrow(ref, AddressHome.class);
AddressRemote remote = home.create(id, customerId, addressData);
... all works great!
But I designed the tool with a CustomerAgent(a SessionBean), who should do all the creation of Customers, Addresses, BankAccounts and Contacts.
So in the client, I only create the customer and tell him to add/create those objects:
Object ref = jndiContext.lookup("CustomerAgent");
CustomerAgentHome custHome = (CustomerAgentHome) PortableRemoteObject.narrow(ref, CustomerAgentHome.class);
CustomerAgentRemote custRemote = custHome.create();
// here starts the object-creation...
custRemote.createCustomer(id, customerData);
custRemote.addAddressToCustomer(customerId, addressData);
...
If I try now in these methods just like
createCustomer or
addAddressToCustomer to create these objects in the database, I get the exception:
ClassCastException at PortableRemoteObject.narrow()...
Why does the creation work with the client, but not with the CustomerAgent?