tag:blogger.com,1999:blog-20849927652778344472024-03-13T21:01:17.061+11:00Youheng Hu's Technical NotesYouheng Huhttp://www.blogger.com/profile/18065339964353737399noreply@blogger.comBlogger18125tag:blogger.com,1999:blog-2084992765277834447.post-80640785051842926532012-08-30T05:36:00.000+10:002012-08-30T05:36:09.437+10:00Reset Portlet Action-scoped Request Attributes<p>
JSR 286 provides a container runtime option <tt>javax.portlet.actionScopedRequestAttributes</tt> that when set to true allows portlets set complex objects as request attributes from the <tt>processAction</tt> method for subsequent rendering.
</p>
<p>
Based on the spec, action-scoped request attributes are kept in the session until are reset in the next action or session timeout. The reset can be done in different ways:
</p>
<p>
1) In portlet <tt>processAction</tt> method, call <tt>request.setAttribute(attributeName, null);</tt>, this call removes the attribute with the given name.
</p>
<p>
2) Build a portlet renderURL with a parameter that has name as <tt>javax.portlet.as</tt> and an empty string value, as shown in below. All action-scoped request attributes will be removed once the renderURL is invoked.
</p>
<p>
<div class="highlight" style="background: #f8f8f8"><pre style="line-height: 125%"><span style="color: #008000; font-weight: bold"><portlet:renderURL</span> <span style="color: #7D9029">var=</span><span style="color: #BA2121">"refreshURL"</span><span style="color: #008000; font-weight: bold">></span>
<span style="color: #008000; font-weight: bold"><portlet:param</span> <span style="color: #7D9029">name=</span><span style="color: #BA2121">"javax.portlet.as"</span> <span style="color: #7D9029">value=</span><span style="color: #BA2121">""</span> <span style="color: #008000; font-weight: bold">/></span>
<span style="color: #008000; font-weight: bold"></portlet:renderURL></span>
</pre></div>
</p>
Youheng Huhttp://www.blogger.com/profile/18065339964353737399noreply@blogger.com0tag:blogger.com,1999:blog-2084992765277834447.post-80244456689813896422012-08-30T05:35:00.000+10:002012-08-30T05:35:16.817+10:00Apache Tiles 2.2 error handling in Websphere Application Server 7<p>
When using Apache Tiles 2.2 in Websphere 7 application, by default the JSP engine renders the response tile-by-tile. When exception happens in one tile and there is error page defined, only the offending tile is rendered with the error page, the others are just rendered fine.
</p>
<p>
To change this behaviour to allow exceptions to bubble up to the including JSP and forwad to the error page, there are two things need to be done:
</p>
<p>
1) Set the container custom property <tt>com.ibm.ws.webcontainer.dispatcherRethrowSError</tt> to <tt>true</tt>. This property is avaiable from WAS Fixpack 7.0.0.15. Details can be found from <a href="http://www-01.ibm.com/support/docview.wss?uid=swg1PM22919 and http://pic.dhe.ibm.com/infocenter/wasinfo/v7r0/index.jsp?topic=%2Fcom.ibm.websphere.express.doc%2Finfo%2Fexp%2Fae%2Frweb_custom_props.html">http://www-01.ibm.com/support/docview.wss?uid=swg1PM22919 and http://pic.dhe.ibm.com/infocenter/wasinfo/v7r0/index.jsp?topic=%2Fcom.ibm.websphere.express.doc%2Finfo%2Fexp%2Fae%2Frweb_custom_props.html</a>.
</p>
<p>
2) Define an errorPage for the template jsp, as shown in below.
</p>
<p>
<div class="highlight" style="background: #f8f8f8"><pre style="line-height: 125%"><span style="color: #008000; font-weight: bold"><%@</span> page errorPage<span style="color: #666666">=</span><span style="color: #BA2121">"/jsp/general/error.jsp"</span> <span style="color: #008000; font-weight: bold">%></span>
<span style="color: #008000; font-weight: bold"><%@</span> taglib uri<span style="color: #666666">=</span><span style="color: #BA2121">"http://tiles.apache.org/tags-tiles"</span> prefix<span style="color: #666666">=</span><span style="color: #BA2121">"tiles"</span> <span style="color: #008000; font-weight: bold">%></span>
<span style="color: #008000; font-weight: bold"><tiles:insertAttribute</span> <span style="color: #7D9029">name=</span><span style="color: #BA2121">"header"</span> <span style="color: #008000; font-weight: bold">/></span>
<span style="color: #008000; font-weight: bold"><tiles:insertAttribute</span> <span style="color: #7D9029">name=</span><span style="color: #BA2121">"body"</span> <span style="color: #008000; font-weight: bold">/></span>
<span style="color: #008000; font-weight: bold"><tiles:insertAttribute</span> <span style="color: #7D9029">name=</span><span style="color: #BA2121">"footer"</span> <span style="color: #008000; font-weight: bold">/></span>
</pre></div>
</p>
Youheng Huhttp://www.blogger.com/profile/18065339964353737399noreply@blogger.com0tag:blogger.com,1999:blog-2084992765277834447.post-15831327969167727862012-07-11T12:29:00.003+10:002012-07-11T12:29:58.096+10:00Websphere Portal Cross-Site-Scripting Protection<p>
Websphere Portal version 7 provides a Cross-Site-Scripting protection mechanism that encodes the "<" and ">" during form post. This protection mechanism is turned on by default. As a consequence, the request values passed to the portlet <tt>processAction</tt> method are encoded values. e.g. "&lt;" for "<" and "&gt;" for ">", thus a Html unescape call is required to retrieve the original input values.
</p>
<p>
To disable the Cross-Site-Scripting protection, the <tt>security.css.protection</tt> service configuration property value needs to be set to <tt>false</tt> using procedure described in <a href="http://www-10.lotus.com/ldd/portalwiki.nsf/dx/Setting_service_configuration_properties_wp7">http://www-10.lotus.com/ldd/portalwiki.nsf/dx/Setting_service_configuration_properties_wp7</a>.
</p>Youheng Huhttp://www.blogger.com/profile/18065339964353737399noreply@blogger.com1tag:blogger.com,1999:blog-2084992765277834447.post-20011891135771447332012-06-22T04:52:00.002+10:002012-06-22T04:52:44.436+10:00Develop a Hello World ESB Java Service using WebSphere Integration Developer 7<p>
This note summarise the development of a Hello World ESB Java service using WebSphere Integration Developer 7.0.
</p>
<p>
<b>Step 1 - Build the ESB Java service</b><br/>
</p>
<p>
1.1) In WebSphere Integration Developer 7.0 workspace, switch to Business Integration Perspective.
</p>
<p>
1.2) In file menu, select <tt>File - New - Module</tt>, use <tt>HelloWorldServiceModule</tt> as the Module name and click <tt>Finish</tt>.
</p>
<p>
1.3) Under the <tt>HelloWorldServiceModule</tt> project, right click <tt>Interfaces</tt>, and select <tt>New - Integerface</tt>, use <tt>HelloWorldInterface</tt> as the interface name, then click <tt>Finish</tt>.
</p>
<p>
1.4) In the interface editor, right click and select <tt>Add Request Response Operation</tt>, use <tt>hello</tt> as operation name, and <tt>message</tt> as the input, <tt>response</tt> as the output, both with <tt>string</tt> type. Save the changes.
</p>
<p>
1.5) Switch to the Assembly Editor, drag and drop a <tt>Java</tt> component from the Palette to the Assembly Editor, name it <tt>HelloWorldService</tt>.
</p>
<p>
1.6) Right click the <tt>HelloWorldService</tt> and select <tt>Add - Interface</tt>, select <tt>HelloWorldInterface</tt>.
</p>
<p>
1.7) Right click the <tt>HelloWorldService</tt> and select <tt>Generate Implementation</tt>, create a new package <tt>demo</tt>.
</p>
<p>
1.8) In the <tt>HelloWorldServiceImpl</tt> Java editor, implemention the <tt>hello</tt> method as the code below, save changes.
</p>
<p>
<div class="highlight" style="background: #f8f8f8"><pre style="line-height: 125%"><span style="color: #408080; font-style: italic">/**</span>
<span style="color: #408080; font-style: italic"> * Method generated to support implementation of operation "hello" defined for WSDL port type </span>
<span style="color: #408080; font-style: italic"> * named "HelloWorldInterface".</span>
<span style="color: #408080; font-style: italic"> * </span>
<span style="color: #408080; font-style: italic"> * Please refer to the WSDL Definition for more information </span>
<span style="color: #408080; font-style: italic"> * on the type of input, output and fault(s).</span>
<span style="color: #408080; font-style: italic"> */</span>
<span style="color: #008000; font-weight: bold">public</span> String <span style="color: #0000FF">hello</span><span style="color: #666666">(</span>String message<span style="color: #666666">)</span> <span style="color: #666666">{</span>
<span style="color: #008000; font-weight: bold">return</span> <span style="color: #BA2121">"Hello:"</span> <span style="color: #666666">+</span> message<span style="color: #666666">;</span>
<span style="color: #666666">}</span>
</pre></div>
</p>
<p>
1.9) Switch to the Assembly Editor, drag and drop a <tt>References</tt> component from the Palette to the Assembly Editor.
</p>
<p>
1.10) Right click the <tt>Stand-alone References</tt>, and select <tt>Add Reference</tt>, then select <tt>HelloWorldInterface</tt>
</p>
<p>
1.11) Link the <tt>Stand-alone References</tt> to <tt>HelloWorldService</tt>, save changes.
</p>
<p>
<b>Step 2 - Build the ESB client</b><br/>
</p>
<p>
2.1) Switch the <tt>Java EE</tt> perspective.
</p>
<p>
2.2) Right click the <tt>HelloWorldServiceModuleWeb</tt> project, and select <tt>New - JSP</tt>, use <tt>client.jsp</tt> as the File name, then click <tt>Finish</tt>.
</p>
<p>
2.3) Add the code below to the <tt>client.jsp</tt> page, save changes.
</p>
<p>
<div class="highlight" style="background: #f8f8f8"><pre style="line-height: 125%"><span style="color: #008000; font-weight: bold"><%@</span> page language<span style="color: #666666">=</span><span style="color: #BA2121">"java"</span> contentType<span style="color: #666666">=</span><span style="color: #BA2121">"text/html; charset=ISO-8859-1"</span>
pageEncoding<span style="color: #666666">=</span><span style="color: #BA2121">"ISO-8859-1"</span><span style="color: #008000; font-weight: bold">%></span>
<span style="color: #008000; font-weight: bold"><%@</span> page import<span style="color: #666666">=</span><span style="color: #BA2121">"com.ibm.websphere.sca.*,commonj.sdo.DataObject"</span> <span style="color: #008000; font-weight: bold">%></span>
<span style="color: #BC7A00"><!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"></span>
<span style="color: #008000; font-weight: bold"><html></span>
<span style="color: #008000; font-weight: bold"><body></span>
<span style="color: #008000; font-weight: bold"><%</span>
String serviceOutput <span style="color: #666666">=</span> <span style="color: #BA2121">"N/A"</span><span style="color: #666666">;</span>
String message <span style="color: #666666">=</span> request<span style="color: #666666">.</span><span style="color: #7D9029">getParameter</span><span style="color: #666666">(</span><span style="color: #BA2121">"message"</span><span style="color: #666666">);</span>
<span style="color: #008000; font-weight: bold">if</span><span style="color: #666666">(</span>message <span style="color: #666666">!=</span> <span style="color: #008000; font-weight: bold">null</span><span style="color: #666666">){</span>
<span style="color: #008000; font-weight: bold">try</span><span style="color: #666666">{</span>
ServiceManager serviceManager <span style="color: #666666">=</span> <span style="color: #008000; font-weight: bold">new</span> ServiceManager<span style="color: #666666">();</span>
Service service <span style="color: #666666">=</span> <span style="color: #666666">(</span>Service<span style="color: #666666">)</span> serviceManager<span style="color: #666666">.</span><span style="color: #7D9029">locateService</span><span style="color: #666666">(</span><span style="color: #BA2121">"HelloWorldInterfacePartner"</span><span style="color: #666666">);</span>
DataObject respObject <span style="color: #666666">=</span> <span style="color: #666666">(</span>DataObject<span style="color: #666666">)</span> service<span style="color: #666666">.</span><span style="color: #7D9029">invoke</span><span style="color: #666666">(</span><span style="color: #BA2121">"hello"</span><span style="color: #666666">,</span> message<span style="color: #666666">);</span>
serviceOutput <span style="color: #666666">=</span> respObject<span style="color: #666666">.</span><span style="color: #7D9029">getString</span><span style="color: #666666">(</span><span style="color: #BA2121">"response"</span><span style="color: #666666">);</span>
<span style="color: #666666">}</span><span style="color: #008000; font-weight: bold">catch</span><span style="color: #666666">(</span>Exception e<span style="color: #666666">){</span>
e<span style="color: #666666">.</span><span style="color: #7D9029">printStackTrace</span><span style="color: #666666">();</span>
<span style="color: #666666">}</span>
<span style="color: #666666">}</span>
<span style="color: #008000; font-weight: bold">%></span>
Service Output : <span style="color: #008000; font-weight: bold"><%=</span> serviceOutput <span style="color: #008000; font-weight: bold">%></span>
<span style="color: #008000; font-weight: bold"><form</span> <span style="color: #7D9029">method=</span><span style="color: #BA2121">"post"</span><span style="color: #008000; font-weight: bold">></span>
<span style="color: #008000; font-weight: bold"><input</span> <span style="color: #7D9029">type=</span><span style="color: #BA2121">"text"</span> <span style="color: #7D9029">NAME=</span><span style="color: #BA2121">"message"</span><span style="color: #008000; font-weight: bold">/></span>
<span style="color: #008000; font-weight: bold"><input</span> <span style="color: #7D9029">TYPE=</span><span style="color: #BA2121">"submit"</span><span style="color: #008000; font-weight: bold">/></span>
<span style="color: #008000; font-weight: bold"></form></span>
<span style="color: #008000; font-weight: bold"></body></span>
<span style="color: #008000; font-weight: bold"></html></span>
</pre></div>
</p>
<p>
<b>Step 3 - Build and run the application</b><br/>
</p>
<p>
3.1) Switch to Business Integration Perspective, right click the <tt>HelloWorldServiceModule</tt>, select <tt>Export</tt> and <tt>Integration modules and libraries</tt> - <tt>Files for server deployment</tt>
</p>
<p>
3.2) Deploy the generated EAR file to Websphere Process Server.
</p>
<p>
3.3) Access the client.jsp from browser to test the application.
</p>Youheng Huhttp://www.blogger.com/profile/18065339964353737399noreply@blogger.com0tag:blogger.com,1999:blog-2084992765277834447.post-31839809182312453342012-06-14T05:20:00.000+10:002012-06-14T05:20:07.007+10:00Develop a Hello World Business Integration Application using WebSphere Integration Developer 7<p>
This note summarise the development of a Hello World Business Integration application using WebSphere Integration Developer 7.0. The demo application reads simple CSV files from the input directory and then writes the data to the output directory in XML format.
</p>
<p>
<b>Step 1 - Install WebSphere Integration Developer 7.0</b><br/>
<p>
Install IID 7.0.0.4 and local Websphere Process server test environment.
</p>
<b>Step 2 - Build the Hello World Business Integration application </b><br/>
<p>
2.1) Create a new module, from menu select <tt>File - New - Module</tt>, and uses <tt>SimpleFileModule</tt> as module name.
</p>
<p>
2.2) Use the default Business Object Parsing Mode, and click <tt>Finish</tt>. Once the module is created, the Assemble Diagram view is displayed
</p>
<p>
2.3) Under the <tt>SimpleFileModule</tt>, right click the <tt>Data Types</tt> node to create a new Business Object.
</p>
<p>
2.4) Enter <tt>Customer</tt> as the Business Object name, click <tt>Next</tt>
</p>
<p>
2.5) Click <tt>Finish</tt> on the <tt>Derived Business Object</tt> screen
</p>
<p>
2.6) Now the Business Object editor screen is displayed
</p>
<p>
2.7) Click the <tt>Add Field</tt> icon to add fields to the <tt>Customer</tt> Business Object.
</p>
<p>
2.8) Add a string field <tt>name</tt> and an int field <tt>age</tt>, then save changes.
</p>
<p>
2.9) Right click the <tt>SimpleFileModule<tt> and select <tt>New - External Service</tt>
</p>
<p>
2.10) Select <tt>Simple inbound Flat File service to read from a local file</tt>, click <tt>Next</tt>.
</p>
<p>
2.11) Use the default values on the <tt>Flat File service name</tt> screen and click <tt>Next</tt>.
</p>
<p>
2.12) Now the <tt>CWYFF_FlatFile</tt> project is imported to the workspace. On the <tt>Business object and directory</tt> screen, select the <tt>Customer<tt> Business object and the input directory. Click <tt>Next</tt>.
</p>
<p>
2.13) Select <tt>Other</tt> as the input format and select the <tt>CSVDataHandler</tt>
</p>
<p>
2.14) Use <tt>"\n"<tt> as the file split delimiter, click <tt>Next</tt>.
</p>
<p>
2.15) Select the local archive directory, click <tt>Finish</tt>.
</p>
<p>
2.16) The <tt>FlatFileExport</tt> interface is now added to the Assemble Diagram.
</p>
<p>
2.17) Right click the <tt>SimpleFileModule</tt> and select <tt>New - External Service</tt> to add a <tt>Simple outbound Flat File service to write to a local file</tt>, click <tt>Next</tt>.
</p>
<p>
2.18) Use the default values on the <tt>Flat File service name</tt> screen and click <tt>Next</tt>.
</p>
<p>
2.19) On the <tt>Business object and directory</tt> screen, select the <tt>Customer</tt> Business object and the output directory, click <tt>Next</tt>.
</p>
<p>
2.20) Set the output file to <tt>Customer.xml</tt> and use other default values on the <tt>Output file name</tt> screen, click <tt>Next</tt>.
</p>
<p>
2.21) Select XML output format, click <tt>Finish</tt>.
</p>
<p>
2.22) The <tt>FlatFileImport</tt> interface is now added to the Assemble Diagram.
</p>
<p>
2.23) Drag and drop a <tt>Mediation Flow</tt> from the Assemble Diagram Palette to the Assemble Diagram editor.
</p>
<p>
2.24) Name the Mediation Flow to <tt>SimpleFileFlow</tt>
</p>
<p>
2.25) Double click the <tt>SimpleFileFlow<tt> and click <tt>Yes</tt> on the confirmation message box.
</p>
<p>
2.26) Use the default value on the <tt>Generate Implementation</tt> screen and click <tt>OK</tt>.
</p>
<p>
2.27) Now the SimpleFileFlow editor is open.
</p>
<p>
2.28) Click the <tt>Add an interface</tt> link and select <tt>FlatFileExport</tt>.
</p>
<p>
2.29) Click the <tt>Add a reference</tt> link and select <tt>FlatFileImport</tt>.
</p>
<p>
2.30) Save changes.
</p>
<p>
2.31) Click the <tt>emit<tt> link from <tt>FlatFileExport</tt>, then select <tt>Operation Map</tt>.
</p>
<p>
2.32) Select the default values on the <tt>Select Reference Operation</tt> screen, click <tt>OK</tt>.
</p>
<p>
2.33) The Mediation Flow Request editor is open.
</p>
<p>
2.34) Double click the <tt>input_map</tt> node, use default values on the <tt>Create an XML Map</tt> screen and click <tt>Next</tt>.
</p>
<p>
2.35) Use default values on the <tt>Specify Message Types</tt> screen and click <tt>Finish</tt>.
</p>
<p>
2.36) Now the map editor is open, expand the <tt>emit<tt> link and the <tt>create<tt> link.
</p>
<p>
2.37) Link the <tt>emitInput</tt> and the <tt>createInput</tt> with a <tt>Move</tt> transformation.
</p>
<p>
2.38) Save all changes and back to the Assemble Diagram editor, link the <tt>FlatFileExport</tt> to <tt>SimpleFileFlow</tt>, then <tt>SimpleFileFlow</tt> to <tt>FlatFileImport</tt>, save changes.
</p>
<b>Step 3 - Testing the module </b><br/>
<p>
To run the module, right click the local Process Server and select <tt>Add and Remove Projects</tt>.
</p>
<p>
Then add the <tt>SimpleFileModuleApp</tt> to the Configured projects list, and click <tt>Finish</tt>.
</p>
<p>
Start the Process Server, and check the <tt>SimpleFileModuleApp</tt> is started and synchronized.
</p>
<p>
Copy a CSV file to the input directory, the file should have a format as shown in below
</p>
<p>
<div class="highlight" style="background: #f8f8f8"><pre style="line-height: 125%">Peter,20
Tom,21
Emma,22
Julia,23
</pre></div>
</p>
<p>
After a few seconds, the application reads the input CSV file and output few output XML files to the output directory, the input file is archived to the archive directory with a .success or .fail extension. The generated XML file has a format as shown in below.
</p>
<p>
<div class="highlight" style="background: #f8f8f8"><pre style="line-height: 125%"><span style="color: #BC7A00"><?xml version="1.0" encoding="UTF-8"?></span>
<span style="color: #008000; font-weight: bold"><p:Customer</span> <span style="color: #7D9029">xsi:type=</span><span style="color: #BA2121">"p:Customer"</span> <span style="color: #7D9029">xmlns:xsi=</span><span style="color: #BA2121">"http://www.w3.org/2001/XMLSchema-instance"</span>
<span style="color: #7D9029">xmlns:p=</span><span style="color: #BA2121">"http://SimpleFileModule"</span><span style="color: #008000; font-weight: bold">></span>
<span style="color: #008000; font-weight: bold"><name></span>Tom<span style="color: #008000; font-weight: bold"></name></span>
<span style="color: #008000; font-weight: bold"><age></span>21<span style="color: #008000; font-weight: bold"></age></span>
<span style="color: #008000; font-weight: bold"></p:Customer></span>
</pre></div>
</p>Youheng Huhttp://www.blogger.com/profile/18065339964353737399noreply@blogger.com0tag:blogger.com,1999:blog-2084992765277834447.post-22472318448330580062012-06-14T05:15:00.000+10:002012-06-14T05:29:31.976+10:00Spring MVC3 Portlets with Websphere Portal 7 Client Side Aggregation<p>
This note summarises the Action ID missing issue and solution found when running Spring MVC3 portlets with Websphere Portal 7 Client Side Aggregation (CSA).
</p>
<p>
The issue can be reproduced with a simple Spring portlet as shown in below. When the form is submitted, the "This portlet is unavailable" message is displayed, and the ffdc log shows an Action ID missing error message.
</p>
<p>
<div class="highlight" style="background: #f8f8f8"><pre style="line-height: 125%"><span style="color: #008000; font-weight: bold"><%@</span>page
language<span style="color: #666666">=</span><span style="color: #BA2121">"java"</span> contentType<span style="color: #666666">=</span><span style="color: #BA2121">"text/html; charset=ISO-8859-1"</span>
pageEncoding<span style="color: #666666">=</span><span style="color: #BA2121">"ISO-8859-1"</span> session<span style="color: #666666">=</span><span style="color: #BA2121">"false"</span><span style="color: #008000; font-weight: bold">%></span>
<span style="color: #008000; font-weight: bold"><%@</span>taglib prefix<span style="color: #666666">=</span><span style="color: #BA2121">"c"</span> uri<span style="color: #666666">=</span><span style="color: #BA2121">"http://java.sun.com/jsp/jstl/core"</span> <span style="color: #008000; font-weight: bold">%></span>
<span style="color: #008000; font-weight: bold"><%@</span>taglib prefix<span style="color: #666666">=</span><span style="color: #BA2121">"spring"</span> uri<span style="color: #666666">=</span><span style="color: #BA2121">"http://www.springframework.org/tags"</span><span style="color: #008000; font-weight: bold">%></span>
<span style="color: #008000; font-weight: bold"><%@</span>taglib prefix<span style="color: #666666">=</span><span style="color: #BA2121">"form"</span> uri<span style="color: #666666">=</span><span style="color: #BA2121">"http://www.springframework.org/tags/form"</span><span style="color: #008000; font-weight: bold">%></span>
<span style="color: #008000; font-weight: bold"><%@</span>taglib prefix<span style="color: #666666">=</span><span style="color: #BA2121">"portlet"</span> uri<span style="color: #666666">=</span><span style="color: #BA2121">"http://java.sun.com/portlet_2_0"</span><span style="color: #008000; font-weight: bold">%></span>
Hello ${demoBean.message}
<span style="color: #008000; font-weight: bold"><portlet:actionURL</span> <span style="color: #7D9029">var=</span><span style="color: #BA2121">"actionURL"</span><span style="color: #008000; font-weight: bold">/></span>
<span style="color: #008000; font-weight: bold"><div></span>
<span style="color: #008000; font-weight: bold"><form:form</span> <span style="color: #7D9029">action=</span><span style="color: #BA2121">"${actionURL}"</span> <span style="color: #7D9029">method=</span><span style="color: #BA2121">"post"</span> <span style="color: #7D9029">modelAttribute=</span><span style="color: #BA2121">"demoBean"</span><span style="color: #008000; font-weight: bold">></span>
<span style="color: #008000; font-weight: bold"><form:input</span> <span style="color: #7D9029">size=</span><span style="color: #BA2121">"20"</span> <span style="color: #7D9029">path=</span><span style="color: #BA2121">"message"</span> <span style="color: #008000; font-weight: bold">/></span>
<span style="color: #008000; font-weight: bold"><input</span> <span style="color: #7D9029">type=</span><span style="color: #BA2121">"submit"</span><span style="color: #008000; font-weight: bold">/></span>
<span style="color: #008000; font-weight: bold"></form:form></span>
<span style="color: #008000; font-weight: bold"></div></span>
</pre></div>
</p>
<p>
<div class="highlight" style="background: #f8f8f8"><pre style="line-height: 125%">[30/05/12 16:53:06:418 EST] 0000004e PortletInvoke W com.ibm.wps.wsrp.producer.provider.pc.waspc.impl.PortletInvokerImpl
newBlockingInteractionResponse Action execution refused due to a security violation. Action ID missing.
[30/05/12 16:53:06:425 EST] 0000004e WSRPEngine E com.ibm.wps.wsrp.producer.impl.WSRPEngine performBlockInteraction
EJPWC1109E: Normal execution of the operation failed.
com.ibm.wps.wsrp.exception.WSRPException: EJPWC1109E: Normal execution of the operation failed.
at com.ibm.wps.wsrp.producer.provider.pc.waspc.impl.PortletInvokerImpl.handleActionProtection(PortletInvokerImpl.java:1083)
at com.ibm.wps.wsrp.producer.provider.pc.waspc.impl.PortletInvokerImpl.invokePerformBlockingInteraction(PortletInvokerImpl.java:833)
at com.ibm.wps.wsrp.producer.provider.pc.impl.PortletInvokerImpl.invokePerformBlockingInteraction(PortletInvokerImpl.java:170)
at com.ibm.wps.wsrp.producer.impl.WSRPEngine.performBlockingInteraction(WSRPEngine.java:833)
at oasis.names.tc.wsrp.v2.bind.WSRP_v2_Markup_Binding_SOAPImpl.performBlockingInteraction(WSRP_v2_Markup_Binding_SOAPImpl.java:213)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at com.ibm.ws.webservices.engine.dispatchers.java.JavaDispatcher.invokeMethod(JavaDispatcher.java:178)
at com.ibm.ws.webservices.engine.dispatchers.java.JavaDispatcher.invokeOperation(JavaDispatcher.java:141)
at com.ibm.ws.webservices.engine.dispatchers.SoapRPCProcessor.processRequestResponse(SoapRPCProcessor.java:481)
at com.ibm.ws.webservices.engine.dispatchers.SoapRPCProcessor.processMessage(SoapRPCProcessor.java:427)
at com.ibm.ws.webservices.engine.dispatchers.BasicDispatcher.processMessage(BasicDispatcher.java:134)
at com.ibm.ws.webservices.engine.dispatchers.java.SessionDispatcher.invoke(SessionDispatcher.java:204)
at com.ibm.ws.webservices.engine.PivotHandlerWrapper.invoke(PivotHandlerWrapper.java:263)
at com.ibm.ws.webservices.engine.handlers.jaxrpc.JAXRPCHandler.invoke(JAXRPCHandler.java:153)
at com.ibm.ws.webservices.engine.handlers.WrappedHandler.invoke(WrappedHandler.java:64)
at com.ibm.ws.webservices.engine.PivotHandlerWrapper.invoke(PivotHandlerWrapper.java:263)
at com.ibm.ws.webservices.engine.PivotHandlerWrapper.invoke(PivotHandlerWrapper.java:263)
</pre></div>
</p>
<p>
Look at the portlet page html source, the form action attribute values is a Websphere Portal javascript in which the portlet action URL is encoded.
</p>
<p>
<div class="highlight" style="background: #f8f8f8"><pre style="line-height: 125%"><span style="color: #008000; font-weight: bold"><form</span> <span style="color: #7D9029">method=</span><span style="color: #BA2121">"post"</span> <span style="color: #7D9029">action=</span><span style="color: #BA2121">"javascript:</span>
<span style="color: #BA2121"> com.ibm.portal.csa.PortletIWidget.Z7_EIH60VH40GNPF0ITR3BKO410I2.onActionLink(</span>
<span style="color: #BA2121"> com.ibm.portal.csa.PortletIWidget.Z7_EIH60VH40GNPF0ITR3BKO410I2.urls.url0.tokens);"</span>
<span style="color: #7D9029">id=</span><span style="color: #BA2121">"demoBean"</span><span style="color: #008000; font-weight: bold">></span>
<span style="color: #008000; font-weight: bold"><input</span> <span style="color: #7D9029">type=</span><span style="color: #BA2121">"text"</span> <span style="color: #7D9029">size=</span><span style="color: #BA2121">"20"</span> <span style="color: #7D9029">value=</span><span style="color: #BA2121">""</span> <span style="color: #7D9029">name=</span><span style="color: #BA2121">"message"</span> <span style="color: #7D9029">id=</span><span style="color: #BA2121">"message"</span><span style="color: #008000; font-weight: bold">></span>
<span style="color: #008000; font-weight: bold"><input</span> <span style="color: #7D9029">type=</span><span style="color: #BA2121">"submit"</span><span style="color: #008000; font-weight: bold">></span>
<span style="color: #008000; font-weight: bold"></form></span>
</pre></div>
</p>
<p>
This solution is to add a <tt>htmlEscape</tt> attribute to the spring form tag and set its value to false to disable html escape so that the portal engine can encode the action URL correctly.
</p>
<p>
<div class="highlight" style="background: #f8f8f8"><pre style="line-height: 125%"><span style="color: #008000; font-weight: bold"><form:form</span> <span style="color: #7D9029">action=</span><span style="color: #BA2121">"${actionURL}"</span> <span style="color: #7D9029">method=</span><span style="color: #BA2121">"post"</span> <span style="color: #7D9029">modelAttribute=</span><span style="color: #BA2121">"demoBean"</span>
<span style="color: #7D9029">htmlEscape=</span><span style="color: #BA2121">"false"</span><span style="color: #008000; font-weight: bold">></span>
...
<span style="color: #008000; font-weight: bold"></form:form></span>
</pre></div>
</p>
<p>
The solution is verified in Websphere Portal 7.0.0.2 with WAS Application Server 7.0.0.21 and Spring MVC 3.1.0.
</p>Youheng Huhttp://www.blogger.com/profile/18065339964353737399noreply@blogger.com0tag:blogger.com,1999:blog-2084992765277834447.post-38957587790340178502012-05-10T06:03:00.000+10:002012-05-10T06:03:35.963+10:00Building AJAX-enabled JSF Portlets in IBM WebSphere Portal 7<p>
This note summarise different approaches to implement an AJAX-enabled JSF portlet in IBM WebSphere Portal 7. The portlet used in the demo has a simple UI that consists of two elements, one list box that has two items and one text label. When AJAX is enabled to the portlet, once the list box selected item changes, an AJAX request is sent to refresh the text label.
</p>
<p>
<b><i>Implementation 1 - IBM JSF Portlet bridge 1.2 with IBM JSF Extension Components</i></b>
</p>
<p>
IBM WebSphere Portal 7 comes with a JSF Portlet bridge 1.2 that supports JSF 1.2 based portlet development. As JSF 1.2 doesn't have built-in AJAX support, IBM JSF Extension Components are used to provide AJAX functionalities, as shown in the code below
</p>
<div class="highlight" style="background: #f8f8f8"><pre style="line-height: 125%"><span style="color: #008000; font-weight: bold"><%@</span>taglib uri<span style="color: #666666">=</span><span style="color: #BA2121">"http://java.sun.com/jsf/core"</span> prefix<span style="color: #666666">=</span><span style="color: #BA2121">"f"</span><span style="color: #008000; font-weight: bold">%></span>
<span style="color: #008000; font-weight: bold"><%@</span>taglib uri<span style="color: #666666">=</span><span style="color: #BA2121">"http://java.sun.com/jsf/html"</span> prefix<span style="color: #666666">=</span><span style="color: #BA2121">"h"</span><span style="color: #008000; font-weight: bold">%></span>
<span style="color: #008000; font-weight: bold"><%@</span>taglib uri<span style="color: #666666">=</span><span style="color: #BA2121">"http://java.sun.com/portlet_2_0"</span> prefix<span style="color: #666666">=</span><span style="color: #BA2121">"portlet"</span><span style="color: #008000; font-weight: bold">%></span>
<span style="color: #008000; font-weight: bold"><%@</span>taglib uri<span style="color: #666666">=</span><span style="color: #BA2121">"http://www.ibm.com/jsf/html_extended"</span> prefix<span style="color: #666666">=</span><span style="color: #BA2121">"hx"</span><span style="color: #008000; font-weight: bold">%></span>
<span style="color: #008000; font-weight: bold"><%@</span>taglib
uri<span style="color: #666666">=</span><span style="color: #BA2121">"http://www.ibm.com/xmlns/prod/websphere/portal/v6.1/portlet-client-model"</span>
prefix<span style="color: #666666">=</span><span style="color: #BA2121">"portlet-client-model"</span><span style="color: #008000; font-weight: bold">%></span>
<span style="color: #008000; font-weight: bold"><%@</span>page language<span style="color: #666666">=</span><span style="color: #BA2121">"java"</span> contentType<span style="color: #666666">=</span><span style="color: #BA2121">"text/html"</span>
pageEncoding<span style="color: #666666">=</span><span style="color: #BA2121">"ISO-8859-1"</span> session<span style="color: #666666">=</span><span style="color: #BA2121">"false"</span><span style="color: #008000; font-weight: bold">%><portlet:defineObjects</span> <span style="color: #008000; font-weight: bold">/></span>
<span style="color: #008000; font-weight: bold"><portlet-client-model:init></span>
<span style="color: #008000; font-weight: bold"><portlet-client-model:require</span> <span style="color: #7D9029">module=</span><span style="color: #BA2121">"ibm.portal.xml.*"</span> <span style="color: #008000; font-weight: bold">/></span>
<span style="color: #008000; font-weight: bold"><portlet-client-model:require</span> <span style="color: #7D9029">module=</span><span style="color: #BA2121">"ibm.portal.portlet.*"</span> <span style="color: #008000; font-weight: bold">/></span>
<span style="color: #008000; font-weight: bold"></portlet-client-model:init></span>
<span style="color: #008000; font-weight: bold"><f:view></span>
<span style="color: #008000; font-weight: bold"><hx:scriptCollector</span> <span style="color: #7D9029">id=</span><span style="color: #BA2121">"scriptCollector1"</span><span style="color: #008000; font-weight: bold">></span>
<span style="color: #008000; font-weight: bold"><h:form</span> <span style="color: #7D9029">styleClass=</span><span style="color: #BA2121">"form"</span> <span style="color: #7D9029">id=</span><span style="color: #BA2121">"form1"</span><span style="color: #008000; font-weight: bold">></span>
<span style="color: #008000; font-weight: bold"><h:selectOneListbox</span> <span style="color: #7D9029">id=</span><span style="color: #BA2121">"listbox1"</span><span style="color: #008000; font-weight: bold">></span>
<span style="color: #008000; font-weight: bold"><f:selectItem</span> <span style="color: #7D9029">itemLabel=</span><span style="color: #BA2121">"Label1"</span>
<span style="color: #7D9029">itemValue=</span><span style="color: #BA2121">"Value1"</span> <span style="color: #7D9029">id=</span><span style="color: #BA2121">"selectItem1"</span> <span style="color: #008000; font-weight: bold">/></span>
<span style="color: #008000; font-weight: bold"><f:selectItem</span> <span style="color: #7D9029">itemLabel=</span><span style="color: #BA2121">"Label2"</span>
<span style="color: #7D9029">itemValue=</span><span style="color: #BA2121">"Value2"</span> <span style="color: #7D9029">id=</span><span style="color: #BA2121">"selectItem2"</span> <span style="color: #008000; font-weight: bold">/></span>
<span style="color: #008000; font-weight: bold"></h:selectOneListbox></span>
<span style="color: #008000; font-weight: bold"><hx:behavior</span> <span style="color: #7D9029">event=</span><span style="color: #BA2121">"onchange"</span> <span style="color: #7D9029">target=</span><span style="color: #BA2121">"listbox1"</span>
<span style="color: #7D9029">behaviorAction=</span><span style="color: #BA2121">"get"</span> <span style="color: #7D9029">targetAction=</span><span style="color: #BA2121">"group1"</span><span style="color: #008000; font-weight: bold">></hx:behavior></span>
<span style="color: #008000; font-weight: bold"></h:form></span>
<span style="color: #008000; font-weight: bold"><h:panelGroup</span> <span style="color: #7D9029">styleClass=</span><span style="color: #BA2121">"panelGroup"</span> <span style="color: #7D9029">id=</span><span style="color: #BA2121">"group1"</span><span style="color: #008000; font-weight: bold">></span>
<span style="color: #008000; font-weight: bold"><h:outputText</span> <span style="color: #7D9029">styleClass=</span><span style="color: #BA2121">"outputText"</span> <span style="color: #7D9029">id=</span><span style="color: #BA2121">"text1"</span>
<span style="color: #7D9029">value=</span><span style="color: #BA2121">"Hello, #{param.listbox1} "</span><span style="color: #008000; font-weight: bold">></h:outputText></span>
<span style="color: #008000; font-weight: bold"></h:panelGroup></span>
<span style="color: #008000; font-weight: bold"><hx:ajaxRefreshRequest</span> <span style="color: #7D9029">target=</span><span style="color: #BA2121">"group1"</span>
<span style="color: #7D9029">id=</span><span style="color: #BA2121">"ajaxRefreshRequest1"</span>
<span style="color: #7D9029">params=</span><span style="color: #BA2121">"listbox1"</span><span style="color: #008000; font-weight: bold">></span>
<span style="color: #008000; font-weight: bold"></hx:ajaxRefreshRequest></span>
<span style="color: #008000; font-weight: bold"></hx:scriptCollector></span>
<span style="color: #008000; font-weight: bold"></f:view></span>
</pre></div>
<p>
<b><i>Implementation 2 - JSF 2.0 Portlet Bridge for IBM WebSphere Portal</i></b>
</p>
<p>
There is a JSF 2.0 Portlet Bridge for IBM WebSphere Portal available from <a href="https://greenhouse.lotus.com/plugins/plugincatalog.nsf/assetDetails.xsp?action=openDocument&documentId=E1704D36E8BA391B85257957002ABC42">Greenhouse Lotus</a> that allows developing portlets based on JSF 2.0 specifications with MyFaces 2.0. With JSF 2.0 build-in AJAX support, the demo can be implemented as JSF code shown in below.
</p>
<div class="highlight" style="background: #f8f8f8"><pre style="line-height: 125%"><span style="color: #008000; font-weight: bold"><div</span> <span style="color: #7D9029">xmlns=</span><span style="color: #BA2121">"http://www.w3.org/1999/xhtml"</span>
<span style="color: #7D9029">xmlns:ui=</span><span style="color: #BA2121">"http://java.sun.com/jsf/facelets"</span>
<span style="color: #7D9029">xmlns:f=</span><span style="color: #BA2121">"http://java.sun.com/jsf/core"</span>
<span style="color: #7D9029">xmlns:h=</span><span style="color: #BA2121">"http://java.sun.com/jsf/html"</span>
<span style="color: #7D9029">xmlns:portlet=</span><span style="color: #BA2121">"http://java.sun.com/portlet_2_0"</span> <span style="color: #008000; font-weight: bold">></span>
<span style="color: #008000; font-weight: bold"><f:view></span>
<span style="color: #008000; font-weight: bold"><h:form></span>
<span style="color: #008000; font-weight: bold"><h:selectOneListbox</span> <span style="color: #7D9029">styleClass=</span><span style="color: #BA2121">"selectOneListbox"</span>
<span style="color: #7D9029">id=</span><span style="color: #BA2121">"listbox1"</span> <span style="color: #7D9029">value=</span><span style="color: #BA2121">"#{testBean.text}"</span><span style="color: #008000; font-weight: bold">></span>
<span style="color: #008000; font-weight: bold"><f:selectItem</span> <span style="color: #7D9029">itemLabel=</span><span style="color: #BA2121">"Label1"</span> <span style="color: #7D9029">itemValue=</span><span style="color: #BA2121">"Value1"</span><span style="color: #008000; font-weight: bold">/></span>
<span style="color: #008000; font-weight: bold"><f:selectItem</span> <span style="color: #7D9029">itemLabel=</span><span style="color: #BA2121">"Label2"</span> <span style="color: #7D9029">itemValue=</span><span style="color: #BA2121">"Value2"</span><span style="color: #008000; font-weight: bold">/></span>
<span style="color: #008000; font-weight: bold"><f:ajax</span> <span style="color: #7D9029">render=</span><span style="color: #BA2121">"text1"</span> <span style="color: #7D9029">execute=</span><span style="color: #BA2121">"@this"</span><span style="color: #008000; font-weight: bold">/></span>
<span style="color: #008000; font-weight: bold"></h:selectOneListbox></span>
<span style="color: #008000; font-weight: bold"><h:outputText</span> <span style="color: #7D9029">id=</span><span style="color: #BA2121">"text1"</span>
<span style="color: #7D9029">value=</span><span style="color: #BA2121">"Hello, #{testBean.text} "</span><span style="color: #008000; font-weight: bold">></span>
<span style="color: #008000; font-weight: bold"></h:outputText></span>
<span style="color: #008000; font-weight: bold"></h:form></span>
<span style="color: #008000; font-weight: bold"></f:view></span>
<span style="color: #008000; font-weight: bold"></div></span>
</pre></div>
<p>
<b><i>Implementation 3 - ICEfaces Enterprise Edition (EE) 3.0</i></b>
</p>
<p>
ICEfaces Enterprise Edition 3.0 provides a PortletFaces Bridge Extensions library that supports JSF 2.0 based portlets on WebSphere Portal 7. The demo can be implemented using the same JSF code as Implementation 2 above with MyFaces 2.0 or Mojarra 2.1, additional change required is add the container runtime option below in <tt>portlet.xml</tt>.
</p>
<div class="highlight" style="background: #f8f8f8"><pre style="line-height: 125%"><span style="color: #008000; font-weight: bold"><container-runtime-option></span>
<span style="color: #008000; font-weight: bold"><name></span>javax.portlet.renderHeaders<span style="color: #008000; font-weight: bold"></name></span>
<span style="color: #008000; font-weight: bold"><value></span>true<span style="color: #008000; font-weight: bold"></value></span>
<span style="color: #008000; font-weight: bold"></container-runtime-option></span>
</pre></div>
<p>
All three implementations are tested in WebSphere Portal 7.0.0.2 and WAS 7.0.0.19 with different theme and render modes, the results are summarised in the table below.
</p>
<table border="1">
<tr>
<td><b>Implementation</b></td>
<td><b>Page Builder theme - SSA</b></td>
<td><b>Page Builder theme - CSA</b></td>
<td><b>Portal theme - SSA only</b></td>
<td><b>Notes</b></td>
</tr>
<tr>
<td>IBM JSF Portlet bridge 1.2 with IBM JSF Extension Components</td>
<td>works as expected</td>
<td><i>The portlet is rendered but AJAX doesn't work, no Javascript errors</i></td>
<td>works as expected</td>
<td> </td>
</tr>
<tr>
<td>JSF 2.0 Portlet Bridge for IBM WebSphere Portal (MyFaces 2.0)</td>
<td>works as expected</td>
<td>works as expected</td>
<td>works as expected</td>
<td><i>The library is provided as is, with no support from IBM</i></td>
</tr>
<tr>
<td>ICEfaces Enterprise Edition 3.0 (MyFaces 2.0/Mojarra 2.1) </td>
<td>works as expected</td>
<td><i>The portlet is unable to render with exceptions from the bridge</i></td>
<td><i>The portlet is rendered but AJAX doesn't work with Javascript errors</i></td>
<td><i>Commercial license required</i></td>
</tr>
</table>Youheng Huhttp://www.blogger.com/profile/18065339964353737399noreply@blogger.com3tag:blogger.com,1999:blog-2084992765277834447.post-32696363654424093272012-05-07T05:09:00.000+10:002012-05-07T05:09:01.438+10:00RAD Application Server Publishing settings and WTP based Maven Projects<br />
The WebSphere Application Server publishing setting in RAD has two options: 1) Run server with resources within the workspace, and 2) Run server with resources on Server. When perform "Run/Debug on Server", with the "within the workspace" option, applications run from the workspace, while with the "on Server" option, applications are deployed to Application Server first and then run from the server. <br />
<br />
When there is a local application server is available, the "within the workspace" option is the default and it takes less publishing time compare to the "on Server" option. However, it may not work with WTP based Maven projects that have "Workspace Resolution" enabled. <br />
<br />
Given a Maven project that consists of two modules - core and web, when perform "Run/Debug on Server" with Maven "Workspace Resolution" enabled and the "within the workspace" option selected. RAD doesn't publish the core jar file to the workspace publishing folder (e.g. <tt>.metadata\.plugins\org.eclipse.wst.server.core\tmp1\</tt>), and uses two different class loaders to load the core jar and the web application, thus causes class loading related issues, examples include <br />
<br />
- spring xml in the web module cannot import spring xml from core module using <tt><import resource="classpath:com/test/resources/spring-core-beans.xml" /></tt><br />
<br />
- the web module cannot load resources from core module using <tt>ResourceBundle.getBundle(baseName) </tt><br />
<br />
An easy solution to these issues is to use the "Run server with resources on Server" publishing settings.Youheng Huhttp://www.blogger.com/profile/18065339964353737399noreply@blogger.com0tag:blogger.com,1999:blog-2084992765277834447.post-88983915424832488922012-05-04T05:05:00.000+10:002012-05-04T05:05:28.472+10:00Using WAR File Name as uid in XMLAccess based Portlet Deployment<p>For portlets that don't have <tt>id</tt> attribute defined in <tt><portlet-app></tt> tag in <tt>portlet.xml</tt>, XMLAccess allows to use the WAR file name as <tt>uid</tt> in XMLAccess request. <br />
</p><br />
<div class="highlight" style="background: #f8f8f8"><pre style="line-height: 125%"><span style="color: #008000; font-weight: bold"><request</span>
<span style="color: #7D9029">xmlns:xsi=</span><span style="color: #BA2121">"http://www.w3.org/2001/XMLSchema-instance"</span>
<span style="color: #7D9029">xsi:noNamespaceSchemaLocation=</span><span style="color: #BA2121">"PortalConfig_7.0.0.xsd"</span>
<span style="color: #7D9029">type=</span><span style="color: #BA2121">"update"</span>
<span style="color: #7D9029">create-oids=</span><span style="color: #BA2121">"true"</span><span style="color: #008000; font-weight: bold">></span>
<span style="color: #008000; font-weight: bold"><portal</span> <span style="color: #7D9029">action=</span><span style="color: #BA2121">"locate"</span><span style="color: #008000; font-weight: bold">></span>
<span style="color: #008000; font-weight: bold"><web-app</span> <span style="color: #7D9029">action=</span><span style="color: #BA2121">"update"</span> <span style="color: #7D9029">active=</span><span style="color: #BA2121">"true"</span> <span style="color: #7D9029">uid=</span><span style="color: #BA2121">"WAR_NAME.webmod"</span><span style="color: #008000; font-weight: bold">></span>
<span style="color: #008000; font-weight: bold"><url></span>file:///PATH_TO_THE_WAR_FILE<span style="color: #008000; font-weight: bold"></url></span>
<span style="color: #008000; font-weight: bold"><portlet-app</span> <span style="color: #7D9029">action=</span><span style="color: #BA2121">"update"</span> <span style="color: #7D9029">active=</span><span style="color: #BA2121">"true"</span> <span style="color: #7D9029">uid=</span><span style="color: #BA2121">"WAR_NAME"</span><span style="color: #008000; font-weight: bold">></span>
<span style="color: #008000; font-weight: bold"><portlet</span> <span style="color: #7D9029">action=</span><span style="color: #BA2121">"update"</span> <span style="color: #7D9029">active=</span><span style="color: #BA2121">"true"</span> <span style="color: #7D9029">name=</span><span style="color: #BA2121">"TestPortlet"</span> <span style="color: #7D9029">objectid=</span><span style="color: #BA2121">"theTestPortlet"</span> <span style="color: #008000; font-weight: bold">/></span>
<span style="color: #008000; font-weight: bold"></portlet-app></span>
<span style="color: #008000; font-weight: bold"></web-app></span>
<span style="color: #008000; font-weight: bold"></portal></span>
<span style="color: #008000; font-weight: bold"></request></span>
</pre></div><br />
<p>The script works fine when install a new portlet, however when re-run the same script to update the portlet, it gives a DuplicateAppException that complains EJPPF0181E The id=XXX already exists for stored standard portlet application. <br />
</p><br />
<p>The solution to this problem is to add a <tt>uniquename</tt> attribute to the <tt><web-app></tt> in XMLAccess script, as shown in below<br />
</p><br />
<div class="highlight" style="background: #f8f8f8"><pre style="line-height: 125%"><span style="color: #008000; font-weight: bold"><request</span>
<span style="color: #7D9029">xmlns:xsi=</span><span style="color: #BA2121">"http://www.w3.org/2001/XMLSchema-instance"</span>
<span style="color: #7D9029">xsi:noNamespaceSchemaLocation=</span><span style="color: #BA2121">"PortalConfig_7.0.0.xsd"</span>
<span style="color: #7D9029">type=</span><span style="color: #BA2121">"update"</span>
<span style="color: #7D9029">create-oids=</span><span style="color: #BA2121">"true"</span><span style="color: #008000; font-weight: bold">></span>
<span style="color: #008000; font-weight: bold"><portal</span> <span style="color: #7D9029">action=</span><span style="color: #BA2121">"locate"</span><span style="color: #008000; font-weight: bold">></span>
<span style="color: #008000; font-weight: bold"><web-app</span> <span style="color: #7D9029">action=</span><span style="color: #BA2121">"update"</span> <span style="color: #7D9029">active=</span><span style="color: #BA2121">"true"</span> <span style="color: #7D9029">uid=</span><span style="color: #BA2121">"WAR_NAME.webmod"</span> <span style="color: #7D9029">uniquename=</span><span style="color: #BA2121">"SOME_UNIQUE_NAME"</span><span style="color: #008000; font-weight: bold">></span>
<span style="color: #008000; font-weight: bold"><url></span>file:///PATH_TO_THE_WAR_FILE<span style="color: #008000; font-weight: bold"></url></span>
<span style="color: #008000; font-weight: bold"><portlet-app</span> <span style="color: #7D9029">action=</span><span style="color: #BA2121">"update"</span> <span style="color: #7D9029">active=</span><span style="color: #BA2121">"true"</span> <span style="color: #7D9029">uid=</span><span style="color: #BA2121">"WAR_NAME"</span><span style="color: #008000; font-weight: bold">></span>
<span style="color: #008000; font-weight: bold"><portlet</span> <span style="color: #7D9029">action=</span><span style="color: #BA2121">"update"</span> <span style="color: #7D9029">active=</span><span style="color: #BA2121">"true"</span> <span style="color: #7D9029">name=</span><span style="color: #BA2121">"TestPortlet"</span> <span style="color: #7D9029">objectid=</span><span style="color: #BA2121">"theTestPortlet"</span> <span style="color: #008000; font-weight: bold">/></span>
<span style="color: #008000; font-weight: bold"></portlet-app></span>
<span style="color: #008000; font-weight: bold"></web-app></span>
<span style="color: #008000; font-weight: bold"></portal></span>
<span style="color: #008000; font-weight: bold"></request></span>
</pre></div><br />
Now the script can be used to install a new portlet and also to update an existing portlet based on the <tt>uniquename</tt> attribute value.Youheng Huhttp://www.blogger.com/profile/18065339964353737399noreply@blogger.com0tag:blogger.com,1999:blog-2084992765277834447.post-71794479630493722202012-04-03T04:49:00.001+10:002012-04-03T04:50:00.600+10:00Using URL Rewrting for Session Tracking in IBM WebSphere Application ServerMy recent application has two access interfaces; the first one in a normal Web interface that end users access to using browsers, the second one is a servlet based B2B interface that business partners access to using their in-house applications. Session tracking is required for both the interface, for Web interface, normal cookies based session tracking mechanism is used; while for B2B interface, as the client applications don't support cookie, URL rewriting based session tracking mechanism is used.
<br />
In order to use URL rewriting, B2B client applications must include <tt>jsessionid</tt> in its request URL. In the current implementation, when a B2B client applicaiton access the application first time, a <tt>jsessionid</tt> is output to the client, then the <tt>jsessionid</tt> is used in following requests.
<br />
<br />
The implementation of the URL rewriting in WAS consists of two parts.
<br />
Firstly, the URL rewriting must be enabled in the application session management. When both cookie and URL rewriting are enabled, WAS by default will use cookie when requests come from clients that have cookie enabled.
<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEisaZ5ef_AQ9Np0Y7ntSfed06OocgdGkoSAgLtrPiHbMMMI9o6bLljcIyXSZ6D4GybJqaSB0rBSUp-omwb1-ZJ3oLh9Ixg1g-K8tBeKmSMDWKboqK8ZxUKLIkmBqpg5bC1ywMumt6NRPF4/s1600/20120402_01.PNG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="341" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEisaZ5ef_AQ9Np0Y7ntSfed06OocgdGkoSAgLtrPiHbMMMI9o6bLljcIyXSZ6D4GybJqaSB0rBSUp-omwb1-ZJ3oLh9Ixg1g-K8tBeKmSMDWKboqK8ZxUKLIkmBqpg5bC1ywMumt6NRPF4/s400/20120402_01.PNG" width="400" /></a></div>
<br />
<br />
Secondly, the application must include the <tt>jsessionid</tt> in the response. Through the <tt>HttpSession</tt> interface provides a <tt>getId</tt> method that returns a unique identifier assigned to this session, but in WAS, the return value is only part of the <tt>jsessionid</tt> string. Currently I use the <tt>response.encodeURL</tt> method to generate a encoded URL that has a format like <tt>...;jsessionid=0000qA9CUpmesNP-MLxR3KoXeaM:-1</tt>, from which the <tt>jsessionid</tt> is extracted using substring methods.Youheng Huhttp://www.blogger.com/profile/18065339964353737399noreply@blogger.com3tag:blogger.com,1999:blog-2084992765277834447.post-39817843920567284402012-03-29T06:02:00.001+11:002012-03-29T06:03:30.955+11:00Mule Studio Hello World ESB ApplicationThis note summarise the development of a Hello World ESB Application using Mule Studio.
<br />
<b>Step 1 - Download and install Mule Studio</b> <br />
Download the Mule ESB Community Edition from <a href="http://www.mulesoft.org/download-mule-esb-community-edition">www.mulesoft.org</a> and save the distribution package zip file.
<br />
There is no installation required. Just unzip the package to local drive and we are ready to go.
<br />
<br />
<b>Step 2 - Launching Mule Studio</b> <br />
Navigate to the directory that contains the <tt>muleStudio.exe</tt> executable.
<br />
Launch the <tt>muleStudio.exe</tt> to start the application.
<br />
Specify the workspace location on the <tt>Select a workspace</tt> screen.
<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi0McUMdTE85rESmiPxdBx_ey0CQhuKwX0HnktoZoPNITC63O7wLVb_eSuecuIPVv6Qu-Wj1-J3meSKLswuAiMHYSEVGMMCDrQbsHd_AuinHtfAJFcXFsajJ_-DE0J2in4WKV0JAUfy2gk/s1600/20120326_00.PNG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi0McUMdTE85rESmiPxdBx_ey0CQhuKwX0HnktoZoPNITC63O7wLVb_eSuecuIPVv6Qu-Wj1-J3meSKLswuAiMHYSEVGMMCDrQbsHd_AuinHtfAJFcXFsajJ_-DE0J2in4WKV0JAUfy2gk/s1600/20120326_00.PNG" /></a></div>
<br />
<b>Step 3 - First Steps</b> <br />
The <tt>First Steps</tt> screen is displayed if the selected workspace is a new one.
<br />
Click <tt>Go to Mule Studio</tt> to start using the application.
<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhTKOSPf2p_xyXb3cp_hD4u5lyD8s-zPtSn-OGd5-lfiVSW0SGSTnQc_WCmirQYgzcASWoXxHwxtdYHRTfb6othiVmXKEmR4GKq6ZhuHBUhBpuK7abv25kfcfLExTRBe-YObHveIcUoS-Q/s1600/20120326_01.PNG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="480" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhTKOSPf2p_xyXb3cp_hD4u5lyD8s-zPtSn-OGd5-lfiVSW0SGSTnQc_WCmirQYgzcASWoXxHwxtdYHRTfb6othiVmXKEmR4GKq6ZhuHBUhBpuK7abv25kfcfLExTRBe-YObHveIcUoS-Q/s640/20120326_01.PNG" width="640" /></a></div>
<br />
<b>Step 4 - Create a new project</b> <br />
Go to the Studio application menu, click <tt>File > New > Mule Project</tt>.
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjnnBWOBq8h9OfodV3O8PCd99oOoJuKKz8lV2X7dhpM9Qyth0frLLio75PK1S9WlflF03q0vy6_u5XfnawO82HQYgybcwrzqqHIHXFBoFvpqVAyrb0vC26JBfiR72YHjiIgrapKRifKXIw/s1600/20120326_01A.PNG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="450" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjnnBWOBq8h9OfodV3O8PCd99oOoJuKKz8lV2X7dhpM9Qyth0frLLio75PK1S9WlflF03q0vy6_u5XfnawO82HQYgybcwrzqqHIHXFBoFvpqVAyrb0vC26JBfiR72YHjiIgrapKRifKXIw/s640/20120326_01A.PNG" width="640" /></a></div>
<br />
<br />
On the <tt>Mule Project</tt> screen, specify the project name and click <tt>Next</tt>.<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiyLE2XKKH7HTJWUscZwav42c3xtDCPp2vEt5nx3mD22F5EVyC7P6brwDIW-c8vuhvYX1HeHVPW8qHXg5RIkYTiE0zjYxNh8vNYFYV_6oUagvWtPD2fCrlnru-dhznLZDBrYLa8IDa6XKo/s1600/20120326_02.PNG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="640" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiyLE2XKKH7HTJWUscZwav42c3xtDCPp2vEt5nx3mD22F5EVyC7P6brwDIW-c8vuhvYX1HeHVPW8qHXg5RIkYTiE0zjYxNh8vNYFYV_6oUagvWtPD2fCrlnru-dhznLZDBrYLa8IDa6XKo/s640/20120326_02.PNG" width="452" /></a></div>
<br />
On the <tt>New Mule Flow</tt> screen, select the <tt>Select to create a new message flow in the project</tt> checkbox, and specify the <tt>Name</tt>, then click <tt>Next</tt>.<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEigluHmGhLOXjXzxwqcJhmxZf6B_BDPSWbrWvuyXj4d5UvOB-5yXW_R25h0r-rG3h4PH1Qqh5V0y-wPyyNgfORzQreep59DBf2L8siAHMlukbU_-xg0tjuoqYv-_Ka2QrZiaxCsKG24uWY/s1600/20120326_03.PNG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="640" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEigluHmGhLOXjXzxwqcJhmxZf6B_BDPSWbrWvuyXj4d5UvOB-5yXW_R25h0r-rG3h4PH1Qqh5V0y-wPyyNgfORzQreep59DBf2L8siAHMlukbU_-xg0tjuoqYv-_Ka2QrZiaxCsKG24uWY/s640/20120326_03.PNG" width="454" /></a></div>
<br />
On the <tt>Create a Java project</tt> screen, use default setting and click <tt>Next</tt>.<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjqNAXHL_nxXiNhykpl7K2TdAZXHt68U2KODF9FrUDTtNc5IJCkPzU3qoH8-j5aOqId03NPok1EMHcK54vYc4_buIqrN5pxvMotLlpVXxIjXD1Hv2wk_qRYMnGnR2dzEz5FIXtMNTl2HVE/s1600/20120326_04.PNG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="640" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjqNAXHL_nxXiNhykpl7K2TdAZXHt68U2KODF9FrUDTtNc5IJCkPzU3qoH8-j5aOqId03NPok1EMHcK54vYc4_buIqrN5pxvMotLlpVXxIjXD1Hv2wk_qRYMnGnR2dzEz5FIXtMNTl2HVE/s640/20120326_04.PNG" width="454" /></a></div>
<br />
On the <tt>Java Settings</tt> screen, use default setting and click <tt>Finish</tt>.<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg_uEiBpm3n3G_A3GbCSkfcZNAD-3Hg-u01Ckx8WsFxgUpE7-qJktC_mbL3DG4p649fdnHXtiDo5dnmQRjFa9ojEEnFksWDZKY1PvQsc4fwsXIXOOzTZ_xtXr4tFdkvHifdlfIogp0ZsL4/s1600/20120326_05.PNG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="640" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg_uEiBpm3n3G_A3GbCSkfcZNAD-3Hg-u01Ckx8WsFxgUpE7-qJktC_mbL3DG4p649fdnHXtiDo5dnmQRjFa9ojEEnFksWDZKY1PvQsc4fwsXIXOOzTZ_xtXr4tFdkvHifdlfIogp0ZsL4/s640/20120326_05.PNG" width="454" /></a></div>
<br />
Once the project is created, the Studio opens the Flow editor for the new message flow.<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh8s0aAy9Vsju-yyNBa1MReq9YAFDmBiwdYh9DeAjMVPMB3W9q-U6PjqAexTbVkmwkOD6Kqft2YE_LWkiRjiFq2UTY8fDsazWAWTqNsUcDDJYZ1_5X_GJQ4AsajjMg0xHd2ueJ2CbjRK9U/s1600/20120326_06.PNG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="480" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh8s0aAy9Vsju-yyNBa1MReq9YAFDmBiwdYh9DeAjMVPMB3W9q-U6PjqAexTbVkmwkOD6Kqft2YE_LWkiRjiFq2UTY8fDsazWAWTqNsUcDDJYZ1_5X_GJQ4AsajjMg0xHd2ueJ2CbjRK9U/s640/20120326_06.PNG" width="640" /></a></div>
<br />
<br />
<b>Step 5 - Build the Hello World message flow</b> <br />
Drag and drop a <tt>File</tt> endpoint from the <tt>Endpoints</tt> panel to the flow editor
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgfV4PG3MtoTOPGwmMBAakoJQ4TcR7SQsO2OWD1Ep1T2Q5gXStk-fVmxiqlQli6c2mIrYr9JoUnIMFINHRXMJrDFWlqdJM2vg8aheSIheke8FnoENALnPeVypTyQgPcCPbVLJQqNbA1-SQ/s1600/20120326_07.PNG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="400" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgfV4PG3MtoTOPGwmMBAakoJQ4TcR7SQsO2OWD1Ep1T2Q5gXStk-fVmxiqlQli6c2mIrYr9JoUnIMFINHRXMJrDFWlqdJM2vg8aheSIheke8FnoENALnPeVypTyQgPcCPbVLJQqNbA1-SQ/s640/20120326_07.PNG" width="640" /></a></div>
<br />
Right click the <tt>File</tt> endpoint in flow editor and click <tt>Properties</tt>
<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhePoDEsXKJBimSILYxmYKxHO5DbeINVJtoGUfa8dDq0pCzsVDit8E6fKw3yPGfFIlD0UF86plPIyxB4Y6cBUSkugFpHztg3-mPWPUsjTih0Gdl4he2HNFPVidDZW73DZEUGITv2B8Ac0E/s1600/20120326_08.PNG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="400" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhePoDEsXKJBimSILYxmYKxHO5DbeINVJtoGUfa8dDq0pCzsVDit8E6fKw3yPGfFIlD0UF86plPIyxB4Y6cBUSkugFpHztg3-mPWPUsjTih0Gdl4he2HNFPVidDZW73DZEUGITv2B8Ac0E/s640/20120326_08.PNG" width="640" /></a></div>
Specify the <tt>Path</tt> property.<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEju8-tsu-xrhozpFdjs1-h05PT6GvTz7jibsD70pJVGCiYOANBEQlNeNn4Gv_a3ycVipXmKyxKM5SN-T6NmCuURE2SF2E0rm8aS2xQskvd5ElLggiWIkLCKY8EDVw-_iJ2hfoUpH-eoc_c/s1600/20120326_09.PNG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="640" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEju8-tsu-xrhozpFdjs1-h05PT6GvTz7jibsD70pJVGCiYOANBEQlNeNn4Gv_a3ycVipXmKyxKM5SN-T6NmCuURE2SF2E0rm8aS2xQskvd5ElLggiWIkLCKY8EDVw-_iJ2hfoUpH-eoc_c/s640/20120326_09.PNG" width="640" /></a></div>
<br />
This <tt>File</tt> endpoint works as the source endpoint, which reads files from the directory that specified in the <tt>Path</tt> property and puts the files into the flow.<br />
<br />
Drag and drop another <tt>File</tt> endpoint from the <tt>Endpoints</tt> panel to the flow editor<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjO_EAiMqS1xKVkq1QuAPGSm2v7OJ5NjUklN-fWx675tVc0nS4bqF-P3MnpaXgLFqBRor4B1NfzbIuq9eWDHENI_zhYOk2HvknryRt-0RQPW8sBPJj2hMJeiLhvHR4hcGcIaDQ4UXEmOws/s1600/20120326_10.PNG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="400" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjO_EAiMqS1xKVkq1QuAPGSm2v7OJ5NjUklN-fWx675tVc0nS4bqF-P3MnpaXgLFqBRor4B1NfzbIuq9eWDHENI_zhYOk2HvknryRt-0RQPW8sBPJj2hMJeiLhvHR4hcGcIaDQ4UXEmOws/s640/20120326_10.PNG" width="640" /></a></div>
<br />
The two file endpoints are linked with an arrow line that indicated the flow direction.<br />
Right click the <tt>File</tt> endpoint in flow editor and click <tt>Properties</tt>
<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgekzwiSpWAgCxSMImetzooWSlTXG38QBI6npNcLHfi6Iw5-vrAHYLJFdnqZKsUVviv3FXHmomEYKz04NQ4fVIDK8k0Wkx-FW7hkGrJ1MZ7E0cl3HhWjDcKVB_KXsyinrSybL5QyzIm0EU/s1600/20120326_11.PNG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="400" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgekzwiSpWAgCxSMImetzooWSlTXG38QBI6npNcLHfi6Iw5-vrAHYLJFdnqZKsUVviv3FXHmomEYKz04NQ4fVIDK8k0Wkx-FW7hkGrJ1MZ7E0cl3HhWjDcKVB_KXsyinrSybL5QyzIm0EU/s640/20120326_11.PNG" width="640" /></a></div>
<br />
Specify the <tt>Path</tt> property.
<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhRFEaJRtwdhxVKtOpr8WT8ZnNHInaNHK2iE_AcpC99KKeMwe7oGduPRG1EQlZPOcqhTVlxHjc94Wn1MecppDy8gRP0mlgvW9YIgazos_GoO_cB5JDnMFLnRvyKROG2TSORGddTvURfWr4/s1600/20120326_12.PNG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="640" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhRFEaJRtwdhxVKtOpr8WT8ZnNHInaNHK2iE_AcpC99KKeMwe7oGduPRG1EQlZPOcqhTVlxHjc94Wn1MecppDy8gRP0mlgvW9YIgazos_GoO_cB5JDnMFLnRvyKROG2TSORGddTvURfWr4/s640/20120326_12.PNG" width="640" /></a></div>
<br />
This <tt>File</tt> endpoint works as the target endpoint, which receives files from the flow and writes them to the directory that specified in the <tt>Path</tt> property.
<br />
<br />
<b>Step 6 - Run the Hello World application</b> <br />
Save the project first, then from the Package Explorer right click the current flow and select <tt>Run as > Mule Application </tt>
<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhU0TpfrzDxdeEEnPoUsmWIbf4g7-syY5mzAyOM6IYMedJHeNlQUkJN1RmwuEW0mRspi-_f0OxRFUdClzPYUTPQ15mcdnKvLAEKp6hag8AxYvAGUwA5mokUGiXXl9i5TxXWcvStIcWKVCw/s1600/20120326_13.PNG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="400" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhU0TpfrzDxdeEEnPoUsmWIbf4g7-syY5mzAyOM6IYMedJHeNlQUkJN1RmwuEW0mRspi-_f0OxRFUdClzPYUTPQ15mcdnKvLAEKp6hag8AxYvAGUwA5mokUGiXXl9i5TxXWcvStIcWKVCw/s640/20120326_13.PNG" width="640" /></a></div>
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEivmzmoC5fDoE9Dnf929zmu1BDt6BvknNQiPkfKfemzyrPT23OwFG3Gm6JIIMQSK79DAFU2Cju7nbCb-DkD67hIo8AqC_qXrEHiWeRr9WEd85FPT0Lo_pTj7m1t0m1fkN8txmNVExG-jfY/s1600/20120326_14.PNG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="400" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEivmzmoC5fDoE9Dnf929zmu1BDt6BvknNQiPkfKfemzyrPT23OwFG3Gm6JIIMQSK79DAFU2Cju7nbCb-DkD67hIo8AqC_qXrEHiWeRr9WEd85FPT0Lo_pTj7m1t0m1fkN8txmNVExG-jfY/s640/20120326_14.PNG" width="640" /></a></div>
Wait for the application to start up, and check the Console shows "Started app..." message without any errors.
<br />
<br />
Once the application is started, copy a file to the directory specified in the source File endpoint <tt>path</tt> property. In few second, this file should be moved to the directory specified in the source File endpoint <tt>path</tt> property.<br />
<br />
Now you have a simple Hello World ESB application running in Mule Studio.Youheng Huhttp://www.blogger.com/profile/18065339964353737399noreply@blogger.com1tag:blogger.com,1999:blog-2084992765277834447.post-53180482494900552672012-03-12T04:48:00.001+11:002012-03-12T04:49:47.394+11:00JSF Portlet File Download using WebSphere JSF 1.2 Portlet Bridge<p>
This note summarise my experience of JSF portlet file download using WebSphere JSF 1.2 Portlet Bridge.
</p>
<p>
<p>
One approach to implement file download from portlets is to use the JSR 286 resource serving mechanism. In order to make it working in JSF portlets, one needs to mix portlet and JSF programming as there is no direct support of the mechanism from JSF 1.2 Portlet Bridge.
<p>
<p>
The implementation consists of three components: a portlet class that extends <tt>FacesPortlet<tt> and overrides the <tt>serveResource</tt> method; a JSF page that provides use the download link; and a JSF managed bean that provides the file content.
<p>
<p>
<span style="color:#990000">The portlet class</span>
</p>
<p>
<div style="background: #d8d8d8">
<pre style="line-height: 125%"><span style="color: #008000; font-weight: bold">package</span> demo<span style="color: #666666">;</span>
<span style="color: #008000; font-weight: bold">import</span> <span style="color: #0000FF; font-weight: bold">java.io.IOException</span><span style="color: #666666">;</span>
<span style="color: #008000; font-weight: bold">import</span> <span style="color: #0000FF; font-weight: bold">java.io.OutputStream</span><span style="color: #666666">;</span>
<span style="color: #008000; font-weight: bold">import</span> <span style="color: #0000FF; font-weight: bold">javax.el.ExpressionFactory</span><span style="color: #666666">;</span>
<span style="color: #008000; font-weight: bold">import</span> <span style="color: #0000FF; font-weight: bold">javax.el.ValueExpression</span><span style="color: #666666">;</span>
<span style="color: #008000; font-weight: bold">import</span> <span style="color: #0000FF; font-weight: bold">javax.faces.context.FacesContext</span><span style="color: #666666">;</span>
<span style="color: #008000; font-weight: bold">import</span> <span style="color: #0000FF; font-weight: bold">javax.faces.lifecycle.Lifecycle</span><span style="color: #666666">;</span>
<span style="color: #008000; font-weight: bold">import</span> <span style="color: #0000FF; font-weight: bold">javax.portlet.PortletException</span><span style="color: #666666">;</span>
<span style="color: #008000; font-weight: bold">import</span> <span style="color: #0000FF; font-weight: bold">javax.portlet.PortletSession</span><span style="color: #666666">;</span>
<span style="color: #008000; font-weight: bold">import</span> <span style="color: #0000FF; font-weight: bold">javax.portlet.ResourceRequest</span><span style="color: #666666">;</span>
<span style="color: #008000; font-weight: bold">import</span> <span style="color: #0000FF; font-weight: bold">javax.portlet.ResourceResponse</span><span style="color: #666666">;</span>
<span style="color: #008000; font-weight: bold">import</span> <span style="color: #0000FF; font-weight: bold">com.ibm.faces.portlet.FacesPortlet</span><span style="color: #666666">;</span>
<span style="color: #008000; font-weight: bold">import</span> <span style="color: #0000FF; font-weight: bold">com.ibm.faces.portlet.httpbridge.PortletRequestWrapper</span><span style="color: #666666">;</span>
<span style="color: #008000; font-weight: bold">import</span> <span style="color: #0000FF; font-weight: bold">com.ibm.faces.portlet.httpbridge.PortletResponseWrapper</span><span style="color: #666666">;</span>
<span style="color: #008000; font-weight: bold">import</span> <span style="color: #0000FF; font-weight: bold">com.ibm.faces.portlet.httpbridge.ResourceRequestWrapper</span><span style="color: #666666">;</span>
<span style="color: #008000; font-weight: bold">import</span> <span style="color: #0000FF; font-weight: bold">com.ibm.faces.portlet.httpbridge.ResourceResponseWrapper</span><span style="color: #666666">;</span>
<span style="color: #008000; font-weight: bold">public</span> <span style="color: #008000; font-weight: bold">class</span> <span style="color: #0000FF; font-weight: bold">JSFPortlet</span> <span style="color: #008000; font-weight: bold">extends</span> FacesPortlet <span style="color: #666666">{</span>
<span style="color: #AA22FF">@Override</span>
<span style="color: #008000; font-weight: bold">public</span> <span style="color: #B00040">void</span> <span style="color: #0000FF">serveResource</span><span style="color: #666666">(</span>ResourceRequest request<span style="color: #666666">,</span> ResourceResponse response<span style="color: #666666">)</span>
<span style="color: #008000; font-weight: bold">throws</span> PortletException<span style="color: #666666">,</span> IOException <span style="color: #666666">{</span>
<span style="color: #008000; font-weight: bold">super</span><span style="color: #666666">.</span><span style="color: #7D9029">serveResource</span><span style="color: #666666">(</span>request<span style="color: #666666">,</span> response<span style="color: #666666">);</span>
TestBean testBean <span style="color: #666666">=</span> <span style="color: #666666">(</span>TestBean<span style="color: #666666">)</span> getJSFManagedBean<span style="color: #666666">(</span>
request<span style="color: #666666">,</span> response<span style="color: #666666">,</span> TestBean<span style="color: #666666">.</span><span style="color: #7D9029">BEAN_NAME</span><span style="color: #666666">,</span> TestBean<span style="color: #666666">.</span><span style="color: #7D9029">class</span><span style="color: #666666">);</span>
<span style="color: #008000; font-weight: bold">final</span> OutputStream out <span style="color: #666666">=</span> response<span style="color: #666666">.</span><span style="color: #7D9029">getPortletOutputStream</span><span style="color: #666666">();</span>
<span style="color: #B00040">byte</span><span style="color: #666666">[]</span> bytes <span style="color: #666666">=</span> testBean<span style="color: #666666">.</span><span style="color: #7D9029">getCsv</span><span style="color: #666666">();</span>
response<span style="color: #666666">.</span><span style="color: #7D9029">setContentType</span><span style="color: #666666">(</span><span style="color: #BA2121">"text/csv"</span><span style="color: #666666">);</span>
response<span style="color: #666666">.</span><span style="color: #7D9029">setProperty</span><span style="color: #666666">(</span><span style="color: #BA2121">"Content-Disposition"</span><span style="color: #666666">,</span>
<span style="color: #BA2121">"attachment; filename=download.csv"</span><span style="color: #666666">);</span>
response<span style="color: #666666">.</span><span style="color: #7D9029">setProperty</span><span style="color: #666666">(</span><span style="color: #BA2121">"Content-length"</span><span style="color: #666666">,</span> String<span style="color: #666666">.</span><span style="color: #7D9029">valueOf</span><span style="color: #666666">(</span>bytes<span style="color: #666666">.</span><span style="color: #7D9029">length</span><span style="color: #666666">));</span>
out<span style="color: #666666">.</span><span style="color: #7D9029">write</span><span style="color: #666666">(</span>bytes<span style="color: #666666">);</span>
out<span style="color: #666666">.</span><span style="color: #7D9029">flush</span><span style="color: #666666">();</span>
out<span style="color: #666666">.</span><span style="color: #7D9029">close</span><span style="color: #666666">();</span>
<span style="color: #666666">}</span>
<span style="color: #008000; font-weight: bold">public</span> Object <span style="color: #0000FF">getJSFManagedBean</span><span style="color: #666666">(</span>ResourceRequest request<span style="color: #666666">,</span>
ResourceResponse response<span style="color: #666666">,</span> String beanName<span style="color: #666666">,</span> Class beanClass<span style="color: #666666">)</span>
<span style="color: #008000; font-weight: bold">throws</span> PortletException <span style="color: #666666">{</span>
PortletSession portletSession <span style="color: #666666">=</span> request<span style="color: #666666">.</span><span style="color: #7D9029">getPortletSession</span><span style="color: #666666">();</span>
Object jsfBean <span style="color: #666666">=</span> <span style="color: #666666">(</span>TestBean<span style="color: #666666">)</span> portletSession<span style="color: #666666">.</span><span style="color: #7D9029">getAttribute</span><span style="color: #666666">(</span>beanName<span style="color: #666666">);</span>
<span style="color: #008000; font-weight: bold">if</span> <span style="color: #666666">(</span>jsfBean <span style="color: #666666">==</span> <span style="color: #008000; font-weight: bold">null</span><span style="color: #666666">)</span> <span style="color: #666666">{</span>
PortletRequestWrapper requestWrapper <span style="color: #666666">=</span> <span style="color: #008000; font-weight: bold">new</span> ResourceRequestWrapper<span style="color: #666666">(</span>
request<span style="color: #666666">);</span>
requestWrapper<span style="color: #666666">.</span><span style="color: #7D9029">setPortletContext</span><span style="color: #666666">(</span>getPortletContext<span style="color: #666666">());</span>
PortletResponseWrapper responseWrapper <span style="color: #666666">=</span> <span style="color: #008000; font-weight: bold">new</span> ResourceResponseWrapper<span style="color: #666666">(</span>
response<span style="color: #666666">);</span>
Lifecycle lifecycle <span style="color: #666666">=</span> getLifecycle<span style="color: #666666">(</span>requestWrapper<span style="color: #666666">);</span>
FacesContext context <span style="color: #666666">=</span> getFacesContext<span style="color: #666666">(</span>requestWrapper<span style="color: #666666">,</span>
responseWrapper<span style="color: #666666">,</span> lifecycle<span style="color: #666666">);</span>
<span style="color: #008000; font-weight: bold">final</span> ExpressionFactory expressionFactory <span style="color: #666666">=</span> context
<span style="color: #666666">.</span><span style="color: #7D9029">getApplication</span><span style="color: #666666">().</span><span style="color: #7D9029">getExpressionFactory</span><span style="color: #666666">();</span>
<span style="color: #008000; font-weight: bold">final</span> ValueExpression valueExpression <span style="color: #666666">=</span> expressionFactory
<span style="color: #666666">.</span><span style="color: #7D9029">createValueExpression</span><span style="color: #666666">(</span>context<span style="color: #666666">.</span><span style="color: #7D9029">getELContext</span><span style="color: #666666">(),</span>
<span style="color: #BA2121">"#{"</span> <span style="color: #666666">+</span> beanName <span style="color: #666666">+</span> <span style="color: #BA2121">"}"</span><span style="color: #666666">,</span> beanClass<span style="color: #666666">);</span>
jsfBean <span style="color: #666666">=</span> <span style="color: #666666">(</span>TestBean<span style="color: #666666">)</span> valueExpression<span style="color: #666666">.</span><span style="color: #7D9029">getValue</span><span style="color: #666666">(</span>context
<span style="color: #666666">.</span><span style="color: #7D9029">getELContext</span><span style="color: #666666">());</span>
<span style="color: #666666">}</span>
<span style="color: #008000; font-weight: bold">return</span> jsfBean<span style="color: #666666">;</span>
<span style="color: #666666">}</span>
<span style="color: #666666">}</span>
</pre>
</div>
</p>
<p>
<span style="color:#990000">The JSF page</span>
</p>
<p>
<div style="background: #d8d8d8">
<pre style="line-height: 125%"><span style="color: #008000; font-weight: bold"><%@</span> taglib uri<span style="color: #666666">=</span><span style="color: #BA2121">"http://java.sun.com/jsf/core"</span> prefix<span style="color: #666666">=</span><span style="color: #BA2121">"f"</span><span style="color: #008000; font-weight: bold">%></span>
<span style="color: #008000; font-weight: bold"><%@</span> taglib uri<span style="color: #666666">=</span><span style="color: #BA2121">"http://java.sun.com/jsf/html"</span> prefix<span style="color: #666666">=</span><span style="color: #BA2121">"h"</span><span style="color: #008000; font-weight: bold">%></span>
<span style="color: #008000; font-weight: bold"><%@</span> taglib uri<span style="color: #666666">=</span><span style="color: #BA2121">"http://java.sun.com/portlet_2_0"</span> prefix<span style="color: #666666">=</span><span style="color: #BA2121">"portlet"</span><span style="color: #008000; font-weight: bold">%></span>
<span style="color: #008000; font-weight: bold"><%@</span>taglib uri<span style="color: #666666">=</span><span style="color: #BA2121">"http://www.ibm.com/xmlns/prod/websphere/portal/v6.1/portlet-client-model"</span>
prefix<span style="color: #666666">=</span><span style="color: #BA2121">"portlet-client-model"</span> <span style="color: #008000; font-weight: bold">%></span>
<span style="color: #008000; font-weight: bold"><%@</span> page language<span style="color: #666666">=</span><span style="color: #BA2121">"java"</span> contentType<span style="color: #666666">=</span><span style="color: #BA2121">"text/html"</span> pageEncoding<span style="color: #666666">=</span><span style="color: #BA2121">"ISO-8859-1"</span> session<span style="color: #666666">=</span><span style="color: #BA2121">"false"</span><span style="color: #008000; font-weight: bold">%></span>
<span style="color: #008000; font-weight: bold"><portlet:defineObjects</span> <span style="color: #008000; font-weight: bold">/></span>
<span style="color: #008000; font-weight: bold"><portlet-client-model:init></span>
<span style="color: #008000; font-weight: bold"><portlet-client-model:require</span> <span style="color: #7D9029">module=</span><span style="color: #BA2121">"ibm.portal.xml.*"</span><span style="color: #008000; font-weight: bold">/></span>
<span style="color: #008000; font-weight: bold"><portlet-client-model:require</span> <span style="color: #7D9029">module=</span><span style="color: #BA2121">"ibm.portal.portlet.*"</span><span style="color: #008000; font-weight: bold">/></span>
<span style="color: #008000; font-weight: bold"></portlet-client-model:init></span>
<span style="color: #008000; font-weight: bold"><f:view></span>
<span style="color: #008000; font-weight: bold"><portlet:resourceURL</span> <span style="color: #7D9029">var=</span><span style="color: #BA2121">"resourceUrl"</span> <span style="color: #008000; font-weight: bold">></span>
<span style="color: #008000; font-weight: bold"><portlet:param</span> <span style="color: #7D9029">name=</span><span style="color: #BA2121">"action"</span> <span style="color: #7D9029">value=</span><span style="color: #BA2121">"csv"</span> <span style="color: #008000; font-weight: bold">/></span>
<span style="color: #008000; font-weight: bold"></portlet:resourceURL></span>
<span style="color: #008000; font-weight: bold"><a</span> <span style="color: #7D9029">href=</span><span style="color: #BA2121">"</span><span style="color: #008000; font-weight: bold"><%=</span>resourceUrl<span style="color: #008000; font-weight: bold">%></span><span style="color: #BA2121">"</span><span style="color: #008000; font-weight: bold">></span>Download CSV<span style="color: #008000; font-weight: bold"></a></span>
<span style="color: #008000; font-weight: bold"></f:view></span>
</pre>
</div>
</p>
<p>
<span style="color:#990000">The JSF managed bean</span>
</p>
<p>
<div style="background: #d8d8d8">
<pre style="line-height: 125%"><span style="color: #008000; font-weight: bold">package</span> demo<span style="color: #666666">;</span>
<span style="color: #008000; font-weight: bold">import</span> <span style="color: #0000FF; font-weight: bold">java.util.Date</span><span style="color: #666666">;</span>
<span style="color: #008000; font-weight: bold">public</span> <span style="color: #008000; font-weight: bold">class</span> <span style="color: #0000FF; font-weight: bold">TestBean</span> <span style="color: #666666">{</span>
<span style="color: #008000; font-weight: bold">public</span> <span style="color: #008000; font-weight: bold">static</span> <span style="color: #008000; font-weight: bold">final</span> String BEAN_NAME <span style="color: #666666">=</span> <span style="color: #BA2121">"testBean"</span><span style="color: #666666">;</span>
<span style="color: #008000; font-weight: bold">public</span> <span style="color: #B00040">byte</span><span style="color: #666666">[]</span> <span style="color: #0000FF">getCsv</span><span style="color: #666666">()</span> <span style="color: #666666">{</span>
<span style="color: #008000; font-weight: bold">return</span> <span style="color: #008000; font-weight: bold">new</span> <span style="color: #0000FF">Date</span><span style="color: #666666">().</span><span style="color: #7D9029">toString</span><span style="color: #666666">().</span><span style="color: #7D9029">getBytes</span><span style="color: #666666">();</span>
<span style="color: #666666">}</span>
<span style="color: #008000; font-weight: bold">public</span> String <span style="color: #0000FF">getText</span><span style="color: #666666">()</span> <span style="color: #666666">{</span>
<span style="color: #008000; font-weight: bold">return</span> <span style="color: #BA2121">"Hello"</span><span style="color: #666666">;</span>
<span style="color: #666666">}</span>
<span style="color: #666666">}</span>
</pre>
</div>
</p>
<p>
Some notes are:
</p>
<p>
- The IBM JSF 1.2 Portlet Bridge doesn't provide a Facelet taglib xml for the <tt><portlet:resourceURL></tt> tag, so the tag cannot be used in Facelet based JSF pages. This issue has been addressed in IBM JSF 2 Portlet Bridge.
</p>
<p>
- The <tt><portlet:resourceURL></tt> tag provides a <tt>var</tt> attribute that can be used to export the resource URL. Based on the JSR 286 spec, the exported variable is created in JSP page scope. As JSF code has no access to JSP page scope, the exported variable can not be used in JSF code.
</p>
<p>
- In traditional Servlet programming, the <tt>response.setHeader</tt> method is used to set HTTP response heads like <tt>Content-Disposition</tt> and <tt>Content-length</tt>, but in portlet, the <tt>ResourceResponse.setProperty</tt> method is used.
</p>
<p>
- There are two ways to access JSF managed beans from the portlet code: if the managed bean is a session scope bean and it's already exists in the session, the <tt>portletSession.getAttribute(BEAN_NAME)</tt> call can be used; otherwise, JSF value expression can be used to get and/or create the bean from FacesContext, as the IBM JSF 1.2 Portlet Bridge doesn't provide any method that the portlet implementation class can directly access FacesContext, some internal code must be used to achieve this.
</p>Youheng Huhttp://www.blogger.com/profile/18065339964353737399noreply@blogger.com7tag:blogger.com,1999:blog-2084992765277834447.post-54008068741541121532012-03-08T05:16:00.001+11:002012-03-08T05:16:21.989+11:00File down with JSF applications<p>
This note summarises different ways to implement file download with JSF applications.
<p>
<p>
<span style="color:#990000">Approach 1- File down using Servlet</span>
</p>
<p>
This approach uses a servlet to serve file download request and the link to the servlet can be implemented by using various JSF components, e.g. <tt>commandLink</tt> and <tt>outputLink</tt>.
</p>
<p>
The servlet based approach is a simply and easy way to implement file down, however, the shortcoming here is the file serving process is outside the JSF life cycle, glue code is required when the download process needs to access JSF faces context and backing beans.
</p>
<p>
A detailed discussion of the approach can be found from <a href="http://balusc.blogspot.com.au/2007/07/fileservlet.html">here</a>.
</p>
<p>
<span style="color:#990000">Approach 2- File down using JSF PhaseListener</span>
</p>
<p>
This approach use a JSF PhaseListener to serving process, an example of such implementation can be found from the <a href="http://kenai.com/projects/scales/pages/Download">Mojarra Scales</a> project, which provides a UI component that renders the download link and a PhaseListener that serves file content, sample usage is shown in below.
</p>
<p>
<div style="background: #d8d8d8">
<pre style="line-height: 125%"><span style="color: #008000; font-weight: bold"><sc:download</span> <span style="color: #7D9029">id=</span><span style="color: #BA2121">"downloadPdf"</span>
<span style="color: #7D9029">method=</span><span style="color: #BA2121">"download"</span>
<span style="color: #7D9029">mimeType=</span><span style="color: #BA2121">"application/pdf"</span>
<span style="color: #7D9029">fileName=</span><span style="color: #BA2121">"sample.pdf"</span>
<span style="color: #7D9029">data=</span><span style="color: #BA2121">"#{testBean.pdf}"</span>
<span style="color: #7D9029">text=</span><span style="color: #BA2121">"Download here"</span><span style="color: #008000; font-weight: bold">></span>
<span style="color: #008000; font-weight: bold"></sc:download></span></pre>
</div>
</p>
<p>
When the Mojarra Scales download component is used to create a download link, it renders a http link on the page with a specific URL format which the PhaseListener is used to identify the file request, once the link is clicked, the PhaseListener serves content in the <tt>beforePhase</tt> method at the <tt>RESTORE_VIEW</tt> phase.
</p>
<p>
By using a JSF PhaseListener, the file serving process is now part of the JSF lifecycle. However, the shortcoming here is the data for download is populated during page render, i.e. the evaluation of the <tt>#{testBean.pdf}</tt> expression in the above example, even the user has NOT click the download click.
</p>
<p>
<span style="color:#990000">Approach 3- File down using JSF Action/ActionListener</span>
</p>
<p>
This approach use JSF Action/ActionListener that attaches to JSF <tt>commandLink</tt> or <tt>commandButton</tt> to serves file content.
</p>
Details discussion on Action based implementation can be found <a href="http://balusc.blogspot.com.au/2006/05/pdf-handling.html">here</a>, ActionListener based implementation can be found from the <a href="http://primefaces.org/">PrimeFaces</a> FileDownload component.
<p>
This is the best approach from my point of view.
</p>Youheng Huhttp://www.blogger.com/profile/18065339964353737399noreply@blogger.com0tag:blogger.com,1999:blog-2084992765277834447.post-17002714658168860872012-03-06T04:41:00.002+11:002012-03-06T04:41:42.081+11:00Use WebSphere wsadmin Jython to customise Web module context root for WAR/EAR deployment<p>
This note explain how to use wsadmin Jython to customise Web module context root for WAR/EAR deployment in WebSphere Application Server.
</p>
<p>
To deploy WAR/EAR file in WAS WebSphere Application Server, wsadmin Jython provides the <tt>AdminApp.install</tt> method, where the <tt>archivePath</tt> parameter gives the full path of the war/ear file, and the <tt>options</tt> parameter gives various options for deployment, including the context root setting.
</p>
<p>
<div style="background: #d8d8d8">
<pre style="line-height: 125%">AdminApp<span style="color: #666666">.</span><span style="color: #7D9029">install</span><span style="color: #666666">(</span>archivePath<span style="color: #666666">,</span> options<span style="color: #666666">)</span>
</pre>
</div>
</p>
<p>
For WAR deployment, the <tt>-contextroot</tt> option is used, the option value is the given context root.
</p>
<p>
<div style="background: #d8d8d8">
<pre style="line-height: 125%">options <span style="color: #666666">=</span> <span style="color: #666666">[]</span>
<span style="color: #666666">...</span>
options<span style="color: #666666">.</span><span style="color: #7D9029">append</span><span style="color: #666666">(</span><span style="color: #BA2121">"-contextroot"</span><span style="color: #666666">)</span>
options<span style="color: #666666">.</span><span style="color: #7D9029">append</span><span style="color: #666666">(</span>contextRoot<span style="color: #666666">)</span>
<span style="color: #666666">...</span>
AdminApp<span style="color: #666666">.</span><span style="color: #7D9029">install</span><span style="color: #666666">(</span>warPath<span style="color: #666666">,</span> options<span style="color: #666666">)</span>
</pre>
</div>
</p>
<p>
For EAR deployment, the <tt>-CtxRootForWebMod</tt> option is used, the option value is a list consists of three items: <tt>Web module name<tt>, <tt>Web module URI</tt>, and the given <tt>context root</tt>. The Web module name and URI values can be set in two ways, using specific values, or using pattern matching:
</p>
<p>
<div style="background: #d8d8d8">
<pre style="line-height: 125%"><span style="color: #408080; font-style: italic">#Set Web module name and URI with specific values</span>
options <span style="color: #666666">=</span> []
<span style="color: #666666">...</span>
options<span style="color: #666666">.</span>append(<span style="color: #BA2121">"-CtxRootForWebMod"</span>)
options<span style="color: #666666">.</span>append([[<span style="color: #BA2121">'My Web Applicaiton'</span>, <span style="color: #BA2121">'my_app.war,WEB-INF/web.xml'</span>, contextRoot]])
<span style="color: #666666">...</span>
AdminApp<span style="color: #666666">.</span>install(earPath, options)
<span style="color: #408080; font-style: italic">#Set Web module name and URI using pattern matching</span>
options <span style="color: #666666">=</span> []
<span style="color: #666666">...</span>
options<span style="color: #666666">.</span>append(<span style="color: #BA2121">"-CtxRootForWebMod"</span>)
options<span style="color: #666666">.</span>append([[<span style="color: #BA2121">'.*'</span>, <span style="color: #BA2121">'.*'</span>, contextRoot]])
<span style="color: #666666">...</span>
AdminApp<span style="color: #666666">.</span>install(earPath, options)
</pre>
</div>
</p>Youheng Huhttp://www.blogger.com/profile/18065339964353737399noreply@blogger.com1tag:blogger.com,1999:blog-2084992765277834447.post-2266555977210723562012-03-05T05:26:00.001+11:002012-03-05T05:28:06.888+11:00Integrating m2eclipse-wtp with IBM Rational Application Developer for Portlet Development<p>
This is a walkthrough for integrating Maven with IBM Rational Application Developer for portlet development using m2eclipse-wtp.
</p>
<p>
<b>Step 1 - Install IBM Rational Application Developer V8.0.4</b>
</p>
<p>
Refer my previous notes - <a href="http://youhenghu.blogspot.com.au/2012/02/setup-portlet-development-environment.html">Setup a Portlet Development Environment With IBM Rational Application Developer 8</a>
</p>
<p>
<b>Step 2 - Install m2eclipse-wtp release 1.0.100</b>
</p>
<p>
1) In RAD open the menu <tt>Window - Preferences - Install/Update - Available Software Sites</tt>, enable sites listed below, <br/>
<br/>
* <tt>http://download.eclipse.org/eclipse/updates/3.6 </tt><br/>
* <tt>http://download.eclipse.org/webtools/repository/helios </tt><br/>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgmpj5mAqXGODaI4oTKY0IsGq1NJjFKGpF-_9K0dVZbBeFDr3X7dy26A9TDzDpW17Oqom36p4PFnTieIey7xyDgu_h-D47OvHkinBNZWLjTzCW_4LPHfq9tlB-3S4O8hXQncWzTzCtDb2w/s1600/20120301_01.PNG" imageanchor="1" style=""><img border="0" height="171" width="400" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgmpj5mAqXGODaI4oTKY0IsGq1NJjFKGpF-_9K0dVZbBeFDr3X7dy26A9TDzDpW17Oqom36p4PFnTieIey7xyDgu_h-D47OvHkinBNZWLjTzCW_4LPHfq9tlB-3S4O8hXQncWzTzCtDb2w/s400/20120301_01.PNG" /></a></div>
</p>
<p>
2) In RAD open the menu <tt>Help -> Install New Software</tt>, add this new location: <br/>
<br/>
<tt>http://download.jboss.org/jbosstools/updates/m2eclipse-wtp</tt><br/>
<br/>
and select the following check boxes: <br/>
<br/>
* Maven Integration for Eclipse <br/>
* Maven Integration for WTP <br/>
* Expand Maven Integration for Eclipse Extras folder and select only m2e connector for maven archiver pom properties <br/>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgI5bpjoWVBra6PTh9V7JW6Or9rVytHLxPRqoa6kR8g-4-jNzqCBYa8x9f8lLthMts9uhwjyTjVD9UetreMesgAOW_k1ByVUrfpJV5LYWg5aGv_N_7dlujFKoxo-peGJuEcxx_YyD9EWuU/s1600/20120301_02.PNG" imageanchor="1" style=""><img border="0" height="299" width="320" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgI5bpjoWVBra6PTh9V7JW6Or9rVytHLxPRqoa6kR8g-4-jNzqCBYa8x9f8lLthMts9uhwjyTjVD9UetreMesgAOW_k1ByVUrfpJV5LYWg5aGv_N_7dlujFKoxo-peGJuEcxx_YyD9EWuU/s320/20120301_02.PNG" /></a></div>
</p>
<p>
<b>Step 3 - Install m2e connectors for software configuration management (SCM) </b>
</p>
<p>
In my case SVN is used as SCM, I first installed Subclipse V1.6.X from update site <tt>http://subclipse.tigris.org/update_1.6.x</tt>, then in RAD open the menu <tt>Window - Preferences - Maven - Discovery</tt>, click the <tt>Open Catalog</tt> button, and select/install the m2e-subclipse connector.
</p>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjbzHtrdlppRn7n2ouM8XIdLmCzBoEycfqvks_-E1qB6ZKnjO83xg4S0ELdbDojcgvPLZMEEgTctwovqBy5kEJejCgHsdGpoegpUXZlQCMtgUaViCEECU3k-gRpYDK6EAp8z4pCf5yL4Yk/s1600/20120301_08.PNG" imageanchor="1" style=""><img border="0" height="320" width="237" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjbzHtrdlppRn7n2ouM8XIdLmCzBoEycfqvks_-E1qB6ZKnjO83xg4S0ELdbDojcgvPLZMEEgTctwovqBy5kEJejCgHsdGpoegpUXZlQCMtgUaViCEECU3k-gRpYDK6EAp8z4pCf5yL4Yk/s320/20120301_08.PNG" /></a></div>
<p>
<b>Step 4 - Setup Java EE and Maven preference</b>
</p>
<p>
1)In RAD open the menu <tt>Window - Preferences - Java EE - Project</tt>, uncheck the <tt>"Add project to an EAR"</tt> checkbox. <br/>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgli9xRZK3jPcZMvgPzyVMSmEQGJniUl3kgtaSGzA7nFyfLamSw_6uTRDSV4u6WR8v_89iBeBa4Tr84H64WyAfmcNj28QhVoohVADSjAKKUvtQ_IeFwOzSaTeuPxiu6u8Rpu3On3cc2Sq8/s1600/20120301_03.PNG" imageanchor="1" style=""><img border="0" height="320" width="298" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgli9xRZK3jPcZMvgPzyVMSmEQGJniUl3kgtaSGzA7nFyfLamSw_6uTRDSV4u6WR8v_89iBeBa4Tr84H64WyAfmcNj28QhVoohVADSjAKKUvtQ_IeFwOzSaTeuPxiu6u8Rpu3On3cc2Sq8/s320/20120301_03.PNG" /></a></div>
</p>
<p>
2)In RAD open the menu <tt>Window - Preferences - Maven - WTP integration</tt>, uncheck the <tt>"Generate application.xml under the build directory"</tt> checkbox. <br/>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg1bNbzJJr6QwWFLJbcZs9-HKTSbrLYxiiobFr_Ak76adrdK0dD1fB2IdIEFKA1mx0kjY_0ggd9jVrWTftjixSqdUNS5EM9j8RO4WN4qWfRYxLWko2JP1SmrTZJsCMsSKtiTCf_tI912fU/s1600/20120301_04.PNG" imageanchor="1" style=""><img border="0" height="320" width="298" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg1bNbzJJr6QwWFLJbcZs9-HKTSbrLYxiiobFr_Ak76adrdK0dD1fB2IdIEFKA1mx0kjY_0ggd9jVrWTftjixSqdUNS5EM9j8RO4WN4qWfRYxLWko2JP1SmrTZJsCMsSKtiTCf_tI912fU/s320/20120301_04.PNG" /></a></div>
</p>
<p>
<b>Step 5 - Add Maven projects into RAD workspace</b>
</p>
<p>
Use RAD "Checkout Maven projects from SCM" or "Import Existing Maven Projects" wizard to add your Maven projects into RAD workspace.
</p>
<p>
In my demo project, I have a Maven project that consists of three modules: <tt>core</tt>, <tt>webapp</tt> and <tt>ear</tt>. When the projects are imported into RAD, the m2eclipse-wtp plugin apply appropriate facets to the projects based on the maven project types
</p>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgiqe3UU7FoKYbngUqF4VHUhW-ih1mZlss5NSKR9f7Y3FikBYp44x7fvV5b_oTqSaa-rdmvOiZaMcYnM6nAD1I2VbyvyM6C47yeVuuGdQTy3OdzKJ3XPdGJNxUmrztcYIpY9NdxvTVeDb8/s1600/20120301_05.PNG" imageanchor="1" style=""><img border="0" height="312" width="203" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgiqe3UU7FoKYbngUqF4VHUhW-ih1mZlss5NSKR9f7Y3FikBYp44x7fvV5b_oTqSaa-rdmvOiZaMcYnM6nAD1I2VbyvyM6C47yeVuuGdQTy3OdzKJ3XPdGJNxUmrztcYIpY9NdxvTVeDb8/s320/20120301_05.PNG" /></a></div>
<p>
<b>Step 6 - Setup EAR project properties</b> <br/>
</p>
<p>
This step is important to use RAD Portlet development features include <tt>debug/run on server</tt>, and edit <tt>WAS deployment descriptor<tt>.
</p>
<p>
1) Right click the ear project and select <tt>Properties - Project Facets</tt>, select the <tt>"Websphere Application(Co-existence)"</tt> and the <tt>"Websphere Application(Extended)"</tt> checkboxes, change the version based on your WAS server version<br/>
</p>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgzU8KR5cbpLck_Wc8kgHFftb-eUCk6Kdxnt9XTbMbH18kCLpYnWqK8nXvlv0LffEmD92R7MdDSJc8XHfF_Pf4tWlgG6ei94PUy9dY0WqST5jt1pY38d8LqEX2FM7WyaDhyphenhyphenqBnagPCT_rM/s1600/20120301_06.PNG" imageanchor="1" style=""><img border="0" height="198" width="320" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgzU8KR5cbpLck_Wc8kgHFftb-eUCk6Kdxnt9XTbMbH18kCLpYnWqK8nXvlv0LffEmD92R7MdDSJc8XHfF_Pf4tWlgG6ei94PUy9dY0WqST5jt1pY38d8LqEX2FM7WyaDhyphenhyphenqBnagPCT_rM/s320/20120301_06.PNG" /></a></div>
<p>
2) Right click the ear project and select <tt>Properties - Targeted Runtimes</tt>, select the <tt>"Websphere Portal"</tt> checkbox.
</p>
<p>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhHc33AhrXTgPkM3D5hRHPYLiz5dzhVLAZ55znGzmegNLbUy3CBd36TtATPj_bgcJ8Z5qqv8EA0RBUe5bBL_MfXoWhsAQdkr_gSIrVNliyZr6IeAMtCBHP3b5b2Wn95pPVJ0ga5zKiWeTA/s1600/20120301_07.PNG" imageanchor="1" style=""><img border="0" height="198" width="320" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhHc33AhrXTgPkM3D5hRHPYLiz5dzhVLAZ55znGzmegNLbUy3CBd36TtATPj_bgcJ8Z5qqv8EA0RBUe5bBL_MfXoWhsAQdkr_gSIrVNliyZr6IeAMtCBHP3b5b2Wn95pPVJ0ga5zKiWeTA/s320/20120301_07.PNG" /></a></div>
<p>
Congratulations! now you have set up a Maevn based portlet development environment in RAD.
</p>
<p>
<b>Issues and Solutions</b>
</p>
<p>
<i>Issue</i> - The EAR project popup menu doesn't show the option <tt>Open WebSphere Application Deployment</tt>
</p>
<p>
<i>Solution</i> - ensure in the <tt>ear</tt> module POM file, the <tt>maven-ear-plugin/configuration/version</tt> property is set to 5 or up.
</p>
<p>
<pre style="line-height: 125%"><span style="color: #008000; font-weight: bold"><plugin></span>
<span style="color: #008000; font-weight: bold"><groupId></span>org.apache.maven.plugins<span style="color: #008000; font-weight: bold"></groupId></span>
<span style="color: #008000; font-weight: bold"><artifactId></span>maven-ear-plugin<span style="color: #008000; font-weight: bold"></artifactId></span>
<span style="color: #008000; font-weight: bold"><version></span>2.6<span style="color: #008000; font-weight: bold"></version></span>
<span style="color: #008000; font-weight: bold"><configuration></span>
<span style="color: #408080; font-style: italic"><!-- generate application.xml version 5, to enable RAD to edit WAS deployment descriptor --></span>
<span style="color: #008000; font-weight: bold"><version></span>5<span style="color: #008000; font-weight: bold"></version></span>
<span style="color: #008000; font-weight: bold"><modules></span>
<span style="color: #008000; font-weight: bold"><webModule></span>
<span style="color: #008000; font-weight: bold"><groupId></span>${project.groupId}<span style="color: #008000; font-weight: bold"></groupId></span>
<span style="color: #008000; font-weight: bold"><artifactId></span>demo-webapp<span style="color: #008000; font-weight: bold"></artifactId></span>
<span style="color: #008000; font-weight: bold"><contextRoot></span>MavenDemoPortlet<span style="color: #008000; font-weight: bold"></contextRoot></span>
<span style="color: #008000; font-weight: bold"></webModule></span>
<span style="color: #008000; font-weight: bold"></modules></span>
<span style="color: #008000; font-weight: bold"></configuration></span>
<span style="color: #008000; font-weight: bold"></plugin></span>
</pre>
</p>
<p>
<i>Issue</i> - Open WebSphere Application Deployment for the EAR project shows error <tt>Could not open the editor: An unexpected exception was thrown.</tt>
</p>
<p>
<i>Solution</i> - check the ear project <tt>settings/org.eclipse.wst.common.component</tt> file, ensure the <tt>deploy-name</tt> attribute of <tt>wb-module</tt> has the same value as the Eclipse project name. This can be achieved by two different ways.
</p>
<p>
1) In <tt>ear</tt> module POM file, add the <tt>build/finalName</tt> property, and set the value as the ear module artifactId,
</p>
<p>
<pre style="line-height: 125%"><span style="color: #008000; font-weight: bold"><build></span>
<span style="color: #408080; font-style: italic"><!-- </span>
<span style="color: #408080; font-style: italic"> same as the artifactId, which is the RAD project name, and also the </span>
<span style="color: #408080; font-style: italic"> deploy-name defined in settings/org.eclipse.wst.common.component </span>
<span style="color: #408080; font-style: italic"> --></span>
<span style="color: #008000; font-weight: bold"><finalName></span>demo-ear<span style="color: #008000; font-weight: bold"></finalName></span>
...
<span style="color: #008000; font-weight: bold"></build></span>
</pre>
</p>
<p>
2) During the project import, use the <tt>[artifactId]-[version]</tt> Name template in Advanced setting.
</p>
<p>
<i>Issue</i> - Run/Debug the portlet on Server shows error <tt>EJPPG0024I: Web application with context root XXX is deployed in the application server but not registered with portal.</tt>
</p>
<p>
<i>Solution</i> - check the webapp project <tt>settings/org.eclipse.wst.common.component</tt> file, ensure the <tt>context-root</tt> property of <tt>wb-module</tt> has the same value as the <tt>contextRoot<tt> defined in the ear maven-ear-plugin. If they are different, either update the ear POM file, or set the <tt>m2eclipse.wtp.contextRoot</tt> or the <tt>build/finalName</tt>property in webapp module POM to update the webapp project <tt>settings/org.eclipse.wst.common.component</tt> file.
</p>
<p>
<pre style="line-height: 125%"><span style="color: #008000; font-weight: bold"><properties></span>
<span style="color: #408080; font-style: italic"><!-- this must be same as the contextRoot defined in the ear module--></span>
<span style="color: #008000; font-weight: bold"><m2eclipse.wtp.contextRoot></span>MavenDemoPortlet<span style="color: #008000; font-weight: bold"></m2eclipse.wtp.contextRoot></span>
<span style="color: #008000; font-weight: bold"></properties></span>
</pre>
</p>Youheng Huhttp://www.blogger.com/profile/18065339964353737399noreply@blogger.com2tag:blogger.com,1999:blog-2084992765277834447.post-88959323052442469242012-02-28T05:21:00.002+11:002012-02-28T05:21:58.215+11:00IBM Rational Floating License on Network Servers<p>
When install IBM Rational floating license on a network server that resides behind firewall, it is importatnt to note in the <tt>license.dat</tt> file, we must specify individual port numbers on not only the SERVER line, but also each VENDOR or DAEMON line, as shown in below.
<div style="background: #d8d8d8">
<pre>
SERVER <hostname> <host or NIC ID> <lmgrd port>
VENDOR ibmratl PORT=<ibmratl port>
</pre>
</div>
<p>
The <tt><lmgrd port></tt> in SERVER line defines the port number used by the license manager daemon (lmgrd), and the <tt><ibmratl port></tt> defines the port number used by the vendor daemon (ibmratl). Once firewall is configured to allow access to these port numbers, desktop IBM Rational applicaitons can now access the license on network server.
<p>Youheng Huhttp://www.blogger.com/profile/18065339964353737399noreply@blogger.com0tag:blogger.com,1999:blog-2084992765277834447.post-46347896278362384572012-02-24T05:28:00.000+11:002012-02-24T05:28:04.334+11:00Setup a Portlet Development Environment With IBM Rational Application Developer 8<p>
This is a walkthrough for setting up a portlet development environment With IBM Rational Application Developer (RAD) 8.
</p>
<p>
<b>Step 1 - Verify you meet the System requirements for Rational Application Developer 8.</b> <br/>
Reference: <a target="_blank" href="http://www-01.ibm.com/support/docview.wss?rs=2042&uid=swg27019500">http://www-01.ibm.com/support/docview.wss?rs=2042&uid=swg27019500</a>
</p>
<p>
<b>Step 2 - Download RAD 8 install package</b> <br/>
Trial version can be found from <a target="_blank" href="http://www.ibm.com/developerworks/downloads/r/rad/?S_CMP=rnav">http://www.ibm.com/developerworks/downloads/r/rad/?S_CMP=rnav</a>
</p>
<p>
<b>Step 3 - Install RAD 8</b> <br/>
Lunch the IBM Installation Manager to install Rational Application Developer for WebSphere, in Features screen, select Portlet and Portal development tool. If you don't have a local portal server installed, make sure the "Tools for developing applications without a local server installation" option is selected, as shown in below.
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEivKJBgpnksLT8uckGmiOfovx2hhPejVslMFbBxori5KYLwHqPNnZ-gufTABUHknZeRaev22CC6RSivJcuT0UyyireWwklwhLA0w6BQgd-EKCf2GHbJa1s6OGns0YEHXieHndV6wd5__pQ/s1600/20120223_1.PNG" imageanchor="1" style=""><img border="0" height="174" width="320" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEivKJBgpnksLT8uckGmiOfovx2hhPejVslMFbBxori5KYLwHqPNnZ-gufTABUHknZeRaev22CC6RSivJcuT0UyyireWwklwhLA0w6BQgd-EKCf2GHbJa1s6OGns0YEHXieHndV6wd5__pQ/s320/20120223_1.PNG" /></a></div>
</p>
<p>
<b>Step 4 - Setup a Portal Server in RAD</b> <br/>
1) From the RAD menu, <tt>Window -> Show View -> Servers</tt> <br/>
2) Right-click the server view and click <tt>New -> Server</tt>. <br/>
3) On the Define a New Server page, select WebSphere Portal Server <br/>
4) Follow the New Server wizard and provide the WebSphere Settings, WebSphere Portal Settings and Properties Publishing Settings.<br/>
</p>
<p>
<b>Step 5 - Verify the setup</b> <br/>
Right-click the Portal server in the server view then do a start and stop to verify the server setup.
</p>
<p>
Congratulations! Now you have set up a portlet development environment in RAD, and you are ready to start portlet development.
</p>Youheng Huhttp://www.blogger.com/profile/18065339964353737399noreply@blogger.com2tag:blogger.com,1999:blog-2084992765277834447.post-36626617915514799972012-02-23T04:55:00.002+11:002012-02-23T04:56:37.516+11:00Maven substitution and Freemarker template<p>
If you're using Freemarker template in Maven projects, double check to be sure your templates are not alerted by Maven filtering during build process.
</p>
<p>
During Maven build, the Maven filtering process will scan all resources for property references surrounded by ${ and }. When it finds these references it will replace them with the appropriate value. If any Freemarker templates are in Maven resource directory (e.g. <tt>src/main/resources</tt>), and contains Freemarker variable names (surrounded by ${ and } as well) that are also maven property names, then these references will be replaced with maven property values.
</p>
<p>
An example is shown in below
</p>
<p>
<div style="background: #d8d8d8">
<pre style="line-height: 125%"><span style="color: #008000; font-weight: bold"><tr></span>
<span style="color: #008000; font-weight: bold"><td</span> <span style="color: #7D9029">class=</span><span style="color: #BA2121">"label"</span><span style="color: #008000; font-weight: bold">></span>Name:<span style="color: #008000; font-weight: bold"></td></span>
<span style="color: #008000; font-weight: bold"><td></span>${name}<span style="color: #008000; font-weight: bold"></td></span>
<span style="color: #008000; font-weight: bold"></tr></span>
</pre>
</div>
</p>
<p>
Where the <tt>${name}</tt> variable is meant to a Freemarker variable name and should be replaced during application runtime using model values, however, during Maven build, it is replaced to the Maven project name and the final package file will have the template file with the variable substituted, as shown in below.
</p>
<p>
<div style="background: #d8d8d8">
<pre style="line-height: 125%"><span style="color: #008000; font-weight: bold"><tr></span>
<span style="color: #008000; font-weight: bold"><td</span> <span style="color: #7D9029">class=</span><span style="color: #BA2121">"label"</span><span style="color: #008000; font-weight: bold">></span>Name:<span style="color: #008000; font-weight: bold"></td></span>
<span style="color: #008000; font-weight: bold"><td></span>My Maven project<span style="color: #008000; font-weight: bold"></td></span>
<span style="color: #008000; font-weight: bold"></tr></span>
</pre>
</div>
</p>
<p>
Simple way to fix this is to use a different variable name that maven doesn't aware, or a better way is to disable the maven filtering for all Freemarker template files in the pom file. In order to do so, you need to declare two mutually exclusive resource sets, the first resource set execludes Freemark templates from the filtering, and the other resource set copies Freemark templates unaltered, as shown in below.
</p>
<p>
<div style="background: #d8d8d8">
<pre style="line-height: 125%"><span style="color: #008000; font-weight: bold"><resources></span>
<span style="color: #008000; font-weight: bold"><resource></span>
<span style="color: #008000; font-weight: bold"><directory></span>src/main/resources<span style="color: #008000; font-weight: bold"></directory></span>
<span style="color: #008000; font-weight: bold"><filtering></span>true<span style="color: #008000; font-weight: bold"></filtering></span>
<span style="color: #008000; font-weight: bold"><excludes></span>
<span style="color: #008000; font-weight: bold"><exclude></span>**/*.ftl<span style="color: #008000; font-weight: bold"></exclude></span>
<span style="color: #008000; font-weight: bold"></excludes></span>
<span style="color: #008000; font-weight: bold"></resource></span>
<span style="color: #008000; font-weight: bold"><resource></span>
<span style="color: #008000; font-weight: bold"><directory></span>src/main/resources<span style="color: #008000; font-weight: bold"></directory></span>
<span style="color: #008000; font-weight: bold"><filtering></span>false<span style="color: #008000; font-weight: bold"></filtering></span>
<span style="color: #008000; font-weight: bold"><includes></span>
<span style="color: #008000; font-weight: bold"><include></span>**/*.ftl<span style="color: #008000; font-weight: bold"></include></span>
<span style="color: #008000; font-weight: bold"></includes></span>
<span style="color: #008000; font-weight: bold"></resource></span>
<span style="color: #008000; font-weight: bold"></resources></span>
</pre>
</div>
</p>Youheng Huhttp://www.blogger.com/profile/18065339964353737399noreply@blogger.com1