3 Replies Latest reply on Aug 22, 2007 11:31 AM by Nick Dodd

    EJB2 and EJB3 in the same system ???

    Hamdy Farid Newbie

      Hi,
      We came to the J2EE world little bit late, we spent all summer migrating our system (which is running on a persistance layer develped by us) to J2EE 1.4 (Jboss 4.0)

      We are looking into adding new feature to our system and I would like to use EJB3 to simplify the development (the prototypes done with EJB3 were very impressive)

      The problems are:
      - deployment. Can I deploy EJ3 based ear and EJB2 ear files in the same server?

      - Releation: Some of the entities which will be introduced as part of the new feature will be in relation with the older EJB2 entities. How can I do this? should I port these EJB2 entites to EJB3 BUT will jboss allows me to access the db table using two diffrent beans ?

      Integrating EJB2 and EJB3 subsystems is the main concern we have right now

      Thanks for your help
      Thanks

        • 1. Re: EJB2 and EJB3 in the same system ???
          Bill Burke Master

          What can you do currently with EJB3 and EJB21?

          - .ejb3 jars support EJB 2.1 Session and MDBs, but not EJB 2.x Entity beans deployed in the same jar. We will eventually ahve to support this, but for now, our EJB3 container does not support EJB 2.x CMP or BMP.

          - You can deploy EJB3 jars and EJB 2.1 jars in the same EAR file. You should also be able to reference EJB3 from EJB 21 and viceversa. We have some unit tests for that. If you find problems in that arena, please post the issues on Jira with small test cases so that we can easily reproduce.

          - The Specification has some EJB3/2.1 integration requirements for session beans. Basically it allows you to have an EJB3 session bean, but the client be an old 2.1 style bean. Basically an EJB3 is allowed to have a home interface if you want to.

          What you cannot do is:
          - Mix CMP and EJB3 persistence together. EJB3 entities and CMP entities will not be aware of one another and it will be very dangerous for you to have a mix there. I suggest migrating your CMP stuff to EJB3 persistence or putting the write facade abstractions in from of your data objects so that it doesn't matter.

          • 2. Re: EJB2 and EJB3 in the same system ???
            Mike Yawn Newbie

            I've had similar questions regarding a mix of JDBC and EJB 3.0 -- the root question of all of this is, can we gradually convert our JDBC code to EJB 3.0, or do we have to have a 'big bang' event where everything gets migrated at once?

            Some of the possible scenarios would be:

            - Do a table-by-table migration. So some tables would be fully EJB 3.0, while others remain fully JDBC. If a EJB 3.0 entity bean has a reference to a class still using JDBC persistence, I'm not sure what we would do -- doesn't seem like it would be possible to model the relationship with @OneToOne (or whatever multiplicity is correct), but I'm not sure what happens if we try to persist an object reference that doesn't include any such annotation.

            - Move all of the create/update/delete methods to EJB 3.0 first, and then migrate the queries later. This way any referential integrity issues would be resolved, queries might get stale data.

            Is there any generally accepted best practice for how to go about such a migration?

            • 3. Re: EJB2 and EJB3 in the same system ???
              Nick Dodd Newbie

              Can anybody confirm the current state of the world with this issue please?

              The above seems to indicate that you can deploy EJB 2 and EJB 3 in the same EAR file (got that working), and even talk to each other through Session Beans. But what I really want to confirm is whether CMR between EJB 2 / EJB3 entity beans is at all possible? (to allow a gradual incremental update of EJB2 to EJB3 without doing a big bang conversion of the whole lot). Bill Burkes comment implies this is not possible but the post is getting on for 2 years old now!

              Many thanks