views:

75

answers:

4

I love Java. It's great. In fact, I think Java code is just down right sexy! But, there are several things I hate about writing Java web apps:

  1. So many configuration files. I have yet to find a server/container/framework/etc that allows me not to have to create a web.xml. And frameworks only ever add to this complexity.

  2. I love the way PHP works. You drop files into a directory, and you can immediately browse them. Why can't Java do this? Java has perfectly fine reflection abilities to handle this. So why can't I drop a couple .class files into a directory, and then be able to immediately browse them? (I know tomcat can deploy from a directory, but that leads to....)

  3. And like PHP, why do I have to restart the server every time I want to redeploy an app? (Glassfish can do hot deploys, but I still have to package it into a .war file)

So, my question is: Is there any use, or and existing solution, for a Java server; that allows you to drop simple POJOs into a directory, and be able to immediately browse them? In essence, I want every thing PHP has, just in Java. Any thoughts?

+3  A: 

Grails may address some of your needs. It favours convention over configuration (like RoR). I think the hot deploy issue is not as sealess as you'd like, however.

If your major concern is writing web.xmls and similar, you can always embed a web container (say, Jetty) into your application and configure it programatically. But (I suspect) that's probably not how you're thinking.

Brian Agnew
Thank you so much Brian. I think this is exactly what I was looking for!
Kevin Hicks
A: 

When you develop inside an IDE in debug mode like Eclipse, just saving the file will recompile it and update the definition inside the JVM (if possible) giving you what you want.

I believe Resin can hot update changes in classes/ but haven't tried lately.

Thorbjørn Ravn Andersen
+1  A: 

From more traditional Java web frameworks Wicket requires the least amount of external configuration. In fact here's the full web.xml content for running Wicket-based web application in deployment mode (taken from here and slightly modified):

<web-app>
    <display-name>Wicket Examples</display-name>
    <filter>
        <filter-name>HelloWorldApplication</filter-name>
        <filter-class>org.apache.wicket.protocol.http.WicketFilter</filter-class>
        <init-param>
          <param-name>applicationClassName</param-name>
          <param-value>org.apache.wicket.examples.helloworld.HelloWorldApplication</param-value>
        </init-param>
        <init-param>
          <param-name>configuration</param-name>
          <param-value>deployment</param-value>
        </init-param>
    </filter>
    <filter-mapping>
        <filter-name>HelloWorldApplication</filter-name>
        <url-pattern>/*</url-pattern>
    </filter-mapping>
</web-app>

If you enjoy Spring, you can actually make your Wicket application Spring applicationcontext aware which means your web.xml configuration would then have only the configs for Spring's listener which is just couple of lines.

Esko
the least? please don't lie in favor of your own preferred framework. take a look at other frameworks (restlet, tapestry, ...). they just need the same amount of configuration. objectivity is important!
Stefan De Boey
@bste: Restlet's Hello World web.xml conf: http://www.restlet.org/documentation/1.1/firstSteps - almost twice as long as Wicket's. Tapestry: http://tapestry.apache.org/tapestry5/tutorial1/first.html - about equal in both size and complexity, in fact seems like it's 1:1 with Wicket's config. I do believe what I said still stands even with these examples.
Esko
+2  A: 

1 So many configuration files. I have yet to find a server/container/framework/etc that allows me not to have to create a web.xml. And frameworks only ever add to this complexity.

Since the new Java EE 6 annotations there's no need for web.xml anymore. Give it a look. As Java EE 6 is relatively new (released 10 Dec 2009), existing frameworks are yet to be upgraded to comply this.

2 I love the way PHP works. You drop files into a directory, and you can immediately browse them. Why can't Java do this? Java has perfectly fine reflection abilities to handle this. So why can't I drop a couple .class files into a directory, and then be able to immediately browse them? (I know tomcat can deploy from a directory, but that leads to....)

You need to enable hotdeploy/autodeploy of the server in question. You'll need to elaborate more about "but that leads to..." so that it can be fixed.

3 And like PHP, why do I have to restart the server every time I want to redeploy an app? (Glassfish can do hot deploys, but I still have to package it into a .war file)

You need an IDE with a good server plugin. In Eclipse with the Glassfish plugin, I really didn't have any need to restart the server for any hiccup.

BalusC