I got this FactorialBean, which has both local and remote home interfaces and remote interfaces (When deploying this bean, I filled up both the remote and local portions of the J2EE RI server). Then I have this second EJB, defined within the same container and the same Jar as my FactorialBean, that is supposed to use FactorialBean (through local interface). Here's the code snippet of the second EJB:
However, when I ran my client application. I encounter a ClassCastException (caused by the second EJB). Here's the code snippet of the client:
I just followed what's on the book. How come this is not working. Please help! Thank you very much
posted 15 years ago
I think I wasn't able to explain myself clearly:
I have this FactorialBean, which has local and remote home/component interfaces defined in J2EE RI. I have only one JNDI name for both, "MyFactorial". It seems weird though, if I call on the remote FactorialBean within the second EJB, it perfectly works. But when I started using the local home, this is the time I encounter ClassCastException. I thought if we want to use local home/component interfaces, we don't have to do narrow-ing anymore, just simple cast is enough?
"I have only one JNDI name for both" David, You can't have one JNDI name for two beans (or two types of the same beans.) If you look at the class hierarchies of the remote and local beans, you will see that they are different. It looks like the remote bean is really bound to that JNDI name.
According to the book that I'm reading, you can expose both local and remote home/component interfaces of an EJB. If this was the case, would that mean you should deploy the FactorialBean twice, first exposing the local stuff, then on the second time exposing the remote stuff, each would have its own JNDI name? Actually I already did this, I had "MyLocalFactorial" and "MyRemoteFactorial" JNDI names for local and remote stuff, respectively. In my second EJB (PermutationBean) I had a lookup on "MyLocalFactorial", but I encountered NamingException instead. Would you know what caused this?
Thank you very much for the help!
Doody calls. I would really rather that it didn't. Comfort me wise and sterile tiny ad: