[jboss-user] [EJB 3.0] - ClassCastException on Stateless Session Bean

robert.geisler do-not-reply at jboss.com
Wed Mar 4 06:12:25 EST 2009


hello everybody,

currently we are migrating our EJB 2.1 (about 850 EJBs) to EJB 3.0. till now there have not been too many problems, but today i meet a special challeng when i migrated a Stateful Session Bean.

the SFSB, lets call it MyStatefulSessionBean implements a Remote Business  Interface (MyStatefulSession) and gets deployed in a EAR (MyEAR.ear). from a standalone client i can lookup, cast and use the SFSB successfully.
otherwise we deploy a WAR, too. from there i can lookup the SFSB, but cannot use it, because casting results in ClassCastException:
Context context = ContextFactory.getInstance().getContext();
  | MyStatefulSession session = (MyStatefulSession) context.lookup("MyEAR/MyStatefulSession/remote");
$Proxy123 cannot be cast to xzy.MyStatefulSession

the MyStatefulSession.class is packaged in server/MyServer/lib/MyLibrary.jar and in our EAR, too.
i tried to remove all duplicate interfaces and classes from the EAR, but than i get java.lang.VerifyError -that i cannot understand- in arbitrary implementation classes (even in EJB 2.1 SLSB).
2009-03-04 11:48:41,837 WARN  [org.jboss.ejb.EJBDeployer] Verify failed; continuing
  | java.lang.VerifyError: (class: a/b/c/ArbitraryBean, method: getSomething signature: (Ljava/lang/String;ILx/y/z/SomeDTO;)Ljava/util/ArrayList;) Incompatible argument to function
  | 	at java.lang.Class.getDeclaredMethods0(Native Method)
  | 	at java.lang.Class.privateGetDeclaredMethods(Unknown Source)
  | 	at java.lang.Class.privateGetPublicMethods(Unknown Source)
  | 	at java.lang.Class.getMethods(Unknown Source)
  | 	at org.jboss.verifier.strategy.AbstractVerifier.hasEJBCreateMethod(AbstractVerifier.java:687)
  | 	at org.jboss.verifier.strategy.EJBVerifier21.verifySessionBean(EJBVerifier21.java:858)

my idea is that all classes and interfaces that will be used from EAR and WAR, should go to server/MyServer/lib/, implementation classes should remain in EAR, servlets should go into WAR.
is that right? if so, we have to refactor our ANT builds, i guess ; )

anyway... i wonder why our packaging strategy do not show any conflicts for Stateless Session Beans. maybe someone can help me with this...?

thanks in advance
robert

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

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



More information about the jboss-user mailing list