9 Replies Latest reply on Apr 24, 2002 3:13 PM by fsyu

    problems when reference external jar deployed on same app se

    kometen

      Hi.

      Have previously posted same question in forum 'persistence'. Sorry for cross-posting, but this is driving me nuts.

      I've deployed the cabin-example from Enterprise JavaBeans by Mr. Monson-Haefel. Creating the cabin-clients works great. Added the test-data without problems.

      When I execute the travelagent-client I'm able to get the jndi-ref. to the travelagent-bean. But the travelagent-bean can't get a reference to the cabin-bean.

      It gets the initial context,. I accessed the cabin-bean directly by a test-client, and got the desired result.

      Here is the output from jboss:

      [INFO,Default] Got context
      [ERROR,TravelAgentEJB] TRANSACTION ROLLBACK EXCEPTION:
      javax.transaction.TransactionRolledbackException: null; nested exception is:
      javax.ejb.EJBException
      ...

      part of TravelAgentBean.java:

      public String [] listCabins(int shipId, int bedCount) {
      try {
      // Get a naming context
      InitialContext jndiContext = new InitialContext();
      System.out.println("Got context");

      // Get a reference to the CabinBean bean
      Object obj = jndiContext.lookup("java:comp/env/ejb/CabinEJB");
      System.out.println("Got reference");

      CabinHomeRemote home = (CabinHomeRemote)
      PortableRemoteObject.narrow(obj, CabinHomeRemote.class);

      Part of ejb-jar.xml:


      <ejb-name>TravelAgentEJB</ejb-name>
      no.gnomeit.travelagent.TravelAgentHomeRemote
      no.gnomeit.travelagent.TravelAgentRemote
      <ejb-class>no.gnomeit.travelagent.TravelAgentBean</ejb-class>
      <session-type>Stateless</session-type>
      <transaction-type>Container</transaction-type>
      <ejb-ref>
      <ejb-ref-name>CabinEJB</ejb-ref-name>
      <ejb-ref-type>Entity</ejb-ref-type>
      no.gnomeit.cabin.CabinHomeRemote
      no.gnomeit.cabin.CabinRemote
      </ejb-ref>

      par of jboss.xml:

      <ejb-name>TravelAgentEJB</ejb-name>
      <ejb-ref-name>CabinJEB</ejb-ref-name>
      <jndi-name>CabinEJB</jndi-name>

      When the jndiContext.lookup is empty (jndiContext.lookup("") the bean is able to continue, but does obviously not get any data back, since it doesn't know where to get it.

      I'm completely out of ideas on how to proceed, have even considered trying a commercial app server, just to see whether it's me or not.

      regards
      Claus

        • 1. Re: problems when reference external jar deployed on same ap

          Does it really say CabinJEB in jboss.xml ?

          Regards,
          Adrian

          • 2. Re: problems when reference external jar deployed on same ap
            kometen

            Sorry, typo. Had problems pasting. It is CabinEJB.

            • 3. Re: problems when reference external jar deployed on same ap

              You might want to compare your example with this one.

              http://www.jboss.org/online-manual/HTML/ch07s13.html

              Regards,
              Adrian

              • 4. Re: problems when reference external jar deployed on same ap
                kometen

                Thank you for the link. I had already tried the suggestions outlined in section 'External EJB ref.' some time ago, but I'm not shure whether I got the URL correct. The syntax says <jndi-name>jnp://otherserver/application/beanB</jndi-name>.

                So otherserver must be localhost in my case.

                But what does application refer to exactly? I assumed that it was the name of the applications deployed, eg. cabin (from cabin.jar) or travelagent. Is this a correct assumption?

                regards
                Claus


                • 5. Re: problems when reference external jar deployed on same ap

                  It is a naming convention to avoid conflicts.

                  This part of the config gets very confusing, especially
                  when everything has the same name.
                  I've probably got the example below wrong :-)

                  In your example this convention would be:
                  [pre]
                  <ejb-name>CabinEJB</ejb-name>
                  <jndi-name>travelApp/ejbs/CabinEJB</jndi-name>
                  ...
                  <ejb-name>TravelAgentEJB</ejb-name>
                  <jndi-name>travelApp/ejbs/TravelAgentEJB</jndi-name>
                  <ejb-ref>
                  <ejb-ref-name>ejb/CabinEJB</ejb-ref-name>
                  <jndi-name>travelApp/ejbs/CabinEJB</jndi-name>
                  </ejb-ref>
                  </ejb-name>
                  [/pre]

                  In English, the travel agent bean has the address
                  travelApp/ejbs/TravelAgentEJB

                  it uses the bean at
                  travelApp/ejbs/CabinEJB

                  calling it the short name
                  ejb/CabinEJB

                  Regards,
                  Adrian

                  • 6. Re: problems when reference external jar deployed on same ap
                    kometen

                    Dear Adrian.

                    Thank you very much for your quick answers. I upgraded to the latest cvs-version as of March the 7'th. and compiled it successfully. I re-deployed my cabin- and travelagent.jar's and was able to make a b2b-communication.

                    It turned out that the code I copied from the book all-ready conformed to EJB 2.0 standard, but jboss 2.4.4 did not support CMP 2.0 as you stated.
                    The code in the book and the online-doc is sufficient to successfully deploy the beans.

                    The doc reg. Mr. Monson-Haefels cabin-example is found at http://jboss.org/online-manual/HTML/ch14.html#d0e12038.

                    It is not neccessary though to include the Cabin*.class-files to the travelagent.jar. But this may have historical reasons why this is done this way.

                    best regards
                    Claus

                    • 7. Re: problems when reference external jar deployed on same ap
                      fsyu

                      Hi,

                      I have a quick question about deploying the TravelAgentBean.

                      I have following the previous post and successfully run the Client_1 and Client_2 without problem. After I deploy the the TravelAgent as a separate jar file, I got an exception

                      java.lang.ClassNotFoundException: com.titan.cain.CabinHomeRemote

                      I don't see the "Nested ..." excepiton as before. Then, I try to put my cabin.jar to the deploy folder, jar it together with the travelAgent.jar, ... But, it still give me the same error. (In the mean time, the Client_1, Client_2 are all working fine.)

                      Do I need to put the Cabin.jar in some specific place? or there is something wrong about my ejb-jar.xml or jboss.xml? Hope someone can help me on this.

                      My ejb-jar.xml contains:

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

                      and my jboss.xml looks like:


                      <enterprise-beans>

                      <ejb-name>TravelAgentEJB</ejb-name>
                      <jndi-name>ejb/TravelAgentEJB</jndi-name>
                      <ejb-ref>
                      <ejb-ref-name>ejb/CabinHome</ejb-ref-name>
                      <jndi-name>CabinEJB</jndi-name>
                      </ejb-ref>


                      </enterprise-beans>


                      In TravelAgentBean.java, I have

                      jndiContext.lookup("java:comp/evn/ejb/CabinHome");

                      Thanks in advance.

                      FengShuo,

                      • 8. Re: problems when reference external jar deployed on same ap
                        lasterra

                        do tou include de interfaces of CabinEJB in the trabelEJB jar?????

                        Regards, Enrique.

                        • 9. Re: problems when reference external jar deployed on same ap
                          fsyu

                          hmm...no. But I included the cabin.jar inside TravelJEB.jar. (why would i do that, I don't know and guess that is not right coz it still didn't work!)

                          By the way, after I jar all the files for Travel and Cabin in just one jar file (and hence, 'the travel.jar include the cabin interface) and deploy it to JBoss, all Client_1, 2, 3 are working fine.

                          But, I still want to deploy them as separate jars and sort of confuse about doing B2B call. As in many situations, jar files are prepared by several sub-teams. And B2B call should be very common scenario in EJB. I will try your suggestion and see how it goes. Thanks.

                          FengShuo,