Well I am using JBoss Plugin with Eclipse 3.2.
This is Client
****************************************
package com.npi.client;
import javax.naming.Context;
import javax.naming.InitialContext;
import javax.naming.NamingException;
import javax.rmi.PortableRemoteObject;
import com.npi.ejb.StatelessCalculator;
import com.npi.ejb.StatelessCalculatorBean;
public class CalculatorClient {
/**
* @param args
*/
public static void main(
String[] args) {
try {
Context context = new InitialContext();
Object ref = context.lookup("StatelessCalculatorBean/remote");
StatelessCalculator calc = (StatelessCalculator) PortableRemoteObject
.narrow(ref, StatelessCalculator.class);
System.out.println("On Addition " + calc.add(12.0, 13.2));
System.out.println("On Addition " + calc.subtract(13.0, 12.0));
System.out.println("On Addition " + calc.add(12.0, 12.0));
System.out.println("On Addition " + calc.add(12.0, 4.0));
} catch (NamingException e) {
Throwable t = new Throwable();
System.err.println(t.getCause());
e.printStackTrace();
}
}
}
******************************************************************
This is Remote Class
package com.npi.ejb;
import javax.ejb.Remote;
@Remote
public interface StatelessCalculator {
public double add(double x,double y);
public double subtract(double x,double y);
public double multiply(double x,double y);
public double divide(double x,double y);
}
****************************************
This is my Bean Class
***********************************************************
package com.npi.ejb;
import javax.ejb.Stateless;
import com.npi.ejb.StatelessCalculator;
public @Stateless class StatelessCalculatorBean implements StatelessCalculator {
public double add(double x, double y) {
return (x+y);
}
public double divide(double x, double y) {
return (x-y);
}
public double multiply(double x, double y) {
return (x*y);
}
public double subtract(double x, double y) {
if(y ==0.0)
{
throw new javax.ejb.EJBException("Number Divided By Zero");
}
return (x/y);
}
}
********************************************
I am really in big trouble since last 20 days
If by tommorrow i could not run it i will leave EJB 3.0
Thanks for your early response