4 Replies Latest reply on Jun 25, 2004 5:36 AM by Darran Lofthouse

    please help urgent!  Exception occurred when a method of a r

    Leung Kam Lung Newbie

      Hello,

      Any help or suggestion is greatly appreciated.
      I have a remote interface called UserControllerRemoteHome that contains a method named validateUserPassword that return a java Serializable object. The client is a Servlet that deployed in a standalone Tomcat version 4.1.30. The Tomcat is running in the same server as Jboss 3.2.1. The servlet accesses the remote ejb with the following code:

       UserControllerRemoteHome homeObject;
       String remoteJndiName = "UserControllerBeanJNDI";
       homeObject = (UserControllerRemoteHome) homesFactory.lookUpHome(remoteJndiName, UserControllerRemoteHome.class);
       // get the EJBObject, UserControllerRemote
       UserControllerRemote ejbObject = homeObject.create();
      
      // Now problem so far up to this point, but an Exception occurred when
      // the validateUserPassword method returned a java serializable object BasicUserInformationDO,
      // however; when the validateUserPassword returned null then no exception occurred.
      // The log file producted by jboss server.log does not show any exception at all
       BasicUserInformationDO basicUserInfoDO = null;
       try {
       basicUserInfoDO = (BasicUserInformationDO)
       ejbObject.validateUserPassword( Integer.parseInt(userID),
       Short.parseShort(subID),
       password, sessionID);
       } catch (IOException ioEx) {
       request.getSession().getServletContext().log("IOException",
       new Throwable(ioEx.toString()));
       } catch (ServletException servletEx) {
       request.getSession().getServletContext().log("Servlet Exception",
       new Throwable(servletEx.toString()));
       }
       } catch (RemoteException remoteEx) {
       request.getSession().getServletContext().log("Remote Exception",
       new Throwable(remoteEx.toString()));
       } catch (CreateException createEx) {
       request.getSession().getServletContext().log("create Exception",
       new Throwable(createEx.toString()));
       } catch (IOException ioEx) {
       request.getSession().getServletContext().log("IOException",
       new Throwable(ioEx.toString()));
       } catch (Exception Ex) {
       request.getSession().getServletContext().log("Exception",
       new Throwable(Ex.toString()));
       }

      ****** Here is the method that returns the serializable object ********

      public BasicUserInformationDO validateUserPassword(int userID, short subID,
       String password, String sessioID)
       {
      
       BasicUserInformationDO basicUserInfoDO = null;
       // To valid the password we need to access the UserBean (ejb-name). However, we also
       // to return the BasicUserInformationDO object, thus we need to access the
       // UserAccountBean (ejb-name). So we need toltal of two references to fulfill this
       // mission.
       // Get a UserBean's home object from the EJBLocalHomeFactory
       try {
       // get an instance of the UserEjbUtil
       UserEjbUtil userBeanUtil = UserEjbUtil.getInstance();
      
       // get the EJBObject, UserLocal
       UserLocal userObject = userBeanUtil.getUser(StringUtilities.getPrimaryKey(userID, subID));
      
       if (userObject != null) {
       // Now we check the password from the user input against the password from the database
      
       // get the EJBObject, UserAccountLocal
       UserAccountEjbUtil userAccountBeanUtil = UserAccountEjbUtil.getInstance();
      
       UserAccountLocal userAccountObject = userAccountBeanUtil.getUserAccount(
       StringUtilities.getPrimaryKey(userID, subID));
      
       if (userAccountObject != null) {
       // Now get the serviceTypesSubscribed and numberOfServicesSubscribed from the UserAccountBean
       basicUserInfoDO = new BasicUserInformationDO(userObject.getFirstName(), userObject.getLastName(),
      
       userObject.getMiddleName(), userID, subID,
       userAccountObject.getNumberOfServicesSubscribed(),
       userAccountObject.getServiceTypesSubscribed());
       if (log.isDebugEnabled()) {
       log.debug(basicUserInfoDO.toString());
       }
       }//End if userAccountObject
       }//End if
       }//End if userObject
       } catch (IOException ioEx) {
       log.debug("IOException" + ExPrintingUtilities.PrintStackTraceElements(ioEx.getStackTrace()));
       } catch (Exception Ex) {
       log.debug("Exception" + ExPrintingUtilities.PrintStackTraceElements(Ex.getStackTrace()));
       } catch (Throwable throwableEx) {
       log.debug("Throwable" + ExPrintingUtilities.PrintStackTraceElements(throwableEx.getStackTrace()));
       }
      
       if (log.isDebugEnabled()) {
       log.debug("End validateUserPassword");
       }
       return basicUserInfoDO;
       } /* End validateUserPassword method */


      Thank you in advance for your help.

      Kam

        • 1. Re: please help urgent!  Exception occurred when a method of
          Darran Lofthouse Master

          1 - Your problem is not urgent here, if you consider it so urgent that we need to be told about it pay for support.

          2 - Your method returns a 'BasicUserInformationDO' why do you need to cast it?

          3 - What are the exceptions and stack traces?

          4 - Are all of the fields contained within the 'BasicUserInformationDO' also Serializable?

          • 2. Re: please help urgent!  Exception occurred when a method of
            Leung Kam Lung Newbie

            Hi Darranl,

            Thank for your reply and sorry for the term argent. It just that I look at the problem for two days and not able to find the solution for it. Anyway,
            about the casting of the return type to BasicUserInformationDO. I try without casting first and have the same problem so I decided to try casting it so that I know that I have the right object.

            Below is the declaration of the BasicUserInformationDO class:

            public class BasicUserInformationDO implements java.io.Serializable
            {
             /* private attributes */
            
             private String userFirstName;
             private String userLastName;
             private String userMiddleName;
             private int userID;
             private short subID;
             private int serviceTypesSubscribed;
             private byte numberOfServicesSubscribed;
            
             ...
            
             public BasicUserInformationDO() {}
            
             public BasicUserInformationDO(String firstName, String lastName,
             String middleName, int userID, short subID,
             byte numberOfServicesSubscribed,
             int serviceTypesSubscribed)
             {
            
             subLog.debug("Starting of BasicUserInformationDO");
             this.userFirstName = firstName;
             this.userLastName = lastName;
             this.userMiddleName = middleName;
             this.userID = userID;
             this.subID = subID;
             this.numberOfServicesSubscribed = numberOfServicesSubscribed;
             this.serviceTypesSubscribed = serviceTypesSubscribed;
             subLog.debug("End of BasicUserInformationDO");
             } /* end of constructor */
            
            }


            ********* Here is the exception stack traces in Tomcat ***********
            INFO [http8091-Processor7] (AccessController.java:100) - Begin doPost
            INFO [http8091-Processor7] (AccessController.java:115) - User I D is : 6
            INFO [http8091-Processor7] (AccessController.java:116) - Sub I D is : 1
            INFO [http8091-Processor7] (AccessController.java:117) - Password is : 01234567
            DEBUG [http8091-Processor7] (EnvEntriesFactory.java:52) - Begin lookUpEnvEntries
            DEBUG [http8091-Processor7] (EnvEntriesFactory.java:53) - EnvEntries : com.wlwa.alert.AppServerIPAddr1
            DEBUG [http8091-Processor7] (EnvEntriesFactory.java:69) - End lookUpEnvEntries
            DEBUG [http8091-Processor7] (EnvEntriesFactory.java:52) - Begin lookUpEnvEntries
            DEBUG [http8091-Processor7] (EnvEntriesFactory.java:53) - EnvEntries : com.wlwa.alert.AppServerIPAddr1PortNumber
            DEBUG [http8091-Processor7] (EnvEntriesFactory.java:69) - End lookUpEnvEntries
            DEBUG [http8091-Processor7] (EnvEntriesFactory.java:52) - Begin lookUpEnvEntries
            DEBUG [http8091-Processor7] (EnvEntriesFactory.java:53) - EnvEntries : com.wlwa.alert.urlPackagePrefixes
            DEBUG [http8091-Processor7] (EnvEntriesFactory.java:69) - End lookUpEnvEntries
            DEBUG [http8091-Processor7] (EnvEntriesFactory.java:52) - Begin lookUpEnvEntries
            DEBUG [http8091-Processor7] (EnvEntriesFactory.java:53) - EnvEntries : com.wlwa.alert.initialContextFactory
            DEBUG [http8091-Processor7] (EnvEntriesFactory.java:69) - End lookUpEnvEntries
            DEBUG [http8091-Processor7] (EJBHomeRemoteFactory.java:107) - Begin Remote lookUpHome
            DEBUG [http8091-Processor7] (EJBHomeRemoteFactory.java:160) - End Remote lookUpHome
            DEBUG [http8091-Processor7] (ExceptionPrintingUtilities.java:29) - Begin PrintStackTraceElements
            DEBUG [http8091-Processor7] (ExceptionPrintingUtilities.java:41) - End PrintStackTraceElements
            FATAL [http8091-Processor7] (AccessController.java:180) -
            $Proxy1.validateUserPassword(Unknown Source)
            com.wlwa.Alert.VoiceComponentTier.Dispatcher.AccessController.doPost(AccessController.java:141)
            javax.servlet.http.HttpServlet.service(HttpServlet.java:760)
            javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
            org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:247)
            org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:193)
            org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:256)
            org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
            org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
            org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
            org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
            org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
            org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
            org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
            org.apache.catalina.core.StandardContext.invoke(StandardContext.java:2422)
            org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:180)
            org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
            org.apache.catalina.valves.ErrorDispatcherValve.invoke(ErrorDispatcherValve.java:171)
            org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:641)
            org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:163)
            org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:641)
            org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
            org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
            org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:174)
            org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
            org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
            org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
            org.apache.coyote.tomcat4.CoyoteAdapter.service(CoyoteAdapter.java:199)
            org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:828)
            org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:700)
            org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java:584)
            org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:683)
            java.lang.Thread.run(Thread.java:534)
            INFO [http8091-Processor7] (AccessController.java:200) - End doPost


            **** Here is debug log in Jbosss which indicates no exception was thrown ***

            DEBUG [UserControllerEJB] Begin ejbCreate
            DEBUG [UserControllerEJB] End of ejbCreate com.wlwa.alert.database.jndi is set to : jdbc/AlertDB
            DEBUG [UserControllerEJB] Begin validateUserPassword
            DEBUG [UserEjbUtil] Begin getUser
            DEBUG [AbstractENCFactory] Begin lookUpEnvEntries
            DEBUG [AbstractENCFactory] EnvEntries : com.wlwa.alert.AppServerIPAddr1
            DEBUG [AbstractENCFactory] End lookUpEnvEntries
            DEBUG [AbstractENCFactory] Begin lookUpEnvEntries
            DEBUG [AbstractENCFactory] EnvEntries : com.wlwa.alert.AppServerIPAddr1PortNumber
            DEBUG [AbstractENCFactory] End lookUpEnvEntries
            DEBUG [AbstractENCFactory] Begin lookUpEnvEntries
            DEBUG [AbstractENCFactory] EnvEntries : com.wlwa.alert.urlPackagePrefixes
            DEBUG [AbstractENCFactory] End lookUpEnvEntries
            DEBUG [AbstractENCFactory] Begin lookUpEnvEntries
            DEBUG [AbstractENCFactory] EnvEntries : com.wlwa.alert.initialContextFactory
            DEBUG [AbstractENCFactory] End lookUpEnvEntries
            DEBUG [AbstractEJBHomeFactory] Begin Local lookUpHome
            DEBUG [AbstractEJBHomeFactory] End Local lookUpHome
            DEBUG [org.jboss.ejb.plugins.cmp.jdbc.JDBCFindByPrimaryKeyQuery.UserBean.findByPrimaryKey] Executing SQL: SELECT primaryKey FROM User WHERE primaryKey=?
            DEBUG [UserEjbUtil] End getUser
            DEBUG [org.jboss.ejb.plugins.cmp.jdbc.JDBCLoadEntityCommand.UserBean] Executing SQL: SELECT accountType, dateOfBirth, iD, subID, lastName, middleName, firstName, password, sSN, emailAddress, creditCardFK FROM User WHERE (primaryKey=?)
            DEBUG [UserAccountEjbUtil] Begin getUserAccount
            DEBUG [AbstractEJBHomeFactory] Begin Local lookUpHome
            DEBUG [AbstractEJBHomeFactory] End Local lookUpHome
            DEBUG [org.jboss.ejb.plugins.cmp.jdbc.JDBCFindByPrimaryKeyQuery.UserAccountBean.findByPrimaryKey] Executing SQL: SELECT primaryKey FROM Account WHERE primaryKey=?
            DEBUG [UserAccountEjbUtil] End getUserAccount
            DEBUG [org.jboss.ejb.plugins.cmp.jdbc.JDBCLoadEntityCommand.UserAccountBean] Executing SQL: SELECT beginDay, beginMonth, beginYear, endDay, endMonth, endYear, numberOfServicesSubscribed, serviceTypesSubscribed, status, type FROM Account WHERE (primaryKey=?)
            DEBUG [root] Starting of BasicUserInformationDO
            DEBUG [root] End of BasicUserInformationDO
            DEBUG [UserControllerEJB] User First Name: Jessica, User Last Name: Leung, User Middle Name: jesses, User ID: 6, Sub ID: 1, Service Type Subscribed: 1, Number of Services Subscribed: 1
            DEBUG [UserControllerEJB] End validateUserPassword






            • 3. Solved : Re:please help urgent!  Exception occurred when a m
              Leung Kam Lung Newbie

              Hi Darranl,

              It turns out the Logger object from log4j is not serializable that caused exception at the client side. My question is that why Jboss did not complain about this at all.

              Thank,
              Kam

              • 4. Re: please help urgent!  Exception occurred when a method of
                Darran Lofthouse Master

                Looking at your code I think you are actually hiding the information in the exceptions that are being thrown, there will probably be a nested NotSerializableException somewhere in there that would have told you the problem.

                As soon as I replied to your post I pointed you in the direction of the actual problem, for some reason when you posted the code of your data object you missed some of the fields out. Making assumptions that certain references in your DO didn't matter has also slowed down resolving your problem.

                Unfortunately I think this is just a lesson learnt the hard way rather than a problem with JBoss.