0
votes

i cant find what is wrong with my application. Using struts 2 and tiles. web.xml:

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://java.sun.com/xml/ns/javaee" 
xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee 
http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
id="WebApp_ID" version="2.5">
<display-name>strutsForScoodle</display-name>

<context-param>
<param-name>
  org.apache.tiles.impl.BasicTilesContainer.DEFINITIONS_CONFIG
</param-name>
<param-value>
  /WEB-INF/tiles.xml
</param-value>
</context-param>

<listener>
<listener-class>
  org.apache.struts2.tiles.StrutsTilesListener
</listener-class>
</listener>

<filter>
<filter-name>struts2</filter-name>
<filter-class>
org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter
</filter-class>
</filter>

<filter-mapping>
  <filter-name>struts2</filter-name>
  <url-pattern>/*</url-pattern>
</filter-mapping>

<welcome-file-list>
  <welcome-file>login.jsp</welcome-file>
</welcome-file-list>
</web-app>

Tiles.xml:

<?xml version="1.0" encoding="UTF-8"?>

<!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>
<definition name="baseLayout" template="/WEB-INF/content/tiles/BaseLayout.jsp">
<put-attribute name="title" value="" />
<put-attribute name="header" value="/WEB-INF/content/tiles/Header.jsp" />
<put-attribute name="body" value="" />
<put-attribute name="footer" value="/WEB-INF/content/tiles/Footer.jsp" />
</definition>
<definition name="logoff.tiles" extends="baseLayout">
<put-attribute name="title" value="Logoff" />
<put-attribute name="body" value="/WEB-INF/content/tiles/logoff.jsp" />
</definition>
<definition name="createSurvey.tiles" extends="baseLayout">
<put-attribute name="title" value="create Survey" />
<put-attribute name="body" value="/WEB-INF/content/tiles/createSurvey.jsp" />
</definition>
</tiles-definitions>

struts.xml:

<?xml version="1.0" encoding="UTF-8"?>

<!DOCTYPE struts PUBLIC
    "-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"
    "http://struts.apache.org/dtds/struts-2.0.dtd">

<struts>

<package name="default" extends="struts-default">
  <result-types>
     <result-type name="tiles" 
     class="org.apache.struts2.views.tiles.TilesResult" />
  </result-types>

  <action name="*Navigate" method="{1}" 
     class="de.umfragetool.action.NavigateAction">
     <result name="overview" type="tiles">overview</result>
     <result name="logoff" type="tiles">logoff</result>
     <result name="createSurvey" type="tiles">createSurvey</result>
  </action>

  </package>
 </struts>

and the pom.xml from maven looks like this:

<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/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>Struts4Scoodle</groupId>
<artifactId>Struts4Scoodle</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>war</packaging>
<name>Scoodle</name>
<description>Scoodle Tool</description>
<build>
<sourceDirectory>src</sourceDirectory>
<plugins>
  <plugin>
    <artifactId>maven-compiler-plugin</artifactId>
    <version>3.1</version>
    <configuration>
      <source>1.7</source>
      <target>1.7</target>
    </configuration>
  </plugin>
  <plugin>
    <artifactId>maven-war-plugin</artifactId>
    <version>2.3</version>
    <configuration>
      <warSourceDirectory>WebContent</warSourceDirectory>
      <failOnMissingWebXml>false</failOnMissingWebXml>
    </configuration>
  </plugin>
 </plugins>
  </build>
 <dependencies>
    <dependency>
        <groupId>junit</groupId>
        <artifactId>junit</artifactId>
        <version>3.8.1</version>
        <scope>test</scope>
    </dependency>
                    <!--        struts -->
<dependency>
<groupId>org.apache.struts</groupId>
<artifactId>struts2-core</artifactId>
<version>2.3.15.2</version>
</dependency>

<dependency>
<groupId>org.apache.struts</groupId>
<artifactId>struts2-convention-plugin</artifactId>
<version>2.3.15.2</version>
</dependency>
<!--                            tiles -->
<dependency>
<groupId>org.apache.struts</groupId>
<artifactId>struts2-tiles-plugin</artifactId>
<version>2.3.15.2</version>
<scope>compile</scope>
</dependency>

<dependency>
<groupId>org.apache.tiles</groupId>
<artifactId>tiles-core</artifactId>
<version>3.0.1</version>
</dependency>

<dependency>
<groupId>org.apache.tiles</groupId>
<artifactId>tiles-servlet</artifactId>
<version>3.0.1</version>
</dependency>

<dependency>
<groupId>org.apache.tiles</groupId>
<artifactId>tiles-compat</artifactId>
<version>3.0.1</version>
</dependency>

</dependencies>
</project>

with all of this i am getting this failure:

`Okt 17, 2013 8:34:41 PM org.apache.catalina.core.AprLifecycleListener init Information: The APR based Apache Tomcat Native library which allows optimal performance in production environments was not found on the java.library.path: C:\Program Files\Java\jre7\bin;C:\Windows\Sun\Java\bin;C:\Windows\system32;C:\Windows;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Program Files (x86)\MiKTeX 2.9\miktex\bin\;C:\Program Files\Java\jdk1.7.0_40;C:\apache-maven-3.1.1-bin\apache-maven-3.1.1\bin;. Okt 17, 2013 8:34:41 PM org.apache.tomcat.util.digester.SetPropertiesRule begin Warnung: [SetPropertiesRule]{Server/Service/Engine/Host/Context} Setting property 'source' to 'org.eclipse.jst.jee.server:Struts4Scoodle' did not find a matching property. Okt 17, 2013 8:34:41 PM org.apache.coyote.AbstractProtocolHandler init Information: Initializing ProtocolHandler ["http-bio-8080"] Okt 17, 2013 8:34:41 PM org.apache.coyote.AbstractProtocolHandler init Information: Initializing ProtocolHandler ["ajp-bio-8009"] Okt 17, 2013 8:34:41 PM org.apache.catalina.startup.Catalina load Information: Initialization processed in 561 ms Okt 17, 2013 8:34:41 PM org.apache.catalina.core.StandardService startInternal Information: Starting service Catalina Okt 17, 2013 8:34:41 PM org.apache.catalina.core.StandardEngine startInternal Information: Starting Servlet Engine: Apache Tomcat/7.0.12 Okt 17, 2013 8:34:42 PM org.apache.catalina.core.StandardContext listenerStart Schwerwiegend: Error configuring application listener of class org.apache.struts2.tiles.StrutsTilesListener java.lang.NoClassDefFoundError: org/apache/tiles/web/startup/TilesListener at java.lang.ClassLoader.defineClass1(Native Method) at java.lang.ClassLoader.defineClass(Unknown Source) at java.security.SecureClassLoader.defineClass(Unknown Source) at org.apache.catalina.loader.WebappClassLoader.findClassInternal(WebappClassLoader.java:2818) at org.apache.catalina.loader.WebappClassLoader.findClass(WebappClassLoader.java:1148) at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1643) at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1521) at org.apache.catalina.core.DefaultInstanceManager.loadClass(DefaultInstanceManager.java:415) at org.apache.catalina.core.DefaultInstanceManager.loadClassMaybePrivileged(DefaultInstanceManager.java:397) at org.apache.catalina.core.DefaultInstanceManager.newInstance(DefaultInstanceManager.java:118) at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4638) at org.apache.catalina.core.StandardContext$1.call(StandardContext.java:5204) at org.apache.catalina.core.StandardContext$1.call(StandardContext.java:5199) at java.util.concurrent.FutureTask.run(Unknown Source) at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source) at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source) at java.lang.Thread.run(Unknown Source) Caused by: java.lang.ClassNotFoundException: org.apache.tiles.web.startup.TilesListener at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1676) at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1521) ... 17 more

Okt 17, 2013 8:34:42 PM org.apache.catalina.core.StandardContext listenerStart Schwerwiegend: Skipped installing application listeners due to previous error(s) Okt 17, 2013 8:34:42 PM org.apache.catalina.core.StandardContext startInternal Schwerwiegend: Error listenerStart Okt 17, 2013 8:34:42 PM org.apache.catalina.core.StandardContext startInternal Schwerwiegend: Context [/Struts4Scoodle] startup failed due to previous errors Okt 17, 2013 8:34:42 PM org.apache.coyote.AbstractProtocolHandler start Information: Starting ProtocolHandler ["http-bio-8080"] Okt 17, 2013 8:34:42 PM org.apache.coyote.AbstractProtocolHandler start Information: Starting ProtocolHandler ["ajp-bio-8009"] Okt 17, 2013 8:34:42 PM org.apache.catalina.startup.Catalina start Information: Server startup in 739 ms`

this is the first time i will use Tiles and i dont get it. Thank you very much.

2
If you want to use Tiles version 3.x you need to use struts2-tiles3-plugin.Aleksandr M
this is the first time i will use Tiles and i dont get it. - Does it worked fine without tiles ?coding_idiot
yes work fine without itRolando Colossus

2 Answers

0
votes
<dependency>
<groupId>org.apache.tiles</groupId>
<artifactId>tiles-core</artifactId>
<version>3.0.1</version>
</dependency>

<dependency>
<groupId>org.apache.tiles</groupId>
<artifactId>tiles-servlet</artifactId>
<version>3.0.1</version>
</dependency>

Remove these above dependencies. The struts2-tiles-plugin, will transitively add the tiles dependencies automatically and those are having version 2.* not 3.*

0
votes

import to library jsp-api-2.1 as struts2-tiles-plugin has a depencency on it