blob: 414bcd0e58dfa0ed428a51f1b4731ca68d1871dc [file] [log] [blame]
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8"/>
<meta name="viewport" content="width=device-width, initial-scale=1.0"/>
<meta name="Date-Revision-yyyymmdd" content="20140918"/>
<meta http-equiv="Content-Language" content="en"/>
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<title>WebSphere</title>
<link href="//fonts.googleapis.com/css?family=Source+Sans+Pro:300,400,600,700,400italic,600italic,700italic" rel="stylesheet" type="text/css">
<link href="//netdna.bootstrapcdn.com/font-awesome/4.0.3/css/font-awesome.css" rel="stylesheet">
<link href="/css/main.css" rel="stylesheet">
<link href="/css/custom.css" rel="stylesheet">
<link href="/highlighter/github-theme.css" rel="stylesheet">
<script src="//code.jquery.com/jquery-1.11.0.min.js"></script>
<script type="text/javascript" src="/bootstrap/js/bootstrap.js"></script>
<script type="text/javascript" src="/js/community.js"></script>
</head>
<body>
<a href="http://github.com/apache/struts" class="github-ribbon">
<img style="position: absolute; right: 0; border: 0;" src="https://s3.amazonaws.com/github/ribbons/forkme_right_red_aa0000.png" alt="Fork me on GitHub">
</a>
<header>
<nav>
<div role="navigation" class="navbar navbar-default navbar-fixed-top">
<div class="container">
<div class="navbar-header">
<button type="button" data-toggle="collapse" data-target="#struts-menu" class="navbar-toggle">
Menu
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a href="/index.html" class="navbar-brand logo"><img src="/img/struts-logo.svg"></a>
</div>
<div id="struts-menu" class="navbar-collapse collapse">
<ul class="nav navbar-nav">
<li class="dropdown">
<a data-toggle="dropdown" href="#" class="dropdown-toggle">
Home<b class="caret"></b>
</a>
<ul class="dropdown-menu">
<li><a href="/index.html">Welcome</a></li>
<li><a href="/download.cgi">Download</a></li>
<li><a href="/releases.html">Releases</a></li>
<li><a href="/announce-2021.html">Announcements</a></li>
<li><a href="http://www.apache.org/licenses/">License</a></li>
<li><a href="https://www.apache.org/foundation/thanks.html">Thanks!</a></li>
<li><a href="https://www.apache.org/foundation/sponsorship.html">Sponsorship</a></li>
</ul>
</li>
<li class="dropdown">
<a data-toggle="dropdown" href="#" class="dropdown-toggle">
Support<b class="caret"></b>
</a>
<ul class="dropdown-menu">
<li><a href="/mail.html">User Mailing List</a></li>
<li><a href="https://issues.apache.org/jira/browse/WW">Issue Tracker</a></li>
<li><a href="/security.html">Reporting Security Issues</a></li>
<li class="divider"></li>
<li><a href="https://cwiki.apache.org/confluence/display/WW/Migration+Guide">Version Notes</a></li>
<li><a href="https://cwiki.apache.org/confluence/display/WW/Security+Bulletins">Security Bulletins</a></li>
<li class="divider"></li>
<li><a href="/maven/project-info.html">Maven Project Info</a></li>
<li><a href="/maven/struts2-core/dependencies.html">Struts Core Dependencies</a></li>
<li><a href="/maven/struts2-plugins/modules.html">Plugin Dependencies</a></li>
</ul>
</li>
<li class="dropdown">
<a data-toggle="dropdown" href="#" class="dropdown-toggle">
Documentation<b class="caret"></b>
</a>
<ul class="dropdown-menu">
<li><a href="/birdseye.html">Birds Eye</a></li>
<li><a href="/primer.html">Key Technologies</a></li>
<li><a href="/kickstart.html">Kickstart FAQ</a></li>
<li><a href="https://cwiki.apache.org/confluence/display/WW/Home">Wiki</a></li>
<li class="divider"></li>
<li><a href="/getting-started/">Getting Started</a></li>
<li><a href="/security/">Security Guide</a></li>
<li><a href="/core-developers/">Core Developers Guide</a></li>
<li><a href="/tag-developers/">Tag Developers Guide</a></li>
<li><a href="/maven-archetypes/">Maven Archetypes</a></li>
<li><a href="/plugins/">Plugins</a></li>
<li><a href="/maven/struts2-core/apidocs/index.html">Struts Core API</a></li>
<li><a href="/tag-developers/tag-reference.html">Tag reference</a></li>
<li><a href="https://cwiki.apache.org/confluence/display/WW/FAQs">FAQs</a></li>
<li><a href="http://cwiki.apache.org/S2PLUGINS/home.html">Plugin registry</a></li>
</ul>
</li>
<li class="dropdown">
<a data-toggle="dropdown" href="#" class="dropdown-toggle">
Contributing<b class="caret"></b>
</a>
<ul class="dropdown-menu">
<li><a href="/youatstruts.html">You at Struts</a></li>
<li><a href="/helping.html">How to Help FAQ</a></li>
<li><a href="/dev-mail.html">Development Lists</a></li>
<li><a href="/contributors/">Contributors Guide</a></li>
<li class="divider"></li>
<li><a href="/submitting-patches.html">Submitting patches</a></li>
<li><a href="/builds.html">Source Code and Builds</a></li>
<li><a href="/coding-standards.html">Coding standards</a></li>
<li><a href="https://cwiki.apache.org/confluence/display/WW/Contributors+Guide">Contributors Guide</a></li>
<li class="divider"></li>
<li><a href="/release-guidelines.html">Release Guidelines</a></li>
<li><a href="/bylaws.html">PMC Charter</a></li>
<li><a href="/volunteers.html">Volunteers</a></li>
<li><a href="https://gitbox.apache.org/repos/asf?p=struts.git">Source Repository</a></li>
<li><a href="/updating-website.html">Updating the website</a></li>
</ul>
</li>
<li class="apache"><a href="http://www.apache.org/"><img src="/img/apache.png"></a></li>
</ul>
</div>
</div>
</div>
</nav>
</header>
<article class="container">
<section class="col-md-12">
<a href="index.html" title="back to Core Developers Guide"><< back to Core Developers Guide</a>
<a class="edit-on-gh" href="https://github.com/apache/struts-site/edit/master/source/core-developers/websphere.md" title="Edit this page on GitHub">Edit on GitHub</a>
<h1 id="websphere">WebSphere</h1>
<h2 id="websphere-51">WebSphere 5.1</h2>
<p>(ok) <a href="http://forums\.opensymphony\.com/thread\.jspa?threadID=26068">Be sure to install WebSphere’s Fix Pack 1</a>^[http://forums.opensymphony.com/thread.jspa?threadID=26068].</p>
<h2 id="websphere-6">WebSphere 6</h2>
<p>See forum thread: <a href="http://forums\.opensymphony\.com/message\.jspa?messageID=119574\#119574">http://forums.opensymphony.com/message.jspa?messageID=119574#119574</a></p>
<blockquote>
</blockquote>
<blockquote>
</blockquote>
<blockquote>
<p>It looks like there is a bug in WebSphere App Server related to which classloader is used at the time that Struts2 is loading the properties files, (all properties files, not just struts.properties and default.properties). The bug may have been fixed in WAS 6.0.2.9, (check out this link for details <a href="http://www\-1\.ibm\.com/support/docview\.wss?uid=swg27006876">http://www-1.ibm.com/support/docview.wss?uid=swg27006876</a>).</p>
</blockquote>
<blockquote>
</blockquote>
<blockquote>
</blockquote>
<blockquote>
<p>If you just want to confirm the issue, or you need just a temporary fix, try this:</p>
</blockquote>
<blockquote>
</blockquote>
<blockquote>
</blockquote>
<blockquote>
<p>1) jar up all properties files for your project, (including default.properties in its full path), and put these into the WS common applications lib directory at the same level as the “profiles” directory.</p>
</blockquote>
<blockquote>
<p>2) Run the application - everything should work</p>
</blockquote>
<blockquote>
</blockquote>
<blockquote>
</blockquote>
<blockquote>
<p>This solution is strictly temporary, as all struts2 apps in this instance of WAS would have to use the same properties files. A better solution:</p>
</blockquote>
<blockquote>
</blockquote>
<blockquote>
</blockquote>
<blockquote>
<p>1) add a servlet that initializes the Struts Dispatcher with the servlet context:</p>
</blockquote>
<blockquote>
<p>import org.apache.struts2.dispatcher.Dispatcher;</p>
<p>public class LaunchServlet extends HttpServlet implements Servlet {</p>
<div class="highlighter-rouge"><div class="highlight"><pre class="highlight"><code>public LaunchServlet() \{
super();
\}
public void init(ServletConfig arg0) throws ServletException \{
// this works around a bug in the websphere classloader\.
super\.init(arg0);
Dispatcher d = new Dispatcher(getServletContext(), new HashMap\&lt;String, String\&gt;());
\}
</code></pre></div> </div>
<p>}</p>
</blockquote>
<blockquote>
<p>2) launch it at start-up (web.xml):</p>
</blockquote>
<blockquote>
<div class="highlighter-rouge"><div class="highlight"><pre class="highlight"><code>\&lt;servlet\&gt;
\&lt;servlet\-name\&gt;dummyaction\&lt;/servlet\-name\&gt;
\&lt;servlet\-class\&gt;com\.xxx\.yyyyyy\.service\.LaunchServlet\&lt;/servlet\-class\&gt;
\&lt;load\-on\-startup\&gt;1\&lt;/load\-on\-startup\&gt;
\&lt;/servlet\&gt;
</code></pre></div> </div>
</blockquote>
<blockquote>
<p>3) Run application and everything should work.</p>
</blockquote>
<blockquote>
</blockquote>
<h2 id="websphere-65">WebSphere 6.5</h2>
<p>To make struts2 work in Websphere, one has to set Websphere specific properties, you may want to add that to the wiki:</p>
<p>The properties are:</p>
<div class="highlighter-rouge"><div class="highlight"><pre class="highlight"><code>
com.ibm.ws.webcontainer.assumefiltersuccessonsecurityerror = true
com.ibm.ws.webcontainer.invokefilterscompatibility = true
</code></pre></div></div>
<p>At least that is necessary when using StrutsPrepareAndExecuteFilter.</p>
<p>In Websphre admin console one has to add those properties here:</p>
<div class="highlighter-rouge"><div class="highlight"><pre class="highlight"><code>
Servers &gt; Application servers &gt; {server name} &gt; Web container &gt; Custom Properties
</code></pre></div></div>
<p>A wsadmin jython script to set those properties could look like this:</p>
<div class="highlighter-rouge"><div class="highlight"><pre class="highlight"><code>
def findObjectName(objectId):
index = objectId.find('(')
return objectId[0 : index]
node = AdminNodeManagement.listNodes()[0]
server = AdminConfig.list('Server')
nodeName = findObjectName(node)
serverName = findObjectName(server)
webContainer = AdminConfig.list('WebContainer', node)
webContainerDetails = AdminConfig.show(webContainer)
if webContainerDetails.find("com.ibm.ws.webcontainer.assumefiltersuccessonsecurityerror") == -1:
print "creating prop: com.ibm.ws.webcontainer.assumefiltersuccessonsecurityerror"
AdminServerManagement.configureCustomProperty(nodeName, serverName, "WebContainer","com.ibm.ws.webcontainer.assumefiltersuccessonsecurityerror", "true")
if webContainerDetails.find("com.ibm.ws.webcontainer.invokefilterscompatibility") == -1:
print "creating prop: com.ibm.ws.webcontainer.invokefilterscompatibility"
AdminServerManagement.configureCustomProperty(nodeName, serverName, "WebContainer", "com.ibm.ws.webcontainer.invokefilterscompatibility", "true")
</code></pre></div></div>
<p>Thanks to Christoph Nenning (christoph dot nenning at lex-com at net)</p>
<h2 id="jsessionid-handling">JSESSIONID handling</h2>
<p>IBM WebSphere Application Server uses the JSESSIONID information to keep track of the client session. If you have an application where the application client must navigate across multiple WebSphere Application Server nodes residing in same domain, then the JSESSIONID information may be over-written on the client because multiple JSESSIONID cookies received with the same name and path.</p>
<p>When persistence is disabled and if the JSESSIONID in the incoming request is not found in the current session manager, then the session manager will generate a new sessionId and create a session object, instead of using the sessionId in the incoming request.</p>
<p>To resolve this issue, configure WebSphere Application Server to reuse the sessionId present in the incoming request.</p>
<p>For All versions:</p>
<ol>
<li>
<p>Open the administrative console.</p>
</li>
<li>
<p>Select Servers &gt; Application Servers &gt; Server_Name &gt; Server Infrastructure &gt; Java and Process Management &gt; Process Definition &gt; Java Virtual Machine &gt; Custom Properties &gt; New</p>
</li>
<li>
<p>Add a new Custom Property for the JVM to reuse the sessionId:</p>
</li>
</ol>
<div class="highlighter-rouge"><div class="highlight"><pre class="highlight"><code>
System Property Name: HttpSessionIdReuse
System Property Value: true
</code></pre></div></div>
<ol>
<li>Save your changes and restart the Application Server.</li>
</ol>
<p>If the application client does not navigate across multiple WebSphere Application Server nodes residing in the same domain but there are multiple WARs with different context roots, following is the step that needs to be followed for session to be maintained in one web application:</p>
<ol>
<li>
<p>Open the administrative console.</p>
</li>
<li>
<p>Select Application servers &gt; Server_Name &gt; Session management &gt; Cookies</p>
</li>
<li>
<p>In “Cookie Path”, specify the context root of web application in which session needs to be maintained. This will ensure that cookies are sent only to /«context_root» URL and prevent overriding of JSSESSIONID cookie which results in new session creation by WAS.</p>
</li>
<li>
<p>Save your changes and restart the Application Server.</p>
</li>
</ol>
<p>Thanks to Vineet Kanwal from IBM!</p>
<p>##Big Picture## {#PAGE_13859}</p>
<p>The diagram describes the framework’s architecture.</p>
<p><img src="/Users/lukaszlenart/Projects/Apache/struts\-site/target/md/attachments/att2475\_Struts2\-Architecture\.png" alt="Struts2-Architecture.png" /></p>
<p>In the diagram, an initial request goes to the Servlet container (such as Jetty or Resin) which is passed through a standard filter chain. The chain includes the (optional) <strong>ActionContextCleanUp</strong> filter, which is useful when integrating technologies such as <em>SiteMesh Plugin</em> . Next, the required <strong>FilterDispatcher</strong> is called, which in turn consults the <a href="#PAGE_14128">ActionMapper</a> to determine if the request should invoke an action.</p>
<p>If the ActionMapper determines that an Action should be invoked, the FilterDispatcher delegates control to the <strong>ActionProxy</strong>. The ActionProxy consults the framework <a href="#PAGE_14163">Configuration Files</a> manager (initialized from the <a href="#PAGE_13901">struts.xml</a> file). Next, the ActionProxy creates an <strong>ActionInvocation</strong>, which is responsible for the command pattern implementation. This includes invoking any <strong>Interceptors</strong> (the <em>before</em> clause) in advance of invoking the <strong>Action</strong> itself.</p>
<p>Once the Action returns, the ActionInvocation is responsible for looking up the proper <strong>result</strong> associated with the <strong>Action result code</strong> mapped in <code class="highlighter-rouge">struts.xml</code>. The result is then executed, which often (but not always, as is the case for <a href="#PAGE_14214">Action Chaining</a>) involves a template written in <em>JSP</em> or <em>FreeMarker</em> to be rendered. While rendering, the templates can use the <em>Struts Tags</em> provided by the framework. Some of those components will work with the ActionMapper to render proper URLs for additional requests.</p>
<table>
<tbody>
<tr>
<td>All objects in this architecture (Actions, <a href="#PAGE_14035">Results</a>, <a href="#PAGE_13941">Interceptors</a>, and so forth) are created by an <a href="#PAGE_27470">ObjectFactory</a>. This ObjectFactory is pluggable. We can provide our own ObjectFactory for any reason that requires knowing when objects in the framework are created. A popular ObjectFactory implementation uses Spring as provided by the <em>Spring Plugin</em> .</td>
</tr>
</tbody>
</table>
<table>
<tbody>
<tr>
</tr>
</tbody>
</table>
<p>Interceptors are executed again (in reverse order, calling the <em>after</em> clause). Finally, the response returns through the filters configured in the <code class="highlighter-rouge">web.xml</code>. If the ActionContextCleanUp filter is present, the FilterDispatcher will <em>not</em> clean up the ThreadLocal <strong>ActionContext</strong>. If the ActionContextCleanUp filter is not present, the FilterDispatcher will cleanup all ThreadLocals.</p>
</section>
</article>
<footer class="container">
<div class="col-md-12">
Copyright &copy; 2000-2018 <a href="http://www.apache.org/">The Apache Software Foundation </a>.
All Rights Reserved.
</div>
<div class="col-md-12">
Apache Struts, Struts, Apache, the Apache feather logo, and the Apache Struts project logos are
trademarks of The Apache Software Foundation.
</div>
<div class="col-md-12">Logo and website design donated by <a href="https://softwaremill.com/">SoftwareMill</a>.</div>
</footer>
<script>!function (d, s, id) {
var js, fjs = d.getElementsByTagName(s)[0];
if (!d.getElementById(id)) {
js = d.createElement(s);
js.id = id;
js.src = "//platform.twitter.com/widgets.js";
fjs.parentNode.insertBefore(js, fjs);
}
}(document, "script", "twitter-wjs");</script>
<script src="https://apis.google.com/js/platform.js" async="async" defer="defer"></script>
<div id="fb-root"></div>
<script>(function (d, s, id) {
var js, fjs = d.getElementsByTagName(s)[0];
if (d.getElementById(id)) return;
js = d.createElement(s);
js.id = id;
js.src = "//connect.facebook.net/en_GB/all.js#xfbml=1";
fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));</script>
</body>
</html>