Problem in configuration project using struts + tiles + maven
Asked Answered
B

2

1

Here is my config in web.xml

<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.FilterDispatcher</filter-class>
    </filter>

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

    <welcome-file-list>
        <welcome-file>index.jsp</welcome-file>
    </welcome-file-list>

in struts.xml

<package name="default" extends="struts-default, tiles-default">
    <action name="home" class="controller.HomeController">
        <result name="success" type="tiles">home</result>
    </action>
</package>

in tiles.xml

<definition name="home" template="/layout.jsp">
    <put-attribute name="body" value="/WEB-INF/pages/home.jsp"/>
</definition>

in pom.xml

<dependency>
        <groupId>org.apache.struts</groupId>
        <artifactId>struts2-core</artifactId>
        <version>2.2.1</version>
        <type>pom</type>
        <scope>compile</scope>
    </dependency>
    <dependency>
        <groupId>org.apache.struts.xwork</groupId>
        <artifactId>xwork-core</artifactId>
        <version>2.2.1</version>
        <type>pom</type>
        <scope>compile</scope>
    </dependency>
    <dependency>
        <groupId>org.apache.tiles</groupId>
        <artifactId>tiles-core</artifactId>
        <version>2.2.2</version>
        <type>pom</type>
        <scope>compile</scope>
    </dependency>
    <dependency>
        <groupId>org.apache.tiles</groupId>
        <artifactId>tiles-jsp</artifactId>
        <version>2.2.2</version>
        <type>pom</type>
        <scope>compile</scope>
    </dependency>
    <dependency>
        <groupId>org.apache.struts</groupId>
        <artifactId>struts2-spring-plugin</artifactId>
        <version>2.2.1</version>
        <type>pom</type>
        <scope>compile</scope>
    </dependency>
    <dependency>
        <groupId>org.apache.tiles</groupId>
        <artifactId>tiles-extras</artifactId>
        <version>2.2.2</version>
        <type>pom</type>
        <scope>compile</scope>
    </dependency>

Here is the complete stack trace:

SEVERE: Error configuring application listener of class org.apache.struts2.tiles.StrutsTilesListener
java.lang.ClassNotFoundException: org.apache.struts2.tiles.StrutsTilesListener
    at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1676)
    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:4537)
    at org.apache.catalina.core.StandardContext$1.call(StandardContext.java:5097)
    at org.apache.catalina.core.StandardContext$1.call(StandardContext.java:5092)
    at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)
    at java.util.concurrent.FutureTask.run(FutureTask.java:138)
    at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
    at java.lang.Thread.run(Thread.java:662)
Baklava answered 16/5, 2011 at 4:7 Comment(0)
M
1

Missing struts2-tiles-plugin-2.2.x.jar in classpath, with dependency:

<dependency>
  <groupId>org.apache.struts</groupId>
  <artifactId>struts2-tiles-plugin</artifactId>
  <version>${version.tiles}</version>
  <scope>compile</scope>
</dependency>

You can solved ClassNotFoundException with findJAR
http://www.findjar.com/index.x?query=org.apache.struts2.tiles.StrutsTilesListener

Mobster answered 16/5, 2011 at 4:40 Comment(7)
Still ClassNotFoundException for StrutsTilesListener ? Add maven dependency of struts2-tiles-plugin?Mobster
I got the same error for the version 2.1.8, when I change to version 2.2.1 it threw this error NoClassDefFoundError: org/slf4j/LoggerFactory I added all the available dependencies found when I searched in eclipse but I still got this error :(Baklava
@Hatake Did your application use Spring? slf4j-api-1.6.1.jar needed for Spring, add slf4j maven dependency/Spring Dependency or download it.Mobster
I plan to use spring, but I'm trying to fix this first, I added all the dependencies for slf4j but I still got NoClassDefFoundError: org/slf4j/LoggerFactory. It's really annoying :((Baklava
Make sure all needed jar files are deployed to server & no duplicate of same library with different version.Mobster
Still no help :(. Btw, +1 for each of your help, thanks anyway :)Baklava
Although I still can't fix it, but this one helped me a lot ;) ^^Baklava
B
0

I guess you are missing the struts2-tiles-plugin

Brigid answered 16/5, 2011 at 4:40 Comment(2)
@Hatake. Why is the <type> set to pom? Can you try removing it? If the dependency is not required for compile, but only runtime, set <scope> to runtime.Brigid
I'm not sure about the type, I added depenencies using eclipse tool, I tried removing those type values and changed to runtime as you told me but nothing changed, I got the same error for the tiles plugin version 2.1.8, when I change to version 2.2.1 it threw this error NoClassDefFoundError: org/slf4j/LoggerFactory. I added all the available dependencies found when I searched in eclipse but I still got this errorBaklava

© 2022 - 2024 — McMap. All rights reserved.