Can I update the HTML files using Wicket and Eclipse without recompiling the classes? - eclipse

I'm using Eclipse and Maven-2 and I'd like to be able to edit my HTML files without "it" (not sure if it's Eclipse or Maven) recompiling my application. I understand that usually Eclipse tries to do a hot replace of new compiled Java classes with Eclipse and Tomcat.
Can I use something like this?
getResourceSettings().setResourcePollFrequency(null);
I know I can turn auto update off for Tomcat in Eclipse but I'd like the HTML file to update and the classes not to update if possible.
BTW, my primary concern is that Tomcat tends to get Perm gen errors after I (hot) reload too many java classes.

You're sort of correct, you're supposed to use setResourcePollFrequency(Duration.ONE_SECOND); or similar. This link has more detailed information. However what I've found is that due to Wicket's caching internal cache containers like to get really messed up after any hotswapping so you may just have to learn the hotkey for restarting Tomcat or start doing Wicket development with the integrated Jetty and WicketTester.

You may want to consider increasing the permgen space when you run eclipse. There is a command line argument:
eclipse [normal arguments] -vmargs -XX:PermSize=64M -XX:MaxPermSize=128M
(copied from:)
http://wiki.eclipse.org/FAQ_How_do_I_increase_the_permgen_size_available_to_Eclipse%3F
I am not sure offhand how to prevent wicket from reloading HTML files but I will see if I can find it.
Edit:
If setting the poll frequency to null doesn't work, try using Duration.MAXIMUM. Also, you can uncheck "Build Automatically" in the eclipse Project menu, though this is more of a hassle then it's worth, IMHO.
According to the wicket FAQ, wicket only reloads changed markup files when you explicitly set the resource poll frequency:
http://www.wicketframework.org/faqs.html
I am not sure how to prevent eclipse from copying altered files to the output aside from disabling build automatically.

If Build Automatically is enabled (it is by default: Project->Build Automatically) then any modification to the project files will trigger the build, regardless of whether they are in source folders or not.
I always work with Build Automatically disabled as I find it too intrusive (for reasons like this), and just hit ctrl-B when I want the project to build, or alt-P N to launch the clean dialog if needed.

I understand you're using (and might want to keep using) Tomcat, but during Wicket development you can run the supplied Jetty server onder /src/test/java/com/your/package/Start.java in debug mode to get this behaviour.. Set Wicket to development mode to use this feature.

HTML files or jsp files?
Are you using tomcat? If you are editing only html files, go ahead and change them as you wish. As long as you don't deploy them somewhere else for tomcat to fetch them, you'll see the update(s).
If it's jsp, save your new file, delete the files under the old work folder. This will make tomcat think it's the first time the file is requested and it will re-compile the jsp on the fly.

Related

Eclipse, maven, tapestry, tomcat auto load

I'm running eclipse mars EE. I have a maven project with tapestry 5.4.1. I have tomcat 7 maven plugin and everything is working fine except I'm not able to immediately see changes to tml and css files. When I make a change to any file it's eventually reloaded but it takes time which slows development. I want to be able to see css and tml changes instantly. I can wait for java changes until tomcat reloads them but I can't wait for css and tml changes.
I've read several articles on configuring the tomcat server within eclipse including this stackoverflow entry
However, they don't seem to work or achieve what I want. It seems the issue lies in the fact that tomcat has to wait for a new jar/war to be created and deployed instead of pulling the files directly from the project.
Also, I'm aware of Tapestry's class reloading feature....which doesn't seem to work either. Perhaps my project isn't configured correctly? Here is a screen shot of my project
There MUST be a way to accomplish this. We've all been writing web apps for tomcat in eclipse for 15 years!
Thanks for your help!
It sounds like you may have several issues that are described in the "Troubleshooting Live Class Reloading" section at the bottom of the https://tapestry.apache.org/class-reloading.html page. Please read the Tomcat-specific help at http://www.tynamo.org/Developing+with+Tomcat+and+Eclipse/ if you haven't already.

Getting Eclipse to automatically reload the JSP pages in my Java web application

I was given a template of a Struts project to work on, and I noticed that when I run the web project on integrated Tomcat in Eclipse and make changes to the .jsp viewpages, they don't automatically reload after a few seconds - which does happen in other projects I made myself.
So I figured this was a configuration issue and I did some research, I had a look at my Tomcat server settings:
(x) Automatically publish when resources change (1 second interval)
But because my own projects reload and I use the same server for them, I figured it must be an application specific issue.
So I looked at context.xml to see if there was anything to change here
<Context
...
reloadable="true"
...
>
Which I can only assume tells the server to indeed reload the application on changes.
So I really can't figure it out. It seems to me like everything is in order here. What am I missing?
From Apache Tomcat documentation about the Context attributes:
reloadable
Set to true if you want Catalina to monitor classes in
/WEB-INF/classes/ and /WEB-INF/lib for changes, and automatically
reload the web application if a change is detected. This feature is
very useful during application development, but it requires
significant runtime overhead and is not recommended for use on
deployed production applications. That's why the default setting for
this attribute is false. You can use the Manager web application,
however, to trigger reloads of deployed applications on demand.
Also maybe this will be interesting for you: Using Tomcat Reload Features To Speed Up Development
I ran into the same problem, with a Java/Spring project that I imported via its Maven .pom files into Eclipse.
I found that I had to run the project with "Debug" instead of "Run" - only then, changes to my .jsp files were noticed, so that a reload of the web page would show the changes almost instantly.

Is it a waste of time to use "Build Automatically" option for Java projects in Eclipse?

I'm developing J2EE webapps in Eclipse (RAD, actually). I've always used the "Project > Build automatically" option. However, I noticed that this isn't always necessary because Eclipse seems to push out changes to my server when I save a file. This works great but I'm wondering why this would be checked by default.
I can think of a few times when it makes sense to fully build and deploy the app:
After changing a XML configuation file that gets loaded at app startup (application.xml, web.xml, bean configuration xml files, etc)
After changing a static variable on a class
Other than this, I can't think of other times when it would be crucial (or useful) to enable the build automatically option. Am I incorrect in my above assumptions? Am I just wasting a bunch of time by building automatically??
The automatic build compiles in the first-place. You can disable the automatic publishing (see screen) if you double-click on the server in the server-view. The automatic publishing has nothing to do with automatic build.

Controlling catalina_home in liferay eclipse tomcat

I have a development system ( linux-Liferay6-tomcat6-Eclipse Helios) that I have version-controlled in SVN. When I roll it out for a new developer in what amounts to a fresh installation, the paths for the tomcat server are wrong because they were written in various places as absolute paths reflecting my desktop.
It looks to me that I could modify catalina.sh or startup.sh to fix this problem, or part of it maybe, but I'd rather have a fix that leaves Tomcat unmolested. I could also require developers to set CATALINA_HOME, but that would break any other tomcat installations they might have ( my own situation in fact).
For instance, maybe a custom Ant script that figures out the path and sets CATALINA_HOME just for the shell thats running this particular Tomcat? Is there a way to do this in the Eclipse IDE, I looked but don't quite see it?
Ideas?
John Fisher
If you're using ant and the liferay plugins sdk, you're supposed to create a build.${username}.properties file in the root folder of the plugins sdk. (substitute ${username} with the name you log in to your OS). In this you override the location of your appserver, e.g. tomcat. Take a look at build.properties. Though you're not supposed to change this file, you can copy the one interesting line (note: it's preconfigured for tomcat) and use it for the appropriate settings.
This way you'll have a per-user setting for the required value.
The server (if you require to start it in eclipse) is to be created in each eclipse instance, independent of each other. The Liferay IDE plugins for eclipse can help you with setting this up.
As I expect the server to be modified by everybody on a frequent basis, I never share the server "project" in version control, but keep it strictly local. It's easily recreated if lost.

JBOSS Eclipse Integration

I am working with Eclipse and JBOSS. I was wondering if there is a way to do hot in-place deployment for a web project, by integrating the JBOSS server with Eclipse.
By hot in-place deployment, I mean, I should be able to view the change made to a jsp , by refreshing the page on the browser, not required to go through the routine , build-deploy-test cycle.
Take a look at JBoss Tools. That has everything you need.
JBoss Tools seems to do auto-redeploy by default when you create a web application with their wizard: http://docs.jboss.org/tools/3.1.0.CR1/en/GettingStartedGuide/html/jsp_application.html#AutoRedeploy
AFAIK every time you save a JSP they copy it to the application deploy directory in JBoss, but if your source layout matches the WAR layout they might run the application directly from your project directory (I know some versions of WTP did this with Tomcat, but with JBoss it's probably harder).
You are after "Exploded Hot Deployment" - deploys a directory of your files rather than an archive and then any subsequent "explode" will only deploy changes rather than the whole project (depending on how you have Ant configured).
Frameworks like Seam do this for you. Maybe worth grabbing a build.xml file from them and modifying it for your use?
Have you tried using JSP-Weaver?
Here is the Wikipedia description:
JSP Weaver is a JavaServer Pages
interpreter. Unlike JSP compilers it
evaluates the JSP files directly,
without generating or compiling
intermediate Java source files for the
JSP Java servlet.
Although this sacrifices some
performance on page rendering (10%-20%
overhead depending on the compiler in
question) it enables a much faster
reloading of changes made to the
source of the JSP file (10-20 times
decrease in time depending on the page
and the compiler in question).
Unlike simpler attempts at
interpreting JSP-like syntax (e.g.
Facelets) it supports embedded Java
statements called Scriptlets (a
standard JSP feature). This allows
full compatibility with the JSP
specification versions 1.0 to 2.1.
I also agree with Sietse in you should check out JBoss Tools. It is a great free alternative to the JBoss Developer Studio