Speeding up Eclipse and JSF+Tomcat development - eclipse

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).

Related

Glassfish: Fast hot deployment setup

What is a good setup for really fast hot deployment of a Java EE application to Glassfish, so the changes are visible in less than e.g. 1 second?
Currently I'm using Eclipse Luna to develop a JSF2.1 application on Glassfish 3.1.2. When I change something in a jsf, a managed bean or an ejb, it takes ages to deploy the changes. I've already found some good advise,
GlassFish (real) hot deployment of JSF pages and resources (CSS etc.) in Eclipse
Glassfish taking 20s to do hot deployment, is that right?
but I don't think I can speed up my setting to get the deployment under e.g. < 1sec. Also I think "directory deployment" is not supported in GF3.
So what setup can you recommend? Should I switch to Netbeans? Or are there any hidden Eclipse settings to speed this up? Or do you reach fast hot deployments with Eclipse Luna and I'm just missing some properties?
Some more information: I have to use GF3.1.2 Furthermore I use maven, the backend jar and the front end war are bundle together in an ear file. I use EJBs and JPA to connect to a DB2 database. So except GF nothing special.
As far as I know, Glassfish does not support hot deployment. You would need something like JRebel to accomplish that. In case you're not bound to glassfish you might consider switching to wildfly or some other AS that supports this feature.

Is it possible to do Hotswapping of ATG classes

The deployment we follow is that we use runAssembler.bat to build an ear file and deploy it in a app server. We are using weblogic and jboss for testing purposes of the modules we built. However for every small change, we need to run runAssembler and build a new ear and deploy it in app server and restart the server.
I would like to find out if anyone figured out a way to do Hotswapping of class files which are generated by the code we write in ATG environment in either weblogic or jboss.
By attaching your IDE to your Application server on the Debug port it is generally possible to do hotswapping. Setting this up on Eclipse and JBoss is documented here, here and here. There is some information for setting it up in WebLogic here.
Attach your debugger, edit the java file, click 'save' and with hot code replacement in your IDE it should now update the running class file. In Eclipse it usually gives a popup if it was unable to do the sync. If you are using Eclipse, make sure the 'Build Automatically' flag under projects is ticked or you'll be waiting forever. I've not had any issues doing this via JBOSS (exploded ATG EAR) and variable success in doing this on WebSphere 7. It may also be prudent to make sure the same JAVAC you use to compile your build is the one loaded into your IDE compile path.
Another way to at least reduce the build/deploy time would be to deploy an unpacked/exploded EAR and simply copy your class files across (you could use the Eclipse FileSync plugin) and restart the server.
There are also some commercial options available, like JRebel
In our organization, we had good success in using DCEVM. It simply patches your JDK (in Windows: jvm.dll).
Download and patch your JDK
Launch your JBoss/Weblogic with the patched JDK
Set up Eclipse's Installed JRE's to point to patched JDK (restart and rebuild once)
Start the server, Launch debugger and connect
Ensure Eclipse's Debug view shows "Dynamic Code Evolution VM" (instead of something like "HotSpot VM")
Change your code, and voila!
You can do this with JRebel. After hotswapping you don't need to restart the server, only reload you deployment from Weblogic.

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.

Tomcat & Eclipse integration

I'm developing on a Ubuntu 8.04 machine using Eclipse Ganymede. I installed Tomcat 5.5 using sudo apt-get install tomcat5.5 tomcat5.5-admin and using an Ant script I deploy my WAR file by copying it to $CATALINA_HOME/webapps.
I then created an Eclipse project and I have it output compiled source in a similar but separate directory structure under $PROJECT_ROOT/target/. I still deploy the WAR file by right clicking on the build.xml and choosing my deploy-war task.
As Tomcat is running as a deamon, automatically started up on booting, I'm not instructing it when to start or exit.
My problems with this setup are:
Using this approach I do not get any output to the Eclipse console, as Tomcat is running under the tomcat55 user and I have a different login and no access to Stdout of tomcat55.
The logging which occurs is also directed to Stdout at the moment, which I find pretty nice during development. But it's not nice when I can't see it. :-)
I don't have any servers under the Server tab and no Run configurations. This makes it impossible for me to use the Debug mode of Eclipse, which otherwise is quite convenient.
What do you think I should do to integrate them and in turn make my development environment much better?
I'd say forget the pre-packaged Tomcat. Grab the apache-tomcat-x.y.z.zip from the site, unzip it somewhere in your $HOME and add a Server to your eclipse workspace, pointing to your local installation of tomcat. Of course you need the j2ee/wtp Eclipse bundle. Works fine on Windows, can't see a reason for it not working on Linux.
Edit: You may have to fiddle with server ports if you have two tomcat installs.
Add Tomcat to the list of Eclipse servers and run your web-app on the server. If you need more details click here.
I never cared about 1 and 2, so I can't really help you with them.
regarding 3:
You don't need any servers under the server tab for debugging to work. Just start tomcat with these environment variables
export JPDA_ADDRESS=8000
export JPDA_TRANSPORT=dt_socket
and configure eclipse accordingly: run - open debug dialog - select remote java app and create a new configuration.
You need eclipse to manage a copy of tomcat, then it can debug it. The clue to the problem was that you have to push deploy-war, this means the files are leaving your development environment and entering an external server. On a properly configured development environment, you only need to save your java file, it will auto-compile and already be on the local tomcat install, which might try to auto reload the web-app, and you can refresh your browser without reloading anything on the server. Look up some more tomcat plugins, there are a few different ways to do this.
If you want to do regular debugging and relaunching of Tomcat apps, you might want to take a look at MyEclipse - it can make things a lot easier.