What is the most efficient way to develop Java webapps? Or to be more specific, say Wicket apps?
this is my first time to post a question here, I will try to make my question as clear as possible.
I try to find a best process to develop Java webapps. After months of trial and error, my web development environment is made up by the following parts:
framework: Apache Wicket 1.4.16
IDE: eclipse Galileo, with m2eclipse plugin Build Tools:Maven 2 Data Access: EclipseLink 2.1.1 via JPA 2.0(with StaticWeave) RDBMS: MSSQL 2005 or above with jTDS DI: Google Guice 2.0 developing web container: Jetty server embedded in Maven Jetty plugin. Target web container: Tomcat 6.x or aboveI use maven Jetty plugin to test run my webapps, enable JPDA while line precision tracing is required.
Whenever a change is made to the source codes, I have to reload my app to take effect. press ENTER to reload is ok, but after several times of reloads(about 3~5 depends on my PermGen settings), OutOfMemoryException is thrown, than I have to shut down and start up my app again. I know auto reload can be achieved by configuration, but it only leads to OOME faster(due to excess reloads).
After googling I realize that there are rel开发者_JAVA百科ated to some memory leak problems. I've tried enlarge MaxPermSize settings, but RAM on my rig is limited, and it's not reasonable to set to something really big. BTW, Memory leak detection is introduced in Tomcat 7, and I found most memory leaks are from jTDS, Google Guice and Wicket itself, but I can do nothing about it.
Is there anything I can do accelerate my developing process? In order to reduce reload times should I move to a more advanced web container like Glassfish(sorry I can't afford a WebLogic or WebSphere here.) or anything.
Thanks in advance, any comments are welcome!
I use JRebel, it really helps a lot. I still have to restart the server now and then, but most changes just work. It's a perfect fit to a Java-centric framework like Wicket. You could also try DCEVM, if you can have a 'hacked' version of the JDK for development.
I have simple Jetty wrapper for starting webapp in eclipse. If I start it in debug mode then no reload is needed unless I change method signatures or field names. No context reloading is needed.
import org.eclipse.jetty.server.Server;
import org.eclipse.jetty.webapp.WebAppContext;
public static void main(String[] args) {
Properties properties= ...//read properties from text file
Server server = new Server(properties.getPort());
WebAppContext webapp = new WebAppContext(
properties.getWebApplicationPath(), properties.getContextPath());
server.start();
//.... and here can be key capture for stopping Jetty
}
where properties.getWebApplicationPath() is ./WebContent (or maybe sth different depending on your maven project structure).
This doesn't resolve memory leaks when deploying in Tomcat, but can be very helpful in development process. I'm also using Wicket and Guice and I didn't noticed memory leaks.
精彩评论