Object obj = ic.lookup("java:comp/env/ejb/RouteFacade"); //这样会有NamingException
Object obj = ic.lookup("RouteFacade"); //这样写就不会出错

解决方案 »

  1.   

    http://www.mail-archive.com/[email protected]/msg22608.html
    java:comp/env/-- is private to each ejb and is defined by the ejb-ref and ejb-local-ref in the bean, what you should do instead is :in your ejb-jar.xml for the bean that references CompanyUser bean through java:comp/env/ejb/CompanyUser<session>
    ...
    <ejb-local-ref>
    <ejb-ref-name>ejb/CompanyUser</ejb-ref-name>
    ...
    plus information according to the bean :
    ejb-ref-type, local-home, local
    ...
    <ejb-link>CompanyUser<ejb-link>
    </ejb-local-ref>
    ...
    </session>of course we assume that you two beans are in the same jar deployement.otherwise you don't specify ejb-link and use jboss.xml instead to make the link to the bean.
      

  2.   

    thanks first!
    不过,对于ejb调用ejb时需要在ejb-jar.xml里面加入引用参考才可以用“java:comp/env/”方式调用这一点我是知道的,
    可我的问题是在app client如果也用“java:comp/env/”方式调用ejb应该怎么做呢,我是在application-client.xml里面加入了关于ejb引用的描述的。有了一个appClient.jar文件了,这个jar文件里面包括了客户应用所需要的ejb远程接口类以及客户程序,还有application-client.xml、MANIFEST.MF,MANIFEST.MF里面定义了main class。然后在jbuilder里面建了一个ear,设置了ejb模块(ejb.jar)和app client模块(appClient.jar),编译成功了,可是deploy的时候报这样的错误:
    Unable to activate application, app, from source, e:\bea\user_projects\mydomain\.\myserver\upload\app\app.ear. Reason: Unable to create mbean Name: appClient.jar Type: null Exception: weblogic.management.MBeanCreationException:  - with nested exception:[javax.management.MalformedObjectNameException: type cannot be null]这是为什么呢?