Logo 
Search:

Java Forum

Ask Question   UnAnswered
Home » Forum » Java       RSS Feeds

ejb hanging

  Asked By: Meenachi    Date: Oct 01    Category: Java    Views: 438
  

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)

Share: 



Tagged: