I tried the jmx-console method displayClassInfo for both interface types and the bean class type. And none of them showed any indication of duplicate class loading.
So, anything other suggestions? Or, I guess I should ask what is the proper way of packaging ejb and web app. Right now, I pack ejb remote/local interface types and bean class types into ejb-jar; and pack ejb remote/local interface types and web app files into the war file.
I tried casting it directly to the remote interface without using PortableRemoteObject.narrow(), but I still got the ClassCastException. Also, I am not sure what you mean by "Try casting it to the Bean class instead of casting to an interface.", my understanding is you only expose ejb interfaces (remote or local) to the client, instead of the actual bean class. Anyway, I also tried that, but still the same thing.
Can you point me to a working sample EAR that has a version 2.4 web app with a ejb 3 module?
What does your application.xml file look like. Can you post that?
Yes, you should only be casting to the interface, I just wanted to see if it was something else. Anyway, you application.xml needs to have modules that point to each archive file. And you definitely have the interfaces in the ejb's jar file?
Originally posted by Tong Wang: I got the same exception even without using PortableRemoteObject.narrow and doing the casting directly. The jndi name seems to be fine, because I can see it in the jmx-console's JNDIView.
Great, that shows that you don't need to use narrow. Forget about narrow.
Now the problem is classpath, for some reason you interfaces are not in the client's classpath.
I packed the interface classes into the WAR and interface and bean classes into the ejb-jar. I don't have any <ejb-ref> in my web.xml, since it's not needed for ejb3. Am I doing anything wrong that could affect the classpath?
I packed the interface classes into the WAR and interface and bean classes into the ejb-jar
There lies the problem. You have placed the interface(s) in more than one package. Remove the interface(s) from the war and let them remain in the ejb-jar. That should solve it. The JMX console method mentioned in one of the links that i posted earlier, should have detected this.