我是新手,学习ejb 3.0
MyFirstEjbApp
@Stateless
@RemoteBinding(jndiBinding="bean1")
public class MyFirstEjb implements MyFirstEjbRemote {
private Logger log = Logger.getLogger(MyFirstEjb.class);
public MyFirstEjb() {
// TODO Auto-generated constructor stub
}
@Override
public void doSomething() {
log.info("do something has been called");
}
@Override
public String getDescription() {
return "get description has returned some value";
}
}
EjbTestClient.java
public class EjbTestClient {
public static void main(String[] args) throws NamingException {
InitialContext context = new InitialContext();
System.out.println("context lookup finished");
MyFirstEjbRemote proxy = (MyFirstEjbRemote)(context.lookup("bean1"));
System.out.println(proxy.getClass().toString());
System.out.println(proxy.getDescription());
proxy.doSomething();
}
}
jndi.properties
java.naming.factory.initial=org.jnp.interfaces.NamingContextFactory
java.naming.factory.url.pkgs=org.jboss.naming.client
java.naming.factory.provider.url=localhost:1099
我认为防火墙可能是问题并禁用它但问题仍然存在。
context lookup finished
打印在控制台上,几秒钟后我收到一个错误: -
context lookup finished
Exception in thread "main" javax.naming.CommunicationException: Receive timed out
[Root exception is java.net.SocketTimeoutException: Receive timed out]
at org.jnp.interfaces.NamingContext.discoverServer(NamingContext.java:1690)
at org.jnp.interfaces.NamingContext.checkRef(NamingContext.java:1812)
at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:695)
at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:688)
at javax.naming.InitialContext.lookup(Unknown Source)
at EjbTestClient.main(EjbTestClient.java:13)
Caused by: java.net.SocketTimeoutException: Receive timed out
at java.net.TwoStacksPlainDatagramSocketImpl.receive0(Native Method)
at java.net.TwoStacksPlainDatagramSocketImpl.receive(Unknown Source)
at java.net.DatagramSocket.receive(Unknown Source)
at org.jnp.interfaces.NamingContext.discoverServer(NamingContext.java:1659)
... 5 more