3 Replies Latest reply on Feb 21, 2006 6:10 PM by starksm64

    Can I use both

    chaser

      Hi, all

      I am just wondering if I can declare both "remote" and "local" reference in the "ejb-jar.xml", like this:

      ...


      <ejb-name>TravelAgentEJB</ejb-name>
      com.titan.travelagent.TravelAgentHomeRemote
      com.titan.travelagent.TravelAgentRemote
      <ejb-class>com.titan.travelagent.TravelAgentBean</ejb-class>
      <session-type>Stateless</session-type>
      <transaction-type>Container</transaction-type>

      <ejb-ref>
      <ejb-ref-name>ejb/CabinHomeRemote</ejb-ref-name>
      <ejb-ref-type>Entity</ejb-ref-type>
      com.titan.cabin.CabinHomeRemote
      com.titan.cabin.CabinRemote
      </ejb-ref>

      <ejb-local-ref>
      <ejb-ref-name>ejb/CabinHomeLocal</ejb-ref-name>
      <ejb-ref-type>Entity</ejb-ref-type>
      <local-home>com.titan.cabin.CabinHomeLocal</local-home>
      com.titan.cabin.CabinLocal
      <!-- ejb-link is required by jboss for local-refs. -->
      <ejb-link>CabinEJB</ejb-link>
      </ejb-local-ref>

      <security-identity><use-caller-identity/></security-identity>


      ...

      I tried this, but it looks not allowed. Or is there a right way to do this?

      You might see that I want the session bean can either reference a remote or local entity. Is this feasible?

      Thanks in advance.

      Chen

        • 1. Re: Can I use both
          starksm64

          Yes, both can be used. Details are needed.

          • 2. Re: Can I use both
            chaser

             

            "scott.stark@jboss.org" wrote:
            Yes, both can be used. Details are needed.


            What kind of information do you need? I paste the entire "ejb-jar.xml" as the follows. If you need more than that, please tell me what parts do you need.

            == 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>

            <enterprise-beans>

            <ejb-name>CabinEJB</ejb-name>
            com.titan.cabin.CabinHomeRemote
            com.titan.cabin.CabinRemote
            <local-home>com.titan.cabin.CabinHomeLocal</local-home>
            com.titan.cabin.CabinLocal
            <ejb-class>com.titan.cabin.CabinBean</ejb-class>
            <persistence-type>Container</persistence-type>
            <prim-key-class>java.lang.Integer</prim-key-class>
            False
            <cmp-version>2.x</cmp-version>
            <abstract-schema-name>Cabin</abstract-schema-name>
            <cmp-field><field-name>id</field-name></cmp-field>
            <cmp-field><field-name>name</field-name></cmp-field>
            <cmp-field><field-name>deckLevel</field-name></cmp-field>
            <cmp-field><field-name>shipId</field-name></cmp-field>
            <cmp-field><field-name>bedCount</field-name></cmp-field>
            <primkey-field>id</primkey-field>
            <security-identity><use-caller-identity/></security-identity>



            <ejb-name>TravelAgentEJB</ejb-name>
            com.titan.travelagent.TravelAgentHomeRemote
            com.titan.travelagent.TravelAgentRemote
            <ejb-class>com.titan.travelagent.TravelAgentBean</ejb-class>
            <session-type>Stateless</session-type>
            <transaction-type>Container</transaction-type>

            <ejb-ref>
            <ejb-ref-name>ejb/CabinHomeRemote</ejb-ref-name>
            <ejb-ref-type>Entity</ejb-ref-type>
            com.titan.cabin.CabinHomeRemote
            com.titan.cabin.CabinRemote
            </ejb-ref>

            <ejb-local-ref>
            <ejb-ref-name>ejb/CabinHomeLocal</ejb-ref-name>
            <ejb-ref-type>Entity</ejb-ref-type>
            <local-home>com.titan.cabin.CabinHomeLocal</local-home>
            com.titan.cabin.CabinLocal
            <!-- ejb-link is required by jboss for local-refs. -->
            <ejb-link>CabinEJB</ejb-link>
            </ejb-local-ref>

            <security-identity><use-caller-identity/></security-identity>


            </enterprise-beans>

            <assembly-descriptor>

            <security-role>

            This role represents everyone who is allowed full access to the beans.

            <role-name>everyone</role-name>
            </security-role>

            <method-permission>
            <role-name>everyone</role-name>

            <ejb-name>CabinEJB</ejb-name>
            <method-name>*</method-name>


            <ejb-name>TravelAgentEJB</ejb-name>
            <method-name>*</method-name>

            </method-permission>

            <container-transaction>

            <ejb-name>CabinEJB</ejb-name>
            <method-name>*</method-name>


            <ejb-name>TravelAgentEJB</ejb-name>
            <method-name>*</method-name>

            <trans-attribute>Required</trans-attribute>
            </container-transaction>

            </assembly-descriptor>

            <ejb-client-jar>titanejb-client.jar</ejb-client-jar>

            </ejb-jar>

            And the

            ==== jboss.xml ===

            <?xml version="1.0"?>


            <enterprise-beans>

            <ejb-name>CabinEJB</ejb-name>
            <jndi-name>CabinHomeRemote</jndi-name>
            <local-jndi-name>CabinHomeLocal</local-jndi-name>


            <ejb-name>TravelAgentEJB</ejb-name>
            <jndi-name>TravelAgentHomeRemote</jndi-name>

            </enterprise-beans>


            And:

            === jbosscmp-jdbc.xml ==

            <?xml version="1.0" encoding="UTF-8"?>

            <!DOCTYPE jbosscmp-jdbc PUBLIC
            "-//JBoss//DTD JBOSSCMP-JDBC 3.0//EN"
            "http://www.jboss.org/j2ee/dtd/jbosscmp-jdbc_3_0.dtd">

            <jbosscmp-jdbc>


            java:/MySqlDS
            <datasource-mapping>mySQL</datasource-mapping>


            <enterprise-beans>

            <ejb-name>CabinEJB</ejb-name>
            <table-name>Cabin</table-name>
            <cmp-field>
            <field-name>id</field-name>
            <column-name>ID</column-name>
            </cmp-field>
            <cmp-field>
            <field-name>name</field-name>
            <column-name>NAME</column-name>
            </cmp-field>
            <cmp-field>
            <field-name>deckLevel</field-name>
            <column-name>DECKLEVEL</column-name>
            </cmp-field>
            <cmp-field>
            <field-name>shipId</field-name>
            <column-name>SHIPID</column-name>
            </cmp-field>
            <cmp-field>
            <field-name>bedCount</field-name>
            <column-name>BEDCOUNT</column-name>
            </cmp-field>

            </enterprise-beans>
            </jbosscmp-jdbc>

            Last,

            === titandb-ds.xml ===

            <?xml version="1.0" encoding="UTF-8"?>

            <!-- ===================================================================== -->
            <!-- -->
            <!-- JBoss Server Configuration -->
            <!-- -->
            <!-- ===================================================================== -->

            <!-- $Id: oracle-ds.xml,v 1.1 2002/07/22 22:57:24 d_jencks Exp $ -->
            <!-- ==================================================================== -->
            <!-- Datasource config for Oracle originally from Steven Coy -->
            <!-- ==================================================================== -->


            <local-tx-datasource>
            <jndi-name>MySqlDS</jndi-name>
            <connection-url>jdbc:mysql://localhost:3306/workbook</connection-url>
            <driver-class>com.mysql.jdbc.Driver</driver-class>
            <user-name>username</user-name>
            password
            </local-tx-datasource>




            • 3. Re: Can I use both
              starksm64

              You have to use [ code ] [ /code ] tags without the spaces to display xml properly. A better description that "it was not allowed" would also help.