Websphere hot deployment and dynamic reloading
In the office we use Websphere AS and RAD as IDE. When you make changes to a Java class file, the changes are publised by the IDE to the AS, and the server restarts for the changes to take effect. This is in contrast to the changes done to JSP which do not require server restart to take effect. Actually there is a possibility of hot deployment and dynamic reloading (http://publib.boulder.ibm.com/infocenter/wsdoc400/v6r0/index.jsp?topic=/com.ibm.websphere.iseries.doc/info/ae/ae/trun_app_hotupgrade.html) which basically works like this: you replace the class file in the server with the new class file and the changes should take effect immediately without needing server restart. This is a very useful feature of WAS and it makes me wonder why the WAS plugin for RAD/Eclipse does not have a feature to enable this. I know there are limitations, like when you replace Hibernate entities or deployment descriptor, then you still need to restart the server but generally this feature is very useful during development.
So i decided to write an ant build file which runs when there is an automatic build. The job of this build file is basically to replace the class files in the server with the newly built class files in the workspace.
To do this, I first need to manually deploy the EAR via the WAS console. This is to make the exploded EAR file available in the server. Because when i deploy the ear by right clicking on the project -> run as -> run in the server, the exploded ear file is not there in the server! I dont know where, probably in one of the numerous plugin directories of the RAD/Eclipse installation.
After the ear file is manually deployed, then disable automatic publishing in the WAS plugin.
And then the ant build file:
Pretty obvious I guess. The src.osms is the workspace build directory while the des.osms is the WAS exploded ear directory. The most important part of the build file is the mnodified selector (https://ant.apache.org/manual/Types/selectors.html#modified) which selects only recently modified file (which is the file newly built by Eclipse automatic build) and copies these files to WAS.
Now, this ant build file needs to run everytime you modify a class file or anything, so enable automatic build on your project.
So i decided to write an ant build file which runs when there is an automatic build. The job of this build file is basically to replace the class files in the server with the newly built class files in the workspace.
To do this, I first need to manually deploy the EAR via the WAS console. This is to make the exploded EAR file available in the server. Because when i deploy the ear by right clicking on the project -> run as -> run in the server, the exploded ear file is not there in the server! I dont know where, probably in one of the numerous plugin directories of the RAD/Eclipse installation.
After the ear file is manually deployed, then disable automatic publishing in the WAS plugin.
And then the ant build file:
Pretty obvious I guess. The src.osms is the workspace build directory while the des.osms is the WAS exploded ear directory. The most important part of the build file is the mnodified selector (https://ant.apache.org/manual/Types/selectors.html#modified) which selects only recently modified file (which is the file newly built by Eclipse automatic build) and copies these files to WAS.
Now, this ant build file needs to run everytime you modify a class file or anything, so enable automatic build on your project.
And then right click on your project -> properties -> builders -> new -> ant builders -> OK. You get this dialog
Choose your ant build file. Then click on the target tab and set the target for manual build and auto build. Done.
PS: if you have money, try JRebel.
0 komentar:
Posting Komentar