如何解决此异常???我错过了任何罐子吗? 当我查看Jboss jmx-console时,“santosh”不可用。
EJBTest.java
它包含EJB远程接口及其实现
package com.ramco.santosh.EJB;
import javax.ejb.Stateless;
import org.jboss.annotation.ejb.*;
@Stateless
@RemoteBinding(jndiBinding="santosh")
public class EJBTest implements EJBTestRemote {
public EJBTest(){}
public void doHello()
{
System.out.println("Hello Mr.Santosh");
}
}
主要
它是通过EJBTestRemote接口访问EJBTest.java的客户端。
import java.util.*;
import javax.naming.*;
import com.ramco.santosh.EJB.*;
public class Main {
public static void main(String[] args) throws NamingException
{
Hashtable hashtable = new Hashtable();
hashtable.put("java.naming.factory.initial","org.jnp.interfaces.NamingContextFactory");
hashtable.put("java.naming.provider.url","jnp://localhost:1099");
hashtable.put("java.naming.factory.url.pkgs","org.jboss.naming:org.jnp.interfaces");
InitialContext context = new InitialContext(hashtable);
Object h=context.lookup("santosh");
EJBTestRemote remote=(EJBTestRemote)h;
remote.doHello();
}
}
Exception in thread "main" javax.naming.NameNotFoundException: santosh not bound
at org.jnp.server.NamingServer.getBinding(NamingServer.java:529)
at org.jnp.server.NamingServer.getBinding(NamingServer.java:537)
at org.jnp.server.NamingServer.getObject(NamingServer.java:543)
at org.jnp.server.NamingServer.lookup(NamingServer.java:296)
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:662)
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:667)
at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:627)
at javax.naming.InitialContext.lookup(InitialContext.java:392)
at Main.main(Main.java:27)
答案 0 :(得分:0)
我的意思是改变这一行
Object h=context.lookup("santosh");
到
Object h=context.lookup("java:santosh");
让我知道这是否有效
答案 1 :(得分:0)
我解决了
的问题Exception in thread "main" javax.naming.NameNotFoundException: santosh not bound
Jboss服务器缺少ejb3-persistence.jar文件。添加EJB应用程序后运行良好。