Hot deploy on Glassfish at Netbeans - maven

I have a project with several applications. I have one war and one EAR package. I am using Glassfish, Netbeans and Maven.
The problem is everytime I make a small change in jsf page I have to build the project and run it on server from the beginning ( deploy).
Also I have changed the build -> compile " Compile on Save" property for WAR to "For application execution only". Also at project properties Run -> I have enabled deploy on save.
Still I have to redeploy it from the beginning to see the changes. Please help, this is taking my time!
Thanks,
Sara.

Make sure the PROJECT_STAGE is set to Development. If it is on production your JSF implementation may cache compiled version and won't check on disk for changes.
You should have something like this in your web.xml
<context-param>
<param-name>javax.faces.PROJECT_STAGE</param-name>
<param-value>Development</param-value>
</context-param>
BTW I have only used maven once with a netbeans java-ee project and using maven is slower then a normal netbeans project. If I remember correctly maven always builds a new war and deploys that. A netbeans project does a so called in place deployment which means that it uses the files from the project directly so any changes to for instance JSF pages or CSS are picked up even without redeploying. Redeploying is only needed for changes to the java code and deployment descriptors.

NetBeans provides the "Deploy on Save" feature. However, it still redeploys the full app. Despite it claims to be able to preserve the session it still takes time.
You might want to check out JRebel - the JVM plugin that can handle in-app updates instantly.
The plugin for NetBeans 7.1 is available here: http://plugins.netbeans.org/plugin/22254/jrebel-netbeans-plugin
And for NetBeans 7.2 the plugin is in development.

Related

Liferay portal deployment going into loop

We are using STS 3.4 to develop Spring portlets for Liferay 6.1.2. When we deploy the project onto the server by droping that on the server view, the deployment never gets completed.
It says the deployment is complete and portlets are ready to use but it again reinitiates the deployment process.
Any idea why this endless deployment loop is happening?
I'm not sure if STS is aware of Liferay's additional deployment process (or if you need/use it): Liferay typically processes a WAR file before actual deployment to tomcat, thus you should drop your WAR file to Liferay's deploy folder. This might add some libraries from Liferay itself (depending on your configuration in liferay-*.xml files or some other necessities that I don't remember.
Especially if you use Liferay's Plugins SDK (you don't state if you do or if you don't). If you indeed use it, you might want to try the Ant target direct-deploy for building the WAR file: The result of this should be able to deploy directly to tomcat. I'm assuming that STS omits the Liferay deployment process (and direct-deploy would mimic it). I hope (from memory) that it was available on 6.1 already.
Can't go without the hint that you should upgrade.

How to pass on changements on server without to be forced to build manually all sub-modules changed?

Hello all !
In my team we currently use Eclipse but I am not satisfied and I wanted to discover netbeans (8 version). It seems very nice. There is a good management of webprojects( angularJS, requirejs). There is a full integration of maven project and Java EE project, it's free ( not like intelliJ) and it seems more intuitive than eclipse et less strange/magic , more compréhensible (because full integration of maven)
There is a lot of points who could push my team to adopt this IDE but there is a problem,a need that I can not satisfy.
I have maven modules projects with dependency mangement. A parent project (called 'webParent' that contains a reference of a big parent project of the team. 'webParent' also contains a sub project 'WebProject' that is a java Webproject that contains web resources( html, js, css) and a java rest webservice management.
'WebProject' use service by injection dependency of an other project called 'business'. 'business' is a part of an other parent project called 'core'. 'core' contains modules that are 'business' (business services of application), 'dataAccess' (gather all DAO), 'External' (gather all external webservice) and 'Authent' (authentication ..).
All these core modules are linked.
'business' need => 'dataAccess' , 'External', 'Authent'
'External' need => 'dataAccess'
'Authent' need => 'dataAccess'
Netbeans has perfectly integrated my project, no problem with that.
I could perfectly use my previous jboss install. Netbeans and jboss work perfectly together. but my problem is that my modifications are not take in account by jboss on redeploy.
I have installed this plugin in my webproject https://docs.jboss.org/jbossas/7/plugins/maven/latest/
Indeed it work fine. When I need to redeploy my project I launch jboss-as:redeploy and a war is regenerated and sent to jboss. Jboss restart speedly and it's cool. But if I modify the java code
in my sub-modules (ex: business) I am forced to click on build button (the hammer) on each sub project I modified. Wait that build say "nothing to compile (indeed the compile on save is checked for all project), regeneration of the jar module"
And I stop on this detail. The "jar". Indeed when I verify my local repository my module jar is not changed with compile on save, it's just the target folder of the project that is modified.
So when I launch the redeploy, the plugin launch the build of my webproject who search my modules jars on my local repository. And take a version not modified ..
This problem slowed a lot the developpement and because of it my team will never use netbeans in the future..
The other problem is that I am forced to lauch jboss-as:redeploy to redeploy web ressource (html, css, js) . For me its should be automatically repercuted on my server. But the problem is that jboss use a war that is generated on install.. What's the solution ? With eclipse it's not based entirely on maven (not cool) but the repercution of modification is very speed ( cool)
Help me to stay on netbeans ! ;)

