3 Replies Latest reply on Dec 18, 2002 6:57 AM by Peter Korsten

    Stateless Local Home wanting create() method with no args

    Christopher Newbie

      We have deployed several beans and this stateless session bean is demanding that we create a method. The error when it is loading is the following

      Warning: Local home interface of a stateless session bean must have one create method that takes no arguments.

      There is a create() in the local home interface but this is not fixing the problem. There is also a ejbCreate() in the bean itself. Is this a bug ? using 3.0.4
      Thanks

        • 1. Re: Stateless Local Home wanting create() method with no arg
          Adrian Brock Master

          Code snippet, deployment descriptors?
          Or do we just take your assertion that you've done
          it correctly?

          Are you sure you have the correct class in the jar?

          Regards,
          Adrian

          • 2. Re: Stateless Local Home wanting create() method with no arg
            Christopher Newbie


            Payment History Stateless Session Bean
            <ejb-name>PaymentHistoryEJB</ejb-name>
            <local-home>com.acs.epay.components.paymenthistory.LocalPaymentHistoryHome</local-home>
            com.acs.epay.components.paymenthistory.LocalPaymentHistory
            <ejb-class>com.acs.epay.components.paymenthistory.PaymentHistoryEJB</ejb-class>
            <session-type>Stateless</session-type>
            <transaction-type>Container</transaction-type>


            local

            package com.acs.epay.components.paymenthistory;

            /**
            * @author H0041755
            *
            * To change this generated comment edit the template variable "typecomment":
            * Window>Preferences>Java>Templates.
            * To enable and disable the creation of type comments go to
            * Window>Preferences>Java>Code Generation.
            */

            import javax.ejb.EJBLocalObject;
            import java.rmi.RemoteException;

            public interface LocalPaymentHistory extends EJBLocalObject {
            public java.util.Vector getPaymentHistory();
            }

            home

            package com.acs.epay.components.paymenthistory;

            /**
            * @author H0041755
            *
            */

            import java.io.Serializable;
            import java.rmi.RemoteException;
            import javax.ejb.CreateException;
            import javax.ejb.EJBLocalHome;

            public interface LocalPaymentHistoryHome extends EJBLocalHome {

            LocalPaymentHistory create() throws CreateException;
            LocalPaymentHistory create(java.lang.String account) throws CreateException;

            }

            ejb

            package com.acs.epay.components.paymenthistory;

            /**
            * @author H0041755
            *
            * To change this generated comment edit the template variable "typecomment":
            * Window>Preferences>Java>Templates.
            * To enable and disable the creation of type comments go to
            * Window>Preferences>Java>Code Generation.
            */

            import javax.ejb.SessionBean;
            import java.sql.ResultSet;
            import java.sql.PreparedStatement;
            import java.sql.Connection;
            import javax.sql.DataSource;
            import java.sql.SQLException;

            import java.util.Vector;
            import javax.ejb.CreateException;
            import javax.ejb.SessionContext;

            import com.acs.epay.components.servicelocator.ejb.ServiceLocator;
            import com.acs.epay.components.servicelocator.ServiceLocatorException;

            import com.acs.epay.components.payment.PaymentVO;

            public class PaymentHistoryEJB implements SessionBean {

            private Vector Payments;
            private String AccountNumber;
            private SessionContext sc;
            private ServiceLocator serviceLocator;

            private static final String SQL = "SELECT PMTRNB, PMCOND, PMCHKD, PMAMNT, PMENID FROM PPPTRSM WHERE PMACCT = ? ORDER BY PMCOND DESC";

            public void ejbCreate() throws CreateException {}

            public void ejbCreate(String account)
            throws CreateException {

            if (account == null) {
            throw new CreateException("Null Account not allowed.");
            }
            else {
            AccountNumber = account;
            LoadPaymentHistory();
            }

            }

            public void LoadPaymentHistory() {

            try{

            Payments = new Vector();
            DataSource ds = serviceLocator.getDataSource("java:jdbc/DB2DS");

            Connection con = ds.getConnection();
            PreparedStatement ps = con.prepareCall(SQL);
            ps.setString(1,AccountNumber);
            ResultSet rs;

            rs = ps.executeQuery();

            while(rs.next()){
            Payments.add(new PaymentVO());
            }

            } catch(SQLException sqe) {

            } catch(ServiceLocatorException sle){

            }

            }

            public Vector getPaymentHistory() {
            return(Payments);
            }

            public PaymentHistoryEJB() {}
            public void ejbRemove() {}
            public void ejbActivate() {}
            public void ejbPassivate() {}
            public void setSessionContext(SessionContext sc) {
            this.sc = sc;
            }

            }

            • 3. Re: Stateless Local Home wanting create() method with no arg
              Peter Korsten Newbie

              You have to remove this create() method:

              LocalPaymentHistory create(java.lang.String account) throws CreateException;

              Since the bean is stateless, it doesn't remember client data. You could get a difference instance of the bean each time you call it. So you can't hand any client-specific data to the bean like the account name/number.

              A stateless session bean must have one and only one create() method, and that method must be paremeterless.

              - Peter