Myeclipse6.6+weblogic9.2开发EJB第一个Helloworld程序时出现这个问题: 
javax.naming.NameNotFoundException: Unable to resolve 'HelloWorld'. Resolved '' [Root exception is javax.naming.NameNotFoundException: Unable to resolve 'HelloWorld'. Resolved '']; remaining name 'HelloWorld' 
at weblogic.rjvm.ResponseImpl.unmarshalReturn(ResponseImpl.java:195) 
at weblogic.rmi.cluster.ClusterableRemoteRef.invoke(ClusterableRemoteRef.java:338) 
at weblogic.rmi.cluster.ClusterableRemoteRef.invoke(ClusterableRemoteRef.java:252) 
at weblogic.jndi.internal.ServerNamingNode_920_WLStub.lookup(Unknown Source) 
at weblogic.jndi.internal.WLContextImpl.lookup(WLContextImpl.java:374) 
at weblogic.jndi.internal.WLContextImpl.lookup(WLContextImpl.java:362) 
at javax.naming.InitialContext.lookup(Unknown Source) 
at com.ejb.TestEJB.main(TestEJB.java:24) TestEJB客户端程序是: 
package com.ejb; 
import java.util.Properties; 
import javax.naming.Context; 
import javax.naming.InitialContext; 
import javax.naming.NamingException; 
import com.interfaces.HelloWorldHome; public class TestEJB { /** 
* @param args 
* @throws NamingException 
*/ 
public static void main(String[] args) throws NamingException { 
// TODO Auto-generated method stub 
Properties properties=new Properties(); 
properties.put(Context.INITIAL_CONTEXT_FACTORY, "weblogic.jndi.WLInitialContextFactory"); 
properties.put(Context.PROVIDER_URL,"t3://localhost:7001"); 
try{ 
Context context=new InitialContext(properties); 
HelloWorldHome home=(HelloWorldHome)context.lookup("HelloWorld"); 
HelloWorld hello=(HelloWorld) home.create(); 
System.out.println(hello.hello()); 

catch(Exception e) 

e.printStackTrace(); 

解决方案 »

  1.   

    对了这个是配置文件:
    <?xml version="1.0" encoding="UTF-8" ?> 
      <!DOCTYPE ejb-jar (View Source for full doctype...)> 
    - <ejb-jar> 
    - <description> 
    - <![CDATA[ No Description. 
      ]]> 
      </description> 
      <display-name>Generated by XDoclet </display-name> 
    - <enterprise-beans> 
    - <!--  Session Beans 
      --> 
    - <session> 
    - <description> 
    - <![CDATA[ 
      ]]> 
      </description> 
      <ejb-name>HelloWorld </ejb-name> 
      <home>com.interfaces.HelloWorldHome </home> 
      <remote>com.interfaces.HelloWorld </remote> 
      <local-home>com.interfaces.HelloWorldLocalHome </local-home> 
      <local>com.interfaces.HelloWorldLocal </local> 
      <ejb-class>com.ejb.HelloWorldSession </ejb-class> 
      <session-type>Stateless </session-type> 
      <transaction-type>Container </transaction-type> 
      </session> 
    - <!--        To add session beans that you have deployment descriptor info for, add 
          a file to your XDoclet merge directory called session-beans.xml that contains 
          the <session> </session> up for those beans. 
        
      --> 
    - <!--  Entity Beans 
      --> 
    - <!--        To add entity beans that you have deployment descriptor info for, add 
          a file to your XDoclet merge directory called entity-beans.xml that contains 
          the <entity> </entity> up for those beans. 
        
      --> 
    - <!--  Message Driven Beans 
      --> 
    - <!--        To add message driven beans that you have deployment descriptor info for, add 
          a file to your XDoclet merge directory called message-driven-beans.xml that contains 
          the <message-driven> </message-driven> up for those beans. 
        
      --> 
      </enterprise-beans> 
    - <!--  Relationships 
      --> 
    - <!--  Assembly Descriptor 
      --> 
    - <!--        To specify your own assembly descriptor info here, add a file to your 
          XDoclet merge directory called assembly-descriptor.xml that contains 
          the <assembly-descriptor> </assembly-descriptor> up. 
        
      --> 
    - <assembly-descriptor> 
    - <!--        To specify additional security-role elements, add a file in the merge 
          directory called ejb-security-roles.xml that contains them. 
        
      --> 
    - <!--  method permissions 
      --> 
    - <!--        To specify additional method-permission elements, add a file in the merge 
          directory called ejb-method-permissions.ent that contains them. 
        
      --> 
    - <!--  transactions 
      --> 
    - <!--        To specify additional container-transaction elements, add a file in the merge 
          directory called ejb-container-transactions.ent that contains them. 
        
      --> 
    - <!--  finder transactions 
      --> 
    - <!--  message destinations 
      --> 
    - <!--        To specify additional message-destination elements, add a file in the merge 
          directory called ejb-message-destinations.ent that contains them. 
        
      --> 
    - <!--  exclude list 
      --> 
    - <!--        To specify an exclude-list element, add a file in the merge directory 
          called ejb-exclude-list.xml that contains it. 
        
      --> 
      </assembly-descriptor> 
      </ejb-jar> 
      <?xml version="1.0" encoding="UTF-8" ?> 
      <!DOCTYPE weblogic-ejb-jar (View Source for full doctype...)> 
    - <weblogic-ejb-jar> 
    - <description> 
    - <![CDATA[ Generated by XDoclet 
      ]]> 
      </description> 
    - <weblogic-enterprise-bean> 
      <ejb-name>HelloWorld </ejb-name> 
      <reference-descriptor /> 
      <jndi-name>HelloWorld </jndi-name> 
      <local-jndi-name>HelloWorldLocal </local-jndi-name> 
      </weblogic-enterprise-bean> 
    - <!--  
    To add enterprise beans that you have deployment descriptor info for, add 
    a file to your XDoclet merge directory called weblogic-enterprise-beans.xml that contains 
    the <weblogic-enterprise-bean> </weblogic-enterprise-bean> up for those beans.   --> 
    - <!--  
    To add a security-role-assignment section, add 
    a file to your XDoclet merge directory called weblogic-security-role-assignment.xml that contains 
    the <security-role-assignment> </security-role-assignment> up.   --> 
    - <!--  
    To add a run-as-role-assignment section, add 
    a file to your XDoclet merge directory called weblogic-run-as-role-assignment.xml that contains 
    the <run-as-role-assignment> </run-as-role-assignment> up.   --> 
      </weblogic-ejb-jar>