5 Replies Latest reply on Jan 30, 2002 11:18 AM by Michele Fabbri

    more many to many relationship with CMP 2.0

    Michele Fabbri Newbie

      Does anyone uses CMP 2.0 many to many relationship with JBoss 3.0alpha?
      Or tries the J2EE Tutorial AppRoster example by Sun
      on JBoss?

      I don't understand why the relationship setting works
      if the database table are empty when I first deploy
      my application and doesn't work the second time when
      database table aren't empty.

      Bye
      Michele

        • 1. Re: more many to many relationship with CMP 2.0
          Dain Sundstrom Master

          > Does anyone uses CMP 2.0 many to many relationship
          > with JBoss 3.0alpha?

          Yep they work fine.

          > Or tries the J2EE Tutorial AppRoster example by Sun
          > on JBoss?

          Nope haven't seen it.

          > I don't understand why the relationship setting
          > works
          > if the database table are empty when I first deploy
          > my application and doesn't work the second time when
          >
          > database table aren't empty.

          You're going to need to be more specific. Please post the important log messanges, and revelent portions of the deployment descriptors.

          • 2. Re: more many to many relationship with CMP 2.0
            Michele Fabbri Newbie

            Hi,

            I posted ejb-jar.xml, jboss.xml, jbosscmp-jdbc.xml and source some threads above, the thread's name is:
            "Does many to many relationship work in Jboss3.0 ? "

            I try to create two entity bean with a many to many relationship, if I create some entity of both bean,
            then I restart the server without deleting the tables,
            and I set a relationship between two or more entities
            jboss log this is the error:

            java.rmi.ServerException: null
            Embedded Exception
            A CMR field cannot be set or added to a relationship in ejbCreate; this should be done in the ejbPostCreate method instead.;

            at org.jboss.ejb.StatelessSessionContainer$ContainerInterceptor.invoke(StatelessSessionContainer.java:634)

            at org.jboss.ejb.plugins.AbstractTxInterceptor.invokeNext(AbstractTxInterceptor.java:96)

            at org.jboss.ejb.plugins.AbstractTxInterceptorBMT.invokeNext(AbstractTxInterceptorBMT.java:142)

            at org.jboss.ejb.plugins.TxInterceptorBMT.invoke(TxInterceptorBMT.java:62)

            at org.jboss.ejb.plugins.StatelessSessionInstanceInterceptor.invoke(StatelessSessionInstanceInterceptor.java:77)

            at org.jboss.ejb.plugins.SecurityInterceptor.invoke(SecurityInterceptor.java:127)

            at org.jboss.ejb.plugins.LogInterceptor.invoke(LogInterceptor.java:166)

            at org.jboss.ejb.StatelessSessionContainer.invoke(StatelessSessionContainer.java:289)

            at org.jboss.ejb.Container.invoke(Container.java:609)
            at com.sun.management.jmx.MBeanServerImpl.invoke(MBeanServerImpl.java:1555)
            at com.sun.management.jmx.MBeanServerImpl.invoke(MBeanServerImpl.java:1523)
            at org.jboss.invocation.jrmp.server.JRMPInvoker.invoke(JRMPInvoker.java:320)
            at java.lang.reflect.Method.invoke(Native Method)
            at sun.rmi.server.UnicastServerRef.dispatch(Unknown Source)
            at sun.rmi.transport.Transport$1.run(Unknown Source)
            at java.security.AccessController.doPrivileged(Native Method)
            at sun.rmi.transport.Transport.serviceCall(Unknown Source)
            at sun.rmi.transport.tcp.TCPTransport.handleMessages(Unknown Source)
            at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(Unknown Source)
            at java.lang.Thread.run(Unknown Source)



            Bye
            Michele

            • 3. Re: more many to many relationship with CMP 2.0
              Nick Kravchenko Newbie

              Hi Michele,

              It seems the point has been missed here, is that
              many-to-many works great. You can do whatever you like
              with either side of the relationship (add/delete). BUT
              once you restart jboss or redeploy - all adds fail.
              The only way out is to drop the relationships table and
              start again.

              The problem is in the Alpha version - i bet (and hope)
              its fixed in the next release.

              I stopped this problem from occuring by getting
              revision 1.10 of JDBCCMRFieldBridge.java, and comment
              out the check in addRelation(). This basically undoes that change (1.10) or you can get (1.9), but I wanted to see what was going on. After compiling, replace the class in lib/ext/jboss.jar.

              PS.
              Is there an easy way of getting a source dump of Jboss
              without using cvs (Just a click and download a .tgz file?)
              Is this what snapshot are ?
              Anyway snapshot urls give me "not found" Http errors

              Good luck. Nick.

              • 4. Re: more many to many relationship with CMP 2.0
                Alexander Lepekhine Newbie

                Dear Michele! Your code doesn't work because "A CMR field cannot be set or added to a relationship in ejbCreate; this should be done in the ejbPostCreate method instead".
                You shoud not add children to this or other EJB in the ejbCreate method. Are you doing it? Check it and move the appropriate code to the ejbPostCreate method. It has the same parameters as the ejbCreate, so it is easy to do.
                But I can say that even after that you program may not work because of some bugs in transaction management in JBoss 3.0alpha. I have a good suspiction about them and the letters in this thread about lost records put my suspictions into assurance.
                Wish you success. Alexander.

                • 5. Re: more many to many relationship with CMP 2.0
                  Michele Fabbri Newbie

                  Hi Nick,

                  I try your patch and now JBoss3.0 works!
                  Your are very clever and I thank you very much.

                  But i don't understand a thing ...
                  Why only you and me have reported this problem?
                  Why has no one ever found this error?

                  I think is a bad thing that persistent management
                  system can't works after a restart without the
                  lost of all the data :-(

                  Bye
                  Michele

                  PS.
                  For Lepekhin, I don't write anything in ejbCreate,
                  I posted the source of my bean in the thread named
                  "Does many to many relationship work in Jboss3.0 ?".
                  Bye.