7 Replies Latest reply on Sep 2, 2011 3:21 AM by Ben Kirby

    client lookup EJB method in JBoss AS 7.0,but return **$$$view1

    Icey Thomas Newbie


           I have a problem.thank you for your kind attention!

           I create a EJB Local bean with just one  method.I lookup the method in a servet ,then a ClassCastException is threw:

           com.multiable.loginBean.login$$$view1  cannot cast to com.multiable.LoginBean.Login.


          With the lookup ,I want it to bu com.multiable.loginBean.login,but the result has something more “$$$view1”.

           Here is my way to do look up:



           how can be like this? Does anyBody know something about this?

        • 1. Re: client lookup EJB method in JBoss AS 7.0,but return **$$$view1
          hay Newbie

          if Login.class in global module or it point to the same login.class,it is right.or it happens ClassCastException

          • 2. Re: client lookup EJB method in JBoss AS 7.0,but return **$$$view1
            Ben Kirby Newbie

            I've also got this problem. Did either of you guys discover what was wrong, or find a workaround?


            I have an EJB Singleton packaged in a JAR, within an EAR. When it deploys, it says the EJB is bound to:












            I try to look it up via JNDI from code within a JAR within another deployed EAR. Only the last entry ({{"java:global/store-ear-2011.1.2-SNAPSHOT/store-core-2011.1.2-SNAPSHOT/StoreFront"}}) can actually be found, and when I try to cast the resulting object to the actual class, I get the following exception:




            Caused by: java.lang.ClassCastException: uk.co.magus.jam.store.core.StoreFront$$$view1 cannot be cast to uk.co.magus.jam.store.core.Store

                    at uk.co.magus.jam.core.link.LinkListener.getStore(LinkListener.java:101) [core-jar-2011.1.2-SNAPSHOT.jar:]

                    at uk.co.magus.jam.core.link.LinkListener.postLoad(LinkListener.java:29) [core-jar-2011.1.2-SNAPSHOT.jar:]

                    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) [:1.6.0_07]

                    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) [:1.6.0_07]

                    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) [:1.6.0_07]

                    at java.lang.reflect.Method.invoke(Method.java:597) [:1.6.0_07]

                    at org.hibernate.ejb.event.ListenerCallback.invoke(ListenerCallback.java:48)

                    at org.hibernate.ejb.event.EntityCallbackHandler.callback(EntityCallbackHandler.java:96)

                    at org.hibernate.ejb.event.EntityCallbackHandler.postLoad(EntityCallbackHandler.java:89)

                    at org.hibernate.ejb.event.EJB3PostLoadEventListener.onPostLoad(EJB3PostLoadEventListener.java:49)

                    at org.hibernate.engine.internal.TwoPhaseLoad.initializeEntity(TwoPhaseLoad.java:264)

                    at org.hibernate.loader.Loader.initializeEntitiesAndCollections(Loader.java:1012)

                    at org.hibernate.loader.Loader.doQuery(Loader.java:889)

                    at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:289)

                    at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:259)

                    at org.hibernate.loader.Loader.loadEntity(Loader.java:2058)

                    at org.hibernate.loader.entity.AbstractEntityLoader.load(AbstractEntityLoader.java:81)

                    at org.hibernate.loader.entity.AbstractEntityLoader.load(AbstractEntityLoader.java:71)

                    at org.hibernate.persister.entity.AbstractEntityPersister.load(AbstractEntityPersister.java:3686)

                    at org.hibernate.event.internal.DefaultLoadEventListener.loadFromDatasource(DefaultLoadEventListener.java:446)

                    at org.hibernate.event.internal.DefaultLoadEventListener.doLoad(DefaultLoadEventListener.java:427)

                    at org.hibernate.event.internal.DefaultLoadEventListener.load(DefaultLoadEventListener.java:204)

                    at org.hibernate.event.internal.DefaultLoadEventListener.proxyOrLoad(DefaultLoadEventListener.java:251)

                    at org.hibernate.event.internal.DefaultLoadEventListener.onLoad(DefaultLoadEventListener.java:148)

                    at org.hibernate.internal.SessionImpl.fireLoad(SessionImpl.java:947)

                    at org.hibernate.internal.SessionImpl.get(SessionImpl.java:863)

                    at org.hibernate.internal.SessionImpl.get(SessionImpl.java:856)

                    at org.hibernate.ejb.AbstractEntityManagerImpl.find(AbstractEntityManagerImpl.java:787)

                    ... 29 more


            • 3. Re: client lookup EJB method in JBoss AS 7.0,but return **$$$view1
              hay Newbie

              i don't konw the reason,but you can move jar that include StoreFront.class to module(common jars).it will be ok.if you find better way,please tell me.

              • 4. Re: client lookup EJB method in JBoss AS 7.0,but return **$$$view1
                Ben Kirby Newbie

                Thanks Hay. Unfortunately that's not an option for me, as both EARs are deployables, that reguarly change.


                To add to the posts above, I'm able to look up the EJB using either of the global jndi names (not just one, as previously stated).


                Whether the EJB is annotated with


                • @Local(Store.class)
                • @Remote(Store.class)
                • @LocalBean


                makes no difference. Store is the interface StoreFront implements. Class declarations look like this:






                // one of @Local, @Remote, @LocalBean as stated above



                public class StoreFront implements Store {





                public interface Store {




                As I understand it, the fact it's returning a proxy 'view' is normal. However, shouldn't I be able to cast that view to the interface?


                My EJB knowledge is not strong, and I'm attempting to rectify that now, but if anyone can shed some light on this I'd really appreciate it.


                How did you get around this, Icey?

                • 6. Re: client lookup EJB method in JBoss AS 7.0,but return **$$$view1
                  hay Newbie

                  maybe you can try it as follows:

                  public interface LocalStore extends  Store {}

                  public interface RemoteStore extends  Store {}


                  @Local(LocalStore.class )

                  public class StoreFront implements LocalStore,Remote{}


                  remote jndi is a bug in jboss as 7 at current

                  • 7. Re: client lookup EJB method in JBoss AS 7.0,but return **$$$view1
                    Ben Kirby Newbie

                    Thanks both - will make my searches more thorough in future.


                    Issue remains the same with that approach unfortunately, Hay - thanks though.


                    Will wait for the fix.