5 Replies Latest reply on Oct 7, 2003 6:04 PM by Adrian Brock

    ClassCastException when redeploying ear file

    velpsamy Newbie

      I am running with jboss-3.2.1_tomcat-4.1.24 connecting to Oracle 8i.

      I have an ear file which contains a jar (with a simple ejb) and a war file.

      I use data transfer objects and those classes are *only* packaged in the ejb jar.

      Everything works fine until I redeploy the ear file.

      When I redeploy the ear file, it gives me classcastexception in the dao layer (called from ejb).

      I even tried adding <loader-repository> tag in jboss-app.xml. It doesn't work.

      If I restart Jboss it works. But I don't want to do that everytime I redeploy.

      Any suggestions?



        • 1. Re: ClassCastException when redeploying ear file
          stefanfreyr Newbie

          What's the stack trace you're getting?

          • 2. Re: ClassCastException when redeploying ear file
            velpsamy Newbie

            16:58:04,708 ERROR [STDERR] java.lang.ClassCastException
            16:58:04,718 ERROR [STDERR] at sample1.dao.cocobase.CBLocalSampleDAO.getNumber(CBLocalSampleDAO.
            java:193)
            16:58:04,728 ERROR [STDERR] at sample1.ejb.SampleBean.getNumber(SampleBean.java:126)
            16:58:04,728 ERROR [STDERR] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
            16:58:04,738 ERROR [STDERR] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorI
            mpl.java:39)
            16:58:04,748 ERROR [STDERR] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodA
            ccessorImpl.java:25)
            16:58:04,758 ERROR [STDERR] at java.lang.reflect.Method.invoke(Method.java:324)
            16:58:04,758 ERROR [STDERR] at org.jboss.ejb.StatelessSessionContainer$ContainerInterceptor.invo
            ke(StatelessSessionContainer.java:629)
            16:58:04,768 ERROR [STDERR] at org.jboss.resource.connectionmanager.CachedConnectionInterceptor.
            invoke(CachedConnectionInterceptor.java:186)
            16:58:04,778 ERROR [STDERR] at org.jboss.ejb.plugins.StatelessSessionInstanceInterceptor.invoke(
            StatelessSessionInstanceInterceptor.java:72)
            16:58:04,788 ERROR [STDERR] at org.jboss.ejb.plugins.AbstractTxInterceptor.invokeNext(AbstractTx
            Interceptor.java:84)
            16:58:04,798 ERROR [STDERR] at org.jboss.ejb.plugins.TxInterceptorCMT.runWithTransactions(TxInte
            rceptorCMT.java:243)
            16:58:04,798 ERROR [STDERR] at org.jboss.ejb.plugins.TxInterceptorCMT.invoke(TxInterceptorCMT.ja
            va:104)
            16:58:04,808 ERROR [STDERR] at org.jboss.ejb.plugins.SecurityInterceptor.invoke(SecurityIntercep
            tor.java:117)
            16:58:04,818 ERROR [STDERR] at org.jboss.ejb.plugins.LogInterceptor.invoke(LogInterceptor.java:1
            91)
            16:58:04,828 ERROR [STDERR] at org.jboss.ejb.plugins.ProxyFactoryFinderInterceptor.invoke(ProxyF
            actoryFinderInterceptor.java:122)
            16:58:04,838 ERROR [STDERR] at org.jboss.ejb.StatelessSessionContainer.internalInvoke(StatelessS
            essionContainer.java:322)
            16:58:04,838 ERROR [STDERR] at org.jboss.ejb.Container.invoke(Container.java:674)
            16:58:04,848 ERROR [STDERR] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
            16:58:04,848 ERROR [STDERR] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorI
            mpl.java:39)
            16:58:04,858 ERROR [STDERR] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodA
            ccessorImpl.java:25)
            16:58:04,868 ERROR [STDERR] at java.lang.reflect.Method.invoke(Method.java:324)
            16:58:04,868 ERROR [STDERR] at org.jboss.mx.capability.ReflectedMBeanDispatcher.invoke(Reflected
            MBeanDispatcher.java:284)
            16:58:04,878 ERROR [STDERR] at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:5
            49)
            16:58:04,888 ERROR [STDERR] at org.jboss.invocation.local.LocalInvoker.invoke(LocalInvoker.java:
            101)
            16:58:04,898 ERROR [STDERR] at org.jboss.invocation.InvokerInterceptor.invoke(InvokerInterceptor
            .java:83)
            16:58:04,908 ERROR [STDERR] at org.jboss.proxy.TransactionInterceptor.invoke(TransactionIntercep
            tor.java:46)
            16:58:04,908 ERROR [STDERR] at org.jboss.proxy.SecurityInterceptor.invoke(SecurityInterceptor.ja
            va:45)
            16:58:04,918 ERROR [STDERR] at org.jboss.proxy.ejb.StatelessSessionInterceptor.invoke(StatelessS
            essionInterceptor.java:100)
            16:58:04,928 ERROR [STDERR] at org.jboss.proxy.ClientContainer.invoke(ClientContainer.java:85)
            16:58:04,928 ERROR [STDERR] at $Proxy41.getNumber(Unknown Source)
            16:58:04,938 ERROR [STDERR] at sample1.delegates.SampleDelegate.getNumber(SampleDelegate.java:11
            1)
            16:58:04,948 ERROR [STDERR] at sample1.web.struts.action.EditNumberAction.execute(EditNumberActi
            on.java:40)
            16:58:04,948 ERROR [STDERR] at org.apache.struts.action.RequestProcessor.processActionPerform(Re
            questProcessor.java:484)
            16:58:04,958 ERROR [STDERR] at org.apache.struts.action.RequestProcessor.process(RequestProcesso
            r.java:274)
            16:58:04,968 ERROR [STDERR] at org.apache.struts.action.ActionServlet.process(ActionServlet.java
            :1482)
            16:58:04,978 ERROR [STDERR] at org.apache.struts.action.ActionServlet.doGet(ActionServlet.java:5
            07)
            16:58:04,988 ERROR [STDERR] at javax.servlet.http.HttpServlet.service(HttpServlet.java:740)
            16:58:04,988 ERROR [STDERR] at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
            16:58:04,998 ERROR [STDERR] at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(
            ApplicationFilterChain.java:247)
            16:58:04,998 ERROR [STDERR] at org.apache.catalina.core.ApplicationFilterChain.doFilter(Applicat
            ionFilterChain.java:193)
            16:58:05,008 ERROR [STDERR] at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrap
            perValve.java:256)
            16:58:05,018 ERROR [STDERR] at org.apache.catalina.core.StandardPipeline$StandardPipelineValveCo
            ntext.invokeNext(StandardPipeline.java:643)
            16:58:05,028 ERROR [STDERR] at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline
            .java:480)
            16:58:05,028 ERROR [STDERR] at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:
            995)
            16:58:05,038 ERROR [STDERR] at org.apache.catalina.core.StandardContextValve.invoke(StandardCont
            extValve.java:191)
            16:58:05,048 ERROR [STDERR] at org.apache.catalina.core.StandardPipeline$StandardPipelineValveCo
            ntext.invokeNext(StandardPipeline.java:643)
            16:58:05,058 ERROR [STDERR] at org.apache.catalina.valves.CertificatesValve.invoke(CertificatesV
            alve.java:246)
            16:58:05,068 ERROR [STDERR] at org.apache.catalina.core.StandardPipeline$StandardPipelineValveCo
            ntext.invokeNext(StandardPipeline.java:641)
            16:58:05,078 ERROR [STDERR] at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline
            .java:480)
            16:58:05,088 ERROR [STDERR] at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:
            995)
            16:58:05,088 ERROR [STDERR] at org.apache.catalina.core.StandardContext.invoke(StandardContext.j
            ava:2415)
            16:58:05,098 ERROR [STDERR] at org.apache.catalina.core.StandardHostValve.invoke(StandardHostVal
            ve.java:180)
            16:58:05,108 ERROR [STDERR] at org.apache.catalina.core.StandardPipeline$StandardPipelineValveCo
            ntext.invokeNext(StandardPipeline.java:643)
            16:58:05,118 ERROR [STDERR] at org.apache.catalina.valves.ErrorDispatcherValve.invoke(ErrorDispa
            tcherValve.java:171)
            16:58:05,118 ERROR [STDERR] at org.apache.catalina.core.StandardPipeline$StandardPipelineValveCo
            ntext.invokeNext(StandardPipeline.java:641)
            16:58:05,128 ERROR [STDERR] at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportVal
            ve.java:172)
            16:58:05,138 ERROR [STDERR] at org.apache.catalina.core.StandardPipeline$StandardPipelineValveCo
            ntext.invokeNext(StandardPipeline.java:641)
            16:58:05,148 ERROR [STDERR] at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.j
            ava:509)
            16:58:05,158 ERROR [STDERR] at org.apache.catalina.core.StandardPipeline$StandardPipelineValveCo
            ntext.invokeNext(StandardPipeline.java:641)
            16:58:05,158 ERROR [STDERR] at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline
            .java:480)
            16:58:05,168 ERROR [STDERR] at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:
            995)
            16:58:05,178 ERROR [STDERR] at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngin
            eValve.java:174)
            16:58:05,188 ERROR [STDERR] at org.apache.catalina.core.StandardPipeline$StandardPipelineValveCo
            ntext.invokeNext(StandardPipeline.java:643)
            16:58:05,198 ERROR [STDERR] at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline
            .java:480)
            16:58:05,198 ERROR [STDERR] at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:
            995)
            16:58:05,208 ERROR [STDERR] at org.apache.coyote.tomcat4.CoyoteAdapter.service(CoyoteAdapter.jav
            a:223)
            16:58:05,218 ERROR [STDERR] at org.apache.coyote.http11.Http11Processor.process(Http11Processor.
            java:594)
            16:58:05,228 ERROR [STDERR] at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.p
            rocessConnection(Http11Protocol.java:392)
            16:58:05,238 ERROR [STDERR] at org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.
            java:565)
            16:58:05,238 ERROR [STDERR] at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(Thr
            eadPool.java:619)
            16:58:05,248 ERROR [STDERR] at java.lang.Thread.run(Thread.java:536)

            • 3. Re: ClassCastException when redeploying ear file
              Bernd Zeitler Expert

              After redeploying, one of the .ear, someone in your .war is probably holding a reference to an object which is now redeployed (and loaded from a different classloader, therefore a different resource).

              If you are using two different loader repositories with java2parent delegation = false, deploying the transport object in both deployments, the check is done by serialization, which should work for resources with the same serial version id. This works with EJBs, I hope even with .wars, since the webserver is using its own classloaders.

              Redeploying even the "dependent" deployments should work at all ;-)

              Greetings,
              Frito

              • 4. Re: ClassCastException when redeploying ear file
                velpsamy Newbie

                Thanks for your response.

                Could you please elaborate on that? I am not quite getting what i should try.

                Thanks

                • 5. Re: ClassCastException when redeploying ear file
                  Adrian Brock Master

                  Your problem is almost certainly struts storing objects
                  in global maps that are still around after a redeploy.
                  I've seen this before. I thought it had been fixed in struts1.1?

                  Get a memory profiler and locate what is holding
                  onto the class object after a redeploy.

                  Regards,
                  Adrian (not a struts user)