4 Replies Latest reply on Sep 5, 2007 12:12 PM by Matus Majchrak

    JBoss 4.04 EJB3 lookup: classCastException on proxy object

    Matus Majchrak Newbie

      Greetings,

      Similiar problem was already solved here, but it came to no help for my case.
      I have simple bean LoginStatistcsBean code:

      @Stateless
      @Remote(LoginStatisticsBeanBI.class)
      @Local(LoginStatisticsBeanBI.class)
      public class LoginStatisticsBean implements LoginStatisticsBeanBI {
      
       public LoginStatisticsBean() {
       }
       public helllo(){
       }
      }


      I have an interface for it used as both local and remote code:
      @Remote
      @Local
      public interface LoginStatisticsBeanBI {
      
       public void hello();
      }



      But my ,,client'' is a FOSessionListener used to record session create/destroy events over JbossPortal serrvlet, placed in jboss-portal.sar/portal-server.war/META-INF/lib. So I created a client-jar archive containing my LoginStatisticsBeanBI interface and placed it into same folder. snippet for lookup:
      Object obj = ic.lookup("LoginStatisticsBean/remote");
      LoginStatisticsBeanBI bi= (LoginStatisticsBeanBI) obj;


      Bean is correctly deployed,and bounded :
      +- LoginStatisticsBean (class: org.jnp.interfaces.NamingContext)
       | +- local (proxy: $Proxy135 implements interface com.giag.fo.statistics.ejb.interfaces.LoginStatisticsBeanBI,interface org.jboss.ejb3.JBossProxy,interface javax.ejb.EJBLocalObject)
       | +- remote (proxy: $Proxy133 implements interface com.giag.fo.statistics.ejb.interfaces.LoginStatisticsBeanBI,interface org.jboss.ejb3.JBossProxy,interface javax.ejb.EJBObject)
      

      and due to this outcome of jndi bounding it is obvious that proxy objects implements LoginStatisticsBeanBI

      But after either rocal or remote lookup, the returned proxy objects cant be casted to The interface.
      exception code:
      10:25:01,453 ERROR [[/]] Session event listener threw exception
      java.lang.ClassCastException: $Proxy133
       at com.giag.fo.statistics.sessionListener.FOSessionListener.sessionDestroyed(FOSessionListener.java:76)
       at org.apache.catalina.session.StandardSession.expire(StandardSession.java:687)
       at org.apache.catalina.session.StandardSession.expire(StandardSession.java:645)
       at org.apache.catalina.session.StandardSession.invalidate(StandardSession.java:1090)
       at org.apache.catalina.session.StandardSessionFacade.invalidate(StandardSessionFacade.java:149)
       at org.jboss.portal.server.aspects.server.SessionInvalidatorInterceptor.after(SessionInvalidatorInterceptor.java:146)
       at org.jboss.portal.server.aspects.server.SessionInvalidatorInterceptor.invoke(SessionInvalidatorInterceptor.java:96)
       at org.jboss.portal.server.ServerInterceptor.invoke(ServerInterceptor.java:37)
       at org.jboss.portal.common.invocation.Invocation.invokeNext(Invocation.java:130)
       at org.jboss.portal.core.aspects.server.TransactionInterceptor.org$jboss$portal$core$aspects$server$TransactionInterceptor$invoke$aop(TransactionInterceptor.java:49)
       at org.jboss.portal.core.aspects.server.TransactionInterceptor$invoke_N5143606530999904530.invokeNext(TransactionInterceptor$invoke_N5143606530999904530.java)
       at org.jboss.aspects.tx.TxPolicy.invokeInOurTx(TxPolicy.java:79)
       at org.jboss.aspects.tx.TxInterceptor$RequiresNew.invoke(TxInterceptor.java:275)
       at org.jboss.portal.core.aspects.server.TransactionInterceptor$invoke_N5143606530999904530.invokeNext(TransactionInterceptor$invoke_N5143606530999904530.java)
       at org.jboss.portal.core.aspects.server.TransactionInterceptor.invoke(TransactionInterceptor.java)
       at org.jboss.portal.server.ServerInterceptor.invoke(ServerInterceptor.java:37)
       at org.jboss.portal.common.invocation.Invocation.invokeNext(Invocation.java:130)
       at org.jboss.portal.common.invocation.Invocation.invoke(Invocation.java:171)
       at org.jboss.portal.server.servlet.PortalServlet.process(PortalServlet.java:294)
       at org.jboss.portal.server.servlet.PortalServlet.doGet(PortalServlet.java:172)
       at javax.servlet.http.HttpServlet.service(HttpServlet.java:697)
       at javax.servlet.http.HttpServlet.service(HttpServlet.java:810)
       at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)
       at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
       at com.giag.fo.statistics.filters.LoginFilter.doFilter(LoginFilter.java:53)
       at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
       at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
       at com.giag.fo.statistics.filters.LoginFilter.doFilter(LoginFilter.java:53)
       at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
       at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
       at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)
       at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
       at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
       at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
       at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)
       at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:175)
       at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:524)
       at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:74)
       at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)
       at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
       at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)
       at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
       at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:869)
       at org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:664)
       at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527)
       at org.apache.tomcat.util.net.MasterSlaveWorkerThread.run(MasterSlaveWorkerThread.java:112)
       at java.lang.Thread.run(Thread.java:595)


      could this be caused by the location of client-jar[containing my bean's interface] in portal-servlet.war archive?
      or is there any other possibility to make my bean visible for the SessionListener placed in portal-server.war archive?
      Thank you very much for your time and effort

      Matus