I have a deployed an ejb and an exploded web application, that should call the ejb.
On looking up the EJB home interface from the webapp there is
Caused by: java.lang.ClassCastException: $Proxy235 cannot be cast to org.omg.CORBA.Object
Object o = context.lookup(jndiName);
MyHome home = (MyHome) PortableRemoteObject.narrow(o, MyHome.class);
Using the remote debugger I found that the result from the JNDI lookup is from the EJB's classloader and MyHome from the WAR classloader.
As MyHome.class is needed in the EJB and in the WAR, what is the recommended place for JBoss 5.1 to put the common classes in?
I removed MyHome.class from the WAR, then it worked (and the MyHome.class was pulled in from the EJB). But it seems strange to have a WAR to use classes from the EJB. And why does the WAR see the EJB's classes?
common classes should be placed either in the EJB jar, or in a JAR file in a "lib" directory in the EAR (the latter is new in JavaEE5). But I think EJB interfaces should always reside in the EJB jar.
Hope this helps