How to reduce time to wait for deploying webapp in Netbeans? - netbeans

Recently I've moved to Java Enterprise world. I use Netbeans IDE with Tomcat to develop my webapp. I faced a problem that it takes long time to deploy the webapp. When I change some code, netbeans requires re-deployment to make changes applied.
I did search around this problem and I found JRebel (which helps us apply code change quickly), but it is not free.
Can you tell me how to apply code changes quickly (freely)? And how to reduce deployment time in Netbeans?
Thank you very much,
Khuong Dao.

Related

Turnaround Time in Spring JBoss Eclipse

I am currently writing a site in Spring, Thymeleaf, JBoss and I am using Spring Tool Suite. The turnaround time is horrible. I have to recompile and package the app, every time I make a change and then push it out to the server. How to make my turnaround time quicker?
Try JRebel. You can get it free if you spread some social media love for them.
http://zeroturnaround.com/software/jrebel/
Consider using a tool which supports continuous integration, and which supports working on an exploded war file.
For example, sbt supports that mode. It integrates jetty, and the webapp is restarted, if a source file changes (resources like .html, .css and .jsp do not restart the container).
As for details look here: Eclipse + Tomcat - Serve webapp directly from workspace. This question shows other possibilities as well.
If you use EJB features like session beans, you can split your project. If the EJB and pressentation is kept separate, the turn around times for redeploying EJB ears are acceptable.

JBoss ejb3.0 instant hot deployment

I am newbie with jboss-eclipse. I have to work on javaEE5 with JBoss AS 5.1.0.GA. I don't want to use JRebel at the moment.
I installed "Eclipse Java EE IDE" with "JBoss Tools". I added the JBoss 5.1 Runtime server on eclipse and added a new ear project with :
an EJB3.0 class in ejb project;
a javabean class and index.jsp in web project.
I noticed when I make a modification in the jsp file, I can see instantly the changes after refreshing the web browser. That's ok.
When I modify EJB and javabean classes, there is no instant hot deployment. I have to restart the ear application (without restrating jboss server) or "full publish" the ear via eclipse to see changes.
Is there any way to have instant hot deployement for EJB and javabeans?
PS: I tried "incremental" publish but it hasn't worked.
Thank you!
You do need 3rd party tools for that, the most notable being JRebel. Without advertising I have to say this tool has saved me lots and lots of hours already while developing EE applications.
In jboss AS 7.1.1 you just have to go to the as admin console at localhost:9990 and select: Profile -> Core -> Deployment Scanners -> Auto-Deploy Exploded . You might also want to change the scan interval to something smaller. Afterwards, you may deploy your application for the first time by selecting "Run on Server". From this time on, your application will get automatically deployed whenever you change a file and it manages to compile.
I do not know if Jboss 5.1 has this feature, and if I were you I'd consider using 7.1.1 for development when it does not have it.
The hot deployment works fine with JBoss when publishing new files in your deploy folder, only class exchange will not happen in your currently deployed application.
That's why you see changes to all static content like HTML files immediately, but not changes to your java code.
In order to do activate them, you'll have to restart your application (not the whole JBoss, only your application, done for example in JBoss server view).
I have no practical experience with JRebel and I do believe that it saves you time, but you have to be careful with such tools, as they can introduce new problems which you spend much times in debugging, ending up in restarting the container and everything works fine.

Java EE 6 + CDI on JBoss 7 - hot deployment possible like in Seam?

I did several projects using Seam 2 on JBoss5/6 and liked the feature that certain java classes (usually GUI handlers and util classes) could be put in a special src folder and be hot replaced through a special class loader after saving the file and an explode target running automatically afterwards.
Now I like to switch to Java EE 6 + CDI and use JBoss7, so I started with a maven based Java EE web project generated by JBoss tools in eclipse Juno. If I only change xhtml files, I can see the changes after the automatic re-publish, but not so with changes in java files.
Is there a way to get a similar behaviour in my new project setup than I had before with Seam 2 without using 3rd party tools like JRebel?
Edit 2012/07/23:
I add another point to the question - with newer containers like JBoss7, restart of an application seems to go quite fast - so is it even necessary trying to integrate code replacement tools and hoping for the best?
When I evaluated JRebel about a year ago for that stack (Java EE 6 / CDI / JBoss AS 6), even that tool did not cope with CDI. This might have improved in the last 12 months, but generally speaking:
I'm not aware of any advanced hot-deployment support of Java EE 6 on JBoss AS, with or without tooling support.
(If you read the thread to the end the situation seems to be better for GF, but that's out of the scope of your question)
Take a look at JRebel. CDI parts are constantly being improved and although there's still a way to go, it can be quite a time saver. If you find the cases when JRebel fails to deliver, report at the forum and the devs will do their best to improve the experience.
In regards to the second question, even if container startup takes no time, like in case of Tomcat or Jetty, the application deployment time will not get much faster and might still take considerable amount of time.
So the answer is - yes - code replacement tools are still relevant even with the lightweight containers.

JavaEE Build tools: Eclipse, Maven, Whatever

I have a newbie question...
I started learning java web development with eclipse (because it takes too much time to compile and put classes into corresponding directories). Actually, eclipse possesses every tool to develop anything there.
But a few days ago I realized that in the books I read about javaEE development eclipse is not even touched upon or referenced - everything the author does is using such tools as Maven, JUnit...
So I started wondering - maybe not learning Maven I am missing something out?
What is it used for (except structuring of the application), what are its benefits over eclipse? Which IDE`s do developers in companies use to create and deploy javaEE applications? If Maven is used, how do they type the program itself - in Notepad?
I think you have a real mess in terms. So here are some quick tips:
Eclipse is an IDE, you have that right.
Maven is many things but not an IDE - it can help you manage dependencies, build process etc.
JUnit is a testing framework.
All of them can be used together in Eclipse and you can write your code as usual. These tools just help you with some repetitive tasks.
I recommend you not to use Notepad for Java development and suggest you to read this article.

Speeding up Eclipse and JSF+Tomcat development

Is there any way I can speed up the development of JSF in Eclipse and Tomcat?
Basically I'm looking for a way to make the client-side changes (.jsf, .html, .css, .js) to happen a lot faster, and with out having to restart tomcat.
And if possible, also a way to make tomcat (or any other Windows + Eclipse compatible Servlet Container), restart a lot faster.
Because if I compare to my experience with ASP.NET/Visual Studio/IIS, it feels like I'm spending half the day waiting for Tomcat to restart, and sometimes I even get 404 in the browser, since it's not going fast enough.
There MUST be some other way to be more productive, and still allow more test driven development.
Just in case you use Maven to build your project, you can use this command line to test in Tomcat:
mvn clean war:exploded tomcat:run
That will run a slim instance of Tomcat (tomcat:run) taking the changes of your web files (.jsp, .html, .css, .js) directly from the source you're editing (war:exploded), so you'll just hit F5 in your browser
A quick and dirty way to force Tomcat to recompile/reload your pages is to delete Tomcat's working directory. In my limited testing it works fine but obviously, I wouldn't recommend this in production. :)
I believe MyEclipse, if configured correctly, will let you update applications running in Tomcat without restarting Tomcat. It is unfortunately a commercial product though.
Oracle JDeveloper had a copy of OC4J bundled and it was possible to make changes on-the-fly without restarting the container, again this may not be possible given your environment.
If I'm not mistaken you can just copy your client-side changes (.jsf, .html, .css, .js) to the webapps folder of your application, whilst it is running. The jboss J2EE version of Eclipse I'm using allows hot replacement of some java code.
You can use some other container, not tomcat, which not needed to be restarted when you make some changes in you project. It's can be Jboss. Also If you will use some tools, for example JBoss Tools, you develop much faster and easy :-)
As for me, when you make changes just in .css or .xhtml page, you shouldn't restart tomcat, you should just republish you application. In JBoss Tools you can make it using JBoss Tools server view.
put this in your web.xml.
<context-param>
<param-name>facelets.REFRESH_PERIOD</param-name>
<param-value>1</param-value>
</context-param>
This means : "how often will the app server recompile my JSP". The value is in seconds.
You should use Dynamic Web Projects and tell Eclipse Java EE to deploy to a suitable Tomcat instance. This will allow Eclipse to help all it can (but that is still not blazing speed though).