deployment - working - wildfly hot deploy
Hot deploy on JBoss-how do I make JBoss “see” the change? (10)
I am developing a Java EE application that I deploy over and over again on a local JBoss installation during development. I want to speed up the build by hot deploying my application straight into [JBOSS]/server/default/deploy/myApp
It seems to work - but there also seems to be a somewhat arbitrary delay between the hard deploy and when JBoss starts using the new classes. I am not very familiar with JBoss, but I assume it caches classes, and that this is what causes the problem.
Am I correct, and if so, how do I make JBoss flush it's cache?
Actually my problem was that the command line mvn utility wouldn't see the changes for some reason. I turned on the Auto-deploy in the Deployment Scanner and there was still no difference. HOWEVER... I was twiddling around with the Eclipse environment and because I had added a JBoss server for it's Servers window I discovered I had the ability to "Add or Remove..." modules in my workspace. Once the project was added whenever I made a change to code the code change was detected by the Deployment Scanner and JBoss went thru the cycle of updating code!!! Works like a charm.
Here are the steps necessary to set this up;
First if you haven't done so add your JBoss Server to your Eclipse using File->New->Other->Server then go thru the motions of adding your JBoss AS 7 server. Being sure to locate the directory that you are using.
Once added, look down near the bottom of Eclipse to the "Servers" tab. You should see your JBoss server. Highlight it and look for "Add or Remove...". From there you should see your project.
Once added, make a small change to your code and watch JBoss go to town hot deploying for you.
Deploy the app as exploded (project.war folder), add in your web.xml:
<web-app> <context-param> <param-name>org.jboss.weld.development</param-name> <param-value>true</param-value> </context-param>
Update the web.xml time every-time you deploy (append blank line):
set PRJ_HOME=C:\Temp2\MyProject\src\main\webapp set PRJ_CLSS_HOME=%PRJ_HOME%\WEB-INF\classes\com\myProject set JBOSS_HOME= C:\Java\jboss-4.2.3.GA-jdk6\server\default\deploy\MyProject.war set JBOSS_CLSS_HOME= %JBOSS_HOME%\WEB-INF\classes\com\myProject copy %PRJ_CLSS_HOME%\frontend\actions\profile\ProfileAction.class %JBOSS_CLSS_HOME%\frontend\actions\profile\ProfileAction.class copy %PRJ_CLSS_HOME%\frontend\actions\profile\AjaxAction.class %JBOSS_CLSS_HOME%\frontend\actions\profile\AjaxAction.class ECHO.>>%JBOSS_HOME%\WEB-INF\web.xml
Hot deployment is stable only for changes on static parts of the application (jsf, xhtml, etc.).
Here is a working solution, according to JBoss AS 7.1.1.Final:
.warfolder) and open it with a text editor (i.e. Notepad++).
When finished, don't forget to copy these changes to your actual development environment, rebuild and redeploy.
I am using JBoss AS 7.1.1.Final. Adding following code snippet in my web.xml helped me to change jsp files on the fly :
<servlet> <servlet-name>jsp</servlet-name> <servlet-class>org.apache.jasper.servlet.JspServlet</servlet-class> <init-param> <param-name>development</param-name> <param-value>true</param-value> </init-param> <load-on-startup>3</load-on-startup> </servlet>
Hope this helps.!!
I have had the same problem, but think I've got it under control now.
Are you using eclipse or command line or ??
When I use the command line, I think I did "seam clean" or "seam undeploy" or maybe even "seam restart" followed by "seam explode". I probably tried all of these at one time or another never bothering to look up what each one does.
The idea is to remove the deployed war file from TWO places
1. $JBOSS_HOME/server/default/deploy 2. $PROJECT_HOME/exploded_archives
I'm pretty sure "seam undeploy" removes the 1st and "seam clean" removes the 2nd.
When I use eclipse (I use the free one), I first turn off "Project/Build Automatically" Then when I am ready to deploy I do either Project/Build Project or Project/Build All depending on what I've changed. When I change xhtml, Build Project is sufficient. When I change java source Build All works. It's possible these do the same things and the difference is in my imagination, but some combination of this stuff will work for you.
You have to watch the output though. Occasionally the app does not get cleaned or undeployed. This would result in not seeing your change. Sometimes I shut down the server first and then rebuild/clean/deploy the project.
Hope this helps.
I've been developing a project with Eclipse and Wildfly and the exploded EAR file was getting big due to deploying of all the 3rd party libraries I needed in the application. I was pointing the deployment to my Maven repository which I guess was recopying the jars each time. So redeploying the application when ever I changed Java code in the service layer was turning into a nightmare.
Then having turned to Hotswap agent this helped a lot as far as seeing changes to EJB code without redeploying the application.
However I have recently upgraded to Wildfly 10, Java 8 and JBoss Developer Studio 10 and during that process I took the time to move all my 3rd party application jars e.g. primefaces into Wildfly modules and I removed my Maven repo from my deployment config. Now redeploying the entire application which is a pretty big one via Eclipse takes just a few seconds and it is much much faster than before. I don't even feel the need to install Hotswap and don't want to risk it anyway right now.
So if you are building under Eclipse with Wildfly then keep you application clear of 3rd party libs using Wildfly Modules and you'll be much better off.
Solution for Netbeans 8.02 and 8.1 IDE and JBOSS EAP 6.4:
- From the services tab of Netbeans, add JBOSS server to your "servers" node.
If you are using MAVEN, netbeans compiles files and maven copies files to ./target directory. You need to create a symbolic link from .\target to JBOSS_HOME\standalone\deployments. Under windows, an example command would be
cd %JBOSS_HOME%\standalone\deployments mklink /d MyWebApplication.war %PROJECTS_HOME%\MyWebApplication\target\MyWebApplication-1.0.0
The above creates a symbolic link from
\target\MyWebApplication-1.0.0which is where maven transfers all files after compilation, or after a jsp, html or any other file changes.
Last think to do is to create a
CentralManagement.war.dodeployfile in %JBOSS_HOME%\standalone\deployments. This file will tell JBOSS to deploy the war "file" as a web application
Start the server in debug mode and It will track changes inside methods. Other changes It will ask to restart the module.
Unfortunately, it's not that easy. There are more complicated things behind the scenes in JBoss (most of them ClassLoader related) that will prevent you from HOT-DEPLOYING your application.
For example, you are not going to be able to HOT-DEPLOY if some of your classes signatures change.
So far, using MyEclipse IDE (a paid distribution of Eclipse) is the only thing I found that does hot deploying quite successfully. Not 100% accuracy though. But certainly better than JBoss Tools, Netbeans or any other Eclipse based solution.
I've been looking for free tools to accomplish what you've just described by asking people in if you want to take a look.
Use Ant script and make target deploy.
The deploy target should:
- Stop JBoss
- Copy the ear or war to the deploy directory
- Start JBoss
==> No caching + also no out of memory issues after subsequent deploys during testing.