Ray, I followed your instructions and now I am getting this exception on startup: java.lang.ClassNotFoundException: org.apache.myfaces.webapp.StartupServletContextListener
I don't have the struts-jsf plugin jar in my web-inf and I removed the myfaces jar files. I did a search of the file directory for the webapp and could not find any references to "myfaces" yet I still get the same failure on startup. Here is my web.xml file: <?xml version="1.0" encoding="ISO-8859-1"?> <!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN" "http://java.sun.com/dtd/web-app_2_3.dtd"> <web-app> <display-name>strutsNotes</display-name> <!-- Define Tiles config files --> <context-param> <param-name>org.apache.tiles.impl.BasicTilesContainer.DEFINITIONS_CONFIG</param-name> <param-value> /WEB-INF/config/tiles-def-struts1.xml, /WEB-INF/config/tiles-def-struts2.xml </param-value> </context-param> <context-param> <param-name>contextConfigLocation</param-name> <param-value>/WEB-INF/applicationContext.xml</param-value> </context-param> <filter> <filter-name>openSessionInViewFilter</filter-name> <filter-class>org.springframework.orm.hibernate3.support.OpenSessionInViewFilter</filter-class> </filter> <filter> <filter-name>filterDispatcher</filter-name> <filter-class>org.apache.struts2.dispatcher.FilterDispatcher</filter-class> </filter> <filter-mapping> <filter-name>openSessionInViewFilter</filter-name> <url-pattern>/*</url-pattern> </filter-mapping> <filter-mapping> <filter-name>filterDispatcher</filter-name> <url-pattern>*.action</url-pattern> </filter-mapping> <listener> <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class> </listener> <!-- Start the Tiles Processor--> <listener> <listener-class>org.apache.tiles.web.startup.TilesListener</listener-class> </listener> <!-- Action Servlet Configuration --> <servlet> <servlet-name>action</servlet-name> <servlet-class>org.apache.struts.action.ActionServlet</servlet-class> <init-param> <param-name>config</param-name> <param-value>/WEB-INF/struts-config.xml</param-value> </init-param> <load-on-startup>1</load-on-startup> </servlet> <servlet> <servlet-name>Tiles Dispatch Servlet</servlet-name> <servlet-class>org.apache.tiles.web.TilesDispatchServlet</servlet-class> </servlet> <!-- Action Servlet Mapping --> <servlet-mapping> <servlet-name>action</servlet-name> <url-pattern>*.do</url-pattern> </servlet-mapping> <servlet-mapping> <servlet-name>Tiles Dispatch Servlet</servlet-name> <url-pattern>*.tiles</url-pattern> </servlet-mapping> <!-- The Usual Welcome File List --> <welcome-file-list> <welcome-file>index.jsp</welcome-file> </welcome-file-list> <error-page> <exception-type>java.lang.Exception</exception-type> <location>/WEB-INF/jsp/Error.jsp</location> </error-page> <taglib> <taglib-uri>/WEB-INF/struts-bean</taglib-uri> <taglib-location>/WEB-INF/struts-bean.tld</taglib-location> </taglib> <taglib> <taglib-uri>/WEB-INF/struts-logic</taglib-uri> <taglib-location>/WEB-INF/struts-logic.tld</taglib-location> </taglib> <taglib> <taglib-uri>/WEB-INF/struts-html</taglib-uri> <taglib-location>/WEB-INF/struts-html.tld</taglib-location> </taglib> <taglib> <taglib-uri>/WEB-INF/struts-tiles</taglib-uri> <taglib-location>/WEB-INF/struts-tiles.tld</taglib-location> </taglib> <taglib> <taglib-uri>/WEB-INF/c</taglib-uri> <taglib-location>/WEB-INF/c.tld</taglib-location> </taglib> <login-config> <auth-method>BASIC</auth-method> </login-config> </web-app> ----- Original Message ---- From: Ray Clough <[EMAIL PROTECTED]> To: user@struts.apache.org Sent: Sunday, August 26, 2007 5:44:08 AM Subject: Re: Struts1/Tiles and Struts2/tiles in same app My previous post failed, presumably the attachment was blocked. Here is the contents of the document I created to define the process of using Tiles-2 as a standalone service with Struts-1 and Struts-2. Sorry if it is long, but I couldn't get the attachment to work. If you ask, I will send the pdf to anyone who wants it. -Ray Clough [EMAIL PROTECTED] Using Tiles-2 as a Standalone Service, Including Deployment with Struts-1 and Struts-2. This document describes using Tiles-2 (T2) in a Java Web Application based on Apache Struts-1 (S1) with Apache Struts-2 (S2). The classical way of using Tiles-1 with S1 involved using a Plugin. The typical way of using T2 with S2 uses a Struts2-Tiles2 plugin module. These instructions do not use any plugins with either S1 or S2. The Tiles processor is installed as an independent service, exactly as it would be in a non-Struts environment. Note that this document describes a basic Tiles installation, and there are advanced features available, but these are not covered in this document. If you are migrating an existing application, it is recommended that the migration be attempted in the smallest possible steps. This way, when a failure occurs, it will logically be attributable to the last step invoked. Of course, this is true of any significant feature migration of an existing application. Finally, note that these instructions are for the latest released version of Tiles-2 at the time of this writing: viz. Tiles-2.0.4. It is expected that changes with future releases will not be big, but there may be changes which will affect these instructions. 1. Requisites: These files must be in the WEB-INF/lib directory: • Tiles-2 Distribution jar files: tiles-core-2.0.4.jar, tiles-api-2.0.4.jar, tiles-jsp-2.0.4.jar • Commons Logging v1.1 or better: commons-logging-1.1.jar • Commons Digester v1.8 or better: commons-digester-1.8.jar • Commons BeanUtils v1.7 or better: commons-beanutils-1.7.0.jar 2. The Tiles processor must be activated when the servlet container starts up. As described in the Tiles-2 Tutorial, at http://tiles.apache.org/tutorial/configuration.html , there are 3 alternative ways of doing this: (a) a Startup Servlet, (b) a Startup Listener, or (c) a Startup Filter. Each of these requires additions to the web.xml web-app deployment descriptor. Using method (b) requires this addition to web.xml: <!-- Start the Tiles Processor--> <listener> <listener-class> org.apache.tiles.web.startup.TilesListener </listener-class> </listener> This method also requires an entry in the <context-param> section of the web.xml file to tell Tiles what the names of the Tiles definitions files are: <!-- Define Tiles config files --> <context-param> <param-name> org.apache.tiles.impl.BasicTilesContainer.DEFINITIONS_CONFIG </param-name> <param-value> /WEB-INF/config/tiles_part1.xml, /WEB-INF/config/tiles_part2.xml </param-value> </context-param> 3. In web.xml, add a reference to the Tiles Dispatch Servlet, and map it to "*.tiles". The Tiles DispatchServlet is responsible for processing all url’s ending in “.tiles” to the Tiles Processor: <servlet> <servlet-name>Tiles Dispatch Servlet</servlet-name> <servlet-class> org.apache.tiles.web.TilesDispatchServlet </servlet-class> <load-on-startup>3</load-on-startup> </servlet> <servlet-mapping> <servlet-name>Tiles Dispatch Servlet</servlet-name> <url-pattern>*.tiles</url-pattern> </servlet-mapping> 4. Migrating S1 portion of the app: • remove the Struts-1 plugin from the WEB-INF/lib directory, depending on the S1 version, delete the file 'struts-tiles-1.3.8.jar'. • There was a difference between the way Tiles was deployed in Struts-1.2 and earlier and Struts-1.3. • Struts 1-2 and earlier: • In struts-config.xml, remove the <plugin> element which deployed Tiles-1. That element looked like this: <plug-in className="org.apache.struts.tiles.TilesPlugin" > <set-property property="definitions-config" value="/WEB-INF/config/tiles-defs.xml" /> <set-property property="moduleAware" value="true" /> <set-property property="definitions-parser-validate" value="true" /> </plug-in> • In struts-config.xml, use the normal Struts RequestProcessor, not the TilesResultsProcessor. That element previously looked like this: <controller processorClass="com.allthisisthat.RaysCathouse.StrutsLayer.controller.MyRequestProcessor" /> • Struts 1.3: • It is possible to deploy tiles in Struts 1.3 apps just like under 1.2 and earlier. In this case, the upgrade path is identical. Struts 1.3 introduced the “Composable Request Processor which gives some other options for deploying Tiles. Whatever Struts features are used to deploy Tiles, remove them from the struts-config.xml file. 5 In Struts-2, the usual way of deploying Tiles places the file “struts2-tiles-plugin-2.0.9.jar” into the WEB-INF/lib directory. This takes advantage of the Struts-2 plugin architecture. It is also necessary to place some elements into the web.xml file to start the Tiles-2 processor. This is very similar to the deployment of the TilesListener described in step 2 above, but with a different class path for the Listener component. Once this file is placed into the application, the Struts-2 actions defined in the configuration file “struts.xml” need to have access to Tiles resources, and the easiest way to do that is to have your packages extend “tiles-default”, or otherwise have access to the Tiles “result” type and interceptor. 6 It is perfectly possible for Struts-1 to use the stand-alone Tiles-2 and for Struts-2 to simultaneously use Tiles-2 deployed using the standard method described in Step-4 above, and covered in detail on the Struts-2 web site. However, there are reasons for not using the Struts-2 plugin, and using Tiles-2 standalone with Struts-2. One of the main reasons for this is that the standard deployment requires adding an attribute to the S2 actions, ‘type=”result”’. If you want to use some other result type, you won’t be able to, because there is only one ‘result’ for an action. Also, to eliminate intermediate layers (ie the plugin) introduces fewer sources of bugs into your app, and fewer dependencies (the plugin, and S2 doesn’t always release with the latest Tiles-2 version). To remove the S2 plugin architecture requires only removing the struts2-tiles-plugin-xxxxx.jar file, removing the extension of the ‘tiles-default’ package by your packages, and not including the result type attribute. Be sure that you use the TilesListener specified in Step-2, not the one which comes with Struts-2. Using the Plugin architecture results in a S2 action definition like this: <package name="greetings" namespace="/greetings" extends="tiles-default"> <action name="Welcome" > <result name="success" type=”tiles”> WELCOME</result> </action> ... For S2 with standalone Tiles-2, this becomes: <package name="greetings" namespace="/greetings" extends="struts-default"> <action name="Welcome" > <result name="success" >/WELCOME.tiles</result> </action> ... Note that the forward page is now preceded by a slash (“/”) and has “.tiles” on the end. This is because the Tiles DispatchServlet is mapped to *.tiles. The *.tiles mapping is default, and may be configurable, but that functionality was missing from a recent release. 7. Now that you have Tiles-2 set up in the app, whether you are using Struts-1, Struts-2, a combination, or are not using Struts at all, you need to create the JSP template files, the tiles definition xml file, and the jsp pages. Be sure to note that the tiles.xml file (or whatever you name it) must use the Tiles-2 DTD, which is different from the Tiles-1 DTD, and the JSP pages must use the correct namespace for Tiles-2. Following are several files used in the deployment of a small demo app which uses S1, S2, and Tiles-2 as a standalone service. Here is “web.xml” <?xml version="1.0" encoding="UTF-8"?> <web-app version="2.4" xmlns="http://java.sun.com/xml/ns/j2ee"; xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"; xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd";> <display-name>Greetings Earth</display-name> <description> Demonstrator for Struts-2 with Struts-1 and Tiles </description> <!-- Specify the definitions file for Tiles (S2) --> <!-- <context-param> <param-name> org.apache.tiles.CONTAINER_FACTORY </param-name> <param-value> org.apache.tiles.factory.TilesContainerFactory </param-value> </context-param> --> <context-param> <param-name> org.apache.tiles.impl.BasicTilesContainer.DEFINITIONS_CONFIG </param-name> <param-value>/WEB-INF/tiles.xml</param-value> </context-param> <!-- Filter (Struts-2) --> <filter> <filter-name>struts2</filter-name> <filter-class> org.apache.struts2.dispatcher.FilterDispatcher </filter-class> </filter> <filter-mapping> <filter-name>struts2</filter-name> <url-pattern>/*</url-pattern> </filter-mapping> <!-- Listener (Struts-2) --> <listener> <listener-class> org.springframework.web.context.ContextLoaderListener </listener-class> </listener> <listener> <listener-class> org.apache.tiles.web.startup.TilesListener </listener-class> </listener> <!-- Struts-1 Action Servlet --> <servlet> <servlet-name>action</servlet-name> <servlet-class> org.apache.struts.action.ActionServlet </servlet-class> <init-param> <param-name>config</param-name> <param-value>/WEB-INF/config/struts-config.xml</param-value> </init-param> <init-param> <param-name>debug</param-name> <param-value>2</param-value> </init-param> <init-param> <param-name>detail</param-name> <param-value>2</param-value> </init-param> <load-on-startup>2</load-on-startup> </servlet> <!-- Tiles-2 Dispatch Servlet (mapped to *.tiles) --> <servlet> <servlet-name>Tiles Dispatch Servlet</servlet-name> <servlet-class> org.apache.tiles.web.util.TilesDispatchServlet </servlet-class> <load-on-startup>3</load-on-startup> </servlet> <!-- Struts-1 Action Servlet Mapping --> <servlet-mapping> <servlet-name>action</servlet-name> <url-pattern>*.do</url-pattern> </servlet-mapping> <!-- Tiles-2 Dispatch Servlet mapping (currently must be *.tiles) --> <servlet-mapping> <servlet-name>Tiles Dispatch Servlet</servlet-name> <url-pattern>*.tiles</url-pattern> </servlet-mapping> <!-- The Welcome File List (forwards to Struts-2 'Welcome.action' --> <welcome-file-list> <welcome-file>html/index.html</welcome-file> </welcome-file-list> <session-config> <session-timeout>30</session-timeout> </session-config> <jsp-config> <jsp-property-group> <description>defines *.jspx as a JSP file</description> <url-pattern>*.jspx</url-pattern> <is-xml>true</is-xml> </jsp-property-group> </jsp-config> </web-app> Here is the Struts-2 deployment file, ‘struts.xml” <!DOCTYPE struts PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 2.0//EN" "http://struts.apache.org/dtds/struts-2.0.dtd";> <struts> <!-- Struts-2 default config file. --> <package name="greetings" namespace="/greetings" extends="struts-default"> <action name="Welcome" > <result name="success" >/WELCOME.tiles</result> </action> <action name="Threat" class="greetings.struts2.action.Threaten" > <result name="success" > /THREATEN.tiles </result> </action> <action name="WeatherOnMars" > <result name="success" > /WEATHER.tiles </result> </action> <action name="NewsletterRegistration_*" method="{1}" class="greetings.struts2.action.NewsletterRegistrationAction" > <!-- returned by the 'input()' method --> <result name="input" > /NEWSLETTER.tiles </result> <result name="success" > /THANKS.tiles </result> </action> <action name="ViewMartian" > <result > /HIGH_COMMANDER.tiles </result> </action> <action name="AjaxDynDoubleSelect_*" method="{1}" class="greetings.struts2.action.AjaxDDS_DemoAction" > <result name="success" > /AJAX_DEMO.tiles </result> </action> <action name="S1ActionWrapper" class="greetings.struts2.action.S1ActionWrapper" > <result name="success" > /POPUP_DEMO.tiles </result> </action> <action name="Popup" > <result name="success" > /jsp/HedgeHog.jspx </result> </action> </package> </struts> Here is the Tiles definition file, defined above to be “tiles.xml”. Note the Tiles-2 DTD. Also note that the tags are somewhat different from Tiles-1: <?xml version="1.0" encoding="ISO-8859-1" ?> <!DOCTYPE tiles-definitions PUBLIC "-//Apache Software Foundation//DTD Tiles Configuration 2.0//EN" "http://tiles.apache.org/dtds/tiles-config_2_0.dtd";> <!-- Tiles definitions for the Struts-2 package. --> <tiles-definitions > <!-- Define a Template which all the screens will use. This method takes the jsp "template" and fills in the values which are common to all the pages. Note the use of the syntax "${xxx}" for the tags which will be filled in by the individual screens. --> <definition name="BaseScreenTemplate" template="/jsp/Template.jspx" > <put-attribute name="title" value="${title}" /> <put-attribute name="meta" value="/jsp/metaTags.jspx" /> <put-attribute name="ajax" value="" type="string" /> <put-attribute name="banner" value="/jsp/Banner.jspx" /> <put-attribute name="menu" value="/jsp/Menu.jspx" /> <put-attribute name="contents" value="${contents}" /> <put-attribute name="footer" value="/jsp/Footer.jspx" /> </definition> <definition name="AjaxScreenTemplate" extends="BaseScreenTemplate"> <put-attribute name="ajax" value="/jsp/AjaxHeader.jspx" /> </definition> <!-- ======================================================== --> <!-- SCREENS --> <!-- ======================================================== --> <definition name="WELCOME" extends="BaseScreenTemplate" > <put-attribute name="title" value="Greetings Earthling" type="string" /> <put-attribute name="contents" value="/jsp/Hippo.jspx" /> </definition> <definition name="NEWSLETTER" extends="BaseScreenTemplate" > <put-attribute name="title" value="Register Now, Earthling!" type="string" /> <put-attribute name="contents" value="/jsp/NewsletterRegistrationForm.jspx" /> </definition> <definition name="THANKS" extends="BaseScreenTemplate" > <put-attribute name="title" value="Thank You For Your Data, Earthling" type="string" /> <put-attribute name="contents" value="/jsp/ThanksForRegistering.jspx" /> </definition> <definition name="WEATHER" extends="BaseScreenTemplate" > <put-attribute name="title" value="Todays Weather on Mars" type="string" /> <put-attribute name="contents" value="/jsp/WeatherOnMars.jspx" /> </definition> <definition name="THREATEN" extends="BaseScreenTemplate" > <put-attribute name="title" value="Beware Earthlings" type="string" /> <put-attribute name="contents" value="/jsp/Threaten.jspx" /> </definition> <definition name="HIGH_COMMANDER" extends="BaseScreenTemplate" > <put-attribute name="title" value="Commander" type="string" /> <put-attribute name="contents" value="/jsp/Commander.jspx" /> </definition> <definition name="AJAX_DEMO" extends="AjaxScreenTemplate" > <put-attribute name="title" value="Demo Ajax Dynamic Double Select" type="string" /> <put-attribute name="contents" value="/jsp/AjaxDemo.jspx" /> </definition> <definition name="POPUP_DEMO" extends="AjaxScreenTemplate" > <put-attribute name="title" value="Demo Popup Using Ajax and S-1 Action" type="string" /> <put-attribute name="contents" value="/jsp/S2_Wrapper.jspx" /> </definition> <!-- Note that the S1 action result is "/BOOK_TRIO_TO_EARTH.tiles", but that the '.tiles' is not used here. --> <definition name="BOOK_TRIP_TO_EARTH" extends="BaseScreenTemplate"> <put-attribute name="title" value="Struts-1 with Tiles-2" type="string"/> <put-attribute name="contents" value="/jsp/BookEarthCruise.jspx" /> </definition> </tiles-definitions> And here is the “template” jspx file. Note that this is in “JSP Document” file and is an xhtml document, and so is named “.jspx”, not “jsp”. Also note the tiles taglib uri, which is different from Tiles-1 <?xml version="1.0" encoding="UTF-8"?> <jsp:root version="2.0" xmlns:jsp="http://java.sun.com/JSP/Page"; xmlns:c="http://java.sun.com/jsp/jstl/core"; xmlns="http://www.w3.org/1999/xhtml"; xmlns:s="/struts-tags" xmlns:tiles="http://tiles.apache.org/tags-tiles"; > <jsp:output omit-xml-declaration="true" doctype-root-element="html" doctype-system="http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"; doctype-public="-//W3C//DTD XHTML 1.0 Transitional//EN" /> <jsp:scriptlet> String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() + request.getContextPath(); pageContext.setAttribute("BasePath",basePath); </jsp:scriptlet> <jsp:directive.page contentType="text/html" /> <html> <head> <!-- title section --> <title><tiles:insertAttribute name="title" /></title> <!-- meta-data section --> <tiles:insertAttribute name="meta" /> <!-- if using Ajax (dojo), need a Struts-2 tag --> <tiles:insertAttribute name="ajax" /> <link rel="stylesheet" type="text/css" href="${BasePath}/css/greetings_earth.css" /> </head> <body > <table id="template_body" > <tr > <td colspan="2" class="masthead" > <div style="text-align:center;" > <tiles:insertAttribute name="banner" /> </div> </td> </tr> <tr > <td> <!-- empty cell improves linearization/accessability --> </td> <td rowspan="2" class="main" > <tiles:insertAttribute name="contents" /> </td> </tr> <tr> <td class="sidebar" > <tiles:insertAttribute name="menu" /> </td> <td></td> </tr> <tr> <td colspan="2" class="footer" > <tiles:insertAttribute name="footer" /> </td> </tr> </table> </body> </html> </jsp:root> -- View this message in context: http://www.nabble.com/Struts1-Tiles-and-Struts2-tiles-in-same-app-tf4329675.html#a12333794 Sent from the Struts - User mailing list archive at Nabble.com. --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]