EJB リモート呼び出しを試してみましたが、エラーが発生しました。というCallerApp
別の Web アプリのメソッドを呼び出す という Web アプリがありRecieverApp
ます。
CallerApp
私はリモートインターフェースを持っています:
@Remote
public interface ControllerRemote {
public int perform(int i);
}
呼び出しはこのクラスで実行されます。
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);
}
}
RecieverApp は、同じ Glassfish サーバーにデプロイされています。
@Stateless
public class Controller implements Serializable, ControllerRemote{
@Override
public int perform(int i){
//return something
}
}
RecieverApp のインターフェイスは、CallerApp のものとまったく同じです。
@Remote
public interface CallerRemote{
public int perform(int i);
}
次の例外が発生します。
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]]
ここで何が間違っていますか?
PS: 私は Glassfish 3.1 を使用しており、両方のアプリケーションが同じサーバーにデプロイされています。