3 Replies Latest reply on Jul 15, 2009 3:56 AM by Julien Flotté

    [EJB 2 in JBoss 5] Error on ClassCastException

    Julien Flotté Newbie

      Hi everoby,

      I have to migrate an application from JBoss 3.2 to JBoss 5.0.
      The deployment is correct (I think) : I have no errors.

      But when I want to acces my first EJB by login, I have a cast exception on a proxy object :

      $Proxy855 cannot be cast to fr.monappli.modele.traitement.service._menu.delegate.MenuService


      Is there differences between JBoss 3.0 ans JBoss 5.0 for EJB2 ? Am I missing something ?

      Cordialy,
      Julien.

        • 1. Re: [EJB 2 in JBoss 5] Error on ClassCastException
          jaikiran pai Master

          Please post the entire exception stacktrace and the relevant code. Also do you package any JBoss specific jar files in your application? If yes, then remove them from the packaging.

          • 2. Re: [EJB 2 in JBoss 5] Error on ClassCastException
            Julien Flotté Newbie

            The entire exception is :

            javax.naming.NameNotFoundException: fr.monappli.modele.traitement.service._menu.delegate.MenuService not bound
            at org.jnp.server.NamingServer.getBinding(NamingServer.java:771)
            at org.jnp.server.NamingServer.getBinding(NamingServer.java:779)
            at org.jnp.server.NamingServer.getObject(NamingServer.java:785)
            at org.jnp.server.NamingServer.lookup(NamingServer.java:443)
            at sun.reflect.GeneratedMethodAccessor318.invoke(Unknown Source)
            at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
            at java.lang.reflect.Method.invoke(Method.java:597)
            at sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:305)
            at sun.rmi.transport.Transport$1.run(Transport.java:159)
            at java.security.AccessController.doPrivileged(Native Method)
            at sun.rmi.transport.Transport.serviceCall(Transport.java:155)
            at sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:535)
            at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run0(TCPTransport.java:790)
            at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:649)
            at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
            at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
            at java.lang.Thread.run(Thread.java:619)
            at sun.rmi.transport.StreamRemoteCall.exceptionReceivedFromServer(StreamRemoteCall.java:255)
            at sun.rmi.transport.StreamRemoteCall.executeCall(StreamRemoteCall.java:233)
            at sun.rmi.server.UnicastRef.invoke(UnicastRef.java:142)
            at org.jnp.server.NamingServer_Stub.lookup(Unknown Source)
            at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:722)
            at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:682)
            at javax.naming.InitialContext.lookup(InitialContext.java:392)
            at fr.gouv.defense.sicagem.modele.traitement.service._menu.ServiceAccessor.getMenuService(ServiceAccessor.java:32)
            at fr.gouv.defense.sicagem.webapp._filter.UserContext.<init>(UserContext.java:77)
            at fr.gouv.defense.sicagem.webapp._page.ApplicationAfficheAction.projectExecute(ApplicationAfficheAction.java:126)
            at fr.gouv.defense.sicagem.webapp._strutsClasseBases.ActionBase.frameworkExecute(ActionBase.java:49)
            at com.airial.framework.struts.FrameWorkAction.execute(FrameWorkAction.java:40)
            at org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:484)
            at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:274)
            at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1482)
            at org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:525)
            at javax.servlet.http.HttpServlet.service(HttpServlet.java:637)
            at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
            at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
            at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
            at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:638)
            at org.apache.catalina.core.ApplicationDispatcher.processRequest(ApplicationDispatcher.java:444)
            at org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:382)
            at org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:310)
            at org.apache.jasper.runtime.PageContextImpl.doForward(PageContextImpl.java:696)
            at org.apache.jasper.runtime.PageContextImpl.forward(PageContextImpl.java:667)
            at org.apache.jsp.logonVerifDpc_jsp._jspService(logonVerifDpc_jsp.java:113)
            at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
            at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
            at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:369)
            at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:322)
            at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:249)
            at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
            at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
            at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
            at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)
            at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
            at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
            at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:235)
            at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
            at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:190)
            at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:433)
            at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:92)
            at org.jboss.web.tomcat.security.SecurityContextEstablishmentValve.process(SecurityContextEstablishmentValve.java:126)
            at org.jboss.web.tomcat.security.SecurityContextEstablishmentValve.invoke(SecurityContextEstablishmentValve.java:70)
            at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
            at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
            at org.jboss.web.tomcat.service.jca.CachedConnectionValve.invoke(CachedConnectionValve.java:158)
            at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
            at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:330)
            at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:829)
            at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:601)
            at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
            at java.lang.Thread.run(Thread.java:619)
            


            The revelant code :

            
            String homeJndi = "fr/monappli/ejb/menu/MenuSL";
            
            try {
             Hashtable<String, String> env = new Hashtable<String, String>();
            
             env.put(Context.INITIAL_CONTEXT_FACTORY, "org.jnp.interfaces.NamingContextFactory");
             env.put(Context.URL_PKG_PREFIXES, "org.jboss.naming:org.jnp.interfaces");
             env.put(Context.PROVIDER_URL, "localhost:1099");
             final Context context = new InitialContext(env);
             MenuService menuService = (MenuService) context.lookup(homeJndi);
             } catch(NamingException e) {
             e.printStackTrace();
             }
            


            And what do you mean by "do you package any JBoss specific jar files in your application? If yes, then remove them from the packaging." ? I have a jar file with all my EJBs. It contains ejb-jar.xml, service.jndi.properties, ...; if i remove this one, everything will be broken ?

            • 3. Re: [EJB 2 in JBoss 5] Error on ClassCastException
              Julien Flotté Newbie

               

              context.lookup(homeJndi)


              returns :

              $Proxy855 : fr/monappli/ejb/menu/MenuSLHome


              Any ideas ?