paint-brush
Migration From JBoss 5 to JBoss 7: All It Takes Is 11 Easy Stepsby@vunnamanusha
1,275 reads
1,275 reads

Migration From JBoss 5 to JBoss 7: All It Takes Is 11 Easy Steps

by Anusha VunnamJune 3rd, 2021
Read on Terminal Reader
Read this story w/o Javascript
tldt arrow

Too Long; Didn't Read

The migration to JBoss 7 and JEE6 took us four weeks to complete. Processing time is among the main advantages. The first significant update for Jboss 7 is here. The migration is significantly more rapid (EJB 3.1 is far better compared to 3.0). Maven annotations should be replaced for them and make sure the initons are singletons. Each of these annotations successfully can be replaced with JPA 20, allowing you to remove them successfully with Hibernate.

Company Mentioned

Mention Thumbnail
featured image - Migration From JBoss 5 to JBoss 7: All It Takes Is 11 Easy Steps
Anusha Vunnam HackerNoon profile picture

Some time ago, from JBoss 5 to JBoss 7, we decided to update our application (technically 7.2). This article will discuss a few items that we found to be troublesome. First, a little background on our application. Technology-based EJB 3.0 was used to create it. JAX-WS and JMS are the two interfaces we use to communicate with other components. The message broker is “JBoss AS 5”, which is run as a distinct JVM process. This system's component was not permitted to be altered. At last, we utilize JPA to save the results of the processing to the Oracle database.

Step 1 – Persuade your Owner of the product

Despite the fact that the application is relatively compact and developed on the JEE5 standard, the migration to JBoss 7 and JEE6 took us four weeks. Hence, you won't be able to perform it as a ticket for maintenance because it's just too large. It's never easy to convince Product Owners and other key business stakeholders to value such migrations. There are various factors that may assist you in persuading them.

Processing time is among the main advantages. The “JBoss 7” is just quicker and more cache-friendly (Ehcache with Infinispan). Another factor is the starting time (In comparison to JBoss 5, the server is up and running in 5 to 6 seconds). Finally, progress is significantly more rapid (EJB 3.1 is far better compared to 3.0). "Time to market" could be interpreted as the final one. I'm confident you'll persuade them using the above arguments.

Step 2 – Make time to read.

If you are new to Jboss, then explore this Jboss tutorial for Beginners to comprehend its features, benefits, architecture, and its terms, procedural steps for installing JBoss setup. Before the move, here's a list of interesting sites to check out:

Step 3 – You're off! – changing dependencies of Maven

Because “JBoss 5” is not neatly packed, I'm guessing your classpath has a lot of dependencies (directly or through transitive dependencies). The first significant update for JBoss 7 is here.

I firmly suggest you include this artifact in your section on dependency management right now:

We also opted to keep to the JEE6 standards and use correct XML files to specify any new JBoss 7 features. If that sounds excellent for the project as well, simply add this dependent and you are done:

For a few days or perhaps weeks, your code will most likely not compile after you've cleaned up dependencies. Cleaning stuff up takes time. 

Step 4 – Migration from EJB 3.0 to EJB 3.1

Because Dependency Injection has been at the core of the program, it's a good place to start. You should be able to run most of the code. However, beans with the @Service annotation will cause some problems (With EJB Extended API in JBoss 5, they are singletons). @Singleton annotations should be replaced for them and make sure the init method has a @PostConstruct annotation. Last but not least, remember to employ the appropriate concurrency approach. We choose to utilize @ConcurrencyManagement (BEAN) instead of changing the implementation.

Step 5 – JPA 2.0 Upgradation

I'm sure you’ve many annotations that aren't standard specifying caching or cascade if you utilized JPA 1.0 with Hibernate. Each of them may be replaced successfully with annotations in JPA 2.0, allowing you to remove Hibernate from the compilation classpath and rely solely on “JPA 2.0”. These are many standard procedures to follow:

  • “Session.evict” from Hibernate must be excluded and shifted to “EntityManager.detach”.
  • Exclude the Hibernate's annotation @Cache and @Cachable should be replaced.
  • The Cascades must be fixed (now orphan erase is a component annotated with @XXXToYYYY).
  • Delete the dependence on Hibernate and adhere to the JEE6 specification.

Step 6 – The sequencer in Hibernate needs to be fixed

Because of the way Hibernate 3 and 4 handle sequences (@Id-annotated fields), It's a little tricky to upgrade to version 4. Instead of incrementing the sequence, Hibernate defaults to using a pool containing ids. Here's a more detailed example:

There's a new sequence generator in Hibernate 4.x that employs new IDs which are 1:1 DB sequence-related. Normally, by default, it is turned off, but not with “JBoss 7.1”. Therefore Hibernate attempts to insert entities with the help of IDs retrieved from a series (making use of a new sequencer) that have previously been used, resulting in a constraint violation. Switching Hibernate to the previous technique of sequence generating (given in the preceding example) is the quickest option, but it necessitates the following persistence.xml has been modified:

Step 7 – Cache-making 

JBoss 7 is pre-configured on Infinispan and requires little setup. In persistence.xml, there is just one setting that must be configured, and others may be deleted:

Infinispan may require further setup; simply follow the instructions in “standalone-full-ha.xml”.

Step 8 – JBoss 5 and RMI

If you're utilizing a huge amount of RMI to communicate with other servers running JBoss 5, I've got some terrible news for you: The JBoss 5 and JBoss 7 are completely distinct, and this type of communication will fail. Switching to a different technology, such as JAX-WS, is strongly advised. Retrospectively, we're delighted we took the initiative.

Step 9 – Migration to JMS

We anticipated that connecting to a JMS server running on “JBoss 5” would be quite difficult. It turns out you have two choices, both of which function fine:

Construct a bridge between your JBoss 5 instance by starting the HornetQ server on your own instance.

JMS Adapter (Generic) should be used: https://github.com/jms-ra/generic-jms-ra

Step 10 – EAR layout must be fixed.

It makes no difference where each and every jar is placed in JBoss 5. All of the EJBs are now running. It is no longer compatible with “JBoss 7”. The module list must include all EJBs that need to be started.

Step 11 – Console for JMX

JBoss 7 does not have this bad information. We really liked it, however, we had to switch to jvisualvm for running our JMX commands. 

Conclusion

This ends the session, you have now read how to implement migration steps successfully. We hope this blog has helped you a lot in learning the technology.