Annotation Driven JSF-Spring-JPA-Spring Security-Orchestra

On my way to combine my favorite frameworks together, I posted an example application called moviestore demonstrating the annotation driven integration of JSF(Facelets)-Spring-JPA. .
Lately I’ve added Spring-Security and Apache MyFaces Orchestra to this formula to fix the missing parts for security and conversation-workflow management.

Here’s the final contents of moviestore;
- JSF with Facelets, Apache MyFaces 1.2 impl
- Spring 2.5.x
- JPA with Toplink
- Spring Security
- Apache MyFaces Orchestra

with jetty and hsqldb

The example contains two modes of new movie entity creation, one is done on single page and the other is the wizard mode and consists of 3 pages.Thanks to MyFaces Orchestra, creating wizards, flowScopes, viewScopes are no-brainer. Best part is that you dont get Lazy Exception since Orchestra manages the entity manager per conversation rescuing us from the openblablainviewfilter pattern. If you’re still not using Orchestra, give it a try, it’ll make your life much easier, simply request or session scope both are not enough for web applications and Orchestra is a life-saver. Again Persistence support
is a fantastic bonus.

Other addition to the moviestore example is the spring-security formerly known as acegi. I really liked the new namespace support, considering the number of xml lines with Acegi, Spring-Security is fun to use.

You can download the moviestore here. It uses in memory db and jetty so just running
mvn jetty:run is enough to test the moviestore in action. By the way,

username: tony
password: 55555

About these ads

14 Responses to Annotation Driven JSF-Spring-JPA-Spring Security-Orchestra

  1. Pingback: Annotation Driven JSF-Spring-JPA-Spring Security-Orchestra « Cagatay Civici’s Weblog

  2. Angel says:

    Hi Cagatay!

    Thank you very much for the example given. I will have a look at it ASAP.

    I would like to know if you have received an email I sent you to the email address: “cagatay.civici@gmail.com”

    It is just because I would appreciate your opinion.

    Thanks again.

    Kind regards.

  3. Looks like you were able to get rid of your Orchestra-related errors, you were posting on the mailing list, right?

    Anyway, I totally agree, that Orchestra is worth to try!

  4. Kaan says:

    Hi Cagatay,

    Thanks for the example.

    Is it possible to annotate a Converter as a spring managed bean so that i can access to my service classes which make use of DAO’s?

    And do you think is it a good idea to do that just to set my parent model’s child object(Please see the jsf fragment below)?

    I can also add a field like `selectedChild` which is String, so no problem will occur but I do not wantthat field in my model object and i do not want to use a value object.

    (note owner is an User.)

  5. Kaan says:

    Hi Cagatay,

    Thanks for the example.

    Is it possible to annotate a Converter as a spring managed bean so that i can access to my service classes which make use of DAO’s?

    And do you think is it a good idea to do that just to set my parent model’s child object(Please see the jsf fragment below)?

    I can also add a field like `selectedChild` which is String, so no problem will occur but I do not wantthat field in my model object and i do not want to use a value object.

    (note owner is an User.)

    Kind regards.

  6. Matt says:

    Note, that one receives build failure using JDK 1.5, due to import of javax.annotation.PostConstruct from ViewMovie.java.

    I believe one needs to download common-annotations.jar

    http://weblogs.java.net/blog/seemarich/archive/2007/11/annotation_base_1.html

  7. Matt says:

    I obtained the common-annotations.jar file from spring-framework-2.5.5-with-dependencies.zip (lib/j2ee folder).

    I installed it using the command:

    mvn install:install-file
    -Dfile=./common-annotations.jar
    -DgroupId=javax
    -DartifactId=annotation
    -Dversion=1
    -Dpackaging=jar

    Add then added the following dependency to the pom …

    javax
    annotation
    1

  8. Matt says:

    javax
    annotation
    1

  9. Matt says:

    <dependency>
    <groupId>
    javax</groupId>
    <artifactId>
    annotation</artifactId>
    <version>1</version>
    </dependency>

  10. Kaan says:

    Sorry for my previous past, it is replicated and xhtml tags are wrongly interrupted.

    I figured out the way to succed using Converts as a spring managed bean. So the only question left is, is it architecturally correct?

  11. angie dickinson says:

    Hi,

    just arrived here searching for an example like this. Anyway, from a fresh Maven2 install like mine, it doesn’t work, it complains about inexistent dependencies. Setting

    org.apache.myfaces.orchestra
    myfaces-orchestra-core
    1.2

    org.apache.myfaces.orchestra
    myfaces-orchestra-core15
    1.0

    seems to fix the problem but, when doing the mvn jetty:run, it complains with a compile error:

    [INFO] Scanning for projects…
    [INFO] Searching repository for plugin with prefix: ‘jetty’.
    [INFO] ————————————————————————
    [INFO] Building moviestore
    [INFO] task-segment: [jetty:run]
    [INFO] ————————————————————————
    [INFO] Preparing jetty:run
    [INFO] [resources:resources]
    [INFO] Using default encoding to copy filtered resources.
    [INFO] [compiler:compile]
    [INFO] Compiling 11 source files to D:\workspaces\myfaces\moviestore_2\target\classes
    [INFO] ————————————————————————
    [ERROR] BUILD FAILURE
    [INFO] ————————————————————————
    [INFO] Compilation failure

    D:\workspaces\myfaces\moviestore_2\src\main\java\com\prime\tutorial\moviestore\view\ViewMovie.java:[5,24] package javax.annotation does not exist

    D:\workspaces\myfaces\moviestore_2\src\main\java\com\prime\tutorial\moviestore\view\ViewMovie.java:[31,9] cannot find symbol
    symbol : class PostConstruct
    location: class com.prime.tutorial.moviestore.view.ViewMovie
    :-(

  12. Tyler says:

    Hi Cagatay,

    I am looking to implement a framework, essentially as you describe here. Specifically, I was looking for a working example of JSF-spring security. I downloaded the moviestore.rar and I could not find an implementation of spring security that I recognized from what I have researched to this point. Can you expand/clarify on this a bit?

    Much appreciated!!
    Tyler

  13. cagataycivici says:

    Hi Tyler,

    checkout the applicationContext.xml under resources, it has spring security config.

  14. neal says:

    Would you happen to have a zip file(in lieu of rar)

Follow

Get every new post delivered to your Inbox.

Join 106 other followers

%d bloggers like this: