我把所有代码贴出来看下:首先开发的是EJB的开发:
接口1,2,3,4:
package wy.ejb;public interface Ejb04Interface01 { public void m1();
}package wy.ejb;public interface Ejb04Interface02 { public void m2();
}package wy.ejb;public interface Ejb04Interface03 { public void m3();
}
package wy.ejb;public interface Ejb04Interface04 { public void m4();
}接口实现类:
package wy.ejb;import javax.ejb.Local;
import javax.ejb.Remote;
import javax.ejb.Stateless;@Stateless(name="ejb04beanname")
@Remote(value={Ejb04Interface01.class,Ejb04Interface02.class})
@Local(value={Ejb04Interface03.class,Ejb04Interface04.class})
public class Ejb04Bean implements Ejb04Interface01,Ejb04Interface02,Ejb04Interface03,Ejb04Interface04{ public void m1() {
// TODO Auto-generated method stub
System.out.println("m1方法被调用了");

} public void m2() {
// TODO Auto-generated method stub
System.out.println("m2方法被调用了");
} public void m3() {
// TODO Auto-generated method stub
System.out.println("m3方法被调用了");
} public void m4() {
// TODO Auto-generated method stub
System.out.println("m4方法被调用了");
}}
上述方法开发完成之后,我采用的是直接用JBOSS服务器部署的方式
客户端代码如下:
package wy.ejb;import java.io.Serializable;import javax.naming.InitialContext;public class Ejb04BeanClient {
public static void main(String[] args) throws Exception {

    InitialContext context=new InitialContext();     Ejb04Interface01 ejb0401=(Ejb04Interface01)context.lookup("Ejb04Bean/remote");
    ejb0401.m1();
    
    Ejb04Interface02 ejb0402=(Ejb04Interface02)context.lookup("Ejb04Bean/remote");
        ejb0402.m2();
   
}}
}jndi.properties文件如下:java.naming.factory.initial=org.jnp.interfaces.NamingContextFactory
java.naming.factory.url.pkgs=org.jboss.naming.org.jnp.interfaces
java.naming.provider.url=localhost
在此开发过程中我已把JBOSS下的Client下的所有JAR包加入到CLASSPATH下面。此时运行上述CLIENT中的MAIN方法报错:
Exception in thread "main" javax.naming.NameNotFoundException: Ejb04Bean 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: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:667)
at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:627)
at javax.naming.InitialContext.lookup(InitialContext.java:392)
at wy.ejb.Ejb04BeanClient.main(Ejb04BeanClient.java:14)请高手指导!!!!!!!!!!!!