<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" media="screen" href="/~d/styles/rss2enclosuresfull.xsl"?><?xml-stylesheet type="text/css" media="screen" href="http://feeds.feedburner.com/~d/styles/itemcontent.css"?><rss xmlns:media="http://search.yahoo.com/mrss/" xmlns:itunes="http://www.itunes.com/dtds/podcast-1.0.dtd" version="2.0"><channel><title>Java Room</title><link>http://myjavaroom.blogspot.com/</link><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" type="application/rss+xml" href="http://feeds.feedburner.com/JavaRoom" /><description>My R&amp;amp;D notes to record the difficulties and solution I found during my web application development in J2EE, Java, JBoss, Seam, CAS SSO, JBoss Rules, Lucene, iText, Remoting, Ajax, JSF, Richfaces and etc.</description><language>en</language><managingEditor>noreply@blogger.com (Lee)</managingEditor><lastBuildDate>Thu, 16 Feb 2012 17:58:42 PST</lastBuildDate><generator>Blogger http://www.blogger.com</generator><openSearch:totalResults xmlns:openSearch="http://a9.com/-/spec/opensearch/1.1/">17</openSearch:totalResults><openSearch:startIndex xmlns:openSearch="http://a9.com/-/spec/opensearch/1.1/">1</openSearch:startIndex><openSearch:itemsPerPage xmlns:openSearch="http://a9.com/-/spec/opensearch/1.1/">25</openSearch:itemsPerPage><feedburner:info xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" uri="javaroom" /><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com/" /><itunes:owner><itunes:email>noreply@blogger.com</itunes:email></itunes:owner><itunes:explicit>no</itunes:explicit><itunes:subtitle>My R&amp;amp;D notes to record the difficulties and solution I found during my web application development in J2EE, Java, JBoss, Seam, CAS SSO, JBoss Rules, Lucene, iText, Remoting, Ajax, JSF, Richfaces and etc.</itunes:subtitle><item><title>Injected Seam Component is NULL in EntityQuery</title><link>http://myjavaroom.blogspot.com/2010/01/injected-seam-component-is-null-in.html</link><category>JBoss Seam</category><author>noreply@blogger.com (Lee)</author><pubDate>Tue, 26 Jan 2010 23:32:50 PST</pubDate><guid isPermaLink="false">tag:blogger.com,1999:blog-3804827704953141110.post-8024473640361682933</guid><description>
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/mSJu_BnWRN_VzgE_y4Vpw48JNLc/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/mSJu_BnWRN_VzgE_y4Vpw48JNLc/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/mSJu_BnWRN_VzgE_y4Vpw48JNLc/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/mSJu_BnWRN_VzgE_y4Vpw48JNLc/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;span style="font-size:85%;"&gt;After read through the Seam Reference, I found there bijection is not allowed if the Seam component's instance is used outside of the Seam context. Seam performs injection by intercepting method call. Since I call the injected component in the query class constructor, Seam will not intercept the call and inject the value.&lt;br /&gt;&lt;/span&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="font-weight: bold;"&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="font-weight: bold;"&gt;ERROR!!&lt;/span&gt;&lt;span style="font-weight: bold;"&gt;&lt;br /&gt;------------&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;@BypassInterceptors&lt;br /&gt;@Name("userTaskList")&lt;br /&gt;public class UserTaskList extends EntityQuery {&lt;br /&gt;&lt;br /&gt;@In(required=true)&lt;br /&gt;private User authenticatedUser;&lt;br /&gt;&lt;br /&gt;public UserTaskList() {&lt;br /&gt;&lt;br /&gt;   //authenticatedUser is NULL&lt;br /&gt;   System.out.println("authenticatedUser = "+authenticatedUser);&lt;br /&gt;&lt;br /&gt;   StringBuffer ejbql = new StringBuffer("SELECT task FROM Task task WHERE task.role IN ");&lt;br /&gt;   ejbql.append("(SELECT a.role FROM AssignRole a WHERE a.user.userId=#{authenticatedUser.userId})");&lt;br /&gt;&lt;br /&gt;   setEjbql(ejbql.toString());&lt;br /&gt;   setMaxResults(25);&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;@Factory(value="taskList", scope=ScopeType.EVENT)&lt;br /&gt;public List&amp;amp;ltTask&gt; getTaskList(){&lt;br /&gt;&lt;br /&gt;   return super.getResultList();&lt;br /&gt;}&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;The "authenticatedUser" in UserTaskList() constructor is returned NULL.&lt;br /&gt;To solve this issue, I moved the EJB-QL to the getTaskList() method.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;SOLUTION:&lt;/span&gt;&lt;span style="font-weight: bold;"&gt;&lt;br /&gt;------------------&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;@BypassInterceptors&lt;br /&gt;@Name("userTaskList")&lt;br /&gt;public class UserTaskList extends EntityQuery {&lt;br /&gt;&lt;br /&gt;@In(required=true)&lt;br /&gt;private User authenticatedUser;&lt;br /&gt;&lt;br /&gt;private static final String EJBQL = "SELECT task FROM Task task";&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;public UserTaskList() {&lt;br /&gt;   //authenticatedUser is NULL&lt;br /&gt;   System.out.println("authenticatedUser = "+authenticatedUser);&lt;br /&gt;   setEjbql(EJBQL);&lt;br /&gt;   setMaxResults(25);&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;@Factory(value="taskList", scope=ScopeType.EVENT)&lt;br /&gt;public List&amp;amp;ltTask&gt; getTaskList(){&lt;br /&gt;&lt;br /&gt;   //authenticatedUser is NOT NULL&lt;br /&gt;   System.out.println("authenticatedUser = "+authenticatedUser);&lt;br /&gt; &lt;br /&gt;   StringBuffer ejbql = new StringBuffer("SELECT task FROM Task task WHERE task.role IN ");&lt;br /&gt;   ejbql.append("(SELECT a.role FROM AssignRole a WHERE a.user.userId=#{authenticatedUser.userId})");&lt;br /&gt;&lt;br /&gt;   setEjbql(ejbql.toString());&lt;br /&gt;&lt;br /&gt;   List&amp;amp;ltTask&gt; list = super.getResultList();&lt;br /&gt; &lt;br /&gt;   return list;&lt;br /&gt;}&lt;br /&gt;}&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3804827704953141110-8024473640361682933?l=myjavaroom.blogspot.com' alt='' /&gt;&lt;/div&gt;</description><app:edited xmlns:app="http://www.w3.org/2007/app">2010-01-27T15:32:50.978+08:00</app:edited><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">38</thr:total></item><item><title>Using "IN" clause in EJB-QL</title><link>http://myjavaroom.blogspot.com/2010/01/using-in-clause-in-ejb-ql.html</link><category>EJB-QL</category><category>JBoss Seam</category><author>noreply@blogger.com (Lee)</author><pubDate>Tue, 26 Jan 2010 23:16:50 PST</pubDate><guid isPermaLink="false">tag:blogger.com,1999:blog-3804827704953141110.post-3826516934033279378</guid><description>
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/XbBWyVYtFY1WyQM9IAV24kifFf4/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/XbBWyVYtFY1WyQM9IAV24kifFf4/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/XbBWyVYtFY1WyQM9IAV24kifFf4/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/XbBWyVYtFY1WyQM9IAV24kifFf4/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;span style="font-size:85%;"&gt;In the below example, the query return NO results. The EJB-QL cannot understand multiple input parameters.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;ERROR!!&lt;/span&gt;&lt;span style="font-weight: bold;"&gt;&lt;br /&gt;------------&lt;/span&gt;&lt;br /&gt;String ejbql = "SELECT task FROM Task task WHERE task.role IN (:=roles)";&lt;br /&gt;&lt;br /&gt;Query query = entityManager.createQuery(ejbql);&lt;br /&gt;query.setParameter("roles", "'admin', 'user'");&lt;br /&gt;&lt;br /&gt;List&amp;amp;ltTask&gt; list = query.getResultList();&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;However,....if I using example below, the query return ResultList I want.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;@In(required=true)&lt;br /&gt;private User authenticatedUser;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;String roles = authenticatedUser.getRoles(); // roles="'admin', 'user'"&lt;br /&gt;String ejbql = "SELECT task FROM Task task WHERE task.role IN ("+roles+")";&lt;br /&gt;&lt;br /&gt;Query query = entityManager.createQuery(ejbql);&lt;br /&gt;List&amp;amp;ltTask&gt; list = query.getResultList();&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;But, this is not the correct way to implement query in EntityQuery class.&lt;br /&gt;And, finally I came out another workaround, which looks more reasonable. I am not sure this is the right way to set the EJB-QL in EntityQuery, I will appreciate if someone can provide better solution for me.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;SOLUTION:&lt;/span&gt;&lt;span style="font-weight: bold;"&gt;&lt;br /&gt;-----------------&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;@In(required=true)&lt;br /&gt;private User authenticatedUser;&lt;br /&gt;&lt;br /&gt;public List&amp;amp;ltTask&gt; getTaskList(){&lt;br /&gt;&lt;br /&gt;StringBuffer ejbql = new StringBuffer("SELECT task FROM Task task WHERE task.role IN ");&lt;br /&gt;ejbql.append("(SELECT a.role FROM AssignRole a WHERE a.user.userId=:userId)");&lt;br /&gt;&lt;br /&gt;Query query = entityManager.createQuery(ejbql.toString());&lt;br /&gt;query.setParameter("userId", authenticatedUser.getUserId());&lt;br /&gt;&lt;br /&gt;List&amp;amp;ltTask&gt; list = query.getResultList();&lt;br /&gt;return list;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3804827704953141110-3826516934033279378?l=myjavaroom.blogspot.com' alt='' /&gt;&lt;/div&gt;</description><app:edited xmlns:app="http://www.w3.org/2007/app">2010-01-27T15:16:50.069+08:00</app:edited><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">0</thr:total></item><item><title>Unique Key Validation</title><link>http://myjavaroom.blogspot.com/2010/01/unique-key-validation.html</link><category>JSF</category><category>Hibernate</category><category>JBoss Seam</category><author>noreply@blogger.com (Lee)</author><pubDate>Wed, 20 Jan 2010 22:08:46 PST</pubDate><guid isPermaLink="false">tag:blogger.com,1999:blog-3804827704953141110.post-6181956778755493224</guid><description>
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/mSyJTngletScOQsbDQ0oqfEn0-s/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/mSyJTngletScOQsbDQ0oqfEn0-s/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/mSyJTngletScOQsbDQ0oqfEn0-s/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/mSyJTngletScOQsbDQ0oqfEn0-s/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;span style="font-family:times new roman;"&gt;@UniqueConstraint Annotation  does not validate the value of entity field. It will not catch the org.hibernate.exception.ConstraintViolationException.&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;font-family:times new roman;" &gt;Example:&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:times new roman;"&gt;@Table(name = "user", uniqueConstraints = @UniqueConstraint(columnNames = "username"))&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;font-family:times new roman;" &gt;Error:&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:times new roman;"&gt;ERROR [AbstractFlushingEventListener] Could not synchronize database state with session&lt;/span&gt;&lt;span style="font-family:times new roman;"&gt; org.hibernate.exception.ConstraintViolationException: Could not execute JDBC batch update...&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;font-family:times new roman;" &gt;SOLUTION: Custom Validator&lt;/span&gt;&lt;br /&gt;&lt;span style="font-weight: bold;font-family:times new roman;" &gt;----------------------------------------&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:times new roman;"&gt;To solve this problem, I created a custom validator to do the validation in JSF before persist the entity.&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:times new roman;"&gt;Seam provides annotations to allow us to use Seam components as JSF converters and validators.&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family:times new roman;"&gt;@Name("usernameValidator")&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:times new roman;"&gt;@BypassInterceptors&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:times new roman;"&gt;@org.jboss.seam.annotations.faces.Validator&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:times new roman;"&gt;public class UsernameValidator implements javax.faces.validator.Validator {&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family:times new roman;"&gt;    public static final String VERIFICATION_MSG_EXPR = "#{messages['validator.duplicateError']}";&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family:times new roman;"&gt;    public void validate(FacesContext context, UIComponent cmp, Object value)throws ValidatorException&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:times new roman;"&gt;    {&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family:times new roman;"&gt;        String ejbql = "select u from User u where u.username=:username";&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family:times new roman;"&gt;        String username = (String)value;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family:times new roman;"&gt;        EntityManager em = (EntityManager) Component.getInstance("entityManager");&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:times new roman;"&gt;        Query query = em.createQuery(ejbql);&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:times new roman;"&gt;        query.setParameter("username", username);&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family:times new roman;"&gt;        List list = query.getResultList();&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family:times new roman;"&gt;        if (!list.isEmpty()) {&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family:times new roman;"&gt;            FacesMessage msg = new FacesMessage();&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:times new roman;"&gt;            msg.setSummary(Interpolator.instance().interpolate(VERIFICATION_MSG_EXPR));&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:times new roman;"&gt;            msg.setSeverity(FacesMessage.SEVERITY_WARN);&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:times new roman;"&gt;            throw new ValidatorException(msg);&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:times new roman;"&gt;        }&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:times new roman;"&gt;    }&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:times new roman;"&gt;}&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;font-family:times new roman;" &gt;In JSF: &lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family:times new roman;"&gt;Registers the Seam component as a JSF validator. Below example is a validator which injects another Seam component. &lt;/span&gt;&lt;span style="font-family:times new roman;"&gt;The injected component is used to validate the value. &lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family:times new roman;"&gt;&amp;lt;h:inputText id="username" value="#{userHome.instance.username}" validator="usernameValidator"/&gt;&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3804827704953141110-6181956778755493224?l=myjavaroom.blogspot.com' alt='' /&gt;&lt;/div&gt;</description><app:edited xmlns:app="http://www.w3.org/2007/app">2010-01-21T14:08:46.738+08:00</app:edited><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">4</thr:total></item><item><title>Seam and Drools integration in jBPM</title><link>http://myjavaroom.blogspot.com/2010/01/seam-and-drools-integration-in-jbpm.html</link><category>JBoss Rules</category><category>Seam</category><category>jBPM</category><author>noreply@blogger.com (Lee)</author><pubDate>Thu, 07 Jan 2010 23:15:23 PST</pubDate><guid isPermaLink="false">tag:blogger.com,1999:blog-3804827704953141110.post-6479424903918706774</guid><description>
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/imMHif7kgPIyudHwKmQOQFw38Ng/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/imMHif7kgPIyudHwKmQOQFw38Ng/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/imMHif7kgPIyudHwKmQOQFw38Ng/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/imMHif7kgPIyudHwKmQOQFw38Ng/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;span style="font-size:100%;"&gt;Recently I am developing a workflow collaboration system which will using JBoss Rules in&lt;span style="text-decoration: underline;"&gt;&lt;/span&gt; jBPM process definition. The example below is documented during my testing and understanding of Drools integration with jBPM in Seam Framework.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold; color: rgb(51, 51, 255);"&gt;Step 1: Add jbpm.cfg.xml and hibernate.cfg.xml config files&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Since we have business process definitions, we need to provide jBPM configuration,&lt;br /&gt;and Hibernate configuration for jBPM.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&amp;lt;jbpm-configuration&gt;&lt;br /&gt;&amp;lt;jbpm-context&gt;&lt;br /&gt; &amp;lt;service name="persistence"&gt;&lt;br /&gt;    &amp;lt;factory&gt;&lt;br /&gt;       &amp;lt;bean class="org.jbpm.persistence.db.DbPersistenceServiceFactory"&gt;&lt;br /&gt;          &amp;lt;field name="isTransactionEnabled"&gt;&amp;lt;false/&gt;&amp;lt;/field&gt;&lt;br /&gt;       &amp;lt;/bean&gt;&lt;br /&gt;    &amp;lt;/factory&gt;&lt;br /&gt; &amp;lt;/service&gt;&lt;br /&gt; &amp;lt;service name="tx" factory="org.jbpm.tx.TxServiceFactory" /&gt;&lt;br /&gt; &amp;lt;service name="message" factory="org.jbpm.msg.db.DbMessageServiceFactory" /&gt;&lt;br /&gt; &amp;lt;service name="scheduler" factory="org.jbpm.scheduler.db.DbSchedulerServiceFactory" /&gt;&lt;br /&gt; &amp;lt;service name="logging" factory="org.jbpm.logging.db.DbLoggingServiceFactory" /&gt;&lt;br /&gt; &amp;lt;service name="authentication"&lt;br /&gt;          factory="org.jbpm.security.authentication.DefaultAuthenticationServiceFactory" /&gt;&lt;br /&gt;&amp;lt;/jbpm-context&gt;&lt;br /&gt;&amp;lt;/jbpm-configuration&gt;&lt;br /&gt;&lt;br /&gt;**NOTE:&lt;br /&gt;jBPM transaction control is disabled in the jbpm.cfg.xml.&lt;br /&gt;Seam or EJB3 should control the JTA transactions.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold; color: rgb(51, 51, 255);"&gt;Step 2: Configure components.xml&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;(1) Create org.drools.RuleBase instance available in a Seam context variable.&lt;br /&gt;(2) Define where to find the business process definitions.&lt;br /&gt;&lt;br /&gt;&amp;lt;drools:rule-base name="ruleBase" rule-files="test.drl"/&gt;&lt;br /&gt;&amp;lt;drools:managed-working-memory name="workingMemory" rule-base="#{ruleBase}"/&gt;&lt;br /&gt;&lt;br /&gt;&amp;lt;bpm:jbpm&gt;&lt;br /&gt; &amp;lt;bpm:process-definitions&gt;&lt;br /&gt;     &amp;lt;value&gt;test.jpdl.xml&amp;lt;/value&gt;&lt;br /&gt; &amp;lt;/bpm:process-definitions&gt;&lt;br /&gt;&amp;lt;/bpm:jbpm&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold; color: rgb(51, 51, 255);"&gt;Step 3: Create Business Process Definition File - test.jpdl.xml&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&amp;lt;?xml version="1.0"?&gt;&lt;br /&gt;&amp;lt;process-definition name="approval_process"&lt;br /&gt; xmlns="urn:jbpm.org:jpdl-3.2"&lt;br /&gt; xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"&lt;br /&gt; xsi:schemaLocation="urn:jbpm.org:jpdl-3.2 http://jbpm.org/xsd/jpdl-3.2.xsd"&gt;&lt;br /&gt;&lt;br /&gt; &amp;lt;start-state name="start"&gt;&lt;br /&gt;     &amp;lt;transition to="checkName"/&gt;&lt;br /&gt; &amp;lt;/start-state&gt;&lt;br /&gt;&lt;br /&gt; &amp;lt;decision name="checkName"&gt;&lt;br /&gt;     &amp;lt;handler class="org.jboss.seam.drools.DroolsDecisionHandler"&gt;&lt;br /&gt;         &amp;lt;workingMemoryName&gt;workingMemory&amp;lt;/workingMemoryName&gt;&lt;br /&gt;         &amp;lt;assertObjects&gt;&lt;br /&gt;             &amp;lt;element&gt;#{approval}&amp;lt;/element&gt;&lt;br /&gt;         &amp;lt;/assertObjects&gt;&lt;br /&gt;     &amp;lt;/handler&gt;&lt;br /&gt; &lt;br /&gt;     &amp;lt;transition name="process" to="processNode"/&gt; &amp;lt;!-- transition name[process] return from rules --&gt;&lt;br /&gt;     &amp;lt;transition name="reject" to="reject_done"/&gt; &amp;lt;!-- transition name[reject] return from rules --&gt;&lt;br /&gt; &amp;lt;/decision&gt;&lt;br /&gt;&lt;br /&gt; &amp;lt;task-node name="processNode"&gt;&lt;br /&gt;     &amp;lt;task name="Process Approval" description="process approval"&gt;&lt;br /&gt;          &amp;lt;assignment actor-id="admin"/&gt;&lt;br /&gt;     &amp;lt;/task&gt;&lt;br /&gt;     &amp;lt;transition name="approve" to="approve_done"/&gt;&lt;br /&gt;     &amp;lt;transition name="reject" to="reject_done"/&gt;&lt;br /&gt; &amp;lt;/task-node&gt;&lt;br /&gt;&lt;br /&gt; &amp;lt;end-state name="approve_done"/&gt;&lt;br /&gt; &amp;lt;end-state name="reject_done"/&gt; &amp;lt;!-- only show in this file. no method available in Approval.class --&gt;&lt;br /&gt;&amp;lt;/process-definition&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold; color: rgb(51, 51, 255);"&gt;Step 4: Create Drools File - test.drl&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Below is a simple example to check whether 'name' and 'description' are equal.&lt;br /&gt;&lt;br /&gt;package test;&lt;br /&gt;import org.jboss.seam.drools.Decision&lt;br /&gt;&lt;br /&gt;global Decision decision&lt;br /&gt;global String name;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;rule Process&lt;br /&gt; when&lt;br /&gt;   Approval(name==description)&lt;br /&gt; then&lt;br /&gt;   decision.setOutcome("process");&lt;br /&gt;end&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;rule Deny&lt;br /&gt; when&lt;br /&gt;     Approval(name!=description)&lt;br /&gt; then&lt;br /&gt;     decision.setOutcome("reject");&lt;br /&gt;end&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold; color: rgb(51, 51, 255);"&gt;Step 5: Create POJO Process Manager&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;package test;&lt;br /&gt;import org.jboss.seam.annotations.Name;&lt;br /&gt;import org.jboss.seam.annotations.bpm.StartTask;&lt;br /&gt;import org.jboss.seam.annotations.bpm.BeginTask;&lt;br /&gt;import org.jboss.seam.annotations.bpm.Transition;&lt;br /&gt;import org.jboss.seam.annotations.bpm.CreateProcess;&lt;br /&gt;import org.jboss.seam.annotations.bpm.EndTask;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;@Name("approval")&lt;br /&gt;public class Approval&lt;br /&gt;{&lt;br /&gt;&lt;br /&gt; private String name;&lt;br /&gt; private String description;&lt;br /&gt;&lt;br /&gt; public void setName(String name){&lt;br /&gt;     this.name = name;&lt;br /&gt; }&lt;br /&gt;&lt;br /&gt; public String getName(){&lt;br /&gt;     return name;&lt;br /&gt; }&lt;br /&gt;&lt;br /&gt; public void setDescription(String description) {&lt;br /&gt; }&lt;br /&gt;&lt;br /&gt; public String getDescription(){&lt;br /&gt;     return description;&lt;br /&gt; }&lt;br /&gt;&lt;br /&gt; @CreateProcess(definition="approval_process")&lt;br /&gt; public void startProcess() {&lt;br /&gt; }&lt;br /&gt;&lt;br /&gt;&lt;br /&gt; @StartTask&lt;br /&gt; @EndTask(transition="approve")&lt;br /&gt; public void approve() {&lt;br /&gt;     System.out.println("process APPROVE ...");&lt;br /&gt; }&lt;br /&gt;&lt;br /&gt;&lt;br /&gt; @StartTask&lt;br /&gt; @EndTask(transition="reject")&lt;br /&gt; public void reject() {&lt;br /&gt;     System.out.println("process REJECT ...");&lt;br /&gt; }&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Note:&lt;br /&gt;&lt;br /&gt;(1) Use the @CreateProcess annotation to initiate a business process instance.&lt;br /&gt;&lt;br /&gt;@CreateProcess(definition="approval_process")&lt;br /&gt;public void startProcess() {&lt;br /&gt;.....&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;(2) To begin work on a task, use either @StartTask or @BeginTask&lt;br /&gt;&lt;br /&gt;@StartTask&lt;br /&gt;public String start() {&lt;br /&gt;...&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;(3) To end the conversation use @EndTask&lt;br /&gt;&lt;br /&gt;@EndTask(transition="approve")&lt;br /&gt;public String approve() {&lt;br /&gt;...&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;**REMARK:&lt;/span&gt;&lt;br /&gt;Without @StartTask, in seam, "Task null not found" exception will be thrown.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold; color: rgb(51, 51, 255);"&gt;Step 6: The View Component&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&amp;lt;!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"&lt;br /&gt; "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt;&lt;br /&gt;&amp;lt;ui:composition xmlns="http://www.w3.org/1999/xhtml"&lt;br /&gt; xmlns:s="http://jboss.com/products/seam/taglib"&lt;br /&gt; xmlns:ui="http://java.sun.com/jsf/facelets"&lt;br /&gt; xmlns:f="http://java.sun.com/jsf/core"&lt;br /&gt; xmlns:h="http://java.sun.com/jsf/html"&lt;br /&gt; template="layout/template.xhtml"&gt;&lt;br /&gt;&lt;br /&gt;&amp;lt;ui:define name="body"&gt;&lt;br /&gt;&lt;br /&gt;&amp;lt;h:form id="list"&gt;&lt;br /&gt;   &amp;lt;div&gt;&lt;br /&gt;      &amp;lt;h:outputText id="noItems" value="There are no items." rendered="#{empty taskInstancePriorityList}"/&gt;&lt;br /&gt;      &amp;lt;h:dataTable id="items" value="#{taskInstancePriorityList}" var="task" rendered="#{not empty taskInstancePriorityList}"&gt;&lt;br /&gt;         &amp;lt;h:column&gt;&lt;br /&gt;             &amp;lt;f:facet name="header"&gt;&lt;br /&gt;                 &amp;lt;h:outputText value="Description"/&gt;&lt;br /&gt;             &amp;lt;/f:facet&gt;&lt;br /&gt;             &amp;lt;h:inputText id="description" value="#{task.description}" style="width: 400"/&gt;&lt;br /&gt;         &amp;lt;/h:column&gt;&lt;br /&gt;         &amp;lt;h:column&gt;&lt;br /&gt;             &amp;lt;f:facet name="header"&gt;&lt;br /&gt;                 &amp;lt;h:outputText value="Created"/&gt;&lt;br /&gt;             &amp;lt;/f:facet&gt;&lt;br /&gt;             &amp;lt;h:outputText value="#{task.taskMgmtInstance.processInstance.start}"&gt;&lt;br /&gt;                 &amp;lt;s:convertDateTime type="date"/&gt;&lt;br /&gt;             &amp;lt;/h:outputText&gt;&lt;br /&gt;         &amp;lt;/h:column&gt;&lt;br /&gt;         &amp;lt;h:column&gt;&lt;br /&gt;             &amp;lt;f:facet name="header"&gt;&lt;br /&gt;                 &amp;lt;h:outputText value="Priority"/&gt;&lt;br /&gt;             &amp;lt;/f:facet&gt;&lt;br /&gt;             &amp;lt;h:inputText id="priority" value="#{task.priority}" style="width: 30"/&gt;&lt;br /&gt;         &amp;lt;/h:column&gt;&lt;br /&gt;         &amp;lt;h:column&gt;&lt;br /&gt;             &amp;lt;f:facet name="header"&gt;&lt;br /&gt;                 &amp;lt;h:outputText value="Due Date"/&gt;&lt;br /&gt;             &amp;lt;/f:facet&gt;&lt;br /&gt;             &amp;lt;h:inputText id="dueDate" value="#{task.dueDate}" style="width: 100"&gt;&lt;br /&gt;                 &amp;lt;s:convertDateTime type="date" dateStyle="short"/&gt;&lt;br /&gt;             &amp;lt;/h:inputText&gt;&lt;br /&gt;         &amp;lt;/h:column&gt;&lt;br /&gt;         &amp;lt;h:column&gt;&lt;br /&gt;             &amp;lt;s:button id="approve" action="#{approval.approve}" taskInstance="#{task}" value="Approve"/&gt;&lt;br /&gt;             &amp;lt;s:button id="reject" action="#{approval.reject}" taskInstance="#{task}" value="Reject"/&gt;&lt;br /&gt;         &amp;lt;/h:column&gt;&lt;br /&gt;      &amp;lt;/h:dataTable&gt;&lt;br /&gt;   &amp;lt;/div&gt;&lt;br /&gt;   &amp;lt;div&gt;&lt;br /&gt;   &amp;lt;h:messages/&gt;&lt;br /&gt;   &amp;lt;/div&gt;&lt;br /&gt;&amp;lt;/h:form&gt;&lt;br /&gt;&amp;lt;h:form id="new"&gt;&lt;br /&gt;   &amp;lt;div&gt;&lt;br /&gt;      Name :&amp;lt;h:inputText id="name" value="#{approval.name}"/&gt;&lt;br /&gt;      Description :&amp;lt;h:inputText id="description" value="#{approval.description}" style="width: 400"/&gt;&lt;br /&gt;      &amp;lt;h:commandButton id="create" value="Create New Item" action="#{approval.startProcess}"/&gt;&lt;br /&gt;   &amp;lt;/div&gt;&lt;br /&gt;&amp;lt;/h:form&gt;&lt;br /&gt;&amp;lt;/ui:define&gt;&lt;br /&gt;&lt;br /&gt;&amp;lt;/ui:composition&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;View the complete files from the links below:&lt;br /&gt;&lt;a href="http://docs.google.com/Doc?docid=0AbmZO9jO9L-nZG5zbWhjN183aHJudDJnNGs&amp;amp;hl=en"&gt;test.drl&lt;/a&gt;&lt;br /&gt;&lt;a href="http://docs.google.com/Doc?docid=0AbmZO9jO9L-nZG5zbWhjN182aGR0N3g0Zng&amp;amp;hl=en"&gt;jbpm.cfg.xml&lt;/a&gt;&lt;br /&gt;&lt;a href="http://docs.google.com/Doc?docid=0AbmZO9jO9L-nZG5zbWhjN181YzI1NXYzYzI&amp;amp;hl=en"&gt;hibernate.cfg.xml&lt;/a&gt;&lt;br /&gt;&lt;a href="http://docs.google.com/Doc?docid=0AbmZO9jO9L-nZG5zbWhjN180ZGJxcXYzY3o&amp;amp;hl=en"&gt;components.xml&lt;/a&gt;&lt;br /&gt;&lt;a href="http://docs.google.com/Doc?docid=0AbmZO9jO9L-nZG5zbWhjN18zZzM5ZDI3Y2Q&amp;amp;hl=en"&gt;approval.jpdl.xml&lt;/a&gt;&lt;br /&gt;&lt;a href="http://docs.google.com/Doc?docid=0AbmZO9jO9L-nZG5zbWhjN18yZzlienNxY2Q&amp;amp;hl=en"&gt;text.xhtml&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3804827704953141110-6479424903918706774?l=myjavaroom.blogspot.com' alt='' /&gt;&lt;/div&gt;</description><app:edited xmlns:app="http://www.w3.org/2007/app">2010-01-08T15:15:23.955+08:00</app:edited><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">0</thr:total></item><item><title>Hibernate Batch Processing and Bulk Update/Delete</title><link>http://myjavaroom.blogspot.com/2010/01/hibernate-batch-processing-and-bulk.html</link><category>Hibernate</category><author>noreply@blogger.com (Lee)</author><pubDate>Wed, 06 Jan 2010 23:23:25 PST</pubDate><guid isPermaLink="false">tag:blogger.com,1999:blog-3804827704953141110.post-604590662990933151</guid><description>
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/rK6WqzRFFv5i41JDxpH9ZBFsTDg/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/rK6WqzRFFv5i41JDxpH9ZBFsTDg/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/rK6WqzRFFv5i41JDxpH9ZBFsTDg/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/rK6WqzRFFv5i41JDxpH9ZBFsTDg/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;div style="text-align: justify;"&gt; &lt;span style="font-family: times new roman; color: rgb(0, 0, 0);"&gt;Last few days, I was working on a system, which require a housekeeping function to clean the system database. According to the hibernate documentation :&lt;br /&gt;&lt;br /&gt;"Object/relational mapping is concerned with the management of object state. This implies that the object state is available in memory, hence updating or deleting (using SQL &lt;/span&gt;&lt;code style="font-family: times new roman; color: rgb(0, 0, 0);" class="literal"&gt;UPDATE&lt;/code&gt;&lt;span style="font-family: times new roman; color: rgb(0, 0, 0);"&gt; and &lt;/span&gt;&lt;code style="font-family: times new roman; color: rgb(0, 0, 0);" class="literal"&gt;DELETE&lt;/code&gt;&lt;span style="font-family: times new roman; color: rgb(0, 0, 0);"&gt;) data directly in the database will not affect in-memory state. However, Hibernate provides methods for bulk SQL-style &lt;/span&gt;&lt;code style="font-family: times new roman; color: rgb(0, 0, 0);" class="literal"&gt;UPDATE&lt;/code&gt;&lt;span style="font-family: times new roman; color: rgb(0, 0, 0);"&gt; and &lt;/span&gt;&lt;code style="font-family: times new roman; color: rgb(0, 0, 0);" class="literal"&gt;DELETE&lt;/code&gt;&lt;span style="font-family: times new roman; color: rgb(0, 0, 0);"&gt; statement execution which are performed through EJB-QL ".&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family: times new roman; color: rgb(0, 0, 0);"&gt;Therefore, I was thinking to use bulk update/delete methods provided by Hibernate as my solution.  However, I found a lot limitations which force me to give up from using it. &lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: times new roman; color: rgb(0, 0, 0);"&gt;According to the hibernate documentation:&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;ul style="font-family: times new roman; color: rgb(0, 0, 0); text-align: justify;" compact="compact"&gt;&lt;li&gt;&lt;p&gt;                     There can only be a single entity named in the from-clause. It can, however, be                     aliased.  If the entity name is aliased, then any property references must                     be qualified using that alias. If the entity name is not aliased, then it is                     illegal for any property references to be qualified.                 &lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p&gt;                     No joins, either implicit or explicit,                  can be specified in a bulk HQL query.  Sub-queries can be used in the where-clause, where                  the subqueries themselves may contain joins.                 &lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;&lt;div style="text-align: justify;"&gt;&lt;span style="font-family: times new roman; color: rgb(0, 0, 0);"&gt;In my database design, most entity contain child entity. Number of condition validations are considered too. At the end, I decide to choose Batch Processing to do my data cleaning process. I am using the example from hibernate to delete my entity one by one.&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family: times new roman; color: rgb(0, 0, 0);"&gt;(1) Set the JDBC batch size to a reasonable number (10-50, for example):&lt;/span&gt;&lt;br /&gt;&lt;pre style="font-family: times new roman; color: rgb(0, 0, 0);" class="programlisting"&gt;hibernate.jdbc.batch_size 50&lt;/pre&gt;&lt;br /&gt;&lt;span style="font-family: times new roman; color: rgb(0, 0, 0);"&gt;(2)&lt;/span&gt;&lt;br /&gt;&lt;pre style="font-family: times new roman; color: rgb(0, 0, 0);" class="programlisting"&gt;&lt;a id="batch-update"&gt;Session session = sessionFactory.openSession();&lt;br /&gt;Transaction tx = session.beginTransaction();&lt;br /&gt; &lt;br /&gt;ScrollableResults customers = session.getNamedQuery("GetCustomers")&lt;br /&gt;   .setCacheMode(CacheMode.IGNORE)&lt;br /&gt;   .scroll(ScrollMode.FORWARD_ONLY);&lt;br /&gt;int count=0;&lt;br /&gt;while ( customers.next() ) {&lt;br /&gt;   Customer customer = (Customer) customers.get(0);&lt;br /&gt;   session.delete(customer);&lt;br /&gt;   if ( ++count % 50 == 0 ) {&lt;br /&gt;       //flush a batch of updates and release memory:&lt;br /&gt;       session.flush();&lt;br /&gt;       session.clear();&lt;br /&gt;   }&lt;br /&gt;}&lt;br /&gt; &lt;br /&gt;tx.commit();&lt;br /&gt;session.close();&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;If anyone of you have any good idea please do let me know, since I really no idea what kind of solution I can use.&lt;br /&gt;&lt;/a&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3804827704953141110-604590662990933151?l=myjavaroom.blogspot.com' alt='' /&gt;&lt;/div&gt;</description><app:edited xmlns:app="http://www.w3.org/2007/app">2010-01-07T15:23:25.402+08:00</app:edited><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">0</thr:total></item><item><title>JBoss Seam Excel Implementation - Part 2</title><link>http://myjavaroom.blogspot.com/2009/12/jboss-seam-excel-implementation-part-2.html</link><category>Excel</category><category>JExcelAPI</category><category>JBoss Seam</category><author>noreply@blogger.com (Lee)</author><pubDate>Sat, 29 May 2010 04:30:20 PDT</pubDate><guid isPermaLink="false">tag:blogger.com,1999:blog-3804827704953141110.post-3389390873523886015</guid><description>
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/kj9pCjT7JUOMTvtDKcq6P_cqnas/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/kj9pCjT7JUOMTvtDKcq6P_cqnas/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/kj9pCjT7JUOMTvtDKcq6P_cqnas/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/kj9pCjT7JUOMTvtDKcq6P_cqnas/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;div style="text-align: justify;"&gt;&lt;span style="font-family: times new roman;"&gt;In my previous post &lt;a href="http://myjavaroom.blogspot.com/2009/10/microsoft-excel-spreadsheet-in-jboss.html"&gt;JBoss Seam Excel Implementation&lt;/a&gt;, I had mentioned how to configure Microsoft® Excel® Spreadsheet in JBoss Seam and some of the usage of different tags available in Seam. Seam generates Microsoft® Excel® spreadsheet application spreadsheets using &lt;/span&gt;&lt;a href="http://jexcelapi.sourceforge.net/" style="font-family: times new roman;" xlink="http://www.w3.org/1999/xlink"&gt;JExcelAPI       &lt;/a&gt;&lt;span style="font-family: times new roman;"&gt; library. For futher information please refer to &lt;/span&gt;&lt;a href="http://jexcelapi.sourceforge.net/" style="font-family: times new roman;" xlink="http://www.w3.org/1999/xlink"&gt;JExcelAPI       &lt;/a&gt; &lt;span style="font-family: times new roman;"&gt;.&lt;/span&gt;&lt;span style="font-family: times new roman;"&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: times new roman;"&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: times new roman;"&gt;In the examples below show how to use Formulas and Format Masks in Excel® worksheet.&lt;/span&gt; &lt;span style="font-family: times new roman;"&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;span style="font-weight: bold;"&gt;(1) Formulas: Dynamic Sum of Selected Cells&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family: times new roman;"&gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;e:worksheet value="#{data}" var="item"&amp;gt;&lt;/span&gt;&lt;span style="font-family: times new roman;"&gt;&lt;br /&gt;
&amp;lt;e:column&amp;gt;&lt;/span&gt;&lt;span style="font-family: times new roman;"&gt;&lt;br /&gt;
&amp;lt;f:facet name="header"&amp;gt;&lt;/span&gt;&lt;span style="font-family: times new roman;"&gt;&lt;br /&gt;
&amp;lt;e:cell value="Amount"/&amp;gt;&lt;/span&gt;&lt;span style="font-family: times new roman;"&gt;&lt;br /&gt;
&amp;lt;/facet&amp;gt;&lt;/span&gt;&lt;span style="font-family: times new roman;"&gt;&lt;/span&gt;&lt;span style="font-family: times new roman;"&gt;&lt;br /&gt;
&amp;lt;e:cell value="#{item.amount}"/&amp;gt;&lt;/span&gt;&lt;span style="font-family: times new roman;"&gt;&lt;br /&gt;
&amp;lt;f:facet name="footer"&amp;gt;&lt;/span&gt;&lt;span style="font-family: times new roman;"&gt;&lt;br /&gt;
&amp;lt;e:formula value="SUM(A2:A#{data.size+1})"/&amp;gt;&lt;/span&gt;&lt;span style="font-family: times new roman;"&gt;&lt;br /&gt;
&amp;lt;/facet&amp;gt;        &lt;/span&gt;&lt;span style="font-family: times new roman;"&gt;&lt;br /&gt;
&amp;lt;/e:column&amp;gt;  &lt;/span&gt;&lt;span style="font-family: times new roman;"&gt;&lt;br /&gt;
&amp;lt;/e:worksheet&amp;gt;&lt;/span&gt;&lt;span style="font-family: times new roman;"&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;div style="text-align: center;"&gt;&lt;a href="http://4.bp.blogspot.com/_0_eQsD3mMAk/SyLzw52cWeI/AAAAAAAAALU/4H3D15mTYpU/s1600-h/excel-part2.JPG" onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}"&gt;&lt;img alt="" border="0" id="BLOGGER_PHOTO_ID_5414157723541199330" src="http://4.bp.blogspot.com/_0_eQsD3mMAk/SyLzw52cWeI/AAAAAAAAALU/4H3D15mTYpU/s400/excel-part2.JPG" style="cursor: pointer; display: block; height: 322px; margin: 0px auto 10px; text-align: center; width: 395px;" /&gt;&lt;/a&gt;&lt;span style="font-family: times new roman; font-style: italic;"&gt;Sample of Dynamic Sum of Selected Cells&lt;/span&gt;&lt;span style="font-family: times new roman;"&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;span style="font-family: times new roman;"&gt;&lt;br /&gt;
&lt;span style="font-weight: bold;"&gt;(2) Format Masks&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family: times new roman;"&gt;&lt;br /&gt;
&lt;br /&gt;
(a) Number masks:&lt;/span&gt;&lt;span style="font-family: times new roman;"&gt;&lt;br /&gt;
&lt;/span&gt;&lt;span style="font-family: times new roman;"&gt;&lt;br /&gt;
&amp;lt;e:cell value="#{item.amount}" style="xls-format-mask: FORMAT3"/&amp;gt;&lt;/span&gt;&lt;span style="font-family: times new roman;"&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;div style="text-align: left;"&gt;&lt;span style="font-family: times new roman;"&gt;For more more information for formal masks pls refer to &lt;a href="http://jexcelapi.sourceforge.net/resources/javadocs/current/docs/jxl/write/NumberFormats.html"&gt;jxl.write.NumberFormats&lt;/a&gt;&lt;/span&gt;&lt;/div&gt;&lt;span style="font-family: times new roman;"&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: times new roman;"&gt;    &lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3804827704953141110-3389390873523886015?l=myjavaroom.blogspot.com' alt='' /&gt;&lt;/div&gt;</description><app:edited xmlns:app="http://www.w3.org/2007/app">2010-05-29T19:30:20.062+08:00</app:edited><media:thumbnail url="http://4.bp.blogspot.com/_0_eQsD3mMAk/SyLzw52cWeI/AAAAAAAAALU/4H3D15mTYpU/s72-c/excel-part2.JPG" height="72" width="72" /><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">3</thr:total></item><item><title>Troubleshooting for CAS SSO and JBoss SSL Configuration</title><link>http://myjavaroom.blogspot.com/2009/12/troubleshooting-for-cas-sso-and-jboss.html</link><category>JBoss AS</category><category>CAS SSO</category><author>noreply@blogger.com (Lee)</author><pubDate>Sat, 05 Dec 2009 05:05:50 PST</pubDate><guid isPermaLink="false">tag:blogger.com,1999:blog-3804827704953141110.post-3039816793014096507</guid><description>
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/f2rEtLvDC2kPJu6yBfabYNitiSY/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/f2rEtLvDC2kPJu6yBfabYNitiSY/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/f2rEtLvDC2kPJu6yBfabYNitiSY/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/f2rEtLvDC2kPJu6yBfabYNitiSY/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;span style=";font-family:&amp;quot;;" &gt;&lt;span style="font-weight: normal;font-family:times new roman;" &gt;Command errors found during CAS SSO implementation on JBoss.&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;p&gt;&lt;/p&gt;&lt;span style=";font-family:&amp;quot;;" &gt;&lt;span style=""&gt;&lt;span style="font-weight: bold;"&gt;Redirect Loop after login to CAS server&lt;br /&gt;-----------------------------------------------------&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;p class="MsoNormal"&gt;&lt;span style=";font-family:&amp;quot;;" &gt;&lt;span style=""&gt;ERROR [Cas20ServiceTicketValidator] javax.net.ssl.SSLHandshakeException: sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target&lt;br /&gt;javax.net.ssl.SSLHandshakeException: sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target&lt;br /&gt;&lt;br /&gt;Caused by: sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target&lt;br /&gt;     at sun.security.validator.PKIXValidator.doBuild(PKIXValidator.java:285)&lt;br /&gt;     at sun.security.validator.PKIXValidator.engineValidate(PKIXValidator.java:191)&lt;br /&gt;     at sun.security.validator.Validator.validate(Validator.java:218)&lt;br /&gt;     at com.sun.net.ssl.internal.ssl.X509TrustManagerImpl.validate(X509TrustManagerImpl.java:126)&lt;br /&gt;     at com.sun.net.ssl.internal.ssl.X509TrustManagerImpl.checkServerTrusted(X509TrustManagerImpl.java:209)&lt;br /&gt;     at com.sun.net.ssl.internal.ssl.X509TrustManagerImpl.checkServerTrusted(X509TrustManagerImpl.java:249)&lt;br /&gt;     at com.sun.net.ssl.internal.ssl.ClientHandshaker.serverCertificate(ClientHandshaker.java:1014)&lt;br /&gt;     ... 59 more&lt;br /&gt;Caused by: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target&lt;br /&gt;     at sun.security.provider.certpath.SunCertPathBuilder.engineBuild(SunCertPathBuilder.java:174)&lt;br /&gt;     at java.security.cert.CertPathBuilder.build(CertPathBuilder.java:238)&lt;br /&gt;     at sun.security.validator.PKIXValidator.doBuild(PKIXValidator.java:280)&lt;br /&gt;     ... 65 more&lt;br /&gt;[Cas20ProxyReceivingTicketValidationFilter] org.jasig.cas.client.validation.TicketValidationException: The CAS server returned no response.&lt;br /&gt;org.jasig.cas.client.validation.TicketValidationException: The CAS server returned no response.&lt;br /&gt;&lt;br /&gt;ERROR [Exceptions] handled and logged exception&lt;br /&gt;javax.servlet.ServletException: org.jasig.cas.client.validation.TicketValidationException: The CAS server returned no response.&lt;br /&gt;&lt;br /&gt;Caused by: org.jasig.cas.client.validation.TicketValidationException: The CAS server returned no response.&lt;br /&gt;     at org.jasig.cas.client.validation.AbstractUrlBasedTicketValidator.validate(AbstractUrlBasedTicketValidator.java:181)        at org.jasig.cas.client.validation.AbstractTicketValidationFilter.doFilter(AbstractTicketValidationFilter.java:132)&lt;br /&gt;     ... 45 more&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;SOLUTION 1:&lt;/span&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class="MsoNormal"&gt;&lt;span style=";font-family:&amp;quot;;" &gt;&lt;span style=""&gt;    You must specify the location of the truststore using: -Djavax.net.ssl.trustStore&lt;br /&gt; If not Tomcat will unable to allocate the truststore file.&lt;br /&gt;&lt;br /&gt; Example:&lt;br /&gt; run.bat -c default -b 192.168.1.8 -Djavax.net.ssl.trustStore="c:/jboss-4.2.3.GA/server/default/conf/javaroom.keystore"&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;SOLUTION 2:&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class="MsoNormal"&gt;&lt;span style=";font-family:&amp;quot;;" &gt;&lt;span style=""&gt;    During generate the keystore file, you must enter the domain name used for the CAS server.&lt;br /&gt;&lt;br /&gt; Example:&lt;br /&gt; What is your first and last name?&lt;br /&gt;   [Unknown]: javaroom.com&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class="MsoNormal"&gt;&lt;br /&gt;&lt;span style=";font-family:&amp;quot;;" &gt;&lt;span style=""&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class="MsoNormal"&gt;&lt;br /&gt;&lt;span style=";font-family:&amp;quot;;" &gt;&lt;span style=""&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class="MsoNormal"&gt;&lt;span style=";font-family:times new roman;font-size:100%;"  &gt;&lt;span style="font-weight: bold;font-family:times new roman;" &gt;Related Posts:&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class="MsoNormal"&gt;&lt;span style="font-family:times new roman;"&gt;&lt;span style="font-family:times new roman;"&gt;&lt;a href="http://myjavaroom.blogspot.com/2009/12/generate-self-signed-certificate-for.html"&gt;Generate Self-signed Certificate for CAS SSO on JBoss&lt;/a&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=";font-family:times new roman;font-size:100%;"  &gt;&lt;span style="font-family:times new roman;"&gt;&lt;a href="http://myjavaroom.blogspot.com/2009/11/cas-single-sign-on-and-jboss-seam.html"&gt;CAS Single Sign-On and JBoss Seam Integration&lt;/a&gt;&lt;/span&gt;&lt;span style="font-family:times new roman;"&gt;&lt;br /&gt;&lt;a href="http://myjavaroom.blogspot.com/2009/11/cas-sso-configuration-using-jdbc.html"&gt;CAS SSO Configuration using JDBC Authentication&lt;br /&gt;&lt;/a&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3804827704953141110-3039816793014096507?l=myjavaroom.blogspot.com' alt='' /&gt;&lt;/div&gt;</description><app:edited xmlns:app="http://www.w3.org/2007/app">2009-12-05T21:05:50.927+08:00</app:edited><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">0</thr:total></item><item><title>Generate Self-signed Certificate for CAS SSO on JBoss</title><link>http://myjavaroom.blogspot.com/2009/12/generate-self-signed-certificate-for.html</link><category>CAS SSO</category><category>Keystore</category><author>noreply@blogger.com (Lee)</author><pubDate>Wed, 20 Oct 2010 23:49:44 PDT</pubDate><guid isPermaLink="false">tag:blogger.com,1999:blog-3804827704953141110.post-618049391038016504</guid><description>
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/Yyi5lE5VFqjzMWPTzi0upxKrDsM/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/Yyi5lE5VFqjzMWPTzi0upxKrDsM/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/Yyi5lE5VFqjzMWPTzi0upxKrDsM/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/Yyi5lE5VFqjzMWPTzi0upxKrDsM/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;div style="text-align: justify;"&gt;&lt;span style="font-size: 100%;"&gt;&lt;span style="font-family: times new roman;"&gt;Last few days I was busy to configure CAS SSO into the Linux server. It was definitely a nightmare for me. I expect it will be same as configuration in Windows. No matter I am using the keystore I generated in Windows or I generate a new copy of keystore and self-signed certificate using keytool or openssl in Linux, when start the server it will throw exception in &lt;/span&gt;&lt;span id="main" style="font-family: times new roman; font-style: italic; font-weight: bold; visibility: visible;"&gt;&lt;span id="search" style="visibility: visible;"&gt;UnsatisfiedLinkError: &lt;i&gt;no sunmscapi&lt;/i&gt; in java.library.path&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family: times new roman;"&gt;. This is something make me so confused! &lt;span class="highlight" style="font-style: italic; font-weight: bold;"&gt;SunMSCAPI&lt;/span&gt; is used in Windows platform. This was definitely wasting so much of my times to find out the reason. And finally I found&lt;span style="font-weight: bold;"&gt; &lt;/span&gt;somebody&lt;span style="font-weight: bold;"&gt; &lt;/span&gt;replaced the &lt;span style="font-style: italic; font-weight: bold;"&gt;java.security&lt;/span&gt; file in linux server with the Windows version!! Arrrgghh........I wanna cry when I saw that. Now my CAS SSO is working very well in the Linux server. The below configuration of keystore and self-signed certificate for CAS SSO in JBoss is working for Linux and Windows.&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;span style="font-size: 100%;"&gt;&lt;span style="font-family: times new roman;"&gt;Platform:&lt;/span&gt;&lt;span style="font-family: times new roman;"&gt;&lt;br /&gt;
Windows/Linux&lt;/span&gt;&lt;span style="font-family: times new roman;"&gt;&lt;br /&gt;
JBoss-4.2.3.GA&lt;/span&gt;&lt;span style="font-family: times new roman;"&gt;&lt;br /&gt;
CAS-server-3.3.4&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;/span&gt;&lt;span style="font-family: times new roman; font-size: 100%; font-weight: bold;"&gt;6 Steps to enable CAS SSO on JBoss&lt;/span&gt;&lt;span style="font-family: times new roman; font-size: 100%; font-weight: bold;"&gt;&lt;br /&gt;
--------------------------------------------------&lt;/span&gt;&lt;span style="font-family: times new roman; font-size: 100%;"&gt;&lt;span style="font-family: times new roman; font-weight: bold;"&gt;--&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
(1) Keystore and Private Key (javaroom.keystore): &lt;/span&gt; &lt;span style="font-family: times new roman; font-size: 100%;"&gt;&lt;br /&gt;
keytool -genkey -alias javaroom -keyalg RSA -keypass changeit -storepass changeit -keystore javaroom.keystore -validity 3650&lt;/span&gt;&lt;span style="font-size: 100%;"&gt;&lt;br /&gt;
&lt;/span&gt;&lt;span style="font-family: times new roman; font-size: 100%;"&gt;&lt;br /&gt;
&lt;span style="color: #3333ff;"&gt;    **Important:&lt;/span&gt;  &lt;/span&gt;&lt;span style="color: #3333ff; font-family: times new roman; font-size: 100%;"&gt;    What is your first and last name?&lt;br /&gt;
[Unknown]:  myhostname.com&lt;br /&gt;
&lt;br /&gt;
(This is very important, must same as the domain name used for CAS server)&lt;/span&gt;&lt;span style="font-family: times new roman; font-size: 100%;"&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;/span&gt;&lt;span style="font-family: times new roman; font-size: 100%;"&gt;(2) Certificate (javaroom.crt):&lt;/span&gt;&lt;span style="font-family: times new roman; font-size: 100%;"&gt;&lt;br /&gt;
&lt;/span&gt;&lt;span style="font-family: times new roman; font-size: 100%;"&gt;      keytool -export -alias javaroom-storepass changeit -file javaroom.crt -keystore misbserver.keystore &lt;/span&gt;&lt;span style="font-size: 100%;"&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;/span&gt;&lt;span style="font-family: times new roman; font-size: 100%;"&gt;(3) TrustStore (javaroom.keystore): &lt;/span&gt;&lt;span style="font-family: times new roman; font-size: 100%;"&gt;&lt;br /&gt;
&lt;/span&gt;&lt;span style="font-family: times new roman; font-size: 100%;"&gt;      keytool -import -trustcacerts -file javaroom.crt -keystore javaroom.keystore -storepass changeit &lt;/span&gt;&lt;span style="font-family: times new roman; font-size: 100%;"&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style="color: #3333ff;"&gt;Enter "yes" when &lt;/span&gt;&lt;/span&gt;&lt;span style="color: #3333ff; font-family: times new roman; font-size: 100%;"&gt;&lt;br /&gt;
(Store the the certificate into the same keystore file)&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;a href="http://2.bp.blogspot.com/_0_eQsD3mMAk/SxhbjTV6CjI/AAAAAAAAAKM/YvYo2lkTD3w/s1600-h/keytool.jpg" onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}"&gt;&lt;img alt="" border="0" id="BLOGGER_PHOTO_ID_5411175614331357746" src="http://2.bp.blogspot.com/_0_eQsD3mMAk/SxhbjTV6CjI/AAAAAAAAAKM/YvYo2lkTD3w/s400/keytool.jpg" style="cursor: pointer; display: block; height: 251px; margin: 0px auto 10px; text-align: center; width: 400px;" /&gt;&lt;/a&gt;&lt;span style="font-size: 100%;"&gt;&lt;br /&gt;
&lt;/span&gt;&lt;span style="font-family: times new roman; font-size: 100%;"&gt;&lt;br /&gt;
(4) Copy misbserver.keystore to c:/jboss/server/default/conf&lt;/span&gt; &lt;span style="font-size: 100%;"&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;/span&gt;&lt;span style="font-family: times new roman; font-size: 100%;"&gt;(5) Update server.xml in c:/jboss/server/default/deploy/jboss-web.deployer&lt;/span&gt;  &lt;span style="font-family: times new roman; font-size: 100%;"&gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;Connector protocol="HTTP/1.1" &lt;/span&gt; &lt;span style="font-family: times new roman; font-size: 100%;"&gt;               port="8443"&lt;br /&gt;
minSpareThreads="5" maxSpareThreads="75"&lt;/span&gt;&lt;span style="font-size: 100%;"&gt;  &lt;/span&gt;&lt;span style="font-family: times new roman; font-size: 100%;"&gt;               enableLookups="true"&lt;br /&gt;
disableUploadTimeout="true"&lt;/span&gt;&lt;span style="font-size: 100%;"&gt; &lt;/span&gt;&lt;span style="font-family: times new roman; font-size: 100%;"&gt;               acceptCount="100"  maxThreads="200"&lt;/span&gt; &lt;span style="font-family: times new roman; font-size: 100%;"&gt;   &lt;br /&gt;
scheme="https" secure="true" SSLEnabled="true"&lt;/span&gt;&lt;span style="font-size: 100%;"&gt; &lt;/span&gt;&lt;span style="font-family: times new roman; font-size: 100%;"&gt;               clientAuth="false" sslProtocol="TLS" &lt;/span&gt; &lt;span style="font-family: times new roman; font-size: 100%;"&gt;&lt;br /&gt;
keystoreFile="${jboss.server.home.dir}/conf/javaroom.keystore"&lt;/span&gt;&lt;span style="font-size: 100%;"&gt; &lt;/span&gt;&lt;span style="font-family: times new roman; font-size: 100%;"&gt;            keystoreType="JKS" keystorePass="changeit"&lt;/span&gt; &lt;span style="font-family: times new roman; font-size: 100%;"&gt;&lt;br /&gt;
truststoreFile="${jboss.server.home.dir}/conf/javaroom.keystore"&lt;/span&gt;&lt;span style="font-size: 100%;"&gt; &lt;/span&gt;&lt;span style="font-family: times new roman; font-size: 100%;"&gt;            truststoreType="JKS"&lt;br /&gt;
truststorePass="changeit"/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;/span&gt;&lt;span style="color: #3333ff; font-family: times new roman; font-size: 100%;"&gt;**Important: &lt;/span&gt; &lt;span style="color: #3333ff; font-family: times new roman; font-size: 100%;"&gt;&lt;br /&gt;
TrustStore file must be specified in &amp;lt;Connector&amp;gt;, if not the default certificate &lt;/span&gt; &lt;span style="color: #3333ff; font-family: times new roman; font-size: 100%;"&gt;        in C:/jdk/jre/lib/security/cacerts will be refered.&lt;/span&gt; &lt;span style="color: #3333ff; font-family: times new roman; font-size: 100%;"&gt;        &lt;/span&gt;  &lt;span style="font-family: times new roman; font-size: 100%;"&gt;&lt;br /&gt;
&lt;br /&gt;
(6) Start server with:&lt;/span&gt;&lt;span style="font-size: 100%;"&gt;  &lt;/span&gt;&lt;span style="font-family: times new roman; font-size: 100%;"&gt;    run.bat -c default -b 192.168.1.8 -Djavax.net.ssl.trustStore="c:/jboss-4.2.3.GA/server/default/conf/javaroom.keystore"&lt;/span&gt;   &lt;span style="font-family: times new roman; font-size: 100%;"&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style="color: #3333ff;"&gt;**Important:&lt;/span&gt;&lt;/span&gt;&lt;span style="font-size: 100%;"&gt;&lt;span style="color: #3333ff;"&gt; &lt;/span&gt;&lt;/span&gt;&lt;span style="color: #3333ff; font-family: times new roman; font-size: 100%;"&gt;    You must specify the location of the truststore using: -Djavax.net.ssl.trustStore. Otherwise,&lt;/span&gt;&lt;span style="font-family: times new roman; font-size: 100%;"&gt;&lt;span style="color: #3333ff;"&gt; Tomcat will unable to allocate the truststore file.&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;span style="font-family: times new roman; font-weight: bold;"&gt;Related Posts:&lt;br /&gt;
&lt;br /&gt;
&lt;/span&gt;&lt;span style="font-family: times new roman;"&gt;&lt;a href="http://myjavaroom.blogspot.com/2009/11/cas-single-sign-on-and-jboss-seam.html"&gt;CAS Single Sign-On and JBoss Seam Integration&lt;/a&gt;&lt;/span&gt;&lt;span style="font-family: times new roman;"&gt;&lt;br /&gt;
&lt;a href="http://myjavaroom.blogspot.com/2009/11/cas-sso-configuration-using-jdbc.html"&gt;CAS SSO Configuration using JDBC Authentication &lt;/a&gt;&lt;/span&gt;&lt;br /&gt;
&lt;/span&gt; &lt;span style="font-family: times new roman; font-size: 100%;"&gt;    &lt;/span&gt; &lt;span style="font-family: times new roman; font-size: 100%;"&gt;    &lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3804827704953141110-618049391038016504?l=myjavaroom.blogspot.com' alt='' /&gt;&lt;/div&gt;</description><app:edited xmlns:app="http://www.w3.org/2007/app">2010-10-21T14:49:44.752+08:00</app:edited><media:thumbnail url="http://2.bp.blogspot.com/_0_eQsD3mMAk/SxhbjTV6CjI/AAAAAAAAAKM/YvYo2lkTD3w/s72-c/keytool.jpg" height="72" width="72" /><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">0</thr:total></item><item><title>CAS SSO Configuration using JDBC Authentication in JBoss</title><link>http://myjavaroom.blogspot.com/2009/11/cas-sso-configuration-using-jdbc.html</link><category>JBoss AS</category><category>CAS SSO</category><author>noreply@blogger.com (Lee)</author><pubDate>Thu, 03 Dec 2009 16:55:50 PST</pubDate><guid isPermaLink="false">tag:blogger.com,1999:blog-3804827704953141110.post-2529696031144123688</guid><description>
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/VphzeU212lzQhZ_HYgEuaeymwKc/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/VphzeU212lzQhZ_HYgEuaeymwKc/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/VphzeU212lzQhZ_HYgEuaeymwKc/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/VphzeU212lzQhZ_HYgEuaeymwKc/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;span style="font-weight: bold;font-family:times new roman;" &gt;The CAS SSO and JBoss-4.2.3.GA  integration is very simple. &lt;/span&gt;&lt;br /&gt;&lt;ol style="font-family: times new roman;"&gt;&lt;li&gt;Rename the cas-3.3.x.war to cas.war. &lt;/li&gt;&lt;li&gt;Configure the CAS SSO authentication using JDBC authentication(refer to the steps below).&lt;br /&gt;&lt;/li&gt;&lt;li&gt;Copy the cas.war into your JBoss deploy directory.&lt;br /&gt;&lt;/li&gt;&lt;/ol&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;font-family:times new roman;" &gt;CAS SSO Configuration using JDBC Authentication:&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family:times new roman;"&gt;1. deployerConfigContext.xml in cas.war&lt;br /&gt;-----------------------------------------&lt;br /&gt;- Configure the DataSource to be used for CAS&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family:times new roman;"&gt;    &amp;lt;bean id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource"&gt;  &lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:times new roman;"&gt;        &amp;lt;property name="driverClassName"&gt;&amp;lt;value&gt;org.postgresql.Driver&amp;lt;/value&gt;&amp;lt;/property&gt;&lt;br /&gt;      &amp;lt;property name="url"&gt;&amp;lt;value&gt;jdbc:postgresql:testDatabase&amp;lt;/value&gt;&amp;lt;/property&gt;&lt;br /&gt;      &amp;lt;property name="username"&gt;&amp;lt;value&gt;test&amp;lt;/value&gt;&amp;lt;/property&gt;&lt;br /&gt;      &amp;lt;property name="password"&gt;&amp;lt;value&gt;test&amp;lt;/value&gt;&amp;lt;/property&gt;  &lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:times new roman;"&gt;    &amp;lt;/bean&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;- If you are using your own password encoder to encrypt for the password to be stored in database,&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:times new roman;"&gt;  add AnyPasswordEncoder.class into the cas-server-core-3.3.4.jar/org/jasig/cas/authentication/handler/&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:times new roman;"&gt;  or you can add the password encoder jar file into cas.war/WEB-INF/lib&lt;br /&gt;&lt;br /&gt;- Configure the Password Encoder&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:times new roman;"&gt;    &amp;lt;bean id="passwordEncoder"  class="org.jasig.cas.authentication.handler.AnyPasswordEncoder"/&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;2. Configure database dialect cas.properties in cas.war/WEB-INF folder&lt;br /&gt;-------------------------------------------------------------------------&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:times new roman;"&gt;&lt;br /&gt;cas.securityContext.serviceProperties.service=https://test.sso:8443/cas/services/j_acegi_cas_security_check&lt;br /&gt;cas.securityContext.casProcessingFilterEntryPoint.loginUrl=https://test.sso:8443/cas/login&lt;br /&gt;cas.securityContext.ticketValidator.casServerUrlPrefix=https://test.sso:8443/cas&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:times new roman;"&gt;&lt;br /&gt;cas.themeResolver.defaultThemeName=default&lt;br /&gt;cas.viewResolver.basename=default&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:times new roman;"&gt;&lt;br /&gt;host.name=cas&lt;br /&gt;&lt;br /&gt;database.hibernate.dialect=org.hibernate.dialect.PostgreSQLDialect&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;3. JDBC Library for CAS&lt;br /&gt;---------------------------&lt;br /&gt;Add libraries below into cas.war/WEB-INF/lib&lt;br /&gt;&lt;br /&gt;- org.springframework.jdbc-2.5.6.jar&lt;br /&gt;- cas-server-support-3.3.2.jar&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family: times new roman;"&gt;If you would like to integrate the CAS SSO with JBoss Seam, please refer to:&lt;/span&gt;&lt;br /&gt;&lt;a style="font-family: times new roman;" href="http://myjavaroom.blogspot.com/2009/11/cas-single-sign-on-and-jboss-seam.html"&gt;CAS Single Sign-On and JBoss Seam Integration&lt;/a&gt;&lt;span style="font-family: times new roman;"&gt; and &lt;/span&gt;&lt;span style="font-family: times new roman;"&gt;&lt;br /&gt;&lt;a href="http://myjavaroom.blogspot.com/2009/12/generate-self-signed-certificate-for.html"&gt;Generate Self-signed Certificate for CAS SSO on JBoss&lt;/a&gt;&lt;/span&gt;&lt;br /&gt;&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3804827704953141110-2529696031144123688?l=myjavaroom.blogspot.com' alt='' /&gt;&lt;/div&gt;</description><app:edited xmlns:app="http://www.w3.org/2007/app">2009-12-04T08:55:50.355+08:00</app:edited><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">0</thr:total></item><item><title>CAS Single Sign-On and JBoss Seam Integration</title><link>http://myjavaroom.blogspot.com/2009/11/cas-single-sign-on-and-jboss-seam.html</link><category>CAS SSO</category><category>JBoss Seam</category><author>noreply@blogger.com (Lee)</author><pubDate>Thu, 03 Dec 2009 16:57:26 PST</pubDate><guid isPermaLink="false">tag:blogger.com,1999:blog-3804827704953141110.post-6255142704553659078</guid><description>
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/cqGxMvEFUeBQAmin_bO6VTzbFdk/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/cqGxMvEFUeBQAmin_bO6VTzbFdk/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/cqGxMvEFUeBQAmin_bO6VTzbFdk/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/cqGxMvEFUeBQAmin_bO6VTzbFdk/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;span style=";font-family:times new roman;font-size:100%;"  &gt;I had implemented CAS SSO in my Seam Application. It is working so well. Hope this document can help those planning to implement CAS SSO in their Seam Application.&lt;br /&gt;&lt;br /&gt;CAS SSO and Seam Environment:&lt;br /&gt;----------------------------------&lt;br /&gt;Jboss-4.2.3.GA&lt;br /&gt;Seam-2.1.2&lt;br /&gt;cas-server-3.3.4-release&lt;br /&gt;cas-client-3.1.3-release&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;1. Create SSOAuntheticator.java&lt;br /&gt;-------------------------------&lt;br /&gt;public class SSOAuthenticator {&lt;br /&gt;&lt;br /&gt;  public void checkLogin()&lt;br /&gt;  {&lt;br /&gt;      // user may already be logged in - check&lt;br /&gt;      final boolean isLoggedIn = Identity.instance().isLoggedIn();&lt;br /&gt;&lt;br /&gt;      if (isLoggedIn) {&lt;br /&gt;        return;&lt;br /&gt;      }&lt;br /&gt;      authenticate();&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;  public boolean authenticate(){&lt;br /&gt;&lt;br /&gt;      Identity identity = Identity.instance();&lt;br /&gt;&lt;br /&gt;      FacesContext facesContext = FacesContext.getCurrentInstance();&lt;br /&gt;      ExternalContext ctx = facesContext.getExternalContext();&lt;br /&gt;&lt;br /&gt;      Principal rawPrincipal = ctx.getUserPrincipal();&lt;br /&gt;      String username = rawPrincipal.getName();&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;      try{&lt;br /&gt;          String ejbql = "select u from UserAccount u where u.username=:username";&lt;br /&gt;          List&amp;lt;UserAccount&gt; result= entityManager.createQuery(ejbql).setParameter("username", username).getResultList();&lt;br /&gt;&lt;br /&gt;          if(result.size()==1)&lt;br /&gt;          {&lt;br /&gt;              UserAccount userAccount = (UserAccount)result.get(0);&lt;br /&gt;&lt;br /&gt;              identity.setUsername(username);&lt;br /&gt;              identity.setPassword(username);&lt;br /&gt;              identity.isLoggedIn(true);&lt;br /&gt;&lt;br /&gt;              log.info("Login status....."+identity.isLoggedIn());&lt;br /&gt;&lt;br /&gt;              if(identity.isLoggedIn())&lt;br /&gt;              {&lt;br /&gt;                  for (UserRole role : userAccount.getRoles())&lt;br /&gt;                  {&lt;br /&gt;&lt;br /&gt;                      identity.addRole(role.getRoleId());&lt;br /&gt;                  }&lt;br /&gt;&lt;br /&gt;                  Events.instance().raiseEvent(Identity.EVENT_LOGIN_SUCCESSFUL);&lt;br /&gt;              }&lt;br /&gt;              return true;&lt;br /&gt;          }&lt;br /&gt;      }catch(Exception e)&lt;br /&gt;          {&lt;br /&gt;              System.err.println("authenticate exception: "+e);&lt;br /&gt;              return false;&lt;br /&gt;          }&lt;br /&gt;      return false;&lt;br /&gt;  }&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;  public void logout(){&lt;br /&gt;      Identity identity = Identity.instance();&lt;br /&gt;      identity.isLoggedIn(false);&lt;br /&gt;      identity.logout();&lt;br /&gt;      Session.instance().invalidate();&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;      FacesContext facesContext = FacesContext.getCurrentInstance();&lt;br /&gt;      ExternalContext ctx = facesContext.getExternalContext();&lt;br /&gt;&lt;br /&gt;      try {&lt;br /&gt;          String url = "https://test.com:8443/cas/logout";&lt;br /&gt;          ctx.redirect(ctx.encodeResourceURL(url));&lt;br /&gt;      } catch (Exception e) {&lt;br /&gt;          System.err.println("logout exception: "+e);&lt;br /&gt;      }&lt;br /&gt;      FacesContext.getCurrentInstance().responseComplete();&lt;br /&gt;&lt;br /&gt;  }&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;2. Configure SSOAuntheticator in components.xml&lt;br /&gt;-----------------------------------------------&lt;br /&gt;&amp;lt;security:identity authenticate-method="#{ssoAuthenticator.authenticate}"/&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;3. Configure login validation in pages.xml&lt;br /&gt;------------------------------------------&lt;br /&gt;&amp;lt;page view-id="*" action="#{ssoAuthenticator.checkLogin}" login-required="false"/&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;4. Configure web.xml for Single Sign-On Filter&lt;br /&gt;----------------------------------------------&lt;br /&gt;- Add CAS Authentication Filter&lt;br /&gt;- Sign Out Filter&lt;br /&gt;- Validation Filter&lt;br /&gt;- HttpServletRequest Wrapper Filter&lt;br /&gt;- Assertion Thread Local Filter&lt;br /&gt;- SingleSignOutHttpSessionListener&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&amp;lt;!-- JA-SIG CAS client for Java --&gt;&lt;br /&gt;&amp;lt;!-- Single sign-on filters --&gt;&lt;br /&gt;  &amp;lt;filter&gt;&lt;br /&gt;      &amp;lt;filter-name&gt;CAS Authentication Filter&amp;lt;/filter-name&gt;&lt;br /&gt;      &amp;lt;filter-class&gt;org.jasig.cas.client.authentication.AuthenticationFilter&amp;lt;/filter-class&gt;&lt;br /&gt;      &amp;lt;init-param&gt;&lt;br /&gt;          &amp;lt;param-name&gt;casServerLoginUrl&amp;lt;/param-name&gt;&lt;br /&gt;          &amp;lt;param-value&gt;https://test.com:8443/cas/login&amp;lt;/param-value&gt;&lt;br /&gt;      &amp;lt;/init-param&gt;&lt;br /&gt;      &amp;lt;init-param&gt;&lt;br /&gt;          &amp;lt;param-name&gt;renew&amp;lt;/param-name&gt;&lt;br /&gt;          &amp;lt;param-value&gt;false&amp;lt;/param-value&gt;&lt;br /&gt;      &amp;lt;/init-param&gt;&lt;br /&gt;      &amp;lt;init-param&gt;&lt;br /&gt;          &amp;lt;param-name&gt;serverName&amp;lt;/param-name&gt;&lt;br /&gt;          &amp;lt;param-value&gt;http://test.com:8080&amp;lt;/param-value&gt;&lt;br /&gt;      &amp;lt;/init-param&gt;&lt;br /&gt;  &amp;lt;/filter&gt;&lt;br /&gt;  &amp;lt;filter&gt;&lt;br /&gt;      &amp;lt;filter-name&gt;CAS Validation Filter&amp;lt;/filter-name&gt;&lt;br /&gt;      &amp;lt;filter-class&gt;org.jasig.cas.client.validation.Cas20ProxyReceivingTicketValidationFilter&amp;lt;/filter-class&gt;&lt;br /&gt;      &amp;lt;init-param&gt;&lt;br /&gt;          &amp;lt;param-name&gt;casServerUrlPrefix&amp;lt;/param-name&gt;&lt;br /&gt;          &amp;lt;param-value&gt;https://test.com:8443/cas&amp;lt;/param-value&gt;&lt;br /&gt;      &amp;lt;/init-param&gt;&lt;br /&gt;      &amp;lt;init-param&gt;&lt;br /&gt;          &amp;lt;param-name&gt;redirectAfterValidation&amp;lt;/param-name&gt;&lt;br /&gt;          &amp;lt;param-value&gt;true&amp;lt;/param-value&gt;&lt;br /&gt;      &amp;lt;/init-param&gt;&lt;br /&gt;      &amp;lt;init-param&gt;&lt;br /&gt;          &amp;lt;param-name&gt;useSession&amp;lt;/param-name&gt;&lt;br /&gt;          &amp;lt;param-value&gt;true&amp;lt;/param-value&gt;&lt;br /&gt;      &amp;lt;/init-param&gt; &lt;br /&gt;      &amp;lt;init-param&gt;&lt;br /&gt;          &amp;lt;param-name&gt;serverName&amp;lt;/param-name&gt;&lt;br /&gt;          &amp;lt;param-value&gt;http://test.com:8080&amp;lt;/param-value&gt;&lt;br /&gt;      &amp;lt;/init-param&gt;&lt;br /&gt;  &amp;lt;/filter&gt;&lt;br /&gt;  &amp;lt;filter&gt;&lt;br /&gt;      &amp;lt;filter-name&gt;CAS HttpServletRequest Wrapper Filter&amp;lt;/filter-name&gt;&lt;br /&gt;      &amp;lt;filter-class&gt;org.jasig.cas.client.util.HttpServletRequestWrapperFilter&amp;lt;/filter-class&gt;&lt;br /&gt;  &amp;lt;/filter&gt;&lt;br /&gt;  &amp;lt;filter&gt;&lt;br /&gt;      &amp;lt;filter-name&gt;CAS Assertion Thread Local Filter&amp;lt;/filter-name&gt;&lt;br /&gt;      &amp;lt;filter-class&gt;org.jasig.cas.client.util.AssertionThreadLocalFilter&amp;lt;/filter-class&gt;&lt;br /&gt;  &amp;lt;/filter&gt;&lt;br /&gt;&lt;br /&gt;  &amp;lt;!-- And now, the single sign-out filters --&gt;&lt;br /&gt;  &amp;lt;filter&gt;&lt;br /&gt;      &amp;lt;filter-name&gt;CAS Single Sign Out Filter&amp;lt;/filter-name&gt;&lt;br /&gt;      &amp;lt;filter-class&gt;org.jasig.cas.client.session.SingleSignOutFilter&amp;lt;/filter-class&gt;&lt;br /&gt;  &amp;lt;/filter&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&amp;lt;!-- Filter mappings in the correct order --&gt;&lt;br /&gt;&lt;br /&gt;  &amp;lt;filter-mapping&gt;&lt;br /&gt;      &amp;lt;filter-name&gt;CAS Single Sign Out Filter&amp;lt;/filter-name&gt;&lt;br /&gt;      &amp;lt;url-pattern&gt;/*&amp;lt;/url-pattern&gt;&lt;br /&gt;  &amp;lt;/filter-mapping&gt;&lt;br /&gt;  &amp;lt;filter-mapping&gt;&lt;br /&gt;      &amp;lt;filter-name&gt;CAS Authentication Filter&amp;lt;/filter-name&gt;&lt;br /&gt;      &amp;lt;url-pattern&gt;/*&amp;lt;/url-pattern&gt;&lt;br /&gt;  &amp;lt;/filter-mapping&gt;&lt;br /&gt;  &amp;lt;filter-mapping&gt;&lt;br /&gt;      &amp;lt;filter-name&gt;CAS Validation Filter&amp;lt;/filter-name&gt;&lt;br /&gt;      &amp;lt;url-pattern&gt;/*&amp;lt;/url-pattern&gt;&lt;br /&gt;  &amp;lt;/filter-mapping&gt;&lt;br /&gt;  &amp;lt;filter-mapping&gt;&lt;br /&gt;      &amp;lt;filter-name&gt;CAS HttpServletRequest Wrapper Filter&amp;lt;/filter-name&gt;&lt;br /&gt;      &amp;lt;url-pattern&gt;/*&amp;lt;/url-pattern&gt;&lt;br /&gt;  &amp;lt;/filter-mapping&gt;&lt;br /&gt;  &amp;lt;filter-mapping&gt;&lt;br /&gt;      &amp;lt;filter-name&gt;CAS Assertion Thread Local Filter&amp;lt;/filter-name&gt;&lt;br /&gt;      &amp;lt;url-pattern&gt;/*&amp;lt;/url-pattern&gt;&lt;br /&gt;  &amp;lt;/filter-mapping&gt;&lt;br /&gt;  &amp;lt;listener&gt;&lt;br /&gt;      &amp;lt;listener-class&gt;org.jasig.cas.client.session.SingleSignOutHttpSessionListener&amp;lt;/listener-class&gt;&lt;br /&gt;  &amp;lt;/listener&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Related Posts:&lt;/span&gt;&lt;br /&gt;&lt;a href="http://myjavaroom.blogspot.com/2009/11/cas-sso-configuration-using-jdbc.html"&gt;CAS SSO Configuration using JDBC Authentication&lt;/a&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-family:times new roman;"&gt;&lt;span style="font-family: times new roman;"&gt;&lt;a href="http://myjavaroom.blogspot.com/2009/12/generate-self-signed-certificate-for.html"&gt;Generate Self-signed Certificate for CAS SSO on JBoss&lt;/a&gt;&lt;/span&gt;&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3804827704953141110-6255142704553659078?l=myjavaroom.blogspot.com' alt='' /&gt;&lt;/div&gt;</description><app:edited xmlns:app="http://www.w3.org/2007/app">2009-12-04T08:57:26.199+08:00</app:edited><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">6</thr:total></item><item><title>Implementation of JNLP/Java Web Start in SSO Environment</title><link>http://myjavaroom.blogspot.com/2009/11/implementation-of-jnlpjava-web-start-in.html</link><category>Servlet</category><category>Java</category><category>CAS SSO</category><category>JNLP</category><category>Java Web Start</category><author>noreply@blogger.com (Lee)</author><pubDate>Sun, 08 Nov 2009 21:52:28 PST</pubDate><guid isPermaLink="false">tag:blogger.com,1999:blog-3804827704953141110.post-7870803009883378471</guid><description>
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/C0XChYxhTEPhaxps8op14H9jJcY/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/C0XChYxhTEPhaxps8op14H9jJcY/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/C0XChYxhTEPhaxps8op14H9jJcY/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/C0XChYxhTEPhaxps8op14H9jJcY/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;div style="text-align: justify;"&gt;&lt;span style="font-family: times new roman;"&gt;&lt;/span&gt;&lt;span style="font-family: times new roman;"&gt;In my &lt;a href="http://myjavaroom.blogspot.com/2009/10/blog-post.html"&gt;previous post&lt;/a&gt;, I came out a workaround to solve the Java Web Start error in Single Sign On environment using JNLP. I thought my problem had been solved and can sleep well. Unfortunately, the nightmare is never gone. I cannot run out from using JNLP in my system:( &lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family: times new roman;"&gt;I have to use JNLP to launch others component in my web application. Finally, I come the right solution to solve my JNLP error in SSO environment. &lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family: times new roman;"&gt;When you log into CAS SSO server, a cookie is saved in your browser. This cookie contains a unique ticket number that identifies you to the CAS server. CAS reads the cookie, looks up the ticket in its database, and identifies you. However, when I generate my dynamic JNLP through a servlet, the JNLP does not contains the cookie. Therefore, when I launch my Java component the java web start throw exception in:&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family: times new roman;"&gt;#### Java Web Start Error:&lt;/span&gt;&lt;span style="font-family: times new roman;"&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: times new roman;"&gt;#### Unable to load resource: http://sso.com:8080/MyApp/test.jar&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: times new roman;"&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: times new roman;"&gt;&lt;/span&gt;&lt;span style="font-family: times new roman;"&gt;com.sun.deploy.net.FailedDownloadException:&lt;br /&gt;Unable to load resource: http://sso.com:8080/MyApp/test.jar&lt;/span&gt;&lt;span style="font-family: times new roman;"&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: times new roman;"&gt;&lt;/span&gt;&lt;span style="font-family: times new roman;"&gt;&lt;br /&gt;and the wrapped exception:&lt;/span&gt;&lt;span style="font-family: times new roman;"&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: times new roman;"&gt;java.util.zip.ZipException: ZIP file must have at least one entry&lt;/span&gt;&lt;span style="font-weight: bold; font-family: times new roman;"&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;SOLUTION:&lt;br /&gt;&lt;/span&gt;&lt;span style="font-family: times new roman;"&gt;&lt;span style="font-weight: bold;"&gt;----------------&lt;/span&gt;&lt;br /&gt;To solve this error, we just need to add the Session Id into the JNLP.&lt;/span&gt;&lt;span style="font-family: times new roman;"&gt;&lt;br /&gt;&lt;br /&gt;&amp;lt;jar href="test.jar;jsessionid=sessionId"/&gt;&lt;/span&gt;&lt;span style="font-family: times new roman;"&gt;&lt;br /&gt;&lt;br /&gt;See, what a simple solution. And I had wasted so much times to work around here and there:(&lt;/span&gt;&lt;span style="font-weight: bold; font-family: times new roman;"&gt;&lt;br /&gt;&lt;br /&gt;Example in the JNLP servlet:&lt;/span&gt;&lt;span style="font-family: times new roman;"&gt;&lt;br /&gt;&lt;br /&gt;public void doGet(HttpServletRequest request, HttpServletResponse response){&lt;/span&gt;&lt;span style="font-family: times new roman;"&gt;&lt;br /&gt;String sessionId = request.getSession().getId();&lt;/span&gt;&lt;span style="font-family: times new roman;"&gt;&lt;br /&gt;response.setContentType("application/x-java-jnlp-file");&lt;/span&gt;&lt;span style="font-family: times new roman;"&gt;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-family: times new roman;"&gt;PrintWriter out = response.getWriter();&lt;/span&gt;&lt;span style="font-family: times new roman;"&gt;&lt;br /&gt;out.println("&amp;lt;?xml version=\"1.0\" encoding=\"UTF-8\"?&gt;");&lt;/span&gt;&lt;span style="font-family: times new roman;"&gt;&lt;br /&gt;out.println("&amp;lt;jnlp spec=\"1.0+\" codebase=\"" + codebaseURL + "\"&gt;");&lt;/span&gt;&lt;span style="font-family: times new roman;"&gt;&lt;br /&gt;out.println("&amp;lt;security&gt;&amp;lt;all-permissions/&gt;&amp;lt;/security&gt;");&lt;/span&gt;&lt;span style="font-family: times new roman;"&gt;&lt;br /&gt;out.println("&amp;lt;resources&gt;&amp;lt;j2se version=\"1.6+\" href=\"http://java.sun.com/products/autodl/j2se\"/&gt;");&lt;/span&gt;&lt;span style="font-family: times new roman;"&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;out.println("&amp;lt;jar href=\"test.jar;jsessionid="+sessionId+"\"/&gt;");&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family: times new roman;"&gt;&lt;br /&gt;out.println("&amp;lt;/resources&gt;");&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: times new roman;"&gt;out.println("&amp;lt;application-desc main-class=\"mainRun\"&gt;");&lt;/span&gt;&lt;span style="font-family: times new roman;"&gt;&lt;br /&gt;out.println("&amp;lt;/application-desc&gt;");&lt;/span&gt;&lt;span style="font-family: times new roman;"&gt;&lt;br /&gt;out.println("&amp;lt;/jnlp&gt;");&lt;/span&gt;&lt;span style="font-family: times new roman;"&gt;&lt;br /&gt;out.flush();&lt;/span&gt;&lt;span style="font-family: times new roman;"&gt;&lt;br /&gt;out.close();    &lt;/span&gt;&lt;span style="font-family: times new roman;"&gt;&lt;br /&gt;}&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3804827704953141110-7870803009883378471?l=myjavaroom.blogspot.com' alt='' /&gt;&lt;/div&gt;</description><app:edited xmlns:app="http://www.w3.org/2007/app">2009-11-09T13:52:28.449+08:00</app:edited><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">2</thr:total></item><item><title>How to Avoid Multiple Loops in JBoss Seam EntityQuery</title><link>http://myjavaroom.blogspot.com/2009/11/how-to-avoid-multiple-loops-in-jboss.html</link><category>JBoss Seam</category><author>noreply@blogger.com (Lee)</author><pubDate>Tue, 03 Nov 2009 18:34:11 PST</pubDate><guid isPermaLink="false">tag:blogger.com,1999:blog-3804827704953141110.post-9054578139365068014</guid><description>
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/jcIWc-9_mz2wfD5l3MPAwQuWc1E/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/jcIWc-9_mz2wfD5l3MPAwQuWc1E/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/jcIWc-9_mz2wfD5l3MPAwQuWc1E/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/jcIWc-9_mz2wfD5l3MPAwQuWc1E/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;span style="font-size:85%;"&gt;In JBoss seam-generated EntityQuery class, when user calls getResultList() method to retrive query result, the getResultList() method will be called many times. This will slow down the system response times and wasting of system resources.&lt;br /&gt;To avoid multiple loops &lt;/span&gt;&lt;span style="font-size:85%;"&gt;in JBoss Seam EntityQuery getResultList() method&lt;/span&gt;&lt;span style="font-size:85%;"&gt;, we can annotate getResultList() with @Factory to return the search results.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Example EntityQuery Class:&lt;/span&gt;&lt;br /&gt;----------------------------------------&lt;br /&gt;@BypassInterceptors&lt;br /&gt;@Name("userList")&lt;br /&gt;public class UserList extends EntityQuery&amp;lt;User&gt; {&lt;br /&gt;&lt;br /&gt;  private static final String EJBQL = "select user from User user";&lt;br /&gt;&lt;br /&gt;  private static final String[] RESTRICTIONS = {&lt;br /&gt;  "lower(user.username) like lower(concat(concat('%', trim(both ' ' from #{userList.username}),'%'))",&lt;br /&gt;  };&lt;br /&gt;&lt;br /&gt;  private User user = new User();&lt;br /&gt;&lt;br /&gt;  public UserList() {&lt;br /&gt;      setEjbql(EJBQL);&lt;br /&gt;      setRestrictionExpressionStrings(Arrays.asList(RESTRICTIONS));&lt;br /&gt;      setMaxResults(25);&lt;br /&gt;  }&lt;br /&gt;&lt;br /&gt;  public User getUser() {&lt;br /&gt;      return user;&lt;br /&gt;  }&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;  @Factory(value="userResultList", scope=ScopeType.EVENT)&lt;br /&gt;  public List&amp;lt;User&gt; getUserResultList() {&lt;br /&gt;      List list = null;&lt;br /&gt;      if (list==null) {&lt;br /&gt;          list = super.getResultList();&lt;br /&gt;      }&lt;br /&gt;      return list;&lt;br /&gt;  }&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-size:85%;"&gt;@BypassInterceptors is used to disable interception of calls to a Seam component or Seam component method. &lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3804827704953141110-9054578139365068014?l=myjavaroom.blogspot.com' alt='' /&gt;&lt;/div&gt;</description><app:edited xmlns:app="http://www.w3.org/2007/app">2009-11-04T10:34:11.407+08:00</app:edited><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">4</thr:total></item><item><title>Optimization for JBoss Seam, Richfaces, Ajax and etc.</title><link>http://myjavaroom.blogspot.com/2009/11/optimization-for-jboss-seam-richfaces.html</link><category>Richfaces</category><category>JSF</category><category>Ajax</category><category>EJB3</category><category>Hibernate</category><category>JBoss Seam</category><author>noreply@blogger.com (Lee)</author><pubDate>Tue, 03 Nov 2009 18:40:29 PST</pubDate><guid isPermaLink="false">tag:blogger.com,1999:blog-3804827704953141110.post-6819851410016310213</guid><description>
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/S8i7CNnjrACpzzcjHIyA8Qt1l0w/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/S8i7CNnjrACpzzcjHIyA8Qt1l0w/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/S8i7CNnjrACpzzcjHIyA8Qt1l0w/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/S8i7CNnjrACpzzcjHIyA8Qt1l0w/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;span style="font-family:lucida grande;"&gt;This post is used to record Seam optimization and other related components to be used (Hibernate, EJB3, Java Persistence, Richfaces, Ajax, JSF and etc..&lt;/span&gt;)&lt;br /&gt;&lt;span style="font-size:85%;"&gt;&lt;br /&gt;1. a4j:repeat or ui:repeat&lt;br /&gt;- avoid to use c:forEach&lt;br /&gt;- use a4j:repeat, if want to display row number.&lt;br /&gt; example: #{uiComponent['result'].rowIndex+1}&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;2. @Factory&lt;br /&gt;- annotate the resultList return in EntityQuery, to avoid multiple loops on the query function&lt;br /&gt;- For details, please refer to the &lt;a href="http://myjavaroom.blogspot.com/2009/11/how-to-avoid-multiple-loops-in-jboss.html"&gt;EntityQuery example&lt;/a&gt;.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;3. rich:modalPanel&lt;br /&gt;- use rich:messages instead of h:messages(won't display in modalPanel)&lt;br /&gt;&lt;br /&gt;&amp;lt;a4j:commandButton value="Save" action="#{myController.save}"&lt;br /&gt;   oncomplete="#{facesContext.maximumSeverity == null ? 'Richfaces.hideModalPanel(\'myModalPanelId\');' : ''}" /&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size:85%;"&gt;More optimization for JBoss Seam Web Application will be added frequently....&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3804827704953141110-6819851410016310213?l=myjavaroom.blogspot.com' alt='' /&gt;&lt;/div&gt;</description><app:edited xmlns:app="http://www.w3.org/2007/app">2009-11-04T10:40:29.800+08:00</app:edited><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">0</thr:total></item><item><title>Implementation of JFrame Component in SSO Environment without JNLP</title><link>http://myjavaroom.blogspot.com/2009/10/blog-post.html</link><category>Java</category><category>XHTML</category><category>CAS SSO</category><category>JNLP</category><author>noreply@blogger.com (Lee)</author><pubDate>Mon, 02 Nov 2009 19:19:54 PST</pubDate><guid isPermaLink="false">tag:blogger.com,1999:blog-3804827704953141110.post-4485358587037969882</guid><description>
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/PCrNX1B7DJ6buQi3hIXztwOVuCw/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/PCrNX1B7DJ6buQi3hIXztwOVuCw/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/PCrNX1B7DJ6buQi3hIXztwOVuCw/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/PCrNX1B7DJ6buQi3hIXztwOVuCw/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;span style="font-size:85%;"&gt;Implementation of JFrame Component in SSO Environment without JNLP&lt;br /&gt;&lt;br /&gt;After implemented CAS SSO in my JBoss Seam web application, the dynamic generated JNLP used to launch&lt;br /&gt;Java print component is not working.&lt;br /&gt;&lt;br /&gt;The java web start throw exception in:&lt;br /&gt;#### Java Web Start Error:&lt;br /&gt;#### Unable to load resource: http://test.com:8080/MyApp/test.jar&lt;br /&gt;&lt;br /&gt;com.sun.deploy.net.FailedDownloadException: Unable to load resource: http://test.com:8080/MyApp/test.jar&lt;br /&gt;&lt;br /&gt;and the wrapped exception:&lt;br /&gt;java.util.zip.ZipException: ZIP file must have at least one entry&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;The CAS SSO blocked the java web start to download jar file. After trying various types of solution found&lt;br /&gt;in forums or other developers, I am still not able to solve this problem.&lt;br /&gt;&lt;br /&gt;After failed up so many times, I decided to use a workaround solution to solve this problem.&lt;br /&gt;&lt;br /&gt;The existing flow is:&lt;br /&gt;---------------------&lt;br /&gt;user submit request -&gt; servlet generate dynamic jnlp -&gt; jnlp load java component(JFrame)&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;The workaround flow:&lt;br /&gt;--------------------&lt;br /&gt;user submit request -&gt; servlet generate dynamic html(applet) -&gt; dynamic html(applet) load java component&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;(1) Applet&lt;br /&gt;  - Create an Applet class to call JFrame&lt;br /&gt;&lt;br /&gt;  public class MyApplet extends JApplet{&lt;br /&gt;      public void init(){&lt;br /&gt;          String param = getParameter("param");&lt;br /&gt;          JFrame frame = new JFrame("New Frame");&lt;br /&gt;          frame.setLayout(new BorderLayout());&lt;br /&gt;          frame.setSize(200, 200);&lt;br /&gt;          frame.setVisible(true);&lt;br /&gt;      }&lt;br /&gt;  } &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;(2) Servlet&lt;br /&gt;  - Change the Servlet generate dynamic JNLP to generate dynamic HTML to embed APPLET.&lt;br /&gt;  - Use the APPLET to load JFrame. JFrame is not allowed in HTML, but we can use JApplet to call JFrame.&lt;br /&gt;&lt;br /&gt;      PrintWriter out = response.getWriter();&lt;br /&gt;  out.println("&amp;lt;applet code=\"test.MyApplet\" archive=\"test.jar\"&gt;");&lt;br /&gt;  out.println("&amp;lt;param name='param' value='paramVal'&gt;&amp;lt;/param&gt;");&lt;br /&gt;  out.println("&amp;lt;/applet&gt;"); &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;(3) XHTML/JSF&lt;br /&gt;  - Link to call servlet (eg. servlet mapping = *.app)&lt;br /&gt;&lt;br /&gt;  &amp;lt;h:outputLink id="test" value="test.app" target="AppletFrame"&gt;&lt;br /&gt;      &amp;lt;h:outputText value="Test"/&gt;&lt;br /&gt;      &amp;lt;f:param name="param" value="123"/&gt;&lt;br /&gt;  &amp;lt;/h:outputLink&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;  - Add an iframe in the html page.&lt;br /&gt;      &amp;lt;iframe name="AppletFrame" id="AppletFrame" style="height:0; width:0;" frameborder="0"&gt;&amp;lt;/iframe&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3804827704953141110-4485358587037969882?l=myjavaroom.blogspot.com' alt='' /&gt;&lt;/div&gt;</description><app:edited xmlns:app="http://www.w3.org/2007/app">2009-11-03T11:19:54.889+08:00</app:edited><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">0</thr:total></item><item><title>JBoss Seam Excel Implementation</title><link>http://myjavaroom.blogspot.com/2009/10/microsoft-excel-spreadsheet-in-jboss.html</link><category>Excel</category><category>Seam</category><author>noreply@blogger.com (Lee)</author><pubDate>Fri, 11 Dec 2009 17:57:55 PST</pubDate><guid isPermaLink="false">tag:blogger.com,1999:blog-3804827704953141110.post-1731196045173349363</guid><description>
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/oriVRXSMDkLUOMfwFkKF_BwqFmw/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/oriVRXSMDkLUOMfwFkKF_BwqFmw/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/oriVRXSMDkLUOMfwFkKF_BwqFmw/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/oriVRXSMDkLUOMfwFkKF_BwqFmw/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;span style="font-size:85%;"&gt;After googling around,  it was so little information about implementation Microsoft® Excel® spreadsheet in JBoss Seam. After taking sometimes to work on this seam excel implementation, I had documented the step by step how to configure jboss seam excel and some of the workaround tips. Hope this is helpful for everyone.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;(1) WEB-INF/lib&lt;/span&gt;&lt;br /&gt;- jboss-seam-excel.jar&lt;br /&gt;- jxl.jar&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;(2) Configure DocumentStore servlet in web.xml&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&amp;lt;servlet&gt;&lt;br /&gt;&amp;lt;servlet-name&gt;Document Store Servlet&amp;lt;/servlet-name&gt;&lt;br /&gt;&amp;lt;servlet-class&gt;org.jboss.seam.document.DocumentStoreServlet&amp;lt;/servlet-class&gt;&lt;br /&gt;&amp;lt;/servlet&gt;&lt;br /&gt;&amp;lt;servlet-mapping&gt;&lt;br /&gt;&amp;lt;servlet-name&gt;Document Store Servlet&amp;lt;/servlet-name&gt;&lt;br /&gt;&amp;lt;url-pattern&gt;*.csv&amp;lt;/url-pattern&gt;&lt;br /&gt;&amp;lt;/servlet-mapping&gt;&lt;br /&gt;&amp;lt;servlet-mapping&gt;&lt;br /&gt;&amp;lt;servlet-name&gt;Document Store Servlet&amp;lt;/servlet-name&gt;&lt;br /&gt;&amp;lt;url-pattern&gt;*.xls&amp;lt;/url-pattern&gt;&lt;br /&gt;&amp;lt;/servlet-mapping&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;(3) Implement the ExcelWorkbook interface and register in components.xml&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&amp;lt;components xmlns:excel="http://jboss.com/products/seam/excel"&lt;br /&gt;  xmlns:document="http://jboss.com/products/seam/document"&lt;br /&gt;      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"&lt;br /&gt;      xsi:schemaLocation="http://jboss.com/products/seam/document http://jboss.com/products/seam/document-2.1.xsd&lt;br /&gt;http://jboss.com/products/seam/excel http://jboss.com/products/seam/excel-2.1.xsd"&gt;&lt;br /&gt;&lt;br /&gt;&amp;lt;document:document-store use-extensions="true"&gt;&amp;lt;/document:document-store&gt;&lt;br /&gt;&lt;br /&gt;&amp;lt;/components&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;(4) Create workbook in XHTML&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&amp;lt;html xmlns="http://www.w3.org/1999/xhtml"&lt;br /&gt;xmlns:ui="http://java.sun.com/jsf/facelets"&lt;br /&gt;xmlns:e="http://jboss.com/products/seam/excel"&lt;br /&gt;xmlns:h="http://java.sun.com/jsf/html"&lt;br /&gt;xmlns:f="http://java.sun.com/jsf/core"&lt;br /&gt;xmlns:c="http://java.sun.com/jstl/core"&gt;&lt;br /&gt;&lt;br /&gt;&amp;lt;e:workbook type="jxl" ignoreBlanks="false" filename="user.xsl"&gt;&lt;br /&gt;&amp;lt;e:worksheet name="User" value="#{userList}" var="user" startRow="0"&gt;&lt;br /&gt;&amp;lt;e:column&gt;&lt;br /&gt;&amp;lt;f:facet name="header"&gt;&lt;br /&gt;&amp;lt;e:cell value="No"/&gt;&lt;br /&gt;&amp;lt;/f:facet&gt;&lt;br /&gt;&amp;lt;e:formula value="ROW()-1"/&gt;&lt;br /&gt;&amp;lt;/e:column&gt;&lt;br /&gt;&amp;lt;e:column&gt;&lt;br /&gt;&amp;lt;f:facet name="header"&gt;&lt;br /&gt;&amp;lt;e:cell value="Name"/&gt;&lt;br /&gt;&amp;lt;/f:facet&gt;&lt;br /&gt;&amp;lt;e:cell&gt;&lt;br /&gt;&amp;lt;h:outputText value="#{user.name}" escape="false"/&gt;&lt;br /&gt;&amp;lt;/e:cell&gt;&lt;br /&gt;&amp;lt;/e:column&gt;&lt;br /&gt;&amp;lt;/e:worksheet&gt;&lt;br /&gt;&amp;lt;/e:workbook&gt;&lt;br /&gt;&amp;lt;/html&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;TIPS for Excel Worksheet Generation:&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;To display dynamic row index no:&lt;/span&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;&lt;/span&gt;&amp;lt;e:formula value="ROW()-1"/&gt;&lt;br /&gt;&lt;br /&gt;ROW()-1, when first row is used by header.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;To display '&amp;amp;'&lt;/span&gt;:&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;&lt;/span&gt;&amp;lt;e:cell&gt;&lt;br /&gt;&amp;lt;h:outputText value="Andy &amp;amp; Sam" escape="false"/&gt;&lt;br /&gt;&amp;lt;/e:cell&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;To display border in blank cell:&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&amp;lt;e:cell value="#{' '}" style="xls-border:thick black"&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;To display multiple lines in worksheet header:&lt;/span&gt;&lt;span style="font-weight: bold;"&gt;&lt;/span&gt;&lt;br /&gt;&amp;lt;e:workbook&gt;&lt;br /&gt;&amp;lt;e:header&gt;&lt;br /&gt;  &amp;lt;f:facet name="center"&gt;&lt;br /&gt;      &amp;lt;e:cell style="xls-wrap:true;"&gt;&lt;br /&gt;          This is line 1&lt;br /&gt;          This is line 2....&lt;br /&gt;          This is line 3....&lt;br /&gt;      &amp;lt;/e:cell&gt;&lt;br /&gt;  &amp;lt;/f:facet&gt;&lt;br /&gt;&amp;lt;/e:header&gt;&lt;br /&gt;&amp;lt;/e:workbook&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;To display multiple List in same worksheet:&lt;/span&gt;&lt;span style="font-weight: bold;"&gt;&lt;/span&gt;&lt;br /&gt;&amp;lt;e:worksheet name="User" value="#{userList}" var="user" startRow="0"&gt;&lt;br /&gt;&amp;lt;e:column&gt;&lt;br /&gt;&amp;lt;f:facet name="header"&gt;&lt;br /&gt;&amp;lt;e:cell value="No"/&gt;&lt;br /&gt;&amp;lt;/f:facet&gt;&lt;br /&gt;&amp;lt;e:formula value="ROW()-1"/&gt;&lt;br /&gt;&amp;lt;/e:column&gt;&lt;br /&gt;&amp;lt;e:column&gt;&lt;br /&gt;&amp;lt;f:facet name="header"&gt;&lt;br /&gt;&amp;lt;e:cell value="Name"/&gt;&lt;br /&gt;&amp;lt;/f:facet&gt;&lt;br /&gt;&amp;lt;e:cell&gt;&lt;br /&gt;&amp;lt;h:outputText value="#{user.name}"/&gt;&lt;br /&gt;&amp;lt;/e:cell&gt;&lt;br /&gt;&amp;lt;/e:column&gt;&lt;br /&gt;&amp;lt;/e:worksheet&gt;&lt;br /&gt;&lt;br /&gt;&amp;lt;c:set var="row" value"#{userList.resultCount}"/&gt;&lt;br /&gt;&lt;br /&gt;&amp;lt;e:worksheet name="Account" value="#{accountList}" var="acc" startRow="#{row+2}"&gt;&lt;br /&gt;&amp;lt;e:column&gt;&lt;br /&gt;&amp;lt;f:facet name="header"&gt;&lt;br /&gt;&amp;lt;e:cell value="Username"/&gt;&lt;br /&gt;&amp;lt;/f:facet&gt;&lt;br /&gt;&amp;lt;e:cell&gt;&lt;br /&gt;&amp;lt;h:outputText value="#{acc.username}"/&gt;&lt;br /&gt;&amp;lt;/e:cell&gt;&lt;br /&gt;&amp;lt;/e:column&gt;&lt;br /&gt;&amp;lt;/e:worksheet&gt;&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3804827704953141110-1731196045173349363?l=myjavaroom.blogspot.com' alt='' /&gt;&lt;/div&gt;</description><app:edited xmlns:app="http://www.w3.org/2007/app">2009-12-12T09:57:55.666+08:00</app:edited><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">5</thr:total></item><item><title>Submit Entity Object through Richfaces Suggestion Box</title><link>http://myjavaroom.blogspot.com/2009/10/submit-entity-object-through-richfaces.html</link><category>Java</category><category>Richfaces</category><category>Seam</category><author>noreply@blogger.com (Lee)</author><pubDate>Wed, 21 Oct 2009 20:30:25 PDT</pubDate><guid isPermaLink="false">tag:blogger.com,1999:blog-3804827704953141110.post-8412767194031327629</guid><description>
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/W2nugJHcsm0emPL8jgbEHGQ6DoI/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/W2nugJHcsm0emPL8jgbEHGQ6DoI/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/W2nugJHcsm0emPL8jgbEHGQ6DoI/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/W2nugJHcsm0emPL8jgbEHGQ6DoI/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;span style="font-size:85%;"&gt;(1) Index the entity&lt;br /&gt;User.java Entity&lt;br /&gt;-----------------&lt;br /&gt;@Indexed&lt;br /&gt;public class User implements java.io.Serializable{&lt;br /&gt; @Field(index = Index.TOKENIZED)&lt;br /&gt;  public String getUsername() {&lt;br /&gt;     return this.username;&lt;br /&gt; }&lt;br /&gt;&lt;br /&gt; public void setUsername(String username) {&lt;br /&gt;     this.username= username;&lt;br /&gt; }&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;(2) Create EntityController class&lt;br /&gt;UserFinder.java EntityController&lt;br /&gt;&lt;br /&gt;@Name("userFinder")&lt;br /&gt;public class UserFinder extends EntityController&lt;br /&gt;{&lt;br /&gt;@Transactional&lt;br /&gt;public List&amp;lt;User&gt; getUserList(String username)&lt;br /&gt;{&lt;br /&gt;   return getEntityManager().createQuery("select u from User bm where lower(u.username) like lower(:name + '%')").setParameter("name", username).getResultList();&lt;br /&gt;}&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;(3) Optimize &amp;lt;rich:suggestionbox&gt;&lt;br /&gt;&lt;br /&gt;selfRendered="true"&lt;br /&gt;minChars="3"&lt;br /&gt;&lt;br /&gt;&amp;lt;rich:suggestionbox for="user" selfRendered="true" minChars="3"&lt;br /&gt;  ignoreDupResponses="true"&lt;br /&gt;         suggestionAction="#{userFinder.getUserList}" var="u"&gt;&lt;br /&gt;                &amp;lt;h:column&gt;&lt;br /&gt;                        &amp;lt;h:outputText value="#{u.username}" /&gt;&lt;br /&gt;                &amp;lt;/h:column&gt;&lt;br /&gt;&amp;lt;/rich:suggestionbox&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;(4)  Submit Entity Object through suggestion box&lt;br /&gt;&lt;br /&gt;&amp;lt;rich:suggestionbox for="user" selfRendered="true" minChars="3"&lt;br /&gt;  ignoreDupResponses="true"&lt;br /&gt;         suggestionAction="#{userFinder.getUserList}" var="u"&gt;&lt;br /&gt;                &amp;lt;h:column&gt;&lt;br /&gt;                        &amp;lt;h:outputText value="#{u.username}" /&gt;&lt;br /&gt;                &amp;lt;/h:column&gt;&lt;br /&gt;                &amp;lt;a4j:support ajaxSingle="true" event="onselect"&gt;&lt;br /&gt;                        &amp;lt;f:setPropertyActionListener value="#{u}"            &lt;br /&gt;                                                                            target="accountHome.instance.user"/&gt;&lt;br /&gt;               &amp;lt;/a4j:support&gt;&lt;br /&gt;&amp;lt;/rich:suggestionbox&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3804827704953141110-8412767194031327629?l=myjavaroom.blogspot.com' alt='' /&gt;&lt;/div&gt;</description><app:edited xmlns:app="http://www.w3.org/2007/app">2009-10-22T11:30:25.066+08:00</app:edited><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">0</thr:total></item><item><title>EntityHome.remove Error - Deleted Entity Passed to Persist</title><link>http://myjavaroom.blogspot.com/2009/10/entityhomeremove-error-deleted-entity.html</link><category>Java</category><category>XHTML</category><category>Seam</category><author>noreply@blogger.com (Lee)</author><pubDate>Wed, 21 Oct 2009 20:30:01 PDT</pubDate><guid isPermaLink="false">tag:blogger.com,1999:blog-3804827704953141110.post-8911236838735224834</guid><description>
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/ETfLjEWofe263uEk5CoDsj8WGJM/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/ETfLjEWofe263uEk5CoDsj8WGJM/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/ETfLjEWofe263uEk5CoDsj8WGJM/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/ETfLjEWofe263uEk5CoDsj8WGJM/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;span style="font-weight: bold;font-size:85%;" &gt;Error:&lt;/span&gt;&lt;span style="font-size:85%;"&gt;&lt;br /&gt;javax.persistence.EntityNotFoundException: deleted entity passed to persist: [com.entity.OrderItem#&amp;lt;null&gt;]&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Order.java&lt;br /&gt;----------&lt;br /&gt;public class Order implements Serializable&lt;br /&gt;{&lt;br /&gt;private long orderId;&lt;br /&gt;private Date orderDate;&lt;br /&gt;private List&amp;lt;OrderItem&gt; orderItems = new ArrayList&amp;lt;OrderItem&gt;();&lt;br /&gt;&lt;br /&gt; @Id&lt;br /&gt; public long getOrderId() {&lt;br /&gt;     return orderId;&lt;br /&gt; }                 &lt;br /&gt; public void setOrderId(long id) {&lt;br /&gt;     this.orderId = id;&lt;br /&gt; }  &lt;br /&gt;&lt;br /&gt; public Date getOrderDate() {&lt;br /&gt;     return orderDate;&lt;br /&gt; }&lt;br /&gt; public void setOrderDate(Date date) {&lt;br /&gt;     this.orderDate = date;&lt;br /&gt; }&lt;br /&gt;&lt;br /&gt; @OneToMany(mappedBy="order", cascade=CascadeType.ALL)&lt;br /&gt; public List&amp;lt;OrderItem&gt; getOrderItems() {&lt;br /&gt;     return orderItems;&lt;br /&gt; }&lt;br /&gt; public void setOrderItems(List&amp;lt;OrderItem&gt; items) {&lt;br /&gt;     this.orderItems = items;&lt;br /&gt; } &lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;OrderItem.java&lt;br /&gt;--------------&lt;br /&gt;public class OrderItem implements Serializable&lt;br /&gt;{&lt;br /&gt; private long orderItemId;&lt;br /&gt; private Product product;&lt;br /&gt; private int quantity;&lt;br /&gt; private Order order;&lt;br /&gt;&lt;br /&gt; @Id&lt;br /&gt; public long getOrderItemId() {&lt;br /&gt;     return orderItemId;&lt;br /&gt; }&lt;br /&gt; public void setOrderItemId(long id) {&lt;br /&gt;     this.orderItemId = id;&lt;br /&gt; }&lt;br /&gt;&lt;br /&gt; public Product getProduct() {&lt;br /&gt;     return product;&lt;br /&gt; }&lt;br /&gt; public void setProduct(Product prod) {&lt;br /&gt;     this.product = prod;&lt;br /&gt; }&lt;br /&gt;&lt;br /&gt; public int getQuantity() {&lt;br /&gt;  return quantity;&lt;br /&gt; }&lt;br /&gt;&lt;br /&gt; public void setQuantity(int qty) {&lt;br /&gt;  this.quantity = qty;&lt;br /&gt; }&lt;br /&gt;&lt;br /&gt; @ManyToOne&lt;br /&gt; public Order getOrder() {&lt;br /&gt;     return order;&lt;br /&gt; }&lt;br /&gt; public void setOrder(Order order) {&lt;br /&gt;     this.order = order;&lt;br /&gt; }&lt;br /&gt;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;OrderItemHome.java&lt;br /&gt;-------------------&lt;br /&gt;public String remove(){&lt;br /&gt; return super.remove();&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;XHTML&lt;br /&gt;-----&lt;br /&gt;&amp;lt;h:commandButton value="Remove" immediate="true" action="#{orderItemHome.remove}"/&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Solution:&lt;/span&gt;&lt;br /&gt;-----------&lt;br /&gt;In Order.java&lt;br /&gt;&lt;br /&gt;@OneToMany(mappedBy="order", cascade=CascadeType.ALL)&lt;br /&gt;public List&amp;lt;OrderItem&gt; getOrderItems() {&lt;br /&gt;return orderItems;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;CascadeType.ALL is equivalent to:&lt;br /&gt;cascade = {CascadeType.MERGE, CascadeType.PERSIST, CascadeType.REMOVE, CascadeType.REFRESH}&lt;br /&gt;&lt;br /&gt;Change the CascadeType.ALL to:&lt;br /&gt;cascade = {CascadeType.MERGE, CascadeType.REMOVE, CascadeType.REFRESH}&lt;br /&gt;&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3804827704953141110-8911236838735224834?l=myjavaroom.blogspot.com' alt='' /&gt;&lt;/div&gt;</description><app:edited xmlns:app="http://www.w3.org/2007/app">2009-10-22T11:30:01.196+08:00</app:edited><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">0</thr:total></item><media:rating>nonadult</media:rating></channel></rss>