Integrating JRebel with custom Ant/Ivy/Tomcat web application with Spring MVC

I am trying to get JRebel working with a fairly large enterprise web application which uses Ant + Ivy for building/dependency management, Spring 2.0 framework and Spring MVC, and all this has to be built and deployed to Tomcat.
I have JRebel enabled on Tomcat and the Project itself. Remoting is not enabled as I assume that if Tomcat and the project are on the same machine, this is not needed. When I start the Tomcat server from within STS, JRebel appears to load fine and I see no (apparent) significant errors.
However, any changes to the project do nothing with regard to deployment, and I see no JRebel messages in the console. The project itself is a somewhat nonstandard layout and does not have the traditional WEB-INF/src structure. When I enabled JRebel on it within STS, it just dumped a rebel.xml file in the root directory.
For reference, the project is based on this codebase and has the same general structure: https://github.com/NCIP/c3pr/tree/master/codebase
While the JRebel guides are good, they only show JRebel being used with very simple projects and do not go into very much depth into exactly how the service works.
Any suggestions, resources, or ideas are greatly appreciated.
thanks
Did you actually recompile (doesn't matter if you use Eclipse or javac) those classes that you changed? It might be a good idea to check if you have "Build automatically" enabled under the "Project" menu.
They way how JRebel works is that it actually monitors the compiler output folder (usually "bin" folder or "build/classes" or something similar).
This folder (or folders) is specified in the rebel.xml file and the file must be in the classpath of your application while you run it (WEB-INF/classes or on the jar file root or in the exploded dir).
Can you make sure, that rebel.xml is actually in the applications classpath?
Also, you should see the message in the console that says something like:
"JRebel: Directory '/path/to/project/bin' will be monitored for changes.".
And also, if you see the JRebel banner in your console, it is useful to check if the license is found (if it is not found then JRebel will not work).
Sometimes there may also be some mismatch when your Eclipse compiles classes to the "bin" folder and your build scripts compile them to under "build/classes" and only one of these locations is specified in the rebel.xml file. In this case, JRebel will monitor only one of them and then it is confusing too.
Wishing the best,
Sigmar

Update dependencies while in hosted mode in GWT

I have a GWT webapp split into two Maven projects where one is a dependency to the other. Each time I change something in the dependency and I'm running webapp in hosted mode I have to rebuild the subproject and restart hosted mode for changes to apply. It takes a lot of time so I'd like to ask you if there is any way to make GWT using "live" version of the dependency?
There are 2 cases:
for server-side code, assuming you use the DevMode's embedded server, rebuilding the app and then refreshing the server should be enough
for client-side code, AFAICT, you have to use the source and output directories of the dependency module rather than the JAR containing them (GWT will load the source from the classpath, but apparently it'll only see the modified sources if it comes from a folder rather than a JAR; at least that's what I found in my tests). This goes against The Maven Way™ but the only solution so far is to use a special profile that will import the sources of the dependency project as sources of the project you're running. You can see examples of that in my archetypes.
There's actually a bug opened for the gwt-maven-plugin, MGWT-332, to do that automatically when running a reactor build. I also mused about what's really needed, for the forthcoming official gwt-maven-plugin (rewritten from scratch, independent from the CodeHaus Mojo plugin).
If your dependency does not come from a reactor build, then you're out on your own: you chose to make it totally distinct, so that's how it'll behave: you'll have to release it (even a snapshot) each time you make a change to it, and use the new version in your app (which means re-launching the DevMode).
This can be circumvented by running DevMode on your own, without the help of the gwt-maven-plugin. You're left on your own managing the classpath though (using the Google Plugin for Eclipse, I suppose you could simply edit the launch configuration to add the source folders of your dependency project to the classpath, before the classpath provided by Maven, that would reference the JAR).
Remove the dependent other application jar file from the primary application lib folder under webapp.
Eclipse should then resolve the dependency using the other project in the workspace if you have added it to your primary application classpath.
As GWT build takes ages, we invested some money in a JRebel license. We have two separate Eclipse projects for our back-end and our GWT front-end. JRebel reloads the classes automatically and I never need to restart my local server while writing code. It proved to be a wonderful time saver. Definitely worth the investment.

Deploy a Maven application in IntelliJ 12 without building with Maven

I have problem with configuration of maven project in IntelliJ. I deploy my application to JBoss, when I start JBoss server via IntelliJ, application is deployed without any additional actions, but when I try to redeploy application after some changes, IntelliJ try to make project with it's own make process, and it fails. I have to make project via maven and restart server to redeploy application. Can I somehow tell intelliJ to use maven while redeploy application? I cannot see such option in Run/Debug configuration window.
I think you are using exploded artefacts (present icon) Server, Deployment Section. Right?
There you can choose the external artefact and disable the make flag.
I always using exploded artefacts, because of the hot code deployment. So I do no need to deploy artefacts again and again.
Please be aware if there is already an artefact (e.g. foobar.war) in the same location (maven target directory), you have to change the name of the exploded artefact (e.g. foobarE.war). Idea is creating a folder named foobarE.war.

Resources