Status

Blog::Calendar

« July 2009 »
SunMonTueWedThuFriSat
   
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
19
20
21
22
23
24
25
26
27
29
30
31
 
       
Today
XML

Blog::Navigation

Blog::Editing

Bookmarks::Blogroll

Blog::Referers

Today''s Page Hits: 32

Other sites

Google Analytics

Powered by Roller Weblogger.
All | JBoss&Seam | JSF | ZK | Music | General | Java
Main | Next day (Jul 19, 2009) »
20090718 Saturday July 18, 2009
Run seam register example in WAR

In past of two days, I was studying JBoss Seam, reading the document and trying to run the tutorial example.
I did a stupid thing that spent me half a day, the example must run in EAR deployment, but I ran it in WAR mode.

I am curious how to make it run in WAR mode.
Cause of the example is made for a EJB, so you need to declare @Stateless/@Stateful for the controller.
In document of Seam, it can control any bean to be a controller, no need to EJB , so we should able to remove EJB annotation.
However cause we still need an entity manager,that annotated by @PersistenceContext, to work, so we don't remove @Stateless/@Stateful directly.
Thanks Seam, it is easy to fix, use @In annotation, you can get a entity manager with out @PersistenceContext

following is the steps to run example in WAR mode.

  1. Remove @Stateless/@Stateful in RegisterAction
  2. Change @PersistenceContext to @In(value="entityManager") , or @In if the EntityManager value name is already "entityManager"
  3. Remove @Local in Register, keep Register interface, I think this interface is still good for a OO Design.
that's all, you only need to care about is the the name of "entityManager" must same as the declartion in components.xml

Copyright (C) 2003, 閣樓貓的五四三 (About Cat)