So it build OK, but we're not done yet. The biggest change with Jaffa v1.3 is that we have moved to use Struts v1.1 as the underlying
presentation libraries. In v1.2 we used Struts v1.0, and there are some significant changes to some of the struts and web config files
that come along with this.
Note: If you want more information about how Jaffa v1.3 and Struts 1.1 (and Tiles) interoperate, there is a separate document
"D:\sandbox\JaffaCore\StrutsVsJaffa.txt" which discusses the differences and which new struts features are not compatible with Jaffa
Step 1 - Change web.xml to use the new Filter
Step 1.1 - Make sure were using Servlet spec 2.3, as 2.2 does not support Filters!
<!DOCTYPE web-app
PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
"http://java.sun.com/dtd/web-app_2_3.dtd">
|
Step 1.2 - Add the filter definition
Assuming from above that we haven't renamed MyUserSessionFilter, (really we should call this MyPortletFilter now!)
<filter>
<filter-name>Portlet Filter</filter-name>
<filter-class>com.xxx.user.services.MyUserSessionFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>Portlet Filter</filter-name>
<url-pattern>*.jsp</url-pattern>
</filter-mapping>
<filter-mapping>
<filter-name>Portlet Filter</filter-name>
<url-pattern>*.do</url-pattern>
</filter-mapping> |
Step 1.3 - Add the Servlet definition
<!-- Standard Action Servlet Configuration (with debugging) -->
<servlet>
<servlet-name>action</servlet-name>
<servlet-class>org.apache.struts.action.ActionServlet</servlet-class>
<init-param>
<param-name>application</param-name>
<param-value>ApplicationResources</param-value>
</init-param>
<init-param>
<param-name>config</param-name>
<param-value>/WEB-INF/struts-config.xml</param-value>
</init-param>
<init-param>
<param-name>debug</param-name>
<param-value>0</param-value>
</init-param>
<init-param>
<param-name>detail</param-name>
<param-value>0</param-value>
</init-param>
<init-param>
<param-name>validate</param-name>
<param-value>true</param-value>
</init-param>
<init-param>
<param-name>listings</param-name>
<param-value>false</param-value>
</init-param>
<load-on-startup>3</load-on-startup>
</servlet> |
Note: The only change here is that we used to use a different class from Jaffa (org.jaffa.presentation.portlet.PortletServlet)
but now we use a filter, and again use the vanilla Struts Controller (org.apache.struts.action.ActionServlet)
Step 1.4 - Change the TagLib entries
These are the new entries that are used with Struts 1.1
<!-- Struts Tag Library Descriptors -->
<taglib>
<taglib-uri>/tags/struts-bean</taglib-uri>
<taglib-location>/WEB-INF/struts-bean.tld</taglib-location>
</taglib>
<taglib>
<taglib-uri>/tags/struts-html</taglib-uri>
<taglib-location>/WEB-INF/struts-html.tld</taglib-location>
</taglib>
<taglib>
<taglib-uri>/tags/struts-logic</taglib-uri>
<taglib-location>/WEB-INF/struts-logic.tld</taglib-location>
</taglib>
<taglib>
<taglib-uri>/tags/struts-nested</taglib-uri>
<taglib-location>/WEB-INF/struts-nested.tld</taglib-location>
</taglib>
<taglib>
<taglib-uri>/tags/struts-tiles</taglib-uri>
<taglib-location>/WEB-INF/struts-tiles.tld</taglib-location>
</taglib> |
Step 1.5 - Catch ComponentExpired Errors
From the v1.3 Release Notes
What's Changed
=====================================================
2) struts-config.xml: Made it compatible with the new Struts1.1 DTD.
Removed the references to the Logon component.
Moved the mapping for pageExpired.jsp from struts-config.xml to web.xml
The new way to map this error to a web page is as follows...
<error-page>
<exception-type>org.jaffa.exceptions.ComponentExpiredException</exception-type>
<location>/jaffa/jsp/pageExpired.jsp</location>
</error-page>
|
Step 2 - Update struts-config.xml to the new format
Step 2.1 - Update the DTD to the latest spec
<!DOCTYPE struts-config PUBLIC
"-//Apache Software Foundation//DTD Struts Configuration 1.0//EN"
"http://jakarta.apache.org/struts/dtds/struts-config_1_1.dtd">
|
Step 2.2 - Remove old admin functions (if you still have them)
<!-- The standard administrative actions available with Struts -->
<!-- These would be either omitted or protected by security -->
<!-- in a real application deployment -->
<action path="/admin/addFormBean"
type="org.apache.struts.actions.AddFormBeanAction"/>
<action path="/admin/addForward"
type="org.apache.struts.actions.AddForwardAction"/>
<action path="/admin/addMapping"
type="org.apache.struts.actions.AddMappingAction"/>
<action path="/admin/reload"
type="org.apache.struts.actions.ReloadAction"/>
<action path="/admin/removeFormBean"
type="org.apache.struts.actions.RemoveFormBeanAction"/>
<action path="/admin/removeForward"
type="org.apache.struts.actions.RemoveForwardAction"/>
<action path="/admin/removeMapping"
type="org.apache.struts.actions.RemoveMappingAction"/>
|
If you are using 'Code Merging' in your struts-config.xml, a typical Jaffa install will look like...
<?xml version="1.0" encoding="ISO-8859-1" ?>
<!DOCTYPE struts-config PUBLIC
"-//Apache Software Foundation//DTD Struts Configuration 1.1//EN"
"http://jakarta.apache.org/struts/dtds/struts-config_1_1.dtd">
<struts-config>
<!-- ========== Form Bean Definitions =================================== -->
<form-beans>
<!-- Code Generated Form-Beans //GEN-BEGIN:StrutsConfigFormBean.xml -->
<!-- //GEN-END:StrutsConfigFormBean.xml -->
<!-- Jaffa Session Explorer -->
<form-bean name="jaffa_sessionExplorerForm"
type="org.jaffa.presentation.portlet.session.ui.SessionExplorerForm"/>
<form-bean name="jaffa_componentExplorerForm"
type="org.jaffa.presentation.portlet.session.ui.ComponentExplorerForm"/>
<form-bean name="jaffa_componentDetailsForm"
type="org.jaffa.presentation.portlet.session.ui.ComponentDetailsForm"/>
</form-beans>
<!-- ========== Global Forward Definitions ============================== -->
<global-forwards>
<!-- Code Generated Global Forwards //GEN-BEGIN:StrutsConfigGlobalForward.xml -->
<!-- //GEN-END:StrutsConfigGlobalForward.xml -->
<!-- Used if a the user has no component access -->
<forward name="jaffa_noComponentAccess" path="/jaffa/jsp/noComponentAccess.jsp"/>
<!-- GlobalForward For The Lookup -->
<forward name="jaffa_lookup" path="/jaffa/jsp/lookup.jsp"/>
<!-- GlobalForward For Closing a Browser Window -->
<forward name="jaffa_closeBrowser" path="/jaffa/jsp/closeBrowser.jsp"/>
<!-- Jaffa Session Explorer -->
<forward name="jaffa_sessionExplorerForm" path="/jaffa/jsp/sessionExplorer.jsp"/>
<forward name="jaffa_componentExplorerForm" path="/jaffa/jsp/componentExplorer.jsp"/>
<forward name="jaffa_componentDetailsForm" path="/jaffa/jsp/componentDetails.jsp"/>
</global-forwards>
<!-- ========== Action Mapping Definitions ============================== -->
<action-mappings>
<!-- Code Generated Actions //GEN-BEGIN:StrutsConfigAction.xml -->
<!-- //GEN-END:StrutsConfigAction.xml -->
<!-- Standard framework action for initializing and executing a component directly -->
<action path="/startComponent"
type="org.jaffa.presentation.portlet.StartComponentAction">
</action>
<!-- Jaffa Session Explorer -->
<action path="/jaffa_sessionExplorer"
type="org.jaffa.presentation.portlet.session.ui.SessionExplorerAction"
name="jaffa_sessionExplorerForm"
validate="false"
scope="request">
</action>
<action path="/jaffa_componentExplorer"
type="org.jaffa.presentation.portlet.session.ui.ComponentExplorerAction"
name="jaffa_componentExplorerForm"
validate="false"
scope="request">
</action>
<action path="/jaffa_componentDetails"
type="org.jaffa.presentation.portlet.session.ui.ComponentDetailsAction"
name="jaffa_componentDetailsForm"
validate="false"
scope="request">
</action>
</action-mappings>
</struts-config>
|
Step 3 - Update the JDBC Engine config (D:\sandbox\MyProject\source\java\resources\jdbc-engine.xml)
From the v1.3 Release Notes
What's Changed
=====================================================
5) Revamped the init.xml to conform to the 'init_1_0.xsd' schema. Some of the major changes are
a) New elements - connection-factory, hitlistSize, jdbcSecurityPlugin, usePreparedStatement
b) The parameters are now children of the connection-factory element
c) New parameters to support DbcpDataSourceConnectionFactory - maxWait, testOnBorrow, testOnReturn, validationQuery
d) New parameters to support JndiDataSourceConnectionFactory - jndiDataSourceName
If you forget to change this file from the v1.2 format and start your web app you will most likely get the following error...
DefaultValidationEventHandler: [ERROR]: tag name "driver" is not allowed. Possible tag names are: <connection-factory>
2003-09-25 08:50:43,619 ERROR configservice.ConfigurationService (?:?) [Thread-4]-Error while parsing the init file resources/jdbc-engine.xml
javax.xml.bind.UnmarshalException
- with linked exception:
[com.sun.msv.verifier.ValidityViolation: tag name "driver" is not allowed. Possible tag names are: <connection-factory>]
at javax.xml.bind.helpers.AbstractUnmarshallerImpl.createUnmarshalException(AbstractUnmarshallerImpl.java:306)
at com.sun.xml.bind.unmarshaller.UnmarshallerImpl.unmarshal(UnmarshallerImpl.java:134)
at javax.xml.bind.helpers.AbstractUnmarshallerImpl.unmarshal(AbstractUnmarshallerImpl.java:139)
at javax.xml.bind.helpers.AbstractUnmarshallerImpl.unmarshal(AbstractUnmarshallerImpl.java:186)
at org.jaffa.persistence.engines.jdbcengine.configservice.ConfigurationService.<init>(Unknown Source)
at org.jaffa.persistence.engines.jdbcengine.configservice.ConfigurationService.createConfigurationServiceInstance(Unknown Source)
|
In Jaffa v1.2 my 'jdbc-engine.xml' file looked like this
<init>
<database name="default" engine="mssqlserver">
<driver url="jdbc:microsoft:sqlserver://<<DATABASE.HOST.SHORT>>:<<DATABASE.PORT>>;databasename=<<DATABASE.SID>>
class="com.microsoft.jdbc.sqlserver.SQLServerDriver"/>
<param name="user" value="<<DATABASE.USER>>"/>
<param name="password" value="<<DATABASE.PASS>>"/>
<param name="hitlistSize" value="<<INIT.XML.HITLISTSIZE>>"/>
<param name="minimumConnections" value="<<INIT.XML.MINIMUMCONNECTIONS>>"/>
<param name="maximumConnections" value="<<INIT.XML.MAXIMUMCONNECTIONS>>"/>
<param name="logFileName" value="<<DBCONNECTIONBROKER.LOG>>"/>
<param name="maxConnTime" value="<<INIT.XML.MAX_CONN_TIME>>"/>
<param name="logAppend" value="<<INIT.XML.LOG_APPEND>>"/>
<param name="maxCheckoutSeconds" value="<<INIT.XML.MAX_CHECKOUT_SECONDS>>"/>
<param name="debugLevel" value="<<INIT.XML.DEBUG_LEVEL>>"/>
</database>
<conf-location>
<dir-loc dir="resources/jdbcengine"/>
</conf-location>
</init>
|
Note, the parameters inside the << >> brackets are substituted in the ant build process with real values.
The new version of this file for Jaffa v1.3 (assuming we still want the same connection pool mechanism as
used in v1.2) looks like...
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE init PUBLIC "-//JAFFA//DTD JDBC Engine Init 1.0//EN"
"http://jaffa.sourceforge.net/DTD/jdbc-engine-init_1_0.dtd">
<init>
<database name="default" engine="<<DATABASE.ENGINE>>">
<!--
*********************************************************************************************
The connection-factory should implement the
org.jaffa.persistence.engines.jdbcengine.datasource.IConnectionFactory interface
*********************************************************************************************
-->
<connection-factory class="org.jaffa.persistence.engines.jdbcengine.datasource.DbConnectionBrokerConnectionFactory">
<!--
*********************************************************************************************
Parameters when using DbConnectionBrokerConnectionFactory or DbcpDataSourceConnectionFactory
*********************************************************************************************
-->
<param name="url" value="<<DATABASE.JDBC.URL>>"/>
<param name="driverClass" value="<<DATABASE.JDBC.DRIVER>>"/>
<param name="user" value="<<DATABASE.USER>>"/>
<param name="password" value="<<DATABASE.PASS>>"/>
<param name="minimumConnections" value="<<INIT.XML.MINIMUMCONNECTIONS>>"/>
<param name="maximumConnections" value="<<INIT.XML.MAXIMUMCONNECTIONS>>"/>
<!--
***********************************************************
Parameters when using DbConnectionBrokerConnectionFactory
***********************************************************
-->
<param name="debugLevel" value="<<INIT.XML.DEBUG_LEVEL>>"/>
<param name="logFileName" value="<<DBCONNECTIONBROKER.LOG>>"/>
<param name="logAppend" value="<<INIT.XML.LOG_APPEND>>"/>
<param name="maxConnTime" value="<<INIT.XML.MAX_CONN_TIME>>"/>
<param name="maxCheckoutSeconds" value="<<INIT.XML.MAX_CHECKOUT_SECONDS>>"/>
</connection-factory>
<hitlistSize value="<<INIT.XML.HITLISTSIZE>>"/>
<!--<jdbcSecurityPlugin value="org.jaffa.security.JDBCSecurityPlugin"/>-->
<usePreparedStatement value="true"/>
</database>
<conf-location>
<dir-loc dir="resources/jdbcengine"/>
</conf-location>
</init>
|
Step 4 - In framework.properties remove the deprecated values
- framework.security.portlet.enabled
- framework.security.portlet.manager
- framework.security.portlet.bypassActionList
- framework.persistence.jdbcengine.usePreparedStatement
- framework.persistence.jdbcengine.security.plugin
|