Java Mailing List Archive

http://www.junlu.com/

Google
Google
Mailing List
Home
Forum Home
JBoss - Java Application Server
Tomcat - JSP/Servlet container
Struts - A MVC web framework
iText - An open source PDF Java Library
JDOM - JDOM XML Parser
J2EE - A mailing list for Java(tm) 2 Platform, Enterprise Edition
JSP - A mailing list about Java Server Pages specification and reference
J2EE Pattern - An interest list for Sun Java Center J2EE Pattern Catalog
Servlet - A mailing list for discussion about Sun Microsystem's Java Servlet API Technology
Struts & Hibernate
Subjects
JSP editor plugin for eclipse ?
org apache jasper JasperException: Unable to compile class for JSP
Tomcat: Connection reset by peer: socket write error
Cannot retrieve definition for form bean null
Struts Tiles Tutorial (free Struts training)
Where do I download Tomcat 4 0 6?
Data Access Object (DAO) pattern, example DAO 's
Where to download Tomcat v 4 1 24 from?
Tomcat 5 0 16 Requested resource not available
Oracle Connection Pooling in 3 2 2
Servlet : Session invalidate
Servlet action is currently unavailable
Tomcat/Struts Unicode Encoding/Decoding problems
Tomcat and webapplication specific java library path
Running a Simple JMS Example
Mapping in workers2 properties
org apache jasper JasperException
Cannot find message resources under key org apache struts action
   MESSAGE
problem with html:text bean throwing exception
Cannot find message resources under key org apache struts action MESSAGE
invalid direct reference problem with solution
Tool for jsp debug Try Sysdeo Eclipse Plugin
Tomcat 5 Cannot load JDBC driver class 'null ' SQL state: null
weblogic ejbc
java properties file
Jboss 3 2 3 Coyote Can 't re
Tomcat 5, Apache2 and mod jk2 integration problem
JBoss example problem new to J2EE
url string for connecting jboss to oracle
Value attribute of <html:checkbox
javax servlet ServletException: BeanUtils populate
HTTP Status 404 The requested resource is not available
5 0 18: Windows XP Pro vs Windows 2000
 
- Conversations - do not work in Seam 1.2.1?

- Conversations - do not work in Seam 1.2.1?

2007-06-13       - By bsmithjj

 Back
I'm working on some code where I am trying to do the following:

1. User clicks a link to an action method on a SFSB
2. method is annotated with @(protected), using a custom conversation id
2a. the custom conversation id comes from the following
2a-1. a @(protected) method in a SLSB creates a new persistent entity; the id of
this entity will be appended to a String to create a custom conversation id
2a-2. the @(protected) class would like to use the existing persistent entity if
possible (avoid creating new persistent or querying for existing persistent
entity) - thus, I have an @(protected) for the entity.
2a-3. here is the class with the @(protected) method:


 | @(protected)
 | @(protected)("draftAccessRequestFinder")
 | public class DraftAccessRequestFinderBean implements
DraftAccessRequestFinder {
 |
 |     @(protected)
 |     private Log log;
 |
 |     @(protected)(unitName = "accessControlDatabase")
 |     private EntityManager em;
 |
 |     @(protected)
 |     private Principal userPrincipal;
 |
 |     @(protected)("#{conversation.id}")
 |     private String conversationId;
 |
 |     @(protected)(required = false) @(protected)(scope= ScopeType.CONVERSATION)
 |     private DraftAccessRequestMaster draftAccessRequestMaster;
 |
 |     @(protected)("draftAccessRequestMaster")
 |     public DraftAccessRequestMaster createMaster() {
 |         log.info("DraftAccessRequestFinderBean.createMaster() :
conversationId -> "+conversationId);
 |         log.info("DraftAccessRequestFinderBean.createMaster() :
draftAccessRequestMaster -> "+draftAccessRequestMaster);
 |         // create or load draftAccessRequest....
 |         if (conversationId != null && conversationId.indexOf(':')>0 &&
draftAccessRequestMaster == null) {
 |             long id = Long.valueOf(conversationId.substring(conversationId
.indexOf(':')+1));
 |             draftAccessRequestMaster = em.find(
 |                 DraftAccessRequestMaster.class, id
 |             );
 |             log.info("loaded draftAccessRequestMaster -> "
+draftAccessRequestMaster);
 |         }
 |
 |         if (draftAccessRequestMaster == null) {
 |             if (userPrincipal == null) {
 |                 throw new RuntimeException("userPrincipal is null.");
 |             }
 |             if (!(userPrincipal instanceof UserPrincipal)) {
 |                 throw new RuntimeException("userPrincipal is not an
instance of com.evergreen.jaas.UserPrincipal.");
 |             }
 |             draftAccessRequestMaster = new DraftAccessRequestMaster();
 |             draftAccessRequestMaster.setUserId(
 |                 ((UserPrincipal) userPrincipal).getUserid()
 |             );
 |             draftAccessRequestMaster.setUserName(
 |                 ((UserPrincipal) userPrincipal).getPersonName()
 |             );
 |             em.persist(draftAccessRequestMaster);
 |             em.flush(); // we need to obtain a PK for this entity now...
 |         }
 |         return draftAccessRequestMaster;
 |     }
 | }
 |

3. here is the SFSB that wants the custom conversation id as well as a
reference to the persistent entity:


 | @(protected)
 | // Seam - defaults to Conversational context...
 | @(protected)("accessRequestManager2")
 | public class AccessRequestManager2Bean implements AccessRequestManager2 {
 |
 |     @(protected)
 |     private Log log;
 |
 |     @(protected)(unitName = "accessControlDatabase")
 |     private EntityManager em;
 |
 |     @(protected)
 |     private UserPrincipal userPrincipal;
 |
 |     // for development purposes only - todo remove this
 |     @(protected)
 |     private Conversation conversation;
 |
 |     @(protected)(create=true) @(protected)(scope= ScopeType.CONVERSATION)
 |     private DraftAccessRequestMaster draftAccessRequestMaster;
 |    
 |     @(protected)
 |     private List<String> errors = new ArrayList<String>();
 |
 |
 |     /**
 |      * Start a new add-access request.  This method also generates the
conversationId to
 |      * use in the conversation that beans of this class are associated with.
 |      *
 |      * This is complicated - in 1 swoop, we need to
 |      * 1 - create the DraftAccessRequestMaster for the conversation
component
 |      * 2 -
 |      */
 |     @(protected)(id = "DraftAccessRequestID:#{draftAccessRequestMaster.id}", join
= true)
 |     public void startAddRequest() {
 |         log.info("startAddRequest()");
 |         log.info(conversation);
 |         log.info("conversation.id = " + conversation.getId());
 |         log.info("conversation.parentId = " + conversation.getParentId());
 |
 |         if (draftAccessRequestMaster == null) {
 |             log.info("draftAccessRequestMaster is null...not expected.");
 |         }
 |         ....
 |     }
 | }  
 |

4. here is a link that calls the SFSB method:


 |             <s:link action="#{accessRequestManager2.startAddRequest}" value
="Add 2"
 |                     title="Add entitlements to an application for a user.">
 |             </s:link>
 |

5. and here is a log of what occurs


 |                   First click of link...
 |
 | 10:53:32,805  INFO com.evergreen.accesscontrol.impl
.DraftAccessRequestFinderBean - DraftAccessRequestFinderBean.createMaster() :
conversationId -> 3
 | 10:53:32,805  INFO com.evergreen.accesscontrol.impl
.DraftAccessRequestFinderBean - DraftAccessRequestFinderBean.createMaster() :
draftAccessRequestMaster -> null
 | 10:53:32,805  INFO com.evergreen.accesscontrol.entity
.DraftAccessRequestMaster - new DraftAccessRequestMaster()
 | 10:53:32,821  INFO com.evergreen.accesscontrol.impl
.AccessRequestManager2Bean - startAddRequest()
 | 10:53:32,821  INFO com.evergreen.accesscontrol.impl
.AccessRequestManager2Bean - org.jboss.seam.core.Conversation@(protected)
 | 10:53:32,821  INFO com.evergreen.accesscontrol.impl
.AccessRequestManager2Bean - conversation.id = DraftAccessRequestID:50
 | 10:53:32,821  INFO com.evergreen.accesscontrol.impl
.AccessRequestManager2Bean - conversation.parentId = null
 |
 |          Second click of link (expecting to find draftAccessRequestMaster
in memory for conversation but it's not found...)
 |
 | 10:53:36,915  INFO com.evergreen.accesscontrol.impl
.DraftAccessRequestFinderBean - DraftAccessRequestFinderBean.createMaster() :
conversationId -> DraftAccessRequestID:50
 | 10:53:36,915  INFO com.evergreen.accesscontrol.impl
.DraftAccessRequestFinderBean - DraftAccessRequestFinderBean.createMaster() :
draftAccessRequestMaster -> null
 | 10:53:36,930  INFO com.evergreen.accesscontrol.entity
.DraftAccessRequestMaster - new DraftAccessRequestMaster()
 | 10:53:36,930  INFO com.evergreen.accesscontrol.impl
.DraftAccessRequestFinderBean - loaded draftAccessRequestMaster ->
DraftAccessRequestMaster{...}
 | 10:53:36,930  INFO com.evergreen.accesscontrol.impl
.AccessRequestManager2Bean - startAddRequest()
 | 10:53:36,930  INFO com.evergreen.accesscontrol.impl
.AccessRequestManager2Bean - org.jboss.seam.core.Conversation@(protected)
 | 10:53:36,946  INFO com.evergreen.accesscontrol.impl
.AccessRequestManager2Bean - conversation.id = DraftAccessRequestID:50
 | 10:53:36,946  INFO com.evergreen.accesscontrol.impl
.AccessRequestManager2Bean - conversation.parentId = null
 |

So note that I @(protected)(ject) the entity to Conversation scope, however, when the
link is clicked the second time the SLSB and the SFSB don't have an instance of
draftAccessRequestMaster injected.  So why can't I find my conversational
-scoped entity?  It looks like the conversation is correctly @(protected)(ning) or
joining based on whether or not the conversation exists.

Thanks,
Brad Smith

View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic
&p=4054036#4054036

Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode
=reply&p=4054036
__ ____ ____ ____ ____ ____ ____ ____ ____ ____
jboss-user mailing list
jboss-user@(protected)
https://lists.jboss.org/mailman/listinfo/jboss-user

©2008 junlu.com - Jax Systems, LLC, U.S.A.