文件ejb-jar.xml的内容为:<?xml version="1.0" encoding="ISO-8859-1"?>
<ejb-jar>
<description>jBoss test application </description>
<display-name>Test</display-name>
<enterprise-beans>
<session>
<ejb-name>GreetEJB</ejb-name>
<home>greet.GreetHome</home>
<remote>greet.Greet</remote>
<ejb-class>greet.GreetBean</ejb-class>
<session-type>Stateless</session-type>
<transaction-type>Bean</transaction-type>
</session>
</enterprise-beans>
</ejb-jar>

解决方案 »

  1.   

    文件jboss.xml的内容为:
    <?xml version="1.0" encoding="ISO-8859-1"?>
    <jboss>
    <enterprise-beans>
    <session>
    <ejb-name>GreetEJB</ejb-name>
    <jndi-name>GreetingEJB</jndi-name>
    </session>
    <secure>false</secure>
    </enterprise-beans>
    <resource-managers/>
    </jboss>
      

  2.   

    客户端文件GreetClient.java的内容为:import javax.naming.*;
    import java.util.Hashtable;
    import javax.rmi.PortableRemoteObject; 
    import greet.*;
    class GreetClient
    {
     public static void main(String[] args) {
      System.setProperty("java.naming.factory.initial", "org.jnp.interfaces.Naming ContextFactory");
      System.setProperty("java.naming.provider.url", "localhost:1099");
    try {
       // Get a naming context
       InitialContext jndiContext = new InitialContext();
       System.out.println("Got context");
       Object ref  = jndiContext.lookup("GreetingEJB");
       System.out.println("Got reference");
       GreetHome home = (GreetHome) 
       PortableRemoteObject.narrow (ref, GreetHome.class);
       Greet greet = home.create();
       System.out.print("The magic number from server is ");
       System.out.println(greet.calculateMagic(123.456));  } catch(Exception e) {
       System.out.println(e.toString());
      }
     }
    }
    注意,编译是没问题的。
      

  3.   

    Hashtable env = new Hashtable();
    env.put(Context.INITIAL_CONTEXT_FACTORY,"org.jnp.interfaces.NamingContextFactory");
    env.put(Context.URL_PKG_PREFIXES,"org.jboss.naming");
    env.put(Context.PROVIDER_URL,"localhost:1099") ;
    Context ctx = new InitialContext(env);
      

  4.   

    把   InitialContext jndiContext = new InitialContext();
    改成 InitialContext jndiContext = new InitialContext(System.getProperties()); 试试
      

  5.   

    有Jboss相关文档吗,请email:[email protected]。谢谢!
      

  6.   

    确认jboss\client\下面的东东在你classpath里能找到
      

  7.   

    http://prdownloads.sourceforge.net/jboss/JBoss.3.0QuickStart.Draft3.pdf
      

  8.   

    org.jnp.interfaces.Naming ContextFactory这句话的Naming ContextFactory之间没有空格的吧,还有这是JBoss提供的一个类,你的client程序运行的时候需要找到这个类的,所以程序运行时候的Classpath路径上需要找到这个类,这个类在Jboss\client目录的jar文件中,把他们加入吧。
      

  9.   

    以下是我的客户端运行文件.
    set jboss_client=D:\jboss-3.0.3_tomcat-4.1.12\clientset classpath=%jboss_client%\jboss-j2ee.jar;%jboss_client%\jaas.jar;%jboss_client%\jbosssx-client.jar;%jboss_client%\jboss-client.jar;%jboss_client%\jnp-client.jar;%jboss_client%\jnet.jar;%jboss_client%\log4j.jar;%jboss_client%\jboss-common-client.jar
    set classpath=%classpath%;.;.\resourcesjava org.jboss.docs.interest.InterestClient把以上所用到的lib加到你的classpath里因该就没问题了.
    resources目录为jndi.properties文件所在目录.
    jndi.properties内容为
    java.naming.factory.initial=org.jnp.interfaces.NamingContextFactory
    java.naming.provider.url=localhost:1099
    java.naming.factory.url.pkgs=org.jboss.naming:org.jnp.interfaces
      

  10.   

    估计你的问题是出在
    java.naming.factory.url.pkgs=org.jboss.naming:org.jnp.interfaces
    java.naming.factory.initial=org.jnp.interfaces.NamingContextFactory