如果你是用jb来做的,完全可以必开手动方式来手写配置文件。
建议使用cmp来做容器管理,相应的把你的TravelAgentBean也作成相应的托管。至于说调用可以采用JNDI的方式来做

解决方案 »

  1.   

    weblogic-ejb-jar中要有ejb中定义的新jndi名称<ejb-ref-name>CarbinRemote</ejb-ref-name>到被引用的ejb 的jndi名字的映射。
    <ejb-ref-description>
         <ejb-ref-name>CarbinRemote</ejb-ref-name>   //ejb-jar里面的那句
         <jndi-name>你用外部test调用该ejb的jndi名称<jndi-name>
    <ejb-ref-description>
    快点结贴,我要拿来做第五条三角裤,还差1元了。
      

  2.   

    谢谢,但是还有问题啊,如果分不够还可以再加to yeshucheng(叶澍成):
    我的CrabinBean就是cmp的,现在CrabinBean和TravelAgentBean不在一个工程里,CrabinBean已经成功部署,并且知道他的jndi是CarbinRemote,现在要在TravelAgentBean里面调用它。您说的,“把你的TravelAgentBean也作成相应的托管”是什么意思?我的TravelAgentBean是无状态的sessionbean.to serf():
    weblogic-ejb-jar.xml中没有“ejb-ref-description”这一项,errors提示:element type "ejb-ref-description" must be declared.
    我的weblogic-ejb-jar.xml内容如下,要在那里加“ejb-ref-description”?
    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE weblogic-ejb-jar PUBLIC "-//BEA Systems, Inc.//DTD WebLogic 8.1.0 EJB//EN" "http://www.bea.com/servers/wls810/dtd/weblogic-ejb-jar.dtd">
    <weblogic-ejb-jar>
      <weblogic-enterprise-bean>
        <ejb-name>TravelAgentBean</ejb-name>
        <jndi-name>TravelAgentBean</jndi-name>
      </weblogic-enterprise-bean>
    </weblogic-ejb-jar>
      

  3.   

    做sessionBean的容器,自然会生成JNDI名称。
    不在同一个工程?呵呵,是不是说错了
    不在同一个工程不可能调的到
      

  4.   

    就是说,cmp的CrabinBean和sessionbean TravelAgentBean必须在一个工程中,统一build然后,部署?如果不这样就不能调用到么?那么如果调用别人写的ejb是不是必须要加到自己的工程中?还是只把别人的编译好的jar比如CrabinBean.jar加入到该sessionbean TravelAgentBean得工程中?
      

  5.   

    对不起,我说错了,应该是weblogic.xml,被你提问给误导了。同一包内可用本地接口(不是说home,是说local),非同一包内用远程接口。这是我的一个web 应用 ejb的示例中web模块内的weblogic.xml
    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE weblogic-web-app PUBLIC "-//BEA Systems, Inc.//DTD Web Application 8.1//EN" "http://www.bea.com/servers/wls810/dtd/weblogic810-web-jar.dtd">  //这个非常重要
    <weblogic-web-app>
      <reference-descriptor>
        <ejb-reference-description>
          <ejb-ref-name>ejb/EjbRef1</ejb-ref-name>
          <jndi-name>TestEJB</jndi-name>
        </ejb-reference-description>
      </reference-descriptor>
      <context-root>WebModule1</context-root>
    </weblogic-web-app>把本地的ejb/ejbref1映射到系统的TestEJB上了。不懂可以看//这个非常重要那行的那个dtd,文件。下载一个,仔细读读。
      

  6.   

    我的不是一个web应用,是两个ejb,是一个ejb调用远程的ejb。我增加了
    <ejb-ref>
            <ejb-ref-name>CarbinRemote</ejb-ref-name>
            <ejb-ref-type>Entity</ejb-ref-type>
            <home>carbin.CarbinRemoteHome</home>
            <remote>carbin.CarbinRemote</remote>
            <ejb-link>Carbin</ejb-link>
          </ejb-ref>但是部署的时候提示我
    Deployment failed on Server myserver
    weblogic.management.DeploymentException: 
    Exception:weblogic.management.ApplicationException: activate failed for TravelAgentBean
    Module: TravelAgentBean Error: Exception activating module: EJBModule(TravelAgentBean,status=PREPARED)
    Unable to deploy EJB: TravelAgentBean from TravelAgentBean.jar:weblogic.deployment.EnvironmentException: [J2EE:160101]Error: The ejb-link 'Carbin' declared in the ejb-ref or ejb-local-ref 'CarbinRemote' in the application module 'TravelAgentBean.jar' could not be resolved. The target EJB for the ejb-ref could not be found. Please ensure the link is correct.我现在糊涂了,到底能不能调用?如果能应该怎样写呢?
      

  7.   

    引用用jbx有工具加的,在ejb design中可以找到.
      

  8.   

    楼上说的应该怎么操作?我没有找到
    只有create ejb和import ejb阿?import之后也不能给两个ejb建立联系阿?
      

  9.   

    现在终于找到解决的办法了,首先在ejb-jar.xml中加入<ejb-ref>,如下:
    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE ejb-jar PUBLIC "-//Sun Microsystems, Inc.//DTD Enterprise JavaBeans 2.0//EN" "http://java.sun.com/dtd/ejb-jar_2_0.dtd">
    <ejb-jar>
      <display-name>TravelAgentBean</display-name>
      <enterprise-beans>
        <session>
          <ejb-name>TravelAgentBean</ejb-name>
          <home>travelagentejb.TravelAgentHome</home>
          <remote>travelagentejb.TravelAgent</remote>
          <ejb-class>travelagentejb.TravelAgentBean</ejb-class>
          <session-type>Stateless</session-type>
          <transaction-type>Container</transaction-type>
          <ejb-ref>
            <ejb-ref-name>ejb/Carbin</ejb-ref-name>
            <ejb-ref-type>Entity</ejb-ref-type>
            <home>carbin.CarbinRemoteHome</home>
            <remote>carbin.CarbinRemote</remote>
            <!--<ejb-link>../CarbinEJB/CarbinEJB.jar#Carbin</ejb-link>-->//这一行不知道要不要加上
          </ejb-ref>
        </session>
      </enterprise-beans>
      <assembly-descriptor>
        <container-transaction>
          <method>
            <ejb-name>TravelAgentBean</ejb-name>
            <method-name>*</method-name>
          </method>
          <trans-attribute>Required</trans-attribute>
        </container-transaction>
      </assembly-descriptor>
    </ejb-jar>然后在weblogic-ejb-jar.xml中加入 <reference-descriptor>,如下:
    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE weblogic-ejb-jar PUBLIC "-//BEA Systems, Inc.//DTD WebLogic 8.1.0 EJB//EN" "http://www.bea.com/servers/wls810/dtd/weblogic-ejb-jar.dtd">
    <weblogic-ejb-jar>
      <weblogic-enterprise-bean>
        <ejb-name>TravelAgentBean</ejb-name>
        <reference-descriptor>
          <ejb-reference-description>
            <ejb-ref-name>ejb/Carbin</ejb-ref-name>
            <jndi-name>CarbinRemote</jndi-name>
          </ejb-reference-description>
        </reference-descriptor>
        <jndi-name>TravelAgentBean</jndi-name>
      </weblogic-enterprise-bean>
    </weblogic-ejb-jar>部署程中,但是test却出现错误,提示:
    weblogic.utils.AssertionError: ***** ASSERTION FAILED *****[ Environment not found on thread ]
    ...
      

  10.   

    发个mail给我,我给你个例子吧。
      

  11.   

    link那句不要,那句是引用同一包内的local接口的。位于同一ejb包,或同一个ear包(包含多个ejb,war包).你说的那句link...在那个配置向导中是一个下拉框。可用的link那里都能选择,否则就不能用,你添了也只会报错。 那么说你已经解决了。恭喜恭喜。