3 Replies Latest reply on Dec 29, 2005 7:47 PM by galderz

    How to call bean in another ear file in Jboss?

      :-)
      hi, i stuck now. actually, i created 2 ear file and deploy it in Jboss. I want to pass data by bean in first ear file to bean in second ear file . For example, package1.ear and package2.ear. How to do that? Please help me?

        • 1. Re: How to call bean in another ear file in Jboss?

          why don't you put the jar file(s) containing your beans in just one ear? Is there any requirement that stops you from putting your beans in the same ear?

          you should be able to reference the second one from the first using ejb-ref element and doing the necessary jndi lookup.

          • 2. Re: How to call bean in another ear file in Jboss?

            I can do what as your said. i can put the package just in 1 ear file. But it requirement.

            This is example of one my ear file.
            Now i have show you my deployment desciptor;
            jboss.xml
            <?xml version="1.0"?>

            <enterprise-beans>


            <ejb-name>honda</ejb-name>
            <jndi-name>honda</jndi-name>


            </enterprise-beans>


            ejb-jar.xml
            <?xml version="1.0"?>
            <!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>
            <![CDATA[No Description.]]>
            <display-name>Generated by XDoclet</display-name>

            <enterprise-beans>


            honda
            <display-name>honda</display-name>
            <ejb-name>honda</ejb-name>
            com.Honda.honda.HondaHome
            com.Honda.honda.Honda
            <ejb-class>com.Honda.honda.HondaBean</ejb-class>
            <session-type>Stateless</session-type>
            <transaction-type>Container</transaction-type>

            </enterprise-beans>

            <assembly-descriptor >
            </assembly-descriptor>

            </ejb-jar>

            ///////////////////////////////////////////////////////////
            May be i can modify my deployment descriptor to import bean from another ear, But I dont know.

            How to can I call another ear-file? Can you show me the solution?

            • 3. Re: How to call bean in another ear file in Jboss?

              The descriptors shown are not descriptors associated with an ear file but a jar file. application.xml and jboss-app.xml are the descriptors associated with an ear file.

              EAR files are enterprise archives that can contain jar, sar, war, har files as well as jar libraries. JAR files are java archives that contain entity and session beans.

              In order to reference one bean from another one, you should populate the ejb-ref element in the first bean.

              Further information on how to populate ejb-ref element can be found in the following dtd file:

              $JBOSS_HOME/docs/ejb-jar_2_0.dtd


              Assuming you wanted to reference bean with ejb-name 'honda2', the following element should be added to the definition of your first session bean in the ejb-jar.xml file:

              <ejb-ref>
               <ejb-ref-name>my-ejb-references/honda2</ejb-ref-name>
              <ejb-ref-type>Session</ejb-ref-type>
              <home>$FULLY_QUALIFIED_NAME_OF_HOME_INTERFACE</home>
              <remote>$FULLY_QUALIFIED_NAME_OF_REMOTE_INTERFACE</remote>
              <ejb-link>honda2</ejb-link> <!-- ejb-name of the second session bean in its ejb-jar.xml file -->
              </ejb-ref>


              Hope this helps :-D