Java – WebSphere 8, web.xml version=”3.0″, default servlet-mapping

javaservlet-3.0web.xmlwebsphere

Migrating a legacy application from WebSphere v.6 to WebSphere v.8. The application's web.xml only contains declarations of servlets but not servlet-mappings. Yet all servlets without a servlet-mapping are accessible by a default url pattern /servlet/[servlet name]. However, on WAS8, if web.xml is updated with attribute version set to "3.0":

 <web-app xmlns="http://java.sun.com/xml/ns/javaee"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
       **version="3.0"**> 

servlets loose default mapping and need to be explicitly mapped otherwise it's 404 page not found.

Is there a way in servlet 3.0 or at least WebSphere 8, to define a default url pattern for all servlets? There's InvokerServlet for tomcat, is there a version of it for WebSphere v.8?

Best Answer

Turns out older versions of WebSphere used proprietary ibm-web-*.xmi descriptors to define vendor specific deployment options. However, since v8.0 the support for .xmi files got dropped (yet still supported for backwards compatibility in applications declared as servlet "2.4"). The old application I was migrating contained the following ibm-web-ext.xmi in WEB-INF:

<?xml version="1.0" encoding="UTF-8"?>
<com.ibm.ejs.models.base.extensions.webappext:WebAppExtension xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:com.ibm.ejs.models.base.extensions.webappext="webappext.xmi" xmi:id="WebApp_ID_Ext" reloadingEnabled="true" fileServingEnabled="true" directoryBrowsingEnabled="false" serveServletsByClassnameEnabled="true">
  <webApp href="WEB-INF/web.xml#cchange"/>
  <extendedServlets xmi:id="ServletExtension_1">
    <extendedServlet href="WEB-INF/web.xml#Servlet_1"/>
  </extendedServlets>
  <jspAttributes xmi:id="JSPAttribute_1" name="keepgenerated" value="true"/>
  <jspAttributes xmi:id="JSPAttribute_1333518196516" name="reloadEnabled" value="true"/>
  <jspAttributes xmi:id="JSPAttribute_1333518196517" name="reloadInterval" value="10"/>
</com.ibm.ejs.models.base.extensions.webappext:WebAppExtension>

so the attribute serveServletsByClassnameEnabled="true" made the old app map servlets by name without servlet-mapping. This is not supported if the application is servlet 3.0..

Related Topic