首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > JAVA > Java Exception >

javax.naming.NameNotFoundException: HelloWorldBean not bound

2014-01-26 
开发环境: MyEclipse5.5 JBoss4.0.4 JDK1.5.0.0.9 EJB3代码如下: import javax.ejb.Remote @Remote public

开发环境:
MyEclipse5.5
JBoss4.0.4
JDK1.5.0.0.9
EJB3代码如下:
import javax.ejb.Remote;
@Remote
public interface HelloWorld {
public void sayHello();
}
------------------------------
import javax.ejb.Remote;
import javax.ejb.Stateless;

@Stateless
@Remote(HelloWorld.class)
public class HelloWorldBean implements HelloWorld {
public void sayHello(){
System.out.println( "Hello World! ");
}
}
测试代码:
public class TestSessionBean {
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:org.jnp.interfaces ");

InitialContext ctx;
try {
ctx = new InitialContext(props);
HelloWorld helloworld = (HelloWorld) ctx.lookup( "HelloWorldBean/remote ");
helloworld.sayHello();
} catch (NamingException e) {
e.printStackTrace();
}
}
}
错误信息:
javax.naming.NameNotFoundException: HelloWorldBean 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:267)
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:585)
at sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:294)
at sun.rmi.transport.Transport$1.run(Transport.java:153)
at java.security.AccessController.doPrivileged(Native Method)
at sun.rmi.transport.Transport.serviceCall(Transport.java:149)
at sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:466)
at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:707)
at java.lang.Thread.run(Thread.java:595)
at sun.rmi.transport.StreamRemoteCall.exceptionReceivedFromServer(Unknown Source)
at sun.rmi.transport.StreamRemoteCall.executeCall(Unknown Source)
at sun.rmi.server.UnicastRef.invoke(Unknown Source)
at org.jnp.server.NamingServer_Stub.lookup(Unknown Source)
at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:625)
at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:587)
at javax.naming.InitialContext.lookup(Unknown Source)
at TestSessionBean.main(TestSessionBean.java:23)
在JBoss的控制台上看不到部署以后的信息

------解决方法--------------------------------------------------------
难道是大小写的原因?
------解决方法--------------------------------------------------------
没有找到 HelloWorldBean ,看看你的配置文件 我没用过ejb3.0。

但是ejb2.0里面 应该有ejb-jar.xml jboss.xml

看看jboss.xml 里面的 jndi-name 是不是 HelloWorldBean/remote

然后看看 ejb-jar.xml 里面 ejb-name 名字对应么

        

热点排行