0

如何解决这个异常???我错过了任何罐子吗?当我查看 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)
4

2 回答 2

0

我解决了问题

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

Jboss 服务器缺少 ejb3-persistence.jar 文件。添加 EJB 应用程序后运行良好。

于 2012-05-18T07:01:45.137 回答
0

我的意思是改变这条线

Object h=context.lookup("santosh");

Object h=context.lookup("java:santosh");

让我知道这是否有效

于 2012-05-17T08:55:35.640 回答