1

I was trying to use Struts 2 & Tiles 3 according to this link. However as soon as I add the listener-class on my web.xml:

<listener>
    <listener-class>org.apache.tiles.extras.complete.CompleteAutoloadTilesListener</listener-class>
</listener>

I had the following error while uploading on my glassfish server:

Error occurred during deployment: Exception while loading the app : java.lang.IllegalStateException: ContainerBase.addChild: start: org.apache.catalina.LifecycleException: java.lang.NoClassDefFoundError: org/springframewor /core/io/support/ResourcePatternResolver. Please see server.log for more details.

The error message was:

[#|2012-12-23T18:36:10.982+0800|SEVERE|glassfish3.1.2|javax.enterprise.system.tools.admin.org.glassfish.deployment.admin|_ThreadID=22;_ThreadName=Thread-4;|Exception while invoking class com.sun.enterprise.web.WebApplication start method java.lang.Exception: java.lang.IllegalStateException: ContainerBase.addChild: start: org.apache.catalina.LifecycleException: java.lang.NoClassDefFoundError: org/springframework/core/io/support/ResourcePatternResolver at com.sun.enterprise.web.WebApplication.start(WebApplication.java:138) at org.glassfish.internal.data.EngineRef.start(EngineRef.java:130) at org.glassfish.internal.data.ModuleInfo.start(ModuleInfo.java:269) at org.glassfish.internal.data.ApplicationInfo.start(ApplicationInfo.java:301) at com.sun.enterprise.v3.server.ApplicationLifecycle.deploy(ApplicationLifecycle.java:461) at com.sun.enterprise.v3.server.ApplicationLifecycle.deploy(ApplicationLifecycle.java:240) at org.glassfish.deployment.admin.DeployCommand.execute(DeployCommand.java:389) at com.sun.enterprise.v3.admin.CommandRunnerImpl$1.execute(CommandRunnerImpl.java:348) at com.sun.enterprise.v3.admin.CommandRunnerImpl.doCommand(CommandRunnerImpl.java:363) at com.sun.enterprise.v3.admin.CommandRunnerImpl.doCommand(CommandRunnerImpl.java:1085) at com.sun.enterprise.v3.admin.CommandRunnerImpl.access$1200(CommandRunnerImpl.java:95) at com.sun.enterprise.v3.admin.CommandRunnerImpl$ExecutionContext.execute(CommandRunnerImpl.java:1291) at com.sun.enterprise.v3.admin.CommandRunnerImpl$ExecutionContext.execute(CommandRunnerImpl.java:1259) at org.glassfish.admin.rest.ResourceUtil.runCommand(ResourceUtil.java:214) at org.glassfish.admin.rest.ResourceUtil.runCommand(ResourceUtil.java:207) at org.glassfish.admin.rest.resources.TemplateListOfResource.createResource(TemplateListOfResource.java:148) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:597) at com.sun.jersey.spi.container.JavaMethodInvokerFactory$1.invoke(JavaMethodInvokerFactory.java:60) at com.sun.jersey.server.impl.model.method.dispatch.AbstractResourceMethodDispatchProvider$ResponseOutInvoker._dispatch(AbstractResourceMethodDispatchProvider.java:205) at com.sun.jersey.server.impl.model.method.dispatch.ResourceJavaMethodDispatcher.dispatch(ResourceJavaMethodDispatcher.java:75) at com.sun.jersey.server.impl.uri.rules.HttpMethodRule.accept(HttpMethodRule.java:288) at com.sun.jersey.server.impl.uri.rules.SubLocatorRule.accept(SubLocatorRule.java:134) at com.sun.jersey.server.impl.uri.rules.RightHandPathRule.accept(RightHandPathRule.java:147) at com.sun.jersey.server.impl.uri.rules.SubLocatorRule.accept(SubLocatorRule.java:134) at com.sun.jersey.server.impl.uri.rules.RightHandPathRule.accept(RightHandPathRule.java:147) at com.sun.jersey.server.impl.uri.rules.ResourceClassRule.accept(ResourceClassRule.java:108) at com.sun.jersey.server.impl.uri.rules.RightHandPathRule.accept(RightHandPathRule.java:147) at com.sun.jersey.server.impl.uri.rules.RootResourceClassesRule.accept(RootResourceClassesRule.java:84) at com.sun.jersey.server.impl.application.WebApplicationImpl._handleRequest(WebApplicationImpl.java:1469) at com.sun.jersey.server.impl.application.WebApplicationImpl._handleRequest(WebApplicationImpl.java:1400) at com.sun.jersey.server.impl.application.WebApplicationImpl.handleRequest(WebApplicationImpl.java:1349) at com.sun.jersey.server.impl.application.WebApplicationImpl.handleRequest(WebApplicationImpl.java:1339) at com.sun.jersey.server.impl.container.grizzly.GrizzlyContainer._service(GrizzlyContainer.java:182) at com.sun.jersey.server.impl.container.grizzly.GrizzlyContainer.service(GrizzlyContainer.java:147) at org.glassfish.admin.rest.adapter.RestAdapter.service(RestAdapter.java:148) at com.sun.grizzly.tcp.http11.GrizzlyAdapter.service(GrizzlyAdapter.java:179) at com.sun.enterprise.v3.server.HK2Dispatcher.dispath(HK2Dispatcher.java:117) at com.sun.enterprise.v3.services.impl.ContainerMapper$Hk2DispatcherCallable.call(ContainerMapper.java:354) at com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:195) at com.sun.grizzly.http.ProcessorTask.invokeAdapter(ProcessorTask.java:849) at com.sun.grizzly.http.ProcessorTask.doProcess(ProcessorTask.java:746) at com.sun.grizzly.http.ProcessorTask.process(ProcessorTask.java:1045) at com.sun.grizzly.http.DefaultProtocolFilter.execute(DefaultProtocolFilter.java:228) at com.sun.grizzly.DefaultProtocolChain.executeProtocolFilter(DefaultProtocolChain.java:137) at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:104) at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:90) at com.sun.grizzly.http.HttpProtocolChain.execute(HttpProtocolChain.java:79) at com.sun.grizzly.ProtocolChainContextTask.doCall(ProtocolChainContextTask.java:54) at com.sun.grizzly.SelectionKeyContextTask.call(SelectionKeyContextTask.java:59) at com.sun.grizzly.ContextTask.run(ContextTask.java:71) at com.sun.grizzly.util.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:532) at com.sun.grizzly.util.AbstractThreadPool$Worker.run(AbstractThreadPool.java:513) at java.lang.Thread.run(Thread.java:680) |#]

It seemed to be loooking for something in Spring Framework, but I'm using Struts2 + Tiles 3. Am I missing anything?

Here's my code:

<?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_3_0.xsd" id="WebApp_ID" version="3.0">
  <display-name>SongLyricsSystemv1</display-name>

    <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>

    <listener>
        <listener-class>org.apache.tiles.extras.complete.CompleteAutoloadTilesListener</listener-class>
    </listener>

    <context-param>
        <param-name>insertAttribute</param-name>
        <param-value>/WEB-INF/tiles.xml</param-value>
    </context-param>

      <welcome-file-list>
        <welcome-file>index.html</welcome-file>
        <welcome-file>index.htm</welcome-file>
        <welcome-file>index.jsp</welcome-file>
        <welcome-file>default.html</welcome-file>
        <welcome-file>default.htm</welcome-file>
        <welcome-file>default.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="WebContent/BaseLayout.jsp">         

    <put-attribute name="menu" value="WebContent/Menu.jsp" />

</definition>

<definition name="/welcome.tiles" extends="baseLayout">
    <put-attribute name="title" value="Welcome" />
    <put-attribute name="body" value="WebContent/Welcome.jsp" />
</definition>

<definition name="/customer.tiles" extends="baseLayout">
    <put-attribute name="title" value="Customer Form" />
    <put-attribute name="body" value="WebContent/Customer.jsp" />
</definition>
<definition name="/customer.success.tiles" extends="baseLayout">
    <put-attribute name="title" value="Customer Added" />
    <put-attribute name="body" value="WebContent/SuccessCustomer.jsp" />
</definition>

</tiles-definitions>

Struts.xml:

 <struts>
<package name="default" namespace="/" extends="struts-default"> 
    <result-types>
        <result-type name="tiles" class="org.apache.struts2.views.tiles.TilesResult" />
    </result-types>
    <action name="login" 
        class="com.java.actions.LoginAction">
        <result name="success" type="tiles">/welcome.tiles</result>
        <result name="error">Login.jsp</result>
    </action>
    <action name="customer" 
        class="com.java.actions.CustomerAction">
        <result name="success" type="tiles">/customer.success.tiles</result>
        <result name="input" type="tiles">/customer.tiles</result>
    </action>
    <action name="customer-form">
        <result name="success" type="tiles">/customer.tiles</result>
    </action>

</package>
</struts>

My list of jar files:

  • antlr-2.7.2.jar
  • classworlds-1.1.jar
  • commons-beanutils-1.8.0.jar
  • commons-chain-1.2.jar
  • commons-collections-3.1.jar
  • commons-digester-2.0.jar
  • commons-fileupload-1.2.2.jar
  • commons-io-2.0.1.jar
  • commons-lang-2.4.jar
  • commons-lang3-3.1.jar
  • commons-logging-1.1.1.jar
  • commons-logging-api-1.1.jar
  • commons-validator-1.3.1.jar
  • freemarker-2.3.19.jar
  • javassist-3.11.0.GA.jar
  • javax.servlet-api.jar
  • javax.servlet.jsp-api.jar
  • jcl-over-slf4j-1.7.2.jar
  • jul-to-slf4j-1.7.2.jar
  • log4j-over-slf4j-1.7.2.jar
  • mvel2-2.1.3.jar
  • ognl-3.0.5.jar
  • oro-2.0.8.jar
  • oval-1.31.jar
  • sitemesh-2.4.2.jar
  • slf4j-api-1.7.2.jar
  • slf4j-ext-1.7.2.jar
  • slf4j-jcl-1.7.2.jar
  • slf4j-jdk14-1.7.2.jar
  • slf4j-log4j12-1.7.2.jar
  • slf4j-migrator-1.7.2.jar
  • slf4j-nop-1.7.2.jar
  • slf4j-simple-1.7.2.jar
  • struts2-core-2.3.7.jar
  • struts2-tiles-plugin-2.3.7.jar
  • tiles-api-3.0.1.jar
  • tiles-autotag-core-runtime-1.1.0.jar
  • tiles-compat-3.0.1.jar
  • tiles-core-3.0.1.jar
  • tiles-el-3.0.1.jar
  • tiles-extras-3.0.1.jar
  • tiles-freemarker-3.0.1.jar
  • tiles-jsp-3.0.1.jar
  • tiles-mvel-3.0.1.jar
  • tiles-ognl-3.0.1.jar
  • tiles-request-api-1.0.1.jar
  • tiles-request-freemarker-1.0.1.jar
  • tiles-request-jsp-1.0.1.jar
  • tiles-request-mustache-1.0.1.jar
  • tiles-request-servlet-1.0.1.jar
  • tiles-request-servlet-wildcard-1.0.1.jar
  • tiles-request-velocity-1.0.1.jar tiles-servlet-3.0.1.jar
  • tiles-template-3.0.1.jar
  • tiles-velocity-3.0.1.jar
  • velocity-1.6.3.jar
  • xstream-1.4.2.jar
  • xwork-core-2.3.7.jar

Is there anything I am still missing?

Community
  • 1
  • 1
prog rice bowl
  • 788
  • 3
  • 19
  • 36
  • Yes spring is required, the link uses maven for build which would take care of the dependencies... I'll provide a full list of JARs in a bit. – Quaternion Dec 28 '12 at 01:09
  • The resulting build in the answer I provided has been tested to work on Glassfish. The full list of jars needed during deployment I think has been provided... sometimes I had jars to glassfish directly, I don't think this is the case here but let me know if you have further issues. You'll also note how short the number of dependencies are in the pom, that short handful is responsible for the long list of jars you'll see here. – Quaternion Dec 28 '12 at 16:58
  • Further information the list of jar is a cut and paste of directory listing so it should be accurate. Did this work for you? – Quaternion Jan 01 '13 at 01:03

2 Answers2

0

These are the jars that are deployed with a working struts2 tiles3 integration (same as the link you pointed to):

aopalliance-1.0.jar
asm-3.3.jar
asm-commons-3.3.jar
asm-tree-3.3.jar
builder-0.6.2.jar
commons-beanutils-1.8.0.jar
commons-collections-3.2.jar
commons-digester-2.0.jar
commons-fileupload-1.2.2.jar
commons-io-2.0.1.jar
commons-lang3-3.1.jar
commons-lang-2.4.jar
core-0.6.2.jar
freemarker-2.3.19.jar
guava-r09.jar
jackson-core-asl-1.5.2.jar
jackson-mapper-asl-1.5.2.jar
javassist-3.11.0.GA.jar
jcl-over-slf4j-1.5.8.jar
mvel2-2.0.11.jar
ognl-3.0.5.jar
oro-2.0.8.jar
slf4j-api-1.5.8.jar
slf4j-jdk14-1.5.8.jar
spring-beans-2.5.6.jar
spring-context-2.5.6.jar
spring-core-2.5.6.jar
spring-web-2.5.6.jar
struts2-convention-plugin-2.3.4.1.jar
struts2-core-2.3.4.1.jar
tiles-api-3.0.1.jar
tiles-autotag-core-runtime-1.1.0.jar
tiles-compat-3.0.1.jar
tiles-core-3.0.1.jar
tiles-el-3.0.1.jar
tiles-extras-3.0.1.jar
tiles-freemarker-3.0.1.jar
tiles-jsp-3.0.1.jar
tiles-mvel-3.0.1.jar
tiles-ognl-3.0.1.jar
tiles-request-api-1.0.1.jar
tiles-request-freemarker-1.0.1.jar
tiles-request-jsp-1.0.1.jar
tiles-request-mustache-1.0.1.jar
tiles-request-servlet-1.0.1.jar
tiles-request-servlet-wildcard-1.0.1.jar
tiles-request-velocity-1.0.1.jar
tiles-servlet-3.0.1.jar
tiles-template-3.0.1.jar
tiles-velocity-3.0.1.jar
velocity-1.6.2.jar
velocity-tools-2.0.jar
xwork-core-2.3.4.1.jar

I would strongly recommend you use maven for the build here is a complete pom.xml:

http://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0

<groupId>com.quaternion</groupId>
<artifactId>Struts2_Tiles3_Integration</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>war</packaging>

<name>Struts2_Tiles3_Integration</name>

<properties>
    <endorsed.dir>${project.build.directory}/endorsed</endorsed.dir>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>

<dependencies>
    <dependency>
        <groupId>org.apache.struts</groupId>
        <artifactId>struts2-convention-plugin</artifactId>
        <version>2.3.4.1</version>
    </dependency>
    <dependency>
        <groupId>org.apache.tiles</groupId>
        <artifactId>tiles-extras</artifactId>
        <version>3.0.1</version>
    </dependency>
    <dependency>
        <groupId>org.slf4j</groupId>
        <artifactId>jcl-over-slf4j</artifactId>
        <version>1.5.8</version>
    </dependency>
    <dependency>
        <groupId>org.slf4j</groupId>
        <artifactId>slf4j-jdk14</artifactId>
        <version>1.5.8</version>
    </dependency>
    <dependency>
        <groupId>javax</groupId>
        <artifactId>javaee-web-api</artifactId>
        <version>6.0</version>
        <scope>provided</scope>
    </dependency>
</dependencies>

<build>
    <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-compiler-plugin</artifactId>
            <version>2.3.2</version>
            <configuration>
                <source>1.6</source>
                <target>1.6</target>
                <compilerArguments>
                    <endorseddirs>${endorsed.dir}</endorseddirs>
                </compilerArguments>
            </configuration>
        </plugin>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-war-plugin</artifactId>
            <version>2.1.1</version>
            <configuration>
                <failOnMissingWebXml>false</failOnMissingWebXml>
            </configuration>
        </plugin>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-dependency-plugin</artifactId>
            <version>2.1</version>
            <executions>
                <execution>
                    <phase>validate</phase>
                    <goals>
                        <goal>copy</goal>
                    </goals>
                    <configuration>
                        <outputDirectory>${endorsed.dir}</outputDirectory>
                        <silent>true</silent>
                        <artifactItems>
                            <artifactItem>
                                <groupId>javax</groupId>
                                <artifactId>javaee-endorsed-api</artifactId>
                                <version>6.0</version>
                                <type>jar</type>
                            </artifactItem>
                        </artifactItems>
                    </configuration>
                </execution>
            </executions>
        </plugin>
    </plugins>
</build>

Quaternion
  • 10,380
  • 6
  • 51
  • 102
  • I haven't tried using maven much because I've been using my macbook for development. Do I just download it and use it from there or do I need any further configurations from there? – prog rice bowl Jan 07 '13 at 07:09
  • I can help with the maven build if your willing to try netbeans for the build once... maven is platform independent but using an IDE makes using it very trivial: http://stackoverflow.com/questions/5718418/struts2-netbeans-7 After using netbeans, it will have setup everything required from there you can figure out how to use the command line to achieve the same or switch to your favourite IDE because any current Java supporting IDE will support maven. – Quaternion Jan 07 '13 at 07:27
  • I'm so sorry! I don't have the time to go through this right now because of my schedule with work... I'll try this as soon as I have time, thanks for the input anyway! Cheers! – prog rice bowl Feb 08 '13 at 07:30
0

I wrote a tutorial that might be helpful here: http://www.nabisoft.com/tutorials/struts2/maven-struts-2-enterprise-application-based-on-java-ee-7-and-glassfish-4

It tells you how to use Struts 2 with Tiles 3 and Maven on Glassfish 4. You can just download a working example (maven project) and use the IDE of your choice, i.e. NetBeans or Eclipse. I hope this helps others. Make sure to configure your JDBC resource as described in the tutorial because the example also uses JPA. Spring is not coverd/used in my tutorial.

Nabi
  • 2,536
  • 1
  • 16
  • 18