10 Replies Latest reply on Aug 17, 2004 6:10 AM by crevette

    Relationships over different jar's

    jdwn

      Hello,

      Is it possible to define a unidirectional relationship between two container managed entity beans, when both entities are in a different jar file.

      I tried to do this, but I always get the exception "Entity: XXXXXX not found for relationship ...." when I'm deploying the last jar in my JBoss server.
      But I just deployed the entity jar file (that is not found) before that.

      Somebody knows if this is possible?

      Any comment is welcome!

      Joris

        • 1. Re: Relationships over different jar's

          Last time I tried this it was not possible. I don't know if 3.2.x has changed wrt this.

          • 2. Re: Relationships over different jar's
            ironbird
            • 3. Re: Relationships over different jar's
              jdwn

              First of all, thanks for the quick replies!

              I watched the other topic (already watched it in a previous search), but it's surprising me that it's impossible to have relationships over different jar's.

              This means that I've to put nearly all my entity beans in one jar file (or dd). This is impossible and makes EB nearly unusable for me.

              If I think of it more, it's saying that in a DB, two tables can't have a relationship even when they are in the same DB!

              Are there possible workarounds for this huge problem?

              Thnx!
              Joris

              • 4. Re: Relationships over different jar's
                jae77

                i believe this can be done (i'm pretty sure i'm doing it right now).

                are you including the deployment descriptor information for the related beans? (you may also need to set dependencies on the other ejbs to make sure they are deployed before you app).



                • 5. Re: Relationships over different jar's
                  ironbird

                   

                  "jdwn" wrote:
                  I watched the other topic (already watched it in a previous search), but it's surprising me that it's impossible to have relationships over different jar's.


                  You watch badly !


                  • 6. Re: Relationships over different jar's
                    jdwn

                    Thanks a lot! One week of searching, never giving up, even when other people are saying it's impossible. It's possible!!!

                    Just put the entity you're refering to also in the ejb-jar.xml file and in the jbosscmp-jdbc.xml file.

                    Thnx!

                    Joris

                    • 7. Re: Relationships over different jar's
                      jdwn

                      And the story never ends :-)

                      After I got the relationship between two different jar files working, I ran very quickly in the following problem:

                      Entity A is in jar 1
                      Entity B1 is in jar 2
                      Entity B2 is in jar 2

                      Now A is having a relationship with B1. This is working perfect by calling A.getB1() and A.setB1().
                      But B1 is having a relationship with B2. When I try to call in a session bean in jar 1 A.getB1().getB2() I get the following error:
                      Method is not a known CMP field accessor, CMR field accessor, or ejbSelect method: methodName=XXXXXXXX

                      If I call B1.getB2() inside jar 2 there's no problem.

                      So I think I'll have to put the DD of B2 also in the DD of jar 1. But I'll also have to put the DD of the relationship between B1 and B2 in the DD of jar 1.

                      The problem is I don't know how to put these relationship tags in the DD using XDoclet.
                      Adding extra tags is easy by defining an other xml file, but I can't find anything about adding extra <ejb-relation> tags

                      Any help is welcome
                      Thanks a lot!!

                      Joris

                      • 8. Re: Relationships over different jar's
                        zarni

                        Hey!

                        "jdwn" wrote:
                        And the story never ends :-)

                        So I think I'll have to put the DD of B2 also in the DD of jar 1. But I'll also have to put the DD of the relationship between B1 and B2 in the DD of jar 1.

                        The problem is I don't know how to put these relationship tags in the DD using XDoclet.
                        Adding extra <entity> tags is easy by defining an other xml file, but I can't find anything about adding extra <ejb-relation> tags


                        Joris


                        To add some extra rel. to the ejb-jar use the ejbdoclet task and run
                        this within the task.




                        Put a file named "relationships.xml" in the ${merge.dir}, and make sure the
                        extra relationships you need are in there :-) .

                        You may want to look here also :

                        http://xdoclet.sourceforge.net/xdoclet/ant/xdoclet/modules/ejb/dd/EjbDotXmlSubTask.html

                        Have a nice day!



                        • 9. Re: Relationships over different jar's
                          zarni

                          :-) He he ... this part disapeard ... :-)

                          <!--deploymentdescriptor
                          destdir="${generated-src.dir}"
                          validatexml="true"
                          mergeDir="${merge.dir}"
                          description="somedescription"
                          >
                          -->


                          • 10. Re: Relationships over different jar's
                            crevette

                             

                            Just put the entity you're refering to also in the ejb-jar.xml file and in the jbosscmp-jdbc.xml file


                            i try this but have a InstanceAlreadyExists exception.
                            so i try to put the realtions in the relationships.xml file, but the relations are not take into account.

                            some idea?
                            thanks