Akshat

What is he upto now?

Blank.war, only with logging, spring, JSF, Jetty and Acegi.

Here is a nice little blank.war all ready for your creative juices to draw a pretty picture on. As an added little something, it has Spring, Log4J, JSF 2, Jetty and basic Acegi security thrown in the mix. Plus, it’s all managed by good ol’ Maven. Yes people, this is your lucky day.

Download the project files here.

Here is what I did to create the war using the latest Java, Eclipse with M2Eclipse and Maven.

  1. Create the project
    1. Fire up eclipse. Create a new Maven project (Skip archetype selection, enter groupId and artifact Id and click finish).
  2. Set the dependencies
    Add the dependencies for JSF, Servlets, log4J, spring framework and acegi.


    com.sun.faces
    jsf-api
    2.0.3-SNAPSHOT


    com.sun.faces
    jsf-impl
    2.0.3-SNAPSHOT


    javax.servlet
    servlet-api
    2.5
    compile


    javax.servlet
    jstl
    1.2


    log4j
    log4j
    1.2.16


    org.springframework
    spring
    2.5.6


    acegisecurity
    acegi-security
    1.0.0
    compile

  3. Add the plugins
    Add jetty-maven-plugin and maven-compiler-plugin
  4. Tweak the plugins
    We added the maven-compiler plugin because we wanted to change the default location of generated class files. You see, the jetty plugin uses various source directory while running so we can quickly turn it on or off, and edit pages as we run them without having to package a war every time. Jetty is able to pick up the right classes, however the Faces annotation provider only seems to look in WEB-INF\classes folder, which ofcourse doesn’t exist until a war is actually packaged inside the target folder. So, we put our classes where the annotation provider is looking for them. That is, in the WEB -INF\classes folder of the source directory. This is against the Maven convention, but this gets the boat rowed without harming anyone. So, we put this line in the compiler plugin:
    src/main/webapp/WEB-INF/classes
    (See Tomasz Lipinski’s post at https://bugs.eclipse.org/bugs/show_bug.cgi?id=288243)
  5. Add log4J (in the resources directory).
  6. Add web.xml, telling spring to look for all files with name like *-spring-config.xml in the classpath. This helps us separate our short spring-beans configuration, and the onerous acegi configuration files.
  7. Even though we use annotations to define our managed beans, we still need faces-config file to define the delegationg variable resolver to make our spring beans accessible to our faces managed beans. I use Spring for my services and faces for my managed beans in the view.
  8. See the acegi tutorial for acegi configuration.
July 5th, 2010 by Akshat
Posted in Tech | No Comments »

Installing MS Virtual PC. All for Java

I’m installing Ubuntu on MS Virtual PC as I write this. Why am I doing it? Because the application I work on at work runs off Java 1.4 (as does our weblogic version). Whereas, all the new libraries, IDEs and stuff run off Java 1.6 (or 1.5 at least). I tried a couple of things, but to no avail. So, I finally decided to install Ubuntu.

What will I do with the new Java version? Pay with JSF 1.2, and 2 for starters. Get a copy of Tomcat which is not about half a century old, and run the latest and greatest eclipse. Doing all this on a 2GB Latitude D610? Now that is folly.

Does anyone else have an idea, about having mutiple Java versions on the same machine? Let me know.

February 13th, 2010 by Akshat
Posted in Tech | No Comments »