ejb hanging

Discussions

EJB programming & troubleshooting: ejb hanging

  1. ejb hanging (5 messages)

    hi frirends,
    i have created a ejb and calling it through client program which is deployed with the ejb application. on running it on

    j2ee Application Server 8

    i get errors on the home interface

    the details: -

    the remote interface

    ------------------------------------------------
    import javax.ejb.EJBObject;
    import java.rmi.RemoteException;
    import java.math.*;
    public interface Converter extends EJBObject {
    public BigDecimal dollarToYen(BigDecimal dollars)
    throws RemoteException;
    public BigDecimal yenToEuro(BigDecimal yen)
    throws RemoteException;
    }

    -----------------------------------------------

    the home interface
    -----------------------------------------------
    import java.rmi.RemoteException;
    import javax.ejb.CreateException;
    import javax.ejb.EJBHome;
    public interface ConverterHome extends EJBHome {
    Converter create()throws RemoteException,CreateException;
    }
    --------------------------------------------

    the EJB class

    --------------------------------------------------
    import java.rmi.RemoteException;
    import javax.ejb.SessionBean;
    import javax.ejb.SessionContext;
    import java.math.*;
    public class ConverterBean implements SessionBean {
    BigDecimal yenRate =new BigDecimal("121.6000");
    BigDecimal euroRate =new BigDecimal("0.0077");
    public BigDecimal dollarToYen(BigDecimal dollars){
    BigDecimal result =dollars.multiply(yenRate);
    return result.setScale(2,BigDecimal.ROUND_UP);
    }
    public BigDecimal yenToEuro(BigDecimal yen){
    BigDecimal result =yen.multiply(euroRate);
    return result.setScale(2,BigDecimal.ROUND_UP);
    }
    public ConverterBean(){}
    public void ejbCreate(){}
    public void ejbRemove(){}
    public void ejbActivate(){}
    public void ejbPassivate(){}
    public void setSessionContext(SessionContext sc){}
    }
    --------------------------------------------------

    the client program

    ---------------------------------------------------

    import javax.naming.Context;
    import javax.naming.InitialContext;
    import javax.rmi.PortableRemoteObject;
    import java.math.BigDecimal;
    public class ConverterClient {
    public static void main(String [] args)){
    try {
    Context myEnv =
    (Context)initial.lookup("java:comp/env");
    Object objref =myEnv.lookup("ejb/SimpleConverter");
    ConverterHome home =
    (ConverterHome)PortableRemoteObject.narrow(objref,
    ConverterHome.class);
    Converter currencyConverter =home.create();
    BigDecimal param =new BigDecimal ("100.00");
    BigDecimal amount =
    currencyConverter.dollarToYen(param);
    System.out.println(amount);
    amount =currencyConverter.yenToEuro(param);
    System.out.println(amount);
    System.exit(0);
    }catch (Exception ex){
    System.err.println("Caught an unexpected exception!");
    ex.printStackTrace();
    }
    }
    }
    ---------------------------------------------------

    in the ejb reference tab in the deploytool

    Coded Name field -> ejb/SimpleConverter
    EJB Type field -> Session
    Interfaces field -> Remote
    Home Interface field -> converter.ConverterHome
    Local/Remote Interface field ->converter.Converter
    JNDI Name field -> ConverterBean
    -----------------------------------------------------

    on running the program
    Appclient –client ConverterAppClient.jar

    i get the error on the command line
    -----------------------------------------------------
    WARNING: ACC003: Application threw an exception.
    java.lang.NoClassDefFoundError: converter.ConverterHome
            at ConverterClient.class$(ConverterClient.java:46)
            at ConverterClient.main(ConverterClient.java:44)
            at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
            at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.
    java:39)
            at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces
    sorImpl.java:25)
            at java.lang.reflect.Method.invoke(Method.java:324)
            at com.sun.enterprise.util.Utility.invokeApplicationMain(Utility.java:28
    5)
            at com.sun.enterprise.appclient.Main.<init>(Main.java:420)
            at com.sun.enterprise.appclient.Main.main(Main.java:92)

    ----------------------------------------------------------------

    any help
    thanks
    Pradyut

    Threaded Messages (5)

  2. ejb hanging[ Go to top ]

    Pradyut -
    I didn't see a package def in your inferfaces. e.g.

    package converter;

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

    public interface Converter extends EJBObject {
    public BigDecimal dollarToYen(BigDecimal dollars)
    throws RemoteException;
    public BigDecimal yenToEuro(BigDecimal yen)
    throws RemoteException;
    }
  3. maybe[ Go to top ]

    did u include the home/remote interfaces in the client's jar ?
  4. maybe[ Go to top ]

    hi,

    giving the package converter in the files

    in the deploytool it is saying

    in j2ee 1.4 i have chosen the ejb class files in the new enterprise bean wizard but on clicking the next button in the ejb jar general settings it is giving the message
    the class (converter.Converter) could not be loaded:

    please consult online help for assisstance in setting up the class root directory and choosing class files.
    pls help

    thanks
    Pradyut
  5. Sure[ Go to top ]

    hi,giving the package converter in the filesin the deploytool it is saying in j2ee 1.4 i have chosen the ejb class files in the new enterprise bean wizard but on clicking the next button in the ejb jar general settings it is giving the message the class (converter.Converter) could not be loaded:please consult online help for assisstance in setting up the class root directory and choosing class files.pls helpthanksPradyut

    If U Have Installed Java Seperately And Have Installed The J2EE Server Platform,This Problem Will Come.Uninstall Java Which U Have Installed Seperately Because J2EE Server Has Its Own JDK In Its J2EE_HOME[Where J2EE Servetr Is Installed
    For Example c:\Sun\AppServer\...].After Removing Java,Set The Path For The JDK Which Resides In The Server Itself.
    Now Compile The Programs And Create The EnterpriseBean.Surely It Will Work.All The Best
  6. Hi,

    When you create New Application Client using deploytool, the J2EE tutorial will only ask you to add the client class file, but make sure you add the Remote interface Converter and Home interface, ConverterHome when you add contents. If it doesn't work with existing ear file, try recreating the .ear file from the start. As the deploytool doesn't very well update the ear file once it saves something to the ear file although you can see in deploytool.