我看的是尚学堂的的EJB课程,就是李鹏飞的那个,跟着他做,第一个小例子就卡住了,请大家救救小女吧,问题如下遇到问题: FirstEjbBean not bound javax.naming.NameNotFoundException: FirstEjbBean 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(Unknown Source) 
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) 
at java.lang.reflect.Method.invoke(Unknown Source) 
at sun.rmi.server.UnicastServerRef.dispatch(Unknown Source) 
at sun.rmi.transport.Transport$1.run(Unknown Source) 
at java.security.AccessController.doPrivileged(Native Method) 
at sun.rmi.transport.Transport.serviceCall(Unknown Source) 
at sun.rmi.transport.tcp.TCPTransport.handleMessages(Unknown Source) 
at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(Unknown Source) 
at java.lang.Thread.run(Unknown Source) 
at sun.rmi.transport.StreamRemoteCall.exceptionReceivedFromServer(StreamRemoteCall.java:247) 
at sun.rmi.transport.StreamRemoteCall.executeCall(StreamRemoteCall.java:223) 
at sun.rmi.server.UnicastRef.invoke(UnicastRef.java:126) 
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(InitialContext.java:351) 
at com.mxf.ejb.FirstEjbClient.main(FirstEjbClient.java:22) 4.我的代码如下: 
--接口 
package com.mxf.ejb; 
public interface FirstEjb { 
public String sayHello(String str); 
} --接口实现Bean 
package com.mxf.ejb; 
import javax.ejb.Remote; 
import javax.ejb.Stateless; 
@Remote 
@Stateless 
public class FirstEjbBean implements FirstEjb { 
public String sayHello(String str) { 
return "您好!"+str; 

} --客户端 
package com.mxf.ejb; 
import javax.naming.InitialContext; 
import javax.naming.NamingException; 
public class FirstEjbClient { 
public static void main(String[] args) { 
try { 
InitialContext itx = new InitialContext(); 
FirstEjb firstEjb = (FirstEjb)itx.lookup("FirstEjbBean/remote"); ---执行到这里报错 
String str=firstEjb.sayHello("remain"); 
System.out.println(str); 
} catch (NamingException e) { 
e.printStackTrace(); 



解决方案 »

  1.   

    在Google上找了两天了,就是没有找到相应的的答案,请高手相救一下
      

  2.   

    有人看过李鹏飞的那个EJB吗
    请说一下吧
      

  3.   

    没有人回答吗,是不是因为下载的jboss-4.0.5.GA.zip
    没有jems-installer-1.2.0.GA.jar 这个安装包的缘故啊,但是我下载解压并配置后,
    输入http://localhost:8080/jmx-console/,也能进入JBOSS的页面啊,
    到底什么原因啊
      

  4.   

     package com.mxf.ejb; 
    import javax.naming.InitialContext; 
    import javax.naming.NamingException; 
    import javax.naming.*;
    import java.util.Properties;
    public class FirstEjbClient { 
    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");
     
    try { 
    InitialContext itx = new InitialContext(props); 
    FirstEjb firstEjb = (FirstEjb)itx.lookup("FirstEjbBean/remote"); ---执行到这里报错 
    String str=firstEjb.sayHello("remain"); 
    System.out.println(str); 
    } catch (NamingException e) { 
    e.printStackTrace(); 



    试一试
      

  5.   

    package com.mxf.ejb; 
    import javax.ejb.Remote; 
    import javax.ejb.Stateless; 
    @Remote ( {FirstEjb.class } )
    @Stateless 
    public class FirstEjbBean implements FirstEjb { 
    public String sayHello(String str) { 
    return "您好!"+str; 

    } 再加上这个看看,我最近也在学ejb3.0,但一直没时间做例子,刚好