2 Replies Latest reply on Jul 22, 2011 3:44 AM by Thunder Lei

    Problem migrating from jboss 4.0.5 to 5.1.0GA

    Juan Estupinan Newbie

      Hi,

       

      I have a problem. I'm migrating from jboss 4.0.5 to 5.1.0GA, and migrating from EJB 2.1 to EJB 3. When I pass an object of type Stagestracking to an EJB, and modify an attribute, the attribute is modified in the ejb, but when using the object to the online, that has not been modified.

       

      Note: jboss 4 at track to reference the object after running the method addStageTrack, this appears modified, while in the JBoss 5 does not appear modified in order

       

       

      for example:

       

      ------------------------------------------------------------------------------------------------------------------------------------------------------------------------

       

      public class OnlineBDAccounting {

       

      protected AccountingFacadeEJB getAccountingFacadeEJB()

              throws NamingException {

              InitialContext ctx = new InitialContext();

              AccountingFacadeEJB accountingEJB = (AccountingFacadeEJB) ctx.lookup("AccountingFacadeEJBBean/remote");

          return accountingEJB;

             

              }

       

       

      public boolean addStageTrack(Stagestracking track)

              throws StagesTrackingException {

          try {

              AccountingFacadeEJB accounting = getAccountingFacadeEJB();

       

              return accounting.addStageTrack(track);

          }catch (NamingException e){

              throw new BDAccountingException(e.getMessage());

         

          }

      }

      }

       

       

        ------------------------------------------------------------------------------------------------------------------------------------------------------------------------

      @Stateless

      @Remote

      public class AccountingFacadeEJBBean implements Serializable {

       

      @Resource(mappedName="java:/JmsXA")

      private ConnectionFactory connectionFactory ;

       

      @Resource(mappedName="queue/A")

      private Queue queue;

       

      @EJB

      private AccountingDocumentsEJB accountingDocumentsEJB;

       

      public boolean addStageTrack(Stagestracking track)

                  throws StagesTrackingException {

       

              return accountingDocumentsEJB.addStageTrack(track);

      }

       

      }

       

      ------------------------------------------------------------------------------------------------------------------------------------------------------------------------

      @Stateless

      @Local

      public class AccountingDocumentsEJBBean implements AccountingDocuments, AccountingDocumentsEJB {

       

          @IgnoreDependency

          @EJB

          private AccountingFacadeEJB accountingFacade;

       

           public boolean addStageTrack(Stagestracking track)

              throws StagesTrackingException {

          try {

              StagesTrackingDAO stagesTrackingDAO = getStagesTrackingDAO();

       

              return stagesTrackingDAO.addStageTrack(track);

          } catch (DAOException e) {

              throw new EJBException(e.getMessage());

          }

       

          }

       

      public boolean addStageTrack(Stagestracking track) throws DAOException {

              boolean returnValue = false;

              track.setId(new Long(378));

              //At this time the variable has been modified

              returnValue = true;

              return returnValue;

      }

       

       

      }

       

      ------------------------------------------------------------------------------------------------------------------------------------------------------------------------

       

       

      Thanks for advance.

        • 1. Re: Problem migrating from jboss 4.0.5 to 5.1.0GA
          Wolfgang Knauf Master

          Hi,

           

          I assume this is a matter of the entity bean lifecycle: as long as an entity bean is managed (under control of the persistence context), all changes will be automatically saved. But if the entity is "detached", you can still change it, but the changes will not be persisted.

           

          To save a detached entity, you have to call "entityManager.merge(...)" yourself.

           

          Take a look e.g. at this for some more details: http://download.oracle.com/javaee/5/tutorial/doc/bnbqw.html

           

          If there are still questions, please provide more details: e.g. I need the information where you load your Entity.

           

          Best regards

           

          Wolfgang

           

          PS: I think the "@Local" and "@Remote" annotations should be placed on the interfaces, not on the bean class!

          • 2. Re: Problem migrating from jboss 4.0.5 to 5.1.0GA
            Thunder Lei Newbie

            Hi,

             

            From my perspective, it's expected behavior of "Remote" sementic.

            When you call the EJB by remote reference, the EJB stub will serialize your parameters and send the result to the EJB container, at container, the parameters are deserialized. All the changes of the parameter Objects in EJB contaimer will NOT be reflected in the calling thread.

            If you want the modified parameter Objects, you have to return that changed Objects from remote EJB methods.

             

            Note: jboss 4 at track to reference the object after running the method addStageTrack, this appears modified, while in the JBoss 5 does not appear modified in order

            This is very interesting...

            Are you sure you run the code on jboss 4 in the same way on Jboss 5?

            In both cases, you run the code in same JVM or different jvm? In both case, you are calling the "Remote" method and NOT local methd?