我试图使用Struts 2&根据此link的瓷砖3。 但是,只要我在web.xml上添加了listener-class:
<listener>
<listener-class>org.apache.tiles.extras.complete.CompleteAutoloadTilesListener</listener-class>
</listener>
在我的glassfish服务器上传时出现以下错误:
部署期间出错:加载应用时出现异常: java.lang.IllegalStateException:ContainerBase.addChild:start: org.apache.catalina.LifecycleException: java.lang.NoClassDefFoundError:org / springframewor /核心/ IO /支持/ ResourcePatternResolver。请参阅server.log了解 更多细节。
错误消息是:
[#| 2012-12-23T18:36:10.982 + 0800 |严重| glassfish3.1.2 | javax.enterprise.system.tools.admin.org.glassfish.deployment.admin | _ThreadID = 22; _ThreadName = Thread- 4; |异常 在调用类com.sun.enterprise.web.WebApplication start时 方法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) 在org.glassfish.internal.data.EngineRef.start(EngineRef.java:130) 在org.glassfish.internal.data.ModuleInfo.start(ModuleInfo.java:269) 在 org.glassfish.internal.data.ApplicationInfo.start(ApplicationInfo.java:301) 在 com.sun.enterprise.v3.server.ApplicationLifecycle.deploy(ApplicationLifecycle.java:461) 在 com.sun.enterprise.v3.server.ApplicationLifecycle.deploy(ApplicationLifecycle.java:240) 在 org.glassfish.deployment.admin.DeployCommand.execute(DeployCommand.java:389) 在 com.sun.enterprise.v3.admin.CommandRunnerImpl $ 1.execute(CommandRunnerImpl.java:348) 在 com.sun.enterprise.v3.admin.CommandRunnerImpl.doCommand(CommandRunnerImpl.java:363) 在 com.sun.enterprise.v3.admin.CommandRunnerImpl.doCommand(CommandRunnerImpl.java:1085) 在 com.sun.enterprise.v3.admin.CommandRunnerImpl.access $ 1200(CommandRunnerImpl.java:95) 在 com.sun.enterprise.v3.admin.CommandRunnerImpl $ ExecutionContext.execute(CommandRunnerImpl.java:1291) 在 com.sun.enterprise.v3.admin.CommandRunnerImpl $ ExecutionContext.execute(CommandRunnerImpl.java:1259) 在 org.glassfish.admin.rest.ResourceUtil.runCommand(ResourceUtil.java:214) 在 org.glassfish.admin.rest.ResourceUtil.runCommand(ResourceUtil.java:207) 在 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) 在 sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) 在java.lang.reflect.Method.invoke(Method.java:597)at com.sun.jersey.spi.container.JavaMethodInvokerFactory $ 1.invoke(JavaMethodInvokerFactory.java:60) 在 com.sun.jersey.server.impl.model.method.dispatch.AbstractResourceMethodDispatchProvider $ ResponseOutInvoker._dispatch(AbstractResourceMethodDispatchProvider.java:205) 在 com.sun.jersey.server.impl.model.method.dispatch.ResourceJavaMethodDispatcher.dispatch(ResourceJavaMethodDispatcher.java:75) 在 com.sun.jersey.server.impl.uri.rules.HttpMethodRule.accept(HttpMethodRule.java:288) 在 com.sun.jersey.server.impl.uri.rules.SubLocatorRule.accept(SubLocatorRule.java:134) 在 com.sun.jersey.server.impl.uri.rules.RightHandPathRule.accept(RightHandPathRule.java:147) 在 com.sun.jersey.server.impl.uri.rules.SubLocatorRule.accept(SubLocatorRule.java:134) 在 com.sun.jersey.server.impl.uri.rules.RightHandPathRule.accept(RightHandPathRule.java:147) 在 com.sun.jersey.server.impl.uri.rules.ResourceClassRule.accept(ResourceClassRule.java:108) 在 com.sun.jersey.server.impl.uri.rules.RightHandPathRule.accept(RightHandPathRule.java:147) 在 com.sun.jersey.server.impl.uri.rules.RootResourceClassesRule.accept(RootResourceClassesRule.java:84) 在 com.sun.jersey.server.impl.application.WebApplicationImpl._handleRequest(WebApplicationImpl.java:1469) 在 com.sun.jersey.server.impl.application.WebApplicationImpl._handleRequest(WebApplicationImpl.java:1400) 在 com.sun.jersey.server.impl.application.WebApplicationImpl.handleRequest(WebApplicationImpl.java:1349) 在 com.sun.jersey.server.impl.application.WebApplicationImpl.handleRequest(WebApplicationImpl.java:1339) 在 com.sun.jersey.server.impl.container.grizzly.GrizzlyContainer._service(GrizzlyContainer.java:182) 在 com.sun.jersey.server.impl.container.grizzly.GrizzlyContainer.service(GrizzlyContainer.java:147) 在 org.glassfish.admin.rest.adapter.RestAdapter.service(RestAdapter.java:148) 在 com.sun.grizzly.tcp.http11.GrizzlyAdapter.service(GrizzlyAdapter.java:179) 在 com.sun.enterprise.v3.server.HK2Dispatcher.dispath(HK2Dispatcher.java:117) 在 com.sun.enterprise.v3.services.impl.ContainerMapper $ Hk2DispatcherCallable.call(ContainerMapper.java:354) 在 com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:195) 在 com.sun.grizzly.http.ProcessorTask.invokeAdapter(ProcessorTask.java:849) 在 com.sun.grizzly.http.ProcessorTask.doProcess(ProcessorTask.java:746) 在 com.sun.grizzly.http.ProcessorTask.process(ProcessorTask.java:1045) 在 com.sun.grizzly.http.DefaultProtocolFilter.execute(DefaultProtocolFilter.java:228) 在 com.sun.grizzly.DefaultProtocolChain.executeProtocolFilter(DefaultProtocolChain.java:137) 在 com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:104) 在 com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:90) 在 com.sun.grizzly.http.HttpProtocolChain.execute(HttpProtocolChain.java:79) 在 com.sun.grizzly.ProtocolChainContextTask.doCall(ProtocolChainContextTask.java:54) 在 com.sun.grizzly.SelectionKeyContextTask.call(SelectionKeyContextTask.java:59) 在com.sun.grizzly.ContextTask.run(ContextTask.java:71)at com.sun.grizzly.util.AbstractThreadPool $ Worker.doWork(AbstractThreadPool.java:532) 在 com.sun.grizzly.util.AbstractThreadPool $ Worker.run(AbstractThreadPool.java:513) 在java.lang.Thread.run(Thread.java:680)|#]
在Spring Framework中似乎有些东西,但我使用的是Struts2 + Tiles 3。 我错过了什么吗?
这是我的代码:
<?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>
我的jar文件列表:
我还有什么遗失吗?
答案 0 :(得分:0)
这些是使用struts2 tiles3集成部署的jar(与您指向的链接相同):
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
我强烈建议您使用maven进行构建,这是一个完整的pom.xml:
http://maven.apache.org/xsd/maven-4.0.0.xsd“&GT; 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>
答案 1 :(得分:0)
我写了一篇可能对此有帮助的教程:http://www.nabisoft.com/tutorials/struts2/maven-struts-2-enterprise-application-based-on-java-ee-7-and-glassfish-4
它告诉您如何在Glassfish 4上使用Struts 2和Tiles 3以及Maven。您可以下载一个工作示例(maven项目)并使用您选择的IDE,即NetBeans或Eclipse。我希望这有助于其他人。确保按照教程中的描述配置JDBC资源,因为该示例也使用JPA。在我的教程中没有覆盖/使用Spring。