3 Replies Latest reply on Aug 29, 2007 6:35 AM by S Ramarao

    Stateless Session Bean - java.lang.reflect.UndeclaredThrowab

    S Ramarao Newbie

      Hi ,
      When i am accessing a stateless session bean methods in a servlet
      i am able to access some methods without any problem. But some methods are throwing the following error.
      I am not able to find oput why it is hapening with only some methods.


      The error is as follows:


      java.lang.reflect.UndeclaredThrowableException
      2007-08-28 16:21:31,765 ERROR STDERR - at $Proxy458.getUserResource(Unknown Source)
      2007-08-28 16:21:31,765 ERROR STDERR - at com.ecc.login.servlets.HomePage.login(HomePage.java:569)
      2007-08-28 16:21:31,765 ERROR STDERR - at com.ecc.login.servlets.HomePage.doPost(HomePage.java:131)
      2007-08-28 16:21:31,765 ERROR STDERR - at javax.servlet.http.HttpServlet.service(HttpServlet.java:710)
      2007-08-28 16:21:31,765 ERROR STDERR - at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
      2007-08-28 16:21:31,765 ERROR STDERR - at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
      2007-08-28 16:21:31,765 ERROR STDERR - at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
      2007-08-28 16:21:31,765 ERROR STDERR - at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)
      2007-08-28 16:21:31,765 ERROR STDERR - at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
      2007-08-28 16:21:31,765 ERROR STDERR - at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
      2007-08-28 16:21:31,765 ERROR STDERR - at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:230)
      2007-08-28 16:21:31,765 ERROR STDERR - at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
      2007-08-28 16:21:31,765 ERROR STDERR - at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:179)
      2007-08-28 16:21:31,765 ERROR STDERR - at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:84)
      2007-08-28 16:21:31,765 ERROR STDERR - at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
      2007-08-28 16:21:31,765 ERROR STDERR - at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:104)
      2007-08-28 16:21:31,765 ERROR STDERR - at org.jboss.web.tomcat.service.jca.CachedConnectionValve.invoke(CachedConnectionValve.java:156)
      2007-08-28 16:21:31,765 ERROR STDERR - at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
      2007-08-28 16:21:31,765 ERROR STDERR - at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:241)
      2007-08-28 16:21:31,765 ERROR STDERR - at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844)
      2007-08-28 16:21:31,765 ERROR STDERR - at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:580)
      2007-08-28 16:21:31,765 ERROR STDERR - at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
      2007-08-28 16:21:31,765 ERROR STDERR - at java.lang.Thread.run(Thread.java:595)
      2007-08-28 16:21:31,765 ERROR STDERR - Caused by: java.io.IOException
      2007-08-28 16:21:31,765 ERROR STDERR - at org.jboss.serial.persister.RegularObjectPersister.readSlotWithMethod(RegularObjectPersister.java:107)
      2007-08-28 16:21:31,765 ERROR STDERR - at org.jboss.serial.persister.RegularObjectPersister.defaultRead(RegularObjectPersister.java:269)
      2007-08-28 16:21:31,765 ERROR STDERR - at org.jboss.serial.persister.RegularObjectPersister.readData(RegularObjectPersister.java:241)
      2007-08-28 16:21:31,765 ERROR STDERR - at org.jboss.serial.objectmetamodel.ObjectDescriptorFactory.readObjectDescriptionFromStreaming(ObjectDescriptorFactory.java:412)
      2007-08-28 16:21:31,765 ERROR STDERR - at org.jboss.serial.objectmetamodel.ObjectDescriptorFactory.objectFromDescription(ObjectDescriptorFactory.java:82)
      2007-08-28 16:21:31,765 ERROR STDERR - at org.jboss.serial.objectmetamodel.DataContainer$DataContainerInput.readObject(DataContainer.java:845)
      2007-08-28 16:21:31,765 ERROR STDERR - at org.jboss.serial.io.MarshalledObjectForLocalCalls.get(MarshalledObjectForLocalCalls.java:60)
      2007-08-28 16:21:31,765 ERROR STDERR - at org.jboss.ejb3.remoting.IsLocalInterceptor.invokeLocal(IsLocalInterceptor.java:94)
      2007-08-28 16:21:31,765 ERROR STDERR - at org.jboss.ejb3.remoting.IsLocalInterceptor.invoke(IsLocalInterceptor.java:70)
      2007-08-28 16:21:31,765 ERROR STDERR - at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
      2007-08-28 16:21:31,765 ERROR STDERR - at org.jboss.ejb3.stateless.StatelessRemoteProxy.invoke(StatelessRemoteProxy.java:103)
      2007-08-28 16:21:31,765 ERROR STDERR - ... 23 more
      2007-08-28 16:21:31,765 ERROR STDERR - Caused by: java.lang.reflect.InvocationTargetException
      2007-08-28 16:21:31,765 ERROR STDERR - at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      2007-08-28 16:21:31,765 ERROR STDERR - at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
      2007-08-28 16:21:31,765 ERROR STDERR - at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
      2007-08-28 16:21:31,765 ERROR STDERR - at java.lang.reflect.Method.invoke(Method.java:585)
      2007-08-28 16:21:31,765 ERROR STDERR - at org.jboss.serial.persister.RegularObjectPersister.readSlotWithMethod(RegularObjectPersister.java:103)
      2007-08-28 16:21:31,765 ERROR STDERR - ... 33 more
      2007-08-28 16:21:31,765 ERROR STDERR - Caused by: org.jboss.serial.exception.SerializationException: Could not create instance of org.apache.log4j.Logger - org.apache.log4j.Logger
      2007-08-28 16:21:31,765 ERROR STDERR - at org.jboss.serial.classmetamodel.ClassMetaData.newInstance(ClassMetaData.java:342)
      2007-08-28 16:21:31,765 ERROR STDERR - at org.jboss.serial.persister.RegularObjectPersister.readData(RegularObjectPersister.java:239)
      2007-08-28 16:21:31,765 ERROR STDERR - at org.jboss.serial.objectmetamodel.ObjectDescriptorFactory.readObjectDescriptionFromStreaming(ObjectDescriptorFactory.java:412)
      2007-08-28 16:21:31,765 ERROR STDERR - at org.jboss.serial.objectmetamodel.ObjectDescriptorFactory.objectFromDescription(ObjectDescriptorFactory.java:82)
      2007-08-28 16:21:31,765 ERROR STDERR - at org.jboss.serial.objectmetamodel.DataContainer$DataContainerInput.readObject(DataContainer.java:845)
      2007-08-28 16:21:31,765 ERROR STDERR - at org.jboss.serial.persister.RegularObjectPersister.readSlotWithFields(RegularObjectPersister.java:353)
      2007-08-28 16:21:31,765 ERROR STDERR - at org.jboss.serial.persister.RegularObjectPersister.defaultRead(RegularObjectPersister.java:273)
      2007-08-28 16:21:31,765 ERROR STDERR - at org.jboss.serial.persister.RegularObjectPersister.readData(RegularObjectPersister.java:241)
      2007-08-28 16:21:31,765 ERROR STDERR - at org.jboss.serial.objectmetamodel.ObjectDescriptorFactory.readObjectDescriptionFromStreaming(ObjectDescriptorFactory.java:412)
      2007-08-28 16:21:31,765 ERROR STDERR - at org.jboss.serial.objectmetamodel.ObjectDescriptorFactory.objectFromDescription(ObjectDescriptorFactory.java:82)
      2007-08-28 16:21:31,765 ERROR STDERR - at org.jboss.serial.objectmetamodel.DataContainer$DataContainerInput.readObject(DataContainer.java:845)
      2007-08-28 16:21:31,765 ERROR STDERR - at org.jboss.serial.persister.RegularObjectPersister.readSlotWithFields(RegularObjectPersister.java:353)
      2007-08-28 16:21:31,765 ERROR STDERR - at org.jboss.serial.persister.RegularObjectPersister.defaultRead(RegularObjectPersister.java:273)
      2007-08-28 16:21:31,765 ERROR STDERR - at org.jboss.serial.persister.RegularObjectPersister.readData(RegularObjectPersister.java:241)
      2007-08-28 16:21:31,765 ERROR STDERR - at org.jboss.serial.objectmetamodel.ObjectDescriptorFactory.readObjectDescriptionFromStreaming(ObjectDescriptorFactory.java:412)
      2007-08-28 16:21:31,765 ERROR STDERR - at org.jboss.serial.objectmetamodel.ObjectDescriptorFactory.objectFromDescription(ObjectDescriptorFactory.java:82)
      2007-08-28 16:21:31,765 ERROR STDERR - at org.jboss.serial.objectmetamodel.DataContainer$DataContainerInput.readObject(DataContainer.java:845)
      2007-08-28 16:21:31,765 ERROR STDERR - at org.jboss.serial.persister.ArrayPersister.readObjectArray(ArrayPersister.java:196)
      2007-08-28 16:21:31,765 ERROR STDERR - at org.jboss.serial.persister.ArrayPersister.readData(ArrayPersister.java:172)
      2007-08-28 16:21:31,765 ERROR STDERR - at org.jboss.serial.objectmetamodel.ObjectDescriptorFactory.readObjectDescriptionFromStreaming(ObjectDescriptorFactory.java:412)
      2007-08-28 16:21:31,765 ERROR STDERR - at org.jboss.serial.objectmetamodel.ObjectDescriptorFactory.objectFromDescription(ObjectDescriptorFactory.java:82)
      2007-08-28 16:21:31,765 ERROR STDERR - at org.jboss.serial.objectmetamodel.DataContainer$DataContainerInput.readObject(DataContainer.java:845)
      2007-08-28 16:21:31,765 ERROR STDERR - at org.jboss.serial.persister.RegularObjectPersister.readSlotWithFields(RegularObjectPersister.java:353)
      2007-08-28 16:21:31,765 ERROR STDERR - at org.jboss.serial.persister.RegularObjectPersister.defaultRead(RegularObjectPersister.java:273)
      2007-08-28 16:21:31,765 ERROR STDERR - at org.jboss.serial.persister.RegularObjectPersister.readData(RegularObjectPersister.java:241)
      2007-08-28 16:21:31,765 ERROR STDERR - at org.jboss.serial.objectmetamodel.ObjectDescriptorFactory.readObjectDescriptionFromStreaming(ObjectDescriptorFactory.java:412)
      2007-08-28 16:21:31,765 ERROR STDERR - at org.jboss.serial.objectmetamodel.ObjectDescriptorFactory.objectFromDescription(ObjectDescriptorFactory.java:82)
      2007-08-28 16:21:31,765 ERROR STDERR - at org.jboss.serial.objectmetamodel.DataContainer$DataContainerInput.readObject(DataContainer.java:845)
      2007-08-28 16:21:31,765 ERROR STDERR - at org.jboss.serial.persister.ObjectInputStreamProxy.readObjectOverride(ObjectInputStreamProxy.java:68)
      2007-08-28 16:21:31,765 ERROR STDERR - at java.io.ObjectInputStream.readObject(ObjectInputStream.java:342)
      2007-08-28 16:21:31,765 ERROR STDERR - at java.util.Hashtable.readObject(Hashtable.java:848)
      2007-08-28 16:21:31,765 ERROR STDERR - ... 38 more
      2007-08-28 16:21:31,765 ERROR STDERR - Caused by: java.lang.InstantiationException: org.apache.log4j.Logger
      2007-08-28 16:21:31,765 ERROR STDERR - at java.lang.Class.newInstance0(Class.java:335)
      2007-08-28 16:21:31,765 ERROR STDERR - at java.lang.Class.newInstance(Class.java:303)
      2007-08-28 16:21:31,765 ERROR STDERR - at org.jboss.serial.classmetamodel.ClassMetaData.newInstance(ClassMetaData.java:334)
      2007-08-28 16:21:31,765 ERROR STDERR - ... 68 more




      can anybody suggests any solution.

      I am using JBoss4.2.0 & JDK5.0.


      Thanks in advance.

        • 1. Re: Stateless Session Bean - java.lang.reflect.UndeclaredThr
          Carlo de Wolf Master

          You're trying to force an object over the line which has a reference to an org.apache.log4j.Logger instance, which is not serializable.

          • 2. Re: Stateless Session Bean - java.lang.reflect.UndeclaredThr
            S Ramarao Newbie

            Hi,
            Thanks for the early response.
            I am giving part of my code where the error is coming. Could you suggest me where may be error.


            Method in the Bean:


            public TabFactory getTabList(String corporateId) throws EccException {
            Connection conn = null;
            TabFactory tabFactory = null;
            logger = EkaLogger.getLogger(this.getClass().getName());
            try {
            logger.debug("came to tab list");
            conn = DbConnection.getConnection(true);
            tabFactory = new TabFactory(conn);
            tabFactory.initialize(corporateId);
            logger.debug("Successfully complted tablist initialization");
            }catch(Exception ex) {
            logger.debug("Exception in EccLoginBean - getTabList");
            throw new EccException(ex.getMessage(),2,ex);
            }finally{
            try {
            if(conn != null) {
            if(rs != null)
            rs.close();
            conn.close();
            logger.debug("Closed connection in EccLoginBean TabList");
            }
            } catch (Exception e) {
            logger.debug("Exception in EccLoginBean - getTabList-2");
            throw new EccException(e.getMessage(),2,e);
            }
            }
            logger.debug("Tabfactory is "+tabFactory);
            return tabFactory;
            }



            Calling part from servlet:

            TabFactory tabFactory = eccLogin.getTabList(strCorporateId);


            • 3. Re: Stateless Session Bean - java.lang.reflect.UndeclaredThr
              S Ramarao Newbie

              Hi All,
              My sincere thanks to Wolfc. He correctly pointed out the error.

              In my code TabFactory contain some other objects which are not serializable. When i made them serializable, it is working fine.
              If anybody faces similar error then plz check you objects returning from remote interface are serializable(including objects that object).


              Regards,