Discussion:
[EJB 3.0] - Re: JBoss 5.0.0.CR1 - EJB Lookup Successful but ClassCastEx
zampu007
2008-07-31 17:05:23 UTC
Permalink
No Idea how I missed my question. Sorry

Question is

Above is the console output when I deployed to code and executed the SecondServlet

The servlet is successful in doning the JNDI lookup and obtains Proxy112 object.

As per JNDIView of the server Proxy112 implements the interfaces $Proxy112 implements interface com.tsb.test.ThirdSession,interface org.jboss.ejb3.proxy.JBossProxy

In my servlet I can cast Proxy112 to org.jboss.ejb3.proxy.JBossProxy however I can not cast the same object to com.tsb.test.ThirdSession and get exception java.lang.ClassCastException: $Proxy112 cannot be cast to com.tsb.test.ThirdSession

Can someone please help me and let me know what am I doing wrong?


View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4167987#4167987

Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4167987
zampu007
2008-07-31 20:42:17 UTC
Permalink
After multiple trials and some hints from other posts I figured out the solution to the project.

Basically the ThirdSession.class (a business interface for EJB) was getting loaded 2 times. One was from EJB project and another from WAR project. Even though my Servlet is making a remote EJB call I modified my eclipse setup so that the business interface class is not loaded as a part of WAR file and only loaded as a part of EJB jar file. Wallah, it worked as expected.

If I deploy the dynamic project along with the business interface in another JBOSS instance then also the code works indicating that one JVM can not have more than one class loaded thru different deployed components.

Seems to be problem in the jboss implementation. This means the the person who is building need to know beforehand how the deployment is going to be. Even though the EJB invocation is thru remote invocation, if EJB and its client are in same JBOSS JVM then care has to be taken so that class is not loaded multiple times. As FYI I never faced similar problem while working with Websphere.


View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4168032#4168032

Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4168032
Loading...