环境:
JBoss4.2GA
JBoss IED
写有下面简单的stateless session bean:
======Remote 接口=========
public interface Hello {
public void hello();
}
=======Bean 类===========
import javax.ejb.Remote;
import javax.ejb.Stateless;
@Stateless
@Remote(Hello.class)
public class HelloBean implements Hello{
public void hello(){
System.out.println("hello()");
}
}
======测试代码================
public class Client {
public static void main(String args[]){
Properties props = new Properties();
props.setProperty("java.naming.factory.initial", "org.jnp.interfaces.NamingContextFactory");
props.setProperty("java.naming.provider.url", "localhost:1099");
props.setProperty("java.naming.factory.url.pkgs", "org.jboss.naming");
InitialContext ctx;
try {
ctx = new InitialContext(props);
Hello hello = (Hello) ctx.lookup("HelloBean/remote");
hello.hello();
} catch (NamingException e) {
e.printStackTrace();
}
}
}
==================================
将jar包部署到JBoss下后,用Jsp页面测试,正常;但是,在Eclipse中运行上面的Client.java时出现异常,如下:
Exception in thread "main" java.lang.reflect.UndeclaredThrowableException
at $Proxy0.hello(Unknown Source)
at org.nj.helloworld.Client.main(Client.java:19)
Caused by: java.lang.Exception: Can not make remoting client invocation due to not being connected to server.
at org.jboss.remoting.Client.invoke(Client.java:1555)
at org.jboss.remoting.Client.invoke(Client.java:530)
at org.jboss.aspects.remoting.InvokeRemoteInterceptor.invoke(InvokeRemoteInterceptor.java:41)
at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:88)
at org.jboss.aspects.tx.ClientTxPropagationInterceptor.invoke(ClientTxPropagationInterceptor.java:46)
at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:88)
at org.jboss.aspects.security.SecurityClientInterceptor.invoke(SecurityClientInterceptor.java:40)
at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:88)
at org.jboss.ejb3.remoting.IsLocalInterceptor.invoke(IsLocalInterceptor.java:72)
at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:88)
at org.jboss.ejb3.stateless.StatelessRemoteProxy.invoke(StatelessRemoteProxy.java:103)
... 2 more
=========================
请问这是什么原因啊?