How to reference ejb in another jar files?


EJB programming & troubleshooting: How to reference ejb in another jar files?

  1. How to reference ejb in another jar files? (3 messages)

    Hi all,

    I hava two EJBs,
    One is entity bean, com.customer.OrganazitionBean, is in customer.jar.
    Another is session bean, com.util.UUIDGeneratorBean, is in util.jar.

    I'd like to call UUIDGeneratorBean in OrganazitionBean, so I insert the following in the deployment description file of customer.jar.

    These jars are deployed on Weblogic7. The following exception is thrown when call UUIDGeneratorBean in OrganazitionBean.
    Exception in thread "main" javax.naming.LinkException: . Root exception is javax.naming.LinkException: .
    Root exception is javax.naming.NameNotFoundException: Unable to resolve
    'app/ejb/util.jar#UUIDGeneratorBean/local-home' Resolved: 'app/ejb' Unresolved:'util.jar#UUIDGeneratorBean'
    ; remaining name '
    If UUIDGeneratorBean is put into customer.jar, and the above <ejb-link> element is replaced with the following,
    This program runs correctly.

    How to resolve this problem?

  2. Hi,

    We had a similar problem months ago wherein the EJBs (ejb.jar) had to access classes in a different jar file (common.jar). What worked for us was to put the specify the classpath in manifest files of ejb.jar.

    The manifest looks like
    Manifest-Version: 1.0
    Class-Path: common.jar

    We had common.jar and ejb.jar in one ear file.

    Hopefully this may help or give you some idea of how to go about

  3. Hi,

    I looked in the spec and it gave this example,


    I think you need to drop "/util/util.jar#" from the ejb-link element.
  4. Actually forget my last answer as I did not read the bit in the spec before that

    "&#8226; Alternatively, to avoid the need to rename enterprise beans to have unique names within an
    entire J2EE application, the Application Assembler may use the following syntax in the
    ejb-link element of the referencing application component. The Application Assembler specifies the path name of the ejb-jar file containing the referenced enterprise bean and
    appends the ejb-name of the target bean separated from the path name by # . The path name
    is relative to the referencing application component jar file. In this manner, multiple beans with
    the same ejb-name may be uniquely identified when the Application Assembler cannot
    change ejb-names."