EJB-J2EE-Unable to deploy application

Discussions

EJB programming & troubleshooting: EJB-J2EE-Unable to deploy application

  1. EJB-J2EE-Unable to deploy application (3 messages)

    This is my very first venture into EJB and I am stuck. I am unable to deploy the application in j2ee . The java files and error messages are as under:

    Can anyone help find a solution.

    I am using j2sdkee1.3.1 and j2sdk1.4.0

     CLASSPATH=.;d:\j2sdkee1.3.1\lib\j2ee.jar;D:\forte_jdk\j2sdk1.4.0\lib\tools.jar;d:\myjava

    Path=C:\WINDOWS;C:\WINDOWS\command;c:;d:\j2sdkee1.3.1\bin;C:\WINDOWS\system32;C:\WINDOWS\system32\WBEM;C:\Program Files\Common Files\Adaptec

    J2EE_HOME=d:\j2sdkee1.3.1

    JAVA_HOME=D:\forte_jdk\j2sdk1.4.0

    ************calculatorHome**********

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

    public interface calculatorHome extends EJBHome
    {
    calculator create() throws RemoteException, CreateException;
    }

    ************calculator***************

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

    public interface calculator extends EJBObject
    {
    public double dollorToRs (double dollars) throws RemoteException;
    }

    **********calculatorEJB***********************

    import java.rmi.RemoteException;
    import javax.ejb.SessionBean;
    import javax.ejb.SessionContext;

    public class calculatorEJB implements SessionBean
    {
    public double dollarToRs (double dollars)
    {
    return dollars * 48.15;
    }
    public calculatorEJB() {}
    public void ejbCreate() {}
    public void ejbRemove() {}
    public void ejbActivate() {}
    public void ejbPassivate() {}
    public void setSessionContext (SessionContext sc) {}
    }

    ***********************************descriptor*************
    <?xml version="1.0" encoding="UTF-8"?>

    <!DOCTYPE ejb-jar PUBLIC '-//Sun Microsystems, Inc.//DTD Enterprise JavaBeans 2.0//EN' 'http://java.sun.com/dtd/ejb-jar_2_0.dtd'>

    <ejb-jar>
      <display-name>newcalculatorjar</display-name>
      <enterprise-beans>
        <session>
          <display-name>calculatorEJB</display-name>
          <ejb-name>calculatorEJB</ejb-name>
          <home>calculatorHome</home>
          <remote>calculator</remote>
          <ejb-class>calculatorEJB</ejb-class>
          <session-type>Stateless</session-type>
          <transaction-type>Bean</transaction-type>
          <security-identity>
            <description></description>
            <use-caller-identity></use-caller-identity>
          </security-identity>
        </session>
      </enterprise-beans>
    </ejb-jar>

    ***************************error message*****

    <?xml version="1.0" encoding="UTF-8"?>

    <!DOCTYPE ejb-jar PUBLIC '-//Sun Microsystems, Inc.//DTD Enterprise JavaBeans 2.0//EN' 'http://java.sun.com/dtd/ejb-jar_2_0.dtd'>

    <ejb-jar>
      <display-name>newcalculatorjar</display-name>
      <enterprise-beans>
        <session>
          <display-name>calculatorEJB</display-name>
          <ejb-name>calculatorEJB</ejb-name>
          <home>calculatorHome</home>
          <remote>calculator</remote>
          <ejb-class>calculatorEJB</ejb-class>
          <session-type>Stateless</session-type>
          <transaction-type>Bean</transaction-type>
          <security-identity>
            <description></description>
            <use-caller-identity></use-caller-identity>
          </security-identity>
        </session>
      </enterprise-beans>
    </ejb-jar>



    ---------------------------
            STATIC VERIFICATION RESULTS
    ---------------------------


    ----------------------------------
    NUMBER OF FAILURES/WARNINGS/ERRORS
    ----------------------------------

    # of Failures : 3
            # of Warnings : 0
    # of Errors : 0
            
    -----------------------------
    RESULTS FOR EJB-RELATED TESTS
    -----------------------------

            

    --------------
    FAILED TESTS :
    --------------


    Test Name : tests.ejb.intf.remoteintf.RemoteInterfaceMatchMethodArgs
    Test Assertion : Remote interface business methods have matching method arguments test
    Test Description : For [ calculatorEJB ]
    For Remote Interface [ calculator ] method [ dollorToRs ]
    Error: No corresponding business method with matching arguments was found for method [ dollorToRs ].


    Test Name : tests.ejb.intf.remoteintf.RemoteInterfaceMatchMethodException
    Test Assertion : Remote interface business methods have matching method exceptions test
    Test Description : For Remote Interface [ calculator ] method [ dollorToRs ]
    Error: No corresponding business method with matching exceptions was found for method [ dollorToRs ].


    Test Name : tests.ejb.intf.remoteintf.RemoteInterfaceMatchMethodReturn
    Test Assertion : Remote interface business methods have matching method return type test
    Test Description : For [ calculatorEJB ]
    For Remote Interface [ calculator ] method [ dollorToRs ]
    Error: No corresponding business method with matching return type was found for method [ dollorToRs ].

    Thanks in advance
  2. There is typo in your calculatorEJB class.
    The remote interface calculator contains method
    a method
              public double dollorToRs (double dollars)...
                                ^
    which should read dollarToRs because your EJB class
    defines a method public double dollarToRs (double dollars)
                                       ^

    public class calculatorEJB implements SessionBean
    {
    public double dollarToRs (double dollars)
    {
    return dollars * 48.15;
    }

    All the best
  3. Thanks a lot. Now it works.
  4. Hand coding the Home and Remote interfaces is good for getting an initial feel for EJBs but error prone, as shown in your example. When you feel you know enough of what's going on behind the scenes, try XDocLet, it does get you out of a lot of trouble.