-
1. Re: client lookup EJB method in JBoss AS 7.0,but return **$$$view1
hay Aug 30, 2011 5:19 AM (in response to icey.xiong)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
benkirby Aug 31, 2011 11:55 AM (in response to hay)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:
{code}
"java:app/store-core-2011.1.2-SNAPSHOT/StoreFront"
"java:app/store-core-2011.1.2-SNAPSHOT/StoreFront!uk.co.magus.jam.store.core.Store"
"java:module/StoreFront"
"java:module/StoreFront!uk.co.magus.jam.store.core.Store"
"java:global/store-ear-2011.1.2-SNAPSHOT/store-core-2011.1.2-SNAPSHOT/StoreFront!uk.co.magus.jam.store.core.Store"
"java:global/store-ear-2011.1.2-SNAPSHOT/store-core-2011.1.2-SNAPSHOT/StoreFront"
{code}
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:
{code}
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
{code}
-
3. Re: client lookup EJB method in JBoss AS 7.0,but return **$$$view1
hay Aug 31, 2011 8:44 PM (in response to benkirby)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
benkirby Sep 1, 2011 6:35 AM (in response to hay)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:
{code}
@Startup
@Singleton
// one of @Local, @Remote, @LocalBean as stated above
@TransactionAttribute(TransactionAttributeType.NOT_SUPPORTED)
@Transactional(TransactionPropagation.SUPPORTS)
public class StoreFront implements Store {
...
{code}
{code}
public interface Store {
...
{code}
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?
-
5. Re: client lookup EJB method in JBoss AS 7.0,but return **$$$view1
jaikiran Sep 1, 2011 9:43 AM (in response to benkirby)It's a bug https://issues.jboss.org/browse/AS7-1658
-
6. Re: client lookup EJB method in JBoss AS 7.0,but return **$$$view1
hay Sep 1, 2011 8:56 PM (in response to benkirby)maybe you can try it as follows:
public interface LocalStore extends Store {}
public interface RemoteStore extends Store {}
@Startup
@Singleton
@Local(LocalStore.class )@Remote(RemoteStore.class)
@TransactionAttribute(TransactionAttributeType.NOT_SUPPORTED)
@Transactional(TransactionPropagation.SUPPORTS)
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
benkirby Sep 2, 2011 3:21 AM (in response to hay)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.