Jan 28 2007

Spring Layout

adam

Over the past 18 months we have been expanding the tag library and Spring MVC extensions that we use to increase our velocity in Web Application development. We always intended to Open Source this stuff as soon as it was mature enough to be easily configured and used by someone without intimate knowledge on how they work and it looks like that time is now just around the corner.

We have a sourceforge project open now here
and will be migrating the source code, documentation and sample application there over the coming week. In general this framework provides integrated tags, much like the struts html tags which provide Spring binding and facilitate 3 modes of display: Read, Edit, and Multi. This allows for form data to be either displayed or provided in an editable format or to be switchable via clicking on the field or label. It provides a tightly integrated, extensible validation framework with simple client side/server side independent or cross field validation with both style sheet and message based error feedback.

In terms of Spring MVC extensions, it provides a Multi-Panel controller which allows for wizard-like multi form data gathering, field level security and controller support special components such as a Datagrid.


Jan 5 2007

Maven 2, MyEclipse & Tomcat Hot Deploy

adam

Recently we have been attempting to move away from manually managing libs for each project and move to a central repository for manging our jars and dependecies. Maven 2 seemed like the ideal tool for this and since it seems to have such a large body of support we thought that it would be reasonably easy to integrate into our current development processes. We even thought we might get quite a bit of leverage out of the other plugins available for Maven 2 which would allow things like automatic site generation for the project and documentation of dependencies.

Unfortunately getting Maven 2 integrated into our current development processes was anything but easy. We usually build Web applications and we use the MyEclipse plugin for eclipse to automate and speed up many of the repetitive tasks. Auto-deploying wars and hot-swapping code is one feature we consider absolutely critical to our rapid development process. The following is a description of how we eventually got this working, and now can in fact get setup quicker than we could our old way.

  1. First make sure that Maven 2 is installed and that it is in the path (see the Maven install instructions if you can find them).
  2. .Configure the M2_REPO variable in Eclipse to point to your maven repository (usually /.m2/repository). This can be configured in Eclipse under windows->preferences->Java->build path->Classpath
  3. Next, I have found that is easier to just follow the Maven folder conventions than to try and get maven to follow yours. This means that the normal src folder becomes src/main/java, all resources and configuration files go in src/main/resources, and the web root becomes src/main/webapp the test tree follows the same structure and becomes src/test/java and src/test/resources. In order for MyEclipse to live with this and do a hot deploy you need to tell the web deployer that your web context root folder is /src/main/webapp, this can be done when you give a project web capabilities but if your project already has web capabilities then you will need to modify the .mymetadata file in order to change it and restart eclipse.
  4. obviously your project needs to have a valid pom.xml in the project root. Under the part of your pom put the following: <plugin>
    <groupid>org.apache.maven.plugins</groupid>
    <artifactid>maven-eclipse-plugin</artifactid>
    <configuration>
    <buildoutputdirectory>src/main/webapp/WEB-INF/classes</buildoutputdirectory>
    <downloadsources>true</downloadsources>
    </configuration>
    </plugin>
  5. this tells eclipse to build to the classes folder under your web root WEB-INF folder (where they need to be for a hot deploy)
  6. Navigate to your project root on the command line and run mvn eclipse:eclipse this should build your .classpath file according to your pom.xml and even attach source code where available.

Most people should be able to hot-deploy as normal now using the MyEclipse server tools, however i have noticed some people have problems with servlet-api.jar and jsp-api.jar conflicts, if that is the case then the following steps should fix that:

  1. Right click on your project and go to the properties>java build path>libraries You will need to look through this list for servlet-api.jar and jsp-api.jar, remove them and add the J2EE library (You will need to do this each time you run the eclipse target or else your servlet-api.jar and jsp-api.jar will get deployed to your web server and may interfere with the one it already has in it’s classpath
  2. Next, still under the project properties item go to MyEclpse->Web->Deployment uncheck the ‘workbench default settings’ and ‘Jars in web Projects user Libraries’

you should now be able to do a normal MyEclipse hot-deploy…