I am new to EJB and trying to develop an application to find sum of two numbers remotely.First,i created an interface and then the bean class and then the client.
The interface Adder.java
gets compiled but compiling the bean class AdderBean.java
gives the following error.
C:\Users\Asad\Desktop\EJB>javac AdderBean.java
AdderBean.java:8: error: cannot find symbol
class AdderBean implements Adder
^
symbol: class Adder
1 error
But i have declared the interface Adder.java
,then why it's giving this error.
Adder interface
import javax.ejb.Remote;
@Remote
public interface Adder
{
int add(int x,int y);
}
Bean Class Code
AdderBean.java
import javax.annotation.PostConstruct;
import javax.annotation.PreDestroy;
import javax.ejb.Stateless;
@Stateless(mappedName="myAdder")
class AdderBean implements Adder
{
@PostConstruct
public void init()
{
System.out.println("post create");
}
@PreDestroy
public void destroy()
{
System.out.println("destroy");
}
public int add(int x,int y)
{
return x+y;
}
}
There was problem with setting of classpath.Just before compiling these classes,i set the classpath to a jar file api.jar
which was present in some other folder.That's why JVM wasn't able to find my interface Adder.java
.Problem solved now.