Is your web.xml file referring to some struts artifact or Struts-Tiles
plugin? I use standalone Tiles and MyFaces without problems (app also
uses Struts, Tomahawk, Trinidad). Does your app otherwise use Struts,
and if so which version? If you use struts, but not the Struts2-Tiles
plugin, you can should the plugin jar.
- Ray Clough
zargarf wrote:
Hi, I'm trying to use myFaces and Standalone Tiles together using maven2.
However, when I try to deploy the war file to Tomcat, I get a
java.lang.NoClassDefFoundError:
org.apache.struts.tiles.DefinitionsFactoryException (which surprises me as
I'm using the jars for the standalone version of tiles). Do any of you know
why it's looking for org.apache.struts.tiles.DefinitionsFactoryException
instead of org.apache.tiles.DefinitionsFactoryException?
Cheers
Faisal
This is the stacktrace:
24-Oct-2007 10:40:08 org.apache.catalina.core.StandardContext listenerStart
SEVERE: Exception sending context initialized event to listener instance of
class org.apache.myfaces.webapp.StartupServletContextListener
java.lang.NoClassDefFoundError:
org.apache.struts.tiles.DefinitionsFactoryException
at java.lang.J9VMInternals.verifyImpl(Native Method)
at java.lang.J9VMInternals.verify(J9VMInternals.java:59)
at java.lang.J9VMInternals.initialize(J9VMInternals.java:120)
at sun.reflect.NativeConstructorAccess
orImpl.newInstance0(Native Method)
at
sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:67)
at
sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:521)
at
org.apache.myfaces.config.FacesConfigurator.getApplicationObject(FacesConfigurator.java:779)
at
org.apache.myfaces.config.FacesConfigurator.configureApplication(FacesConfigurator.java:699)
at
org.apache.myfaces.config.FacesConfigurator.configure(FacesConfigurator.java:230)
at
org.apache.myfaces.webapp.StartupServletContextListener.initFaces(StartupServletContextListener.java:68)
at
org.apache.myfaces.webapp.StartupServletContextListener.contextInitialized(StartupServletContextListener.java:51)
at
org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:3764)
at
org.apache.catalina.core.StandardContext.start(StandardContext.java:4216)
at
org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:760)
at
org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:740)
at
org.apache.catalina.core.StandardHost.addChild(StandardHost.java:544)
at
org.apache.catalina.startup.HostConfig.deployWAR(HostConfig.java:825)
at
org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:515)
at
org.apache.catalina.startup.HostConfig.check(HostConfig.java:1220)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:64)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:615)
at
org.apache.commons.modeler.BaseModelMBean.invoke(BaseModelMBean.java:458)
at
com.sun.jmx.mbeanserver.DynamicMetaDataImpl.invoke(DynamicMetaDataImpl.java:231)
at
com.sun.jmx.mbeanserver.MetaDataImpl.invoke(MetaDataImpl.java:238)
at
com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.invoke(DefaultMBeanServerInterceptor.java:833)
at
com.sun.jmx.mbeanserver.JmxMBeanServer.invoke(JmxMBeanServer.java:802)
at
org.apache.catalina.manager.ManagerServlet.check(ManagerServlet.java:1394)
at
org.apache.catalina.manager.ManagerServlet.deploy(ManagerServlet.java:635)
at
org.apache.catalina.manager.ManagerServlet.doPut(ManagerServlet.java:424)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:713)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
at
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:269)
at
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:188)
at
org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
at
org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:174)
at
org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:525)
at
org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
at
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:117)
at
org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:108)
at
org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:151)
at
org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:874)
at
org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:665)
at
org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:528)
at
org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:81)
at
org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:689)
at java.lang.Thread.run(Thread.java:799)
Below, you can find the .pom file, the web.xml and the faces-config.
Here is my application.pom file for maven<?xml version="1.0"
encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.zargonsolutions</groupId>
<artifactId>zargonsolutions_myfaces_webapp</artifactId>
<packaging>war</packaging>
<version>1.0-SNAPSHOT</version>
<name>A custom project using myfaces</name>
<url>http://www.myorganization.org</url>
<build>
<finalName>zargonsolutions_myfaces_webapp</finalName>
</build>
<!-- Profile to run jetty, so the tomcat jars are included in the
bundle. They are not included by default -->
<profiles>
<profile>
<id>jettyConfig</id>
<build>
<plugins>
<plugin>
<groupId>org.mortbay.jetty</groupId>
<artifactId>maven-jetty-plugin</artifactId>
<configuration>
<scanIntervalSeconds>10</scanIntervalSeconds>
</configuration>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>jsp-api</artifactId>
<version>2.0</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>tomcat</groupId>
<artifactId>jasper-compiler</artifactId>
<version>5.5.9</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>tomcat</groupId>
<artifactId>jasper-runtime</artifactId>
<version>5.5.9</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>tomcat</groupId>
<artifactId>jasper-compiler-jdt</artifactId>
<version>5.5.9</version>
<scope>compile</scope>
</dependency>
</dependencies>
<pluginRepositories>
<!-- Repository to get the jetty plugin -->
<pluginRepository>
<id>mortbay-repo</id>
<name>mortbay-repo</name>
<url>http://www.mortbay.org/maven2/snapshot</url>
</pluginRepository>
</pluginRepositories>
</profile>
</profiles>
<repositories>
<repository>
<releases>
<enabled>false</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
</snapshots>
<id>apache-maven-snapshots</id>
<url>http://people.apache.org/repo/m2-snapshot-repository</url>
</repository>
</repositories>
<!-- Project dependencies -->
<dependencies>
<dependency>
<groupId>org.apache.myfaces.core</groupId>
<artifactId>myfaces-api</artifactId>
<version>1.1.6-SNAPSHOT</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.apache.myfaces.core</groupId>
<artifactId>myfaces-impl</artifactId>
<version>1.1.6-SNAPSHOT</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>myfaces</groupId>
<artifactId>tomahawk</artifactId>
<version>1.1.1</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.0</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.tiles</groupId>
<artifactId>tiles-core</artifactId>
<version>2.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.apache.tiles</groupId>
<artifactId>tiles-jsp</artifactId>
<version>2.0.4</version>
</dependency>
<dependency>
<groupId>org.apache.tiles</groupId>
<artifactId>tiles-api</artifactId>
<version>2.0.4</version>
</dependency>
</dependencies>
</project>
Here is the web.xml
<web-app 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"
version="2.4">
<description>MyProject web.xml</description>
<context-param>
<description>Comma separated list of URIs of (additional) faces
config files.
(e.g. /WEB-INF/my-config.xml)
See JSF 1.0 PRD2, 10.3.2
Attention: You do not need to put /WEB-INF/faces-config.xml in
here.
</description>
<param-name>javax.faces.CONFIG_FILES</param-name>
<param-value>/WEB-INF/faces-config.xml</param-value>
</context-param>
<context-param>
<description>State saving method: "client" or "server" (= default)
See JSF Specification 2.5.3</description>
<param-name>javax.faces.STATE_SAVING_METHOD</param-name>
<param-value>client</param-value>
</context-param>
<context-param>
<description>Only applicable if state saving method is "server" (=
default).
Defines the amount (default = 20) of the latest views are stored
in session.</description>
<param-name>org.apache.myfaces.NUMBER_OF_VIEWS_IN_SESSION</param-name>
<param-value>20</param-value>
</context-param>
<context-param>
<description>Only applicable if state saving method is "server" (=
default).
If true (default) the state will be serialized to a byte stream
before it
is written to the session.
If false the state will not be serialized to a byte
stream.</description>
<param-name>org.apache.myfaces.SERIALIZE_STATE_IN_SESSION</param-name>
<param-value>true</param-value>
</context-param>
<context-param>
<description>Only applicable if state saving method is "server" (=
default) and if
org.apache.myfaces.SERIALIZE_STATE_IN_SESSION is true (=
default)
If true (default) the serialized state will be compressed before
it
is written to the session. If false the state will not be
compressed.</description>
<param-name>org.apache.myfaces.COMPRESS_STATE_IN_SESSION</param-name>
<param-value>true</param-value>
</context-param>
<context-param>
<description>This parameter tells MyFaces if javascript code should
be allowed in the
rendered HTML output.
If javascript is allowed, command_link anchors will have
javascript code
that submits the corresponding form.
If javascript is not allowed, the state saving info and nested
parameters
will be added as url parameters.
Default: "true"</description>
<param-name>org.apache.myfaces.ALLOW_JAVASCRIPT</param-name>
<param-value>true</param-value>
</context-param>
<context-param>
<param-name>org.apache.myfaces.DETECT_JAVASCRIPT</param-name>
<param-value>false</param-value>
</context-param>
<context-param>
<description>If true, rendered HTML code will be formatted, so that
it is "human readable".
i.e. additional line separators and whitespace will be written,
that do not
influence the HTML code.
Default: "true"</description>
<param-name>org.apache.myfaces.PRETTY_HTML</param-name>
<param-value>true</param-value>
</context-param>
<context-param>
<description>If true, a javascript function will be rendered that is
able to restore the
former vertical scroll on every request. Convenient feature if
you have pages
with long lists and you do not want the browser page to always
jump to the top
if you trigger a link or button action that stays on the same
page.
Default: "false"</description>
<param-name>org.apache.myfaces.AUTO_SCROLL</param-name>
<param-value>true</param-value>
</context-param>
<context-param>
<description>Used for encrypting view state. Only relevant for
client side
state saving. See MyFaces wiki/web site documentation for
instructions
on how to configure an application for diffenent encryption
strengths.
</description>
<param-name>org.apache.myfaces.SECRET</param-name>
<param-value>NzY1NDMyMTA=</param-value>
</context-param>
<context-param>
<description>
Validate managed beans, navigation rules and ensure that forms
are not nested.
</description>
<param-name>org.apache.myfaces.VALIDATE</param-name>
<param-value>true</param-value>
</context-param>
<context-param>
<description>
Treat readonly same as if disabled attribute was set for select
elements.
</description>
<param-name>org.apache.myfaces.READONLY_AS_DISABLED_FOR_SELECTS</param-name>
<param-value>true</param-value>
</context-param>
<context-param>
<description>
Use the defined class as the class which will be called when a
resource is added to the
ExtensionFilter handling. Using StreamingAddResource here helps
with performance. If you want to add
custom components and want to use the ExtensionFilter, you need
to provide your custom implementation here.
</description>
<param-name>org.apache.myfaces.ADD_RESOURCE_CLASS</param-name>
<param-value>org.apache.myfaces.renderkit.html.util.DefaultAddResource</param-value>
</context-param>
<context-param>
<description>
Virtual path in the URL which triggers loading of resources for
the MyFaces extended components
in the ExtensionFilter.
</description>
<param-name>org.apache.myfaces.RESOURCE_VIRTUAL_PATH</param-name>
<param-value>/faces/myFacesExtensionResource</param-value>
</context-param>
<context-param>
<description>
Check if the extensions-filter has been properly configured.
</description>
<param-name>org.apache.myfaces.CHECK_EXTENSIONS_FILTER</param-name>
<param-value>true</param-value>
</context-param>
<context-param>
<description>
Define partial state saving as true/false.
</description>
<param-name>javax.faces.PARTIAL_STATE_SAVING_METHOD</param-name>
<param-value>false</param-value>
</context-param>
<!-- Extensions Filter -->
<filter>
<filter-name>extensionsFilter</filter-name>
<filter-class>org.apache.myfaces.webapp.filter.ExtensionsFilter</filter-class>
<init-param>
<description>Set the size limit for uploaded files.
Format: 10 - 10 bytes
10k - 10 KB
10m - 10 MB
1g - 1 GB</description>
<param-name>uploadMaxFileSize</param-name>
<param-value>100m</param-value>
</init-param>
<init-param>
<description>Set the threshold size - files
below this limit are stored in memory, files above
this limit are stored on disk.
Format: 10 - 10 bytes
10k - 10 KB
10m - 10 MB
1g - 1 GB</description>
<param-name>uploadThresholdSize</param-name>
<param-value>100k</param-value>
</init-param>
</filter>
<filter-mapping>
<filter-name>extensionsFilter</filter-name>
<url-pattern>*.jsf</url-pattern>
</filter-mapping>
<filter-mapping>
<filter-name>extensionsFilter</filter-name>
<url-pattern>/faces/*</url-pattern>
</filter-mapping>
<!-- Listener, to allow Jetty serving MyFaces apps -->
<listener>
<listener-class>org.apache.myfaces.webapp.StartupServletContextListener</listener-class>
</listener>
<!-- Faces Servlet -->
<servlet>
<servlet-name>Faces Servlet</servlet-name>
<servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet>
<servlet-name>tiles</servlet-name>
<servlet-class>org.apache.tiles.servlet.TilesServlet</servlet-class>
<init-param>
<param-name>org.apache.tiles.impl.BasicTilesContainer.DEFINITIONS_CONFIG</param-name>
<param-value>/WEB-INF/tiles-def.xml</param-value>
</init-param>
<load-on-startup>2</load-on-startup>
</servlet>
<!-- Faces Servlet Mapping -->
<servlet-mapping>
<servlet-name>Faces Servlet</servlet-name>
<url-pattern>*.jsf</url-pattern>
</servlet-mapping>
<!-- Welcome files -->
<welcome-file-list>
<welcome-file>index.jsp</welcome-file>
<welcome-file>index.html</welcome-file>
</welcome-file-list>
</web-app>
Here is the faces-config
<faces-config>
<application>
<view-handler>org.apache.myfaces.application.jsp.JspTilesViewHandlerImpl</view-handler>
</application>
<!-- managed beans of the simple hello world app -->
<managed-bean>
<managed-bean-name>helloWorldBacking</managed-bean-name>
<managed-bean-class>org.apache.myfaces.blank.HelloWorldBacking</managed-bean-class>
<managed-bean-scope>request</managed-bean-scope>
</managed-bean>
<!-- navigation rules for helloWorld.jsp -->
<navigation-rule>
<from-view-id>/helloWorld.jsp</from-view-id>
<navigation-case>
<from-outcome>success</from-outcome>
<to-view-id>/page2.jsp</to-view-id>
</navigation-case>
</navigation-rule>
<!-- navigation rules for page2.jsp -->
<navigation-rule>
<from-view-id>/page2.jsp</from-view-id>
<navigation-case>
<from-outcome>back</from-outcome>
<to-view-id>/helloWorld.jsp</to-view-id>
</navigation-case>
</navigation-rule>
</faces-config>
Here is the tiles-def
<!DOCTYPE tiles-definitions PUBLIC
"-//Apache Software Foundation//DTD Tiles Configuration 2.0//EN"
"http://tiles.apache.org/dtds/tiles-config_2_0.dtd">
<definition name="zargonsolutions.layout"
template="/pages/template.jsp">
<put-attribute name="header" value="/pages/includes/header.jsp" />
<put-attribute name="footer" value="/pages/includes/footer.jsp" />
<put-attribute name="title" value="Welcome to Zargon Solutions" />
</definition>
<definition name="/pages/home.tiles" extends="zargonsolutions.layout">
<put name="body" value="/pages/home.jsp" />
<put name="title" value="Zargon Solutions - Home Page" />
</definition>