Status

Blog::Calendar

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

Blog::Navigation

Blog::Editing

Bookmarks::Blogroll

Blog::Referers

Today''s Page Hits: 435

Other sites

Google Analytics

Powered by Roller Weblogger.
All | JBoss&Seam | JSF | ZK | Music | General | Java
« 雞生蛋,蛋生雞 | Main | How to install JBPM4... »
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

Trackback URL: http://www.javaworld.com.tw/roller/atticcat/entry/run_seam_register_example_in
Comments:

Any additional input about studying JBoss Seam?

Regards,

Posted by Marcos de Sousa on July 19, 2009 at 10:49 PM CST #

just found the online document on the official site....

Posted by Dennis on July 20, 2009 at 09:50 AM CST #

Post a Comment:

Name:
E-Mail:
URL:

Your Comment:

HTML Syntax: NOT allowed
Copyright (C) 2003, 閣樓貓的五四三 (About Cat)