我正在尝试使用EJB远程调用,但是我收到了一个错误.我有一个名为的Web应用程序调用CallerApp另一个名为的Web应用程序中的方法RecieverApp.
在CallerApp我有一个远程接口:
@Remote
public interface ControllerRemote {
public int perform(int i);
}
Run Code Online (Sandbox Code Playgroud)
并且在此课程中执行调用:
public class Talker {
@EJB private ControllerRemote remote;
//constructor and invoke setRemote() method to set remote
private void setRemote() throws Exception{
Properties p = new Properties();
Context jndiContext = new InitialContext(p);
Object ref = jndiContext.lookup("java:global/RecieverApp/Controller!bean.ControllerRemote");
remote = (ControllerRemote) PortableRemoteObject.narrow(ref, ControllerRemote.class);
}
public void action(){
remote.perform(5);
}
}
Run Code Online (Sandbox Code Playgroud)
RecieverApp在同一个Glassfish服务器上被拆除:
@Stateless
public class Controller implements Serializable, ControllerRemote{
@Override
public int perform(int i){
//return something
}
}
Run Code Online (Sandbox Code Playgroud)
RecieverApp中的界面与CallerApp中的界面完全相同:
@Remote
public interface CallerRemote{
public int perform(int i);
}
Run Code Online (Sandbox Code Playgroud)
我收到以下异常:
SEVERE: javax.naming.NamingException: Lookup failed for 'java:global/RecieverApp/Controller!bean.ControllerRemote'
in SerialContext[myEnv={java.naming.factory.initial=com.sun.enterprise.naming.impl.SerialInitContextFactory,
java.naming.factory.state=com.sun.corba.ee.impl.presentation.rmi.JNDIStateFactoryImpl,
java.naming.factory.url.pkgs=com.sun.enterprise.naming}
[Root exception is javax.naming.NamingException: ejb ref resolution error for remote business interfacebean.ControllerRemote
[Root exception is java.lang.ClassNotFoundException: bean.ControllerRemote]]
Run Code Online (Sandbox Code Playgroud)
我在这里做错了什么?
PS:我正在使用Glassfish 3.1,两个应用程序都部署在同一台服务器上.
| 归档时间: |
|
| 查看次数: |
3798 次 |
| 最近记录: |