2010-03-14 39 views
5

我有以下錯誤JBoss的EJB的Bean未綁定

Exception in thread "main" javax.naming.NameNotFoundException: CounterBean not bound 

試圖訪問從應用服務器以外的客戶端應用程序部署在JBoss5上的EJB JAR CounterBean.jar。

從Jboss日誌看來,它看起來沒有全局JNDI名稱?這個可以嗎? 我做錯了什麼?

JBoss的日誌:

13:50:39,669 INFO [JBossASKernel] Created KernelDeployment for: Counter.jar 
13:50:39,672 INFO [JBossASKernel] installing bean: jboss.j2ee:jar=Counter.jar,name=CounterBean,service=EJB3 
13:50:39,672 INFO [JBossASKernel] with dependencies: 
13:50:39,672 INFO [JBossASKernel] and demands: 
13:50:39,673 INFO [JBossASKernel]  partition:partitionName=DefaultPartition; Required: Described 
13:50:39,673 INFO [JBossASKernel]  jboss.ejb:service=EJBTimerService; Required: Described 
13:50:39,673 INFO [JBossASKernel] and supplies: 
13:50:39,673 INFO [JBossASKernel]  jndi:CounterBean 
13:50:39,673 INFO [JBossASKernel] Added bean(jboss.j2ee:jar=Counter.jar,name=CounterBean,service=EJB3) to KernelDeployment of: Counter.jar 
13:50:39,712 INFO [SessionSpecContainer] Starting jboss.j2ee:jar=Counter.jar,name=CounterBean,service=EJB3 
13:50:39,727 INFO [EJBContainer] STARTED EJB: com.don.CounterBean ejbName: CounterBean 
13:50:39,732 INFO [JndiSessionRegistrarBase] Binding the following Entries in Global JNDI: 

的客戶端代碼:

public static void main(String[] args) throws NamingException, InterruptedException { 
    InitialContext ctx = new InitialContext(); 
    Counter s = (Counter)ctx.lookup("CounterBean/remote"); 
    for(int i = 0; i < 100; i++) { 
     s.printCount(i); 
     Thread.sleep(1000); 
    } 
} 

錯誤消息:

java -Djava.naming.provider.url=jnp://123.123.123.123:1099 -Djava.naming.factory.initial=org.jnp.interfaces.NamingContextFactory com.don.Client 

Exception in thread "main" javax.naming.NameNotFoundException: CounterBean not bound 
    at org.jnp.server.NamingServer.getBinding(NamingServer.java:771) 
    at org.jnp.server.NamingServer.getBinding(NamingServer.java:779) 
    at org.jnp.server.NamingServer.getObject(NamingServer.java:785) 
    at org.jnp.server.NamingServer.lookup(NamingServer.java:396) 
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) 
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) 
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) 
    at java.lang.reflect.Method.invoke(Method.java:597) 
    at sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:305) 
    at sun.rmi.transport.Transport$1.run(Transport.java:159) 
    at java.security.AccessController.doPrivileged(Native Method) 
    at sun.rmi.transport.Transport.serviceCall(Transport.java:155) 
    at sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:535) 
    at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run0(TCPTransport.java:790) 
    at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:649) 
    at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886) 
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908) 
    at java.lang.Thread.run(Thread.java:619) 
    at sun.rmi.transport.StreamRemoteCall.exceptionReceivedFromServer(StreamRemoteCall.java:255) 
    at sun.rmi.transport.StreamRemoteCall.executeCall(StreamRemoteCall.java:233) 
    at sun.rmi.server.UnicastRef.invoke(UnicastRef.java:142) 
    at org.jnp.server.NamingServer_Stub.lookup(Unknown Source) 
    at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:726) 
    at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:686) 
    at javax.naming.InitialContext.lookup(InitialContext.java:392) 
     at com.don.Client.main(Client.java:10) 

回答

6

這是當我部署一個簡單的無狀態會話Bean(我得到什麼SLSB)和JBoss 5.x上的遠程接口:

01:52:07,313 INFO [JBossASKernel] Created KernelDeployment for: sandbox-services-1.0-SNAPSHOT.jar 
01:52:07,313 INFO [JBossASKernel] installing bean: jboss.j2ee:jar=sandbox-services-1.0-SNAPSHOT.jar,name=EchoBean,service=EJB3 
01:52:07,314 INFO [JBossASKernel] with dependencies: 
01:52:07,314 INFO [JBossASKernel] and demands: 
01:52:07,314 INFO [JBossASKernel] jboss.ejb:service=EJBTimerService 
01:52:07,314 INFO [JBossASKernel] and supplies: 
01:52:07,314 INFO [JBossASKernel] Class:com.stackoverflow.q2440956.samples.services.hello.Echo 
01:52:07,314 INFO [JBossASKernel] jndi:EchoBean/remote-com.stackoverflow.q2440956.samples.services.hello.Echo 
01:52:07,314 INFO [JBossASKernel] jndi:EchoBean/remote 
01:52:07,314 INFO [JBossASKernel] Added bean(jboss.j2ee:jar=sandbox-services-1.0-SNAPSHOT.jar,name=EchoBean,service=EJB3) to KernelDeployment of: sandbox-services-1.0-SNAPSHOT.jar 
01:52:07,315 INFO [EJB3EndpointDeployer] Deploy [email protected]{name=jboss.j2ee:jar=sandbox-services-1.0-SNAPSHOT.jar,name=EchoBean,service=EJB3_endpoint bean=org.jboss.ejb3.endpoint.deployers.impl.EndpointImpl properties=[container] constructor=null autowireCandidate=true} 
01:52:07,381 INFO [SessionSpecContainer] Starting jboss.j2ee:jar=sandbox-services-1.0-SNAPSHOT.jar,name=EchoBean,service=EJB3 
01:52:07,382 INFO [EJBContainer] STARTED EJB: com.stackoverflow.q2440956.samples.services.hello.EchoBean ejbName: EchoBean 
01:52:07,412 INFO [JndiSessionRegistrarBase] Binding the following Entries in Global JNDI: 

    EchoBean/remote - EJB3.x Default Remote Business Interface 
    EchoBean/remote-com.stackoverflow.q2440956.samples.services.hello.Echo - EJB3.x Remote Business Interface 

當我查看您提供的跟蹤時,我看不到任何與遠程接口(遠程調用需要)相關的任何內容,因此沒有JNDI名稱。所以問題是:您的SLSB是否正確定義和實施遠程接口?

就我而言,我的豆的定義是這樣的:

@Stateless 
public class EchoBean implements Echo { 
    ... 
} 

和遠程接口的樣子:

@Remote 
public interface Echo { 
    String echo(final String in); 
} 

你有類似的東西?

+0

感謝Pascal,出於某種原因,我遺漏了「在我的ejb bean中實現Echo」,這就是爲什麼沒有遠程接口被限制的原因。 – portoalet