6 Replies Latest reply on Jun 22, 2012 3:11 AM by Gajendra Rathore

    ClassCastException in EJB

    Gajendra Rathore Newbie

      Hi ,

       

      I am getting ClassCastException, when calling one of the EJB

       

      (BrandBroker) InitialContext.lookup("java:app/lmsEjb3/BrandBrokerBean!com.lms.profile.brandBroker.BrandBroker");

       

      Following are the genrated JNDI name :

       

      java:global/lms/lmsEjb3/BrandBrokerBean!com.lms.profile.brandBroker.BrandBroker

      java:app/lmsEjb3/BrandBrokerBean!com.lms.profile.brandBroker.BrandBroker

      java:module/BrandBrokerBean!com.lms.profile.brandBroker.BrandBroker

      java:global/lms/lmsEjb3/BrandBrokerBean

      java:app/lmsEjb3/BrandBrokerBean

      java:module/BrandBrokerBean

       

      Exception :-

       

      Caused by: java.lang.RuntimeException: java.lang.ClassCastException: com.lms.profile.brandBroker.BrandBroker$$$view272 cannot be cast to com.lms.profile.brandBroker.BrandBroker

              at com.util.ejb.Brokers.createBrandBroker(Brokers.java:553) [lmsEjbs.jar:]

              at com.lms.studentUIBroker.StudentUIBrokerBean.getBrandProfile(StudentUIBrokerBean.java:1154) [lmsEjbs.jar:]

              ... 107 more

      Caused by: java.lang.ClassCastException: com.lms.profile.brandBroker.BrandBroker$$$view272 cannot be cast to com.lms.profile.brandBroker.BrandBroker

              at com.util.ejb.Brokers.createBrandBroker(Brokers.java:550) [lmsEjbs.jar:]

              ... 108 more

        • 1. Re: ClassCastException in EJB
          jaikiran pai Master

          Are you packaging the com.lms.profile.brandBroker.BrandBroker in more than one location? Perhaps in a jar and in the war? If yes, then just package it in one location and place that jar in  .ear/lib.

          • 2. Re: ClassCastException in EJB
            Gajendra Rathore Newbie

            Hi Jaikiran,

             

            Thanks, for the solution. but finally I got stuck into below exception :-

             

            06:03:56,283 ERROR [com.util.RequestTimingFilter] (ajp-localhost-127.0.0.1-8411-1) java.lang.RuntimeException: java.lang.ClassCastException: $Proxy43 cannot be cast to javax.ejb.EJBHome: java.lang.RuntimeException: java.lang.ClassCastException: $Proxy43 cannot be cast to javax.ejb.EJBHome

                    at com.lms.ui.admin.usermgnt.AdminJB.initBrokers(AdminJB.java:635) [nonEjb.jar:]

                    at com.lms.ui.admin.usermgnt.PersonJB.<init>(PersonJB.java:511) [nonEjb.jar:]

                    at com.lms.ui.admin.usermgnt.AdminJB.<init>(AdminJB.java:49) [nonEjb.jar:]

                    at org.apache.jsp.index_jsp._jspService(index_jsp.java:245) [catalina-root.jar:]

                    at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70) [jbossweb-7.0.13.Final.jar:]

                    at javax.servlet.http.HttpServlet.service(HttpServlet.java:847) [jboss-servlet-api_3.0_spec-1.0.0.Final.jar:1.0.0.Final]

                    at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:369) [jbossweb-7.0.13.Final.jar:]

                    at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:326) [jbossweb-7.0.13.Final.jar:]

                    at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:253) [jbossweb-7.0.13.Final.jar:]

                    at javax.servlet.http.HttpServlet.service(HttpServlet.java:847) [jboss-servlet-api_3.0_spec-1.0.0.Final.jar:1.0.0.Final]

                    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:329) [jbossweb-7.0.13.Final.jar:]

                    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:248) [jbossweb-7.0.13.Final.jar:]

                    at com.security.servlet.LmnkXSSFilter.doFilter(LmnkXSSFilter.java:59) [nonEjb.jar:]

                    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:280) [jbossweb-7.0.13.Final.jar:]

                    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:248) [jbossweb-7.0.13.Final.jar:]

                    at com.util.servlet.LmnkEntityValueTranslatorFilter.doFilter(LmnkEntityValueTranslatorFilter.java:36) [nonEjb.jar:]

                    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:280) [jbossweb-7.0.13.Final.jar:]

                    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:248) [jbossweb-7.0.13.Final.jar:]

                    at com.util.RequestTimingFilter.doFilter(RequestTimingFilter.java:59) [nonEjb.jar:]

                    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:280) [jbossweb-7.0.13.Final.jar:]

                    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:248) [jbossweb-7.0.13.Final.jar:]

                    at com.service.log.servlet.JspLogFilter.doFilter(JspLogFilter.java:173) [nonEjb.jar:]

                    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:280) [jbossweb-7.0.13.Final.jar:]

                    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:248) [jbossweb-7.0.13.Final.jar:]

                    at com.util.session.SessionFailoverFilter.doFilter(SessionFailoverFilter.java:138) [nonEjb.jar:]

                    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:280) [jbossweb-7.0.13.Final.jar:]

                    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:248) [jbossweb-7.0.13.Final.jar:]

                    at com.security.servlet.LoginSecurityFilter.doFilter(LoginSecurityFilter.java:126) [nonEjb.jar:]

                    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:280) [jbossweb-7.0.13.Final.jar:]

                    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:248) [jbossweb-7.0.13.Final.jar:]

                    at com.security.servlet.OrgSecurityFilter.doFilter(OrgSecurityFilter.java:74) [nonEjb.jar:]

                    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:280) [jbossweb-7.0.13.Final.jar:]

                    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:248) [jbossweb-7.0.13.Final.jar:]

                    at com.security.servlet.LmnkSecurityFilter.doFilter(LmnkSecurityFilter.java:156) [nonEjb.jar:]

                    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:280) [jbossweb-7.0.13.Final.jar:]

                    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:248) [jbossweb-7.0.13.Final.jar:]

                    at com.service.log.servlet.LogContextFilter.doFilter(LogContextFilter.java:69) [nonEjb.jar:]

                    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:280) [jbossweb-7.0.13.Final.jar:]

                    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:248) [jbossweb-7.0.13.Final.jar:]

                    at com.planetj.servlet.filter.compression.CompressingFilter.doFilter(CompressingFilter.java:270) [pjl-comp-filter-1.7.jar:]

                    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:280) [jbossweb-7.0.13.Final.jar:]

                    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:248) [jbossweb-7.0.13.Final.jar:]

                    at com.util.RequestAuditingFilter.doFilter(RequestAuditingFilter.java:148) [nonEjb.jar:]

                    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:280) [jbossweb-7.0.13.Final.jar:]

                    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:248) [jbossweb-7.0.13.Final.jar:]

                    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:275) [jbossweb-7.0.13.Final.jar:]

                    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:161) [jbossweb-7.0.13.Final.jar:]

                    at org.jboss.modcluster.container.jbossweb.JBossWebContext$RequestListenerValve.event(JBossWebContext.java:67)

                    at org.jboss.modcluster.container.jbossweb.JBossWebContext$RequestListenerValve.invoke(JBossWebContext.java:48)

                    at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:397) [jbossweb-7.0.13.Final.jar:]

                    at org.jboss.as.jpa.interceptor.WebNonTxEmCloserValve.invoke(WebNonTxEmCloserValve.java:50) [jboss-as-jpa-7.1.1.Final.jar:7.1.1.Final]

                    at org.jboss.as.web.security.SecurityContextAssociationValve.invoke(SecurityContextAssociationValve.java:153) [jboss-as-web-7.1.1.Final.jar:7.1.1.Final

                    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:155) [jbossweb-7.0.13.Final.jar:]

                    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102) [jbossweb-7.0.13.Final.jar:]

                    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109) [jbossweb-7.0.13.Final.jar:]

                    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:368) [jbossweb-7.0.13.Final.jar:]

                    at org.apache.coyote.ajp.AjpProcessor.process(AjpProcessor.java:505) [jbossweb-7.0.13.Final.jar:]

                    at org.apache.coyote.ajp.AjpProtocol$AjpConnectionHandler.process(AjpProtocol.java:445) [jbossweb-7.0.13.Final.jar:]

                    at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:930) [jbossweb-7.0.13.Final.jar:]

                    at java.lang.Thread.run(Thread.java:619) [rt.jar:1.6.0_10-rc2]

            Caused by: java.lang.ClassCastException: $Proxy43 cannot be cast to javax.ejb.EJBHome

                    at com.service.jndi.HomeLookup.lookup(HomeLookup.java:63) [nonEjb.jar:]

                    at com.util.ejb.Brokers.createAccessControlBroker(Brokers.java:414) [nonEjb.jar:]

                    at com.lms.ui.admin.usermgnt.AdminJB.initBrokers(AdminJB.java:629) [nonEjb.jar:]

                    ... 59 more

            • 3. Re: ClassCastException in EJB
              jaikiran pai Master

              I think you are using the wrong JNDI name for the lookup. The java:app/lmsEjb3/BrandBrokerBean!com.lms.profile.brandBroker.BrandBroker jndi name doesn't seem like the one for the home interface.

              1 of 1 people found this helpful
              • 4. Re: ClassCastException in EJB
                Gajendra Rathore Newbie

                Hi Jaikiran,

                 

                Below are the JNDI names generated for BrandBrokerBean :-

                 

                java:global/lms/lmsEjb3/BrandBrokerBean!com.lms.profile.brandBroker.BrandBroker

                java:app/lmsEjb3/BrandBrokerBean!com.lms.profile.brandBroker.BrandBroker

                java:module/BrandBrokerBean!com.lms.profile.brandBroker.BrandBroker

                java:global/lms/lmsEjb3/BrandBrokerBean

                java:app/lmsEjb3/BrandBrokerBean

                java:module/BrandBrokerBean

                 

                and I have used "java:global/lms/lmsEjb3/BrandBrokerBean" JNDI name.

                • 5. Re: ClassCastException in EJB
                  jaikiran pai Master

                  But what do those JNDI names correspond to? What does your home interface and ejb-jar.xml look like?

                  • 6. Re: ClassCastException in EJB
                    Gajendra Rathore Newbie

                    Got it , issue was with AccessControlBroker JNDI name.

                     

                    Thanks a lot