14 Replies Latest reply on Nov 19, 2008 11:17 AM by rober-mpp

    java.lang.ClassCastException: $Proxy79 getting conext

    ericchile

      Can't seem to get the stateless facade from within my webapp. I hava the webapp and the jar (bean) in the same ear. It appears the the context for the bean is correct. I also made sure there were no references to that bean in my WEB-INF/classes or lib. Anyone have a clue as to what is going on here?

       final Context context = new InitialContext();
       WebkidsFacade =
       (webkidsFacade) context.lookup("WebkidsAdminLite/webkidsFacade/local");
      
      




      Global JNDI Namespace
      
       +- XAConnectionFactory (class: org.jboss.mq.SpyXAConnectionFactory)
       +- TopicConnectionFactory (class: org.jboss.naming.LinkRefPair)
       +- WebkidsAdminLite (class: org.jnp.interfaces.NamingContext)
       | +- webkidsFacade (class: org.jnp.interfaces.NamingContext)
       | | +- local (proxy: $Proxy79 implements interface org.usiis.model.webkidsFacadeLocal,interface org.jboss.ejb3.JBossProxy,interface javax.ejb.EJBLocalObject)
       | | +- remote (proxy: $Proxy77 implements interface org.usiis.model.webkidsFacade,interface org.jboss.ejb3.JBossProxy,interface javax.ejb.EJBObject)
       +- UserTransactionSessionFactory (proxy: $Proxy46 implements interface org.jboss.tm.usertx.interfaces.UserTransactionSessionFactory)
       +- UIL2ConnectionFactory[link -> ConnectionFactory] (class: javax.naming.LinkRef)
       +- UIL2XAConnectionFactory[link -> XAConnectionFactory] (class: javax.naming.LinkRef)
       +- console (class: org.jnp.interfaces.NamingContext)
       | +- PluginManager (proxy: $Proxy40 implements interface org.jboss.console.manager.PluginManagerMBean)
       +- QueueConnectionFactory (class: org.jboss.naming.LinkRefPair)
       +- topic (class: org.jnp.interfaces.NamingContext)
       | +- testDurableTopic (class: org.jboss.mq.SpyTopic)
       | +- testTopic (class: org.jboss.mq.SpyTopic)
       | +- securedTopic (class: org.jboss.mq.SpyTopic)
       +- queue (class: org.jnp.interfaces.NamingContext)
       | +- A (class: org.jboss.mq.SpyQueue)
       | +- testQueue (class: org.jboss.mq.SpyQueue)
       | +- ex (class: org.jboss.mq.SpyQueue)
       | +- DLQ (class: org.jboss.mq.SpyQueue)
       | +- D (class: org.jboss.mq.SpyQueue)
       | +- C (class: org.jboss.mq.SpyQueue)
       | +- B (class: org.jboss.mq.SpyQueue)
       +- ConnectionFactory (class: org.jboss.mq.SpyConnectionFactory)
       +- UserTransaction (class: org.jboss.tm.usertx.client.ClientUserTransaction)
       +- jmx (class: org.jnp.interfaces.NamingContext)
       | +- invoker (class: org.jnp.interfaces.NamingContext)
       | | +- RMIAdaptor (proxy: $Proxy39 implements interface org.jboss.jmx.adaptor.rmi.RMIAdaptor,interface org.jboss.jmx.adaptor.rmi.RMIAdaptorExt)
       | +- rmi (class: org.jnp.interfaces.NamingContext)
       | | +- RMIAdaptor[link -> jmx/invoker/RMIAdaptor] (class: javax.naming.LinkRef)
       +- UILXAConnectionFactory[link -> XAConnectionFactory] (class: javax.naming.LinkRef)
       +- UILConnectionFactory[link -> ConnectionFactory] (class: javax.naming.LinkRef)
      


      13:45:37,245 ERROR [STDERR] java.lang.ClassCastException: $Proxy79
      13:45:37,245 ERROR [STDERR] at org.usiis.view.backing.Login.<init>(Login.jav
      a:43)
      13:45:37,245 ERROR [STDERR] at sun.reflect.NativeConstructorAccessorImpl.new
      Instance0(Native Method)
      13:45:37,245 ERROR [STDERR] at sun.reflect.NativeConstructorAccessorImpl.new
      Instance(NativeConstructorAccessorImpl.java:39)
      13:45:37,245 ERROR [STDERR] at sun.reflect.DelegatingConstructorAccessorImpl
      .newInstance(DelegatingConstructorAccessorImpl.java:27)
      13:45:37,245 ERROR [STDERR] at java.lang.reflect.Constructor.newInstance(Con
      structor.java:494)
      13:45:37,245 ERROR [STDERR] at java.lang.Class.newInstance0(Class.java:350)
      13:45:37,245 ERROR [STDERR] at java.lang.Class.newInstance(Class.java:303)
      13:45:37,245 ERROR [STDERR] at org.apache.myfaces.shared_impl.util.ClassUtil
      s.newInstance(ClassUtils.java:274)
      13:45:37,245 ERROR [STDERR] at org.apache.myfaces.shared_impl.util.ClassUtil
      s.newInstance(ClassUtils.java:265)
      13:45:37,245 ERROR [STDERR] at org.apache.myfaces.config.ManagedBeanBuilder.
      buildManagedBean(ManagedBeanBuilder.java:50)
      13:45:37,245 ERROR [STDERR] at org.apache.myfaces.el.VariableResolverImpl.re
      solveVariable(VariableResolverImpl.java:311)
      13:45:37,245 ERROR [STDERR] at org.apache.myfaces.config.LastVariableResolve
      rInChain.resolveVariable(LastVariableResolverInChain.java:42)
      13:45:37,245 ERROR [STDERR] at org.apache.myfaces.el.ValueBindingImpl$ELVari
      ableResolver.resolveVariable(ValueBindingImpl.java:574)
      13:45:37,245 ERROR [STDERR] at org.apache.commons.el.NamedValue.evaluate(Nam
      edValue.java:124)
      13:45:37,245 ERROR [STDERR] at org.apache.commons.el.ComplexValue.evaluate(C
      omplexValue.java:140)
      13:45:37,245 ERROR [STDERR] at org.apache.myfaces.el.ValueBindingImpl.getVal


        • 1. Re: java.lang.ClassCastException: $Proxy79 getting conext
          alrubinger

          Try:

          WebkidsFacadeLocal =
          (webkidsFacadeLocal) context.lookup("WebkidsAdminLite/webkidsFacade/local");


          ...looks like "WebkidsFacade" is stored under "remote".

          S,
          ALR

          • 2. Re: java.lang.ClassCastException: $Proxy79 getting conext
            ericchile

             

            Global JNDI Namespace
            
             +- XAConnectionFactory (class: org.jboss.mq.SpyXAConnectionFactory)
             +- TopicConnectionFactory (class: org.jboss.naming.LinkRefPair)
             +- WebkidsAdminLite (class: org.jnp.interfaces.NamingContext)
             | +- webkidsFacade (class: org.jnp.interfaces.NamingContext)
             | | +- local (proxy: $Proxy79 implements interface org.usiis.model.webkidsFacadeLocal,interfac
            e org.jboss.ejb3.JBossProxy,interface javax.ejb.EJBLocalObject)
             | | +- remote (proxy: $Proxy77 implements interface org.usiis.model.webkidsFacade,interface or
            g.jboss.ejb3.JBossProxy,interface javax.ejb.EJBObject)
            


            There is an interface for both local and remote

            • 3. Re: java.lang.ClassCastException: $Proxy79 getting conext
              alrubinger

              Yes. And you're looking up the one in local, and trying to cast it into the object type stored under remote.

              WebkidsAdminLite/webkidsFacade/local < $Proxy79 implements interface org.usiis.model.webkidsFacadeLocal


              WebkidsAdminLite/webkidsFacade/remote < $Proxy77 implements interface org.usiis.model.webkidsFacade


              S,
              ALR



              • 4. Re: java.lang.ClassCastException: $Proxy79 getting conext
                ericchile

                Awesome that was it....

                now Im getting a different error....
                [Code]
                java.io.IOException: No properties file: users.properties or defaults: defaultUs
                ers.properties found
                at org.jboss.security.auth.spi.Util.loadProperties(Util.java:315)
                at org.jboss.security.auth.spi.UsersRolesLoginModule.loadUsers(UsersRole
                sLoginModule.java:186)
                at org.jboss.security.auth.spi.UsersRolesLoginModule.createUsers(UsersRo

                • 5. Re: java.lang.ClassCastException: $Proxy79 getting conext
                  helloween0809

                  I met the same problem.

                  and the same code runs correctly in a java eclipse.


                  ============= the code ===================

                  public class MainFrame {

                  public static void main(String[] args) throws Exception {

                  Properties props = new Properties();

                  props.setProperty("java.naming.factory.initial", "org.jnp.interfaces.NamingContextFactory");
                  props.setProperty("java.naming.factory.url.pkgs", "org.jboss.naming:org.jnp.interfaces");
                  props.setProperty("java.naming.provider.url", "localhost:1099");

                  InitialContext initCtx = new InitialContext(props);

                  Rankgrade rankgrade = (Rankgrade)initCtx.lookup("RankgradeBean/remote");

                  }

                  }



                  =========== the excepiton ====================

                  16:16:28,064 WARN [RequestProcessor] Unhandled Exception thrown: class java.lang.ClassCastException
                  16:16:28,064 ERROR [[action]] Servlet.service() for servlet action threw exception
                  java.lang.ClassCastException: $Proxy100
                  at com.ufmobile.mstreet.rank.action.RankGradeAction.execute(RankGradeAction.java:57)
                  at org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:419)
                  at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:224)
                  at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1194)
                  at org.apache.struts.action.ActionServlet.doGet(ActionServlet.java:414)
                  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 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.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.jboss.web.tomcat.tc5.jca.CachedConnectionValve.invoke(CachedConnectionValve.java:156)
                  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)


                  ========= the JNDI ===================

                  +- StreetBean (class: org.jnp.interfaces.NamingContext)
                  | +- local (proxy: $Proxy92 implements interface com.ufmobile.mstreet.street.bo.Street,interface org.jboss.ejb3.JBossProxy,interface javax.ejb.EJBLocalObject)
                  | +- remote (proxy: $Proxy91 implements interface com.ufmobile.mstreet.street.bo.Street,interface org.jboss.ejb3.JBossProxy,interface javax.ejb.EJBObject)
                  +- RankplaceBean (class: org.jnp.interfaces.NamingContext)
                  | +- local (proxy: $Proxy75 implements interface com.ufmobile.mstreet.rank.bo.Rankplace,interface org.jboss.ejb3.JBossProxy,interface javax.ejb.EJBLocalObject)
                  | +- remote (proxy: $Proxy73 implements interface com.ufmobile.mstreet.rank.bo.Rankplace,interface org.jboss.ejb3.JBossProxy,interface javax.ejb.EJBObject)
                  +- QueueConnectionFactory (class: org.jboss.naming.LinkRefPair)



                  • 6. Re: java.lang.ClassCastException: $Proxy79 getting conext
                    chrisrevilla

                    does anybody solved this problem?

                    • 7. Re: java.lang.ClassCastException: $Proxy79 getting conext
                      chrisrevilla

                      PLEASE i HAVE THE SAME PROBLEM

                      • 8. Re: java.lang.ClassCastException: $Proxy79 getting conext
                        alrubinger

                        Which same problem? The ClassCastException originally posted in this thread? Or the IOException EricChile had during invocation to a secured bean?

                        Gotta post some code or configuration, and explain exactly what's wrong. And if your error isn't the same as the one started in this Thread, please start a new one; it helps us all to better figure out the cause of your errors.

                        S,
                        ALR

                        • 9. Re: java.lang.ClassCastException: $Proxy79 getting conext
                          rober-mpp

                          Hi all,

                          I'm having the ClassCastException issue, but I only have one remote interface.

                          This is my java code:

                          Hashtable<String, String> contextProperties = new Hashtable<String, String>();
                           contextProperties.put( InitialContext.INITIAL_CONTEXT_FACTORY, "org.jnp.interfaces.NamingContextFactory" );
                           contextProperties.put( InitialContext.PROVIDER_URL, "jnp://127.0.0.1:1099" );
                          
                           InitialContext initialContext = new InitialContext( contextProperties );
                          
                           Object obj = initialContext.lookup( "ZaraServer/FachadaBean/remote" );
                          
                           FachadaInterfaz fachada = (FachadaInterfaz)obj;


                          The exception being throwed on the last line when trying to cast:
                          23:01:47,984 ERROR [STDERR] java.lang.ClassCastException: $Proxy91 cannot be cast to zara.server.session.fachada.FachadaInterfaz
                          23:01:48,000 ERROR [STDERR] at ws.RecibirEnvioATiendaSoapBindingImpl.inicializarFachada(RecibirEnvioATiendaSoapBindingImpl.java:95)
                          23:01:48,000 ERROR [STDERR] at ws.RecibirEnvioATiendaSoapBindingImpl.recibirEnvioATienda(RecibirEnvioATiendaSoapBindingImpl.java:57)
                          23:01:48,000 ERROR [STDERR] at ws.RecibirEnvioATiendaSoapBindingSkeleton.recibirEnvioATienda(RecibirEnvioATiendaSoapBindingSkeleton.java:56)
                          23:01:48,000 ERROR [STDERR] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
                          23:01:48,000 ERROR [STDERR] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
                          23:01:48,000 ERROR [STDERR] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
                          23:01:48,000 ERROR [STDERR] at java.lang.reflect.Method.invoke(Method.java:597)
                          23:01:48,015 ERROR [STDERR] at org.apache.axis.providers.java.RPCProvider.invokeMethod(RPCProvider.java:397)
                          23:01:48,015 ERROR [STDERR] at org.apache.axis.providers.java.RPCProvider.processMessage(RPCProvider.java:186)
                          23:01:48,015 ERROR [STDERR] at org.apache.axis.providers.java.JavaProvider.invoke(JavaProvider.java:323)
                          23:01:48,015 ERROR [STDERR] at org.apache.axis.strategies.InvocationStrategy.visit(InvocationStrategy.java:32)
                          23:01:48,015 ERROR [STDERR] at org.apache.axis.SimpleChain.doVisiting(SimpleChain.java:118)
                          23:01:48,015 ERROR [STDERR] at org.apache.axis.SimpleChain.invoke(SimpleChain.java:83)
                          23:01:48,015 ERROR [STDERR] at org.apache.axis.handlers.soap.SOAPService.invoke(SOAPService.java:453)
                          23:01:48,015 ERROR [STDERR] at org.apache.axis.server.AxisServer.invoke(AxisServer.java:281)
                          23:01:48,015 ERROR [STDERR] at org.apache.axis.transport.http.AxisServlet.doPost(AxisServlet.java:699)
                          23:01:48,031 ERROR [STDERR] at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
                          23:01:48,031 ERROR [STDERR] at org.apache.axis.transport.http.AxisServletBase.service(AxisServletBase.java:327)
                          23:01:48,031 ERROR [STDERR] at javax.servlet.http.HttpServlet.service(HttpServlet.java:810)
                          23:01:48,031 ERROR [STDERR] at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)
                          23:01:48,031 ERROR [STDERR] at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
                          23:01:48,031 ERROR [STDERR] at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)
                          23:01:48,031 ERROR [STDERR] at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
                          23:01:48,046 ERROR [STDERR] at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
                          23:01:48,046 ERROR [STDERR] at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
                          23:01:48,046 ERROR [STDERR] at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)
                          23:01:48,046 ERROR [STDERR] at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:175)
                          23:01:48,046 ERROR [STDERR] at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:74)
                          23:01:48,046 ERROR [STDERR] at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)
                          23:01:48,046 ERROR [STDERR] at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
                          23:01:48,046 ERROR [STDERR] at org.jboss.web.tomcat.tc5.jca.CachedConnectionValve.invoke(CachedConnectionValve.java:156)
                          23:01:48,046 ERROR [STDERR] at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)
                          23:01:48,062 ERROR [STDERR] at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
                          23:01:48,062 ERROR [STDERR] at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:869)
                          23:01:48,062 ERROR [STDERR] at org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:664)
                          23:01:48,062 ERROR [STDERR] at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527)
                          23:01:48,062 ERROR [STDERR] at org.apache.tomcat.util.net.MasterSlaveWorkerThread.run(MasterSlaveWorkerThread.java:112)
                          23:01:48,062 ERROR [STDERR] at java.lang.Thread.run(Thread.java:619)
                          


                          The JNDI namespace

                          Global JNDI Namespace
                          
                           +- XAConnectionFactory
                           +- TopicConnectionFactory
                           +- UIL2ConnectionFactory[link -> ConnectionFactory]
                           +- UserTransactionSessionFactory (proxy: $Proxy39 implements interface org.jboss.tm.usertx.interfaces.UserTransactionSessionFactory)
                           +- UIL2XAConnectionFactory[link -> XAConnectionFactory]
                           +- QueueConnectionFactory
                           +- ZaraServer
                           | +- AdministradorArticulosBean
                           | | +- local (proxy: $Proxy74 implements interface zara.server.session.articulos.AdministradorArticulosInterfaz,interface org.jboss.ejb3.JBossProxy,interface javax.ejb.EJBLocalObject)
                           | +- AdministradorVentasBean
                           | | +- local (proxy: $Proxy80 implements interface zara.server.session.venta.AdministradorVentasInterfaz,interface org.jboss.ejb3.JBossProxy,interface javax.ejb.EJBLocalObject)
                           | +- FachadaBean
                           | | +- remote (proxy: $Proxy83 implements interface zara.server.session.fachada.FachadaInterfaz,interface org.jboss.ejb3.JBossProxy,interface javax.ejb.EJBObject)
                           | +- AdministradorPedidosBean
                           | | +- local (proxy: $Proxy77 implements interface zara.server.session.pedidos.AdministradorPedidosInterfaz,interface org.jboss.ejb3.JBossProxy,interface javax.ejb.EJBLocalObject)
                          


                          I think I may be going crazy with this issue, but I can't make it work.

                          Thanks all for your help
                          Cheers.

                          • 10. Re: java.lang.ClassCastException: $Proxy79 getting conext
                            rober-mpp

                            Sorry guys, just to give you more background information.

                            I'm using a jboss version 4.0.5.GA.

                            I have an EAR deployed called ZaraServer, and I'm trying to get the remote reference inside another webapp that is also deployed on the same jboss instance.

                            Thanks again
                            Rober

                            • 11. Re: java.lang.ClassCastException: $Proxy79 getting conext
                              rober-mpp

                              Ok i've solved this problem with a little help from my friend Agus.

                              I have duplicated some of the jars in both, the ear and the webapp, in order to make the IDE compile. That was causing the interface in the client not to match the remote reference.

                              I've removed the duplicated jars from the webapp that was calling the ejb, and added the dependency between projects to make the IDE compile.
                              This part is solved, now I have a bunch of other problems, but different ones :P

                              Thanks

                              • 12. Re: java.lang.ClassCastException: $Proxy79 getting conext
                                peterj

                                Please post the declaration of your interface and EJB, including any annotations (you do not need to post the body of the class or interface).

                                Also, the client code you posted - is that a stand-alone client or is this client also running within JBossAS? If it is running within JBossAS, do you by any chance have two copies of the interface, one in the EJB jar and another with the client?

                                • 13. Re: java.lang.ClassCastException: $Proxy79 getting conext
                                  peterj

                                  Sorry, didn't see that here was a second page to this topic when I responded.

                                  • 14. Re: java.lang.ClassCastException: $Proxy79 getting conext
                                    rober-mpp

                                     

                                    "PeterJ" wrote:
                                    ...do you by any chance have two copies of the interface, one in the EJB jar and another with the client?


                                    That was exactly the problem. I had the interfaces in both apps.

                                    The client code is executed on another web application that is running on the same jboss instances.

                                    It's working fine now.

                                    Thanks 4 your help.