Friday, July 16, 2010

Struts 2.x Application Deployment On WAS 6.1

Recently one my colleagues - @chaituvj - was trying to deploy a Struts 2.1 web application on WAS 6.1. Upon hitting the first action (*.action), page showed HTTP 404: File Not Found error and WAS threw following exception
java.io.FileNotFoundException: /login.action
      at com.ibm.ws.webcontainer.extension.DefaultExtensionProcessor.handleRequest(DefaultExtensionProcessor.java:414)
      at com.ibm.ws.wswebcontainer.extension.DefaultExtensionProcessor.handleRequest(DefaultExtensionProcessor.java:113)
      at com.ibm.ws.webcontainer.webapp.WebApp.handleRequest(WebApp.java:3276)
      at com.ibm.ws.webcontainer.webapp.WebGroup.handleRequest(WebGroup.java:267)
      at com.ibm.ws.webcontainer.WebContainer.handleRequest(WebContainer.java:811)
      at com.ibm.ws.wswebcontainer.WebContainer.handleRequest(WebContainer.java:1455)
      at com.ibm.ws.webcontainer.channel.WCChannelLink.ready(WCChannelLink.java:113)
      ...

Same war file works like a charm on JBoss and Tomcat container, but when it comes to WAS 6.1, it just cant find the struts action URLs.

Upon reviewing application code, configurations a zillion time we turned to the life saver - Google. Instantly we realized that we are not the only unlucky soles. Upon going through many posts we found that WAS 6.1 web container by default does not invoke any of the custom servlet filters defined in web.xml. This means that it does not invoke the Struts 2 filter and hence Struts application context was never initialized (Smart IBM guys). To change this behavior and enable invocation of custom filters, a custom property needs to be defined for the web container under WAS 6.1. Here is what you need to do...

  1. Open the WAS admin console.
  2. Select the application server where you are deploying the *ill-fated* Struts 2 application
  3. Select Web Container Settings
  4. Select Web Container
  5. Select Custom Properties
  6. Define new property com.ibm.ws.webcontainer.invokefilterscompatibility and set its value as true
  7. Restart application server
  8. Done !!!

With above change your Struts 2 web app should start working with WAS 6.1

Cheers !!!
- Jay

1 comment :

  1. Helped a lot... Thank You..

    ReplyDelete

 
Disclaimer : This is a personal blog and all content represent what I think and it does not advocate/support/advertise any other person/company. I do not earn money or intended to do so with this blog or any of the contents the blog hosts (except the google ads which you see). If I post something here that you find helpful, that's wonderful. Just in case, if I say something stupid, the stupidity is mine, and mine alone and I can not be held for anything if you fall for such stupidity :-). I cannot be held responsible for any kind of damage that may be caused by downloading or viewing the files or information provided herewith. Anybody and everybody can use/refer the contents of this blog at their own will and of course at own risk. There is no need for any kind of approval of the author. Although it would be great if feedback is left for any such usage to the author.