ashwinsakthi
ashwinsakthi

Reputation: 1956

Can i prevent restarting my application each time i make a change in my java code?

The ide used is :IBM Rational® Software Architect™ for WebSphere® Software Version: 7.5.5.3

The app server used is Wbesphere 6.1.

I am posting this question because my server takes about 7 to 8 minutes to start.

So even if i make a small change ,i have to wait 10 minutes to test the change in my application.So is there a way where i can make changes to my java code and test them without restarting the server.

Suggestions appreciated !!!

Note:

I am not supposed to use any build tool in my environment.

Upvotes: 4

Views: 2351

Answers (3)

Mike Braun
Mike Braun

Reputation: 3769

Theoretically reloading classes is build into the JVM, although most implementations (specifically Oracle's) only reload (hot swap) as long as you only change code inside the body of a method.

The other problem is that in Eclipse the WTP adapter has to cooperate and only deploy the changed class definition (incremental deploy). GlassFish for some reason has always been a big opponent of incremental deployments, and hence its WTP adapter restarts the server after making even the most tiny change.

JBoss used to be a proponent of incremental deployments, but after AS 7 ("everything has to be different"), they are now a follower of the "restart the server" school as well.

Yet another issue is that plain class loading is often only one part of the story. In EJB, JSF, JPA and many other frameworks classes also have to be re-registered by the framework, caches have to be cleared, etc

This all is where something like JRebel comes it. It reloads nearly all kinds of changes to classes. It also works independently from the WTP adapter thus freeing you from the whims of the server vendors regarding if restarting is hip today and lame tomorrow or exactly the other way around. JRebel also has knowledge and plugins for many frameworks.

Unfortunately JRebel is not perfect and occasionally things will just fail, but overall it works pretty well.

One other piece of advice: most modern application servers start up in a second on relative fast hardware and with a small application or a some 10 seconds for a larger app. With those and session serialization you almost don't need things like JRebel anymore.

Upvotes: 1

user1123557
user1123557

Reputation:

Dynamic Code Evolution VM is open source alternative to JRebel you can try for reloading classes. It will do entire class redefinition, even reloads changes done to class hierarchy.

Upvotes: 3

Keppil
Keppil

Reputation: 46219

There is a plugin called JRebel that let's you do changes without restarting the server.

Upvotes: 7

Related Questions