一尘不染

Struts Spring和Hibernate集成在在线考试中

hibernate

实际上,我正在尝试将Struts Spring和Hibernate集成到在线考试系统中。在运行项目时,它会引发以下错误

Http Status 404 - online Exam/registration.jsp

Description: The requested resource is not available.

在控制台中,出现以下内容,

INFO: TLD skipped. URI: /struts-tags is already defined
Sep 10, 2013 9:14:28 PM org.apache.catalina.core.ApplicationContext log
INFO: No Spring WebApplicationInitializer types detected on classpath
Sep 10, 2013 9:14:28 PM org.apache.catalina.core.StandardContext listenerStart
SEVERE: Exception sending context initialized event to listener instance of class org.apache.tiles.extras.complete.CompleteAutoloadTilesListener
java.lang.NoSuchMethodError: org.apache.tiles.startup.TilesInitializer.initialize(Lorg/apache/tiles/request/ApplicationContext;)V
    at org.apache.tiles.web.startup.AbstractTilesListener.contextInitialized(AbstractTilesListener.java:53)
    at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4939)
    at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5434)
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
    at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1559)
    at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1549)
    at java.util.concurrent.FutureTask.run(FutureTask.java:266)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
    at java.lang.Thread.run(Thread.java:724)

Sep 10, 2013 9:14:28 PM org.apache.catalina.core.ApplicationContext log
INFO: Initializing Spring root WebApplicationContext
Sep 10, 2013 9:14:31 PM org.apache.catalina.core.StandardContext startInternal
SEVERE: Error listenerStart
Sep 10, 2013 9:14:31 PM org.apache.catalina.core.StandardContext startInternal
SEVERE: Context [/iSAS] startup failed due to previous errors
Sep 10, 2013 9:14:31 PM org.apache.catalina.core.ApplicationContext log
INFO: Closing Spring root WebApplicationContext
Sep 10, 2013 9:14:31 PM org.apache.catalina.core.StandardContext listenerStop
SEVERE: Exception sending context destroyed event to listener instance of class org.apache.tiles.extras.complete.CompleteAutoloadTilesListener
java.lang.NoSuchMethodError: org.apache.tiles.startup.TilesInitializer.destroy()V
    at org.apache.tiles.web.startup.AbstractTilesListener.contextDestroyed(AbstractTilesListener.java:63)
    at org.apache.catalina.core.StandardContext.listenerStop(StandardContext.java:4980)
    at org.apache.catalina.core.StandardContext.stopInternal(StandardContext.java:5626)
    at org.apache.catalina.util.LifecycleBase.stop(LifecycleBase.java:232)
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:160)
    at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1559)
    at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1549)
    at java.util.concurrent.FutureTask.run(FutureTask.java:266)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
    at java.lang.Thread.run(Thread.java:724)

Sep 10, 2013 9:14:31 PM org.apache.catalina.loader.WebappClassLoader clearReferencesJdbc
SEVERE: The web application [/iSAS] registered the JDBC driver [com.mysql.jdbc.Driver] but failed to unregister it when the web application was stopped. To prevent a memory leak, the JDBC Driver has been forcibly unregistered.
Sep 10, 2013 9:14:31 PM org.apache.coyote.AbstractProtocol start
INFO: Starting ProtocolHandler ["http-apr-8080"]
Sep 10, 2013 9:14:31 PM org.apache.coyote.AbstractProtocol start
INFO: Starting ProtocolHandler ["ajp-apr-8009"]
Sep 10, 2013 9:14:31 PM org.apache.catalina.startup.Catalina start
INFO: Server startup in 11274 ms

web.xml

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

<web-app version="2.5" 
    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/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">


    <description>iSAS</description>

    <filter>
        <filter-name>struts2</filter-name>
    <!--<filter-class>org.apache.struts2.dispatcher.FilterDispatcher</filter-class> -->
           <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>registration.jsp</welcome-file>
    </welcome-file-list>

 <jsp-config>
        <taglib>
            <taglib-uri>struts-tags.tld</taglib-uri>
            <taglib-location>/WEB-INF/tlds/struts-tags.tld</taglib-location>            
        </taglib>
        <taglib>
            <taglib-uri>tiles-jsp.tld</taglib-uri>
            <taglib-location>/WEB-INF/tlds/tiles-jsp.tld</taglib-location>          
        </taglib>   
    </jsp-config>

    <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.tiles.extras.complete.CompleteAutoloadTilesListener</listener-class>
    </listener>

    <listener>
    <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
    </listener> 
    <listener>
        <listener-class>org.springframework.web.context.request.RequestContextListener</listener-class>
    </listener> 
    <context-param>
        <param-name>contextConfigLocation</param-name>
        <param-value>/WEB-INF/applicationContext.xml</param-value>
    </context-param>

</web-app>

struts.xml

<struts>

    <constant name="struts.objectFactory" value="org.apache.struts2.spring.StrutsSpringObjectFactory" />
    <constant name="struts.ui.theme" value="simple" />
    <constant name="struts.devMode" value="true" />

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

        <action name="userRegistration_*" method="{1}" class="userRegistration">
            <result name="SUCCESS" type="tiles">onlineexam.user.registration</result>
            <result name="ERROR" type="tiles">onlineexam.errorPage</result>
            <result name="input" type="tiles">onlineexam.user.registration</result>
        </action>

    </package>
</struts>

但是我已经上传了所有需要的jar。但是在apache tomcat 7.0.42中运行时,仍然给我以下错误。我正在使用Eclipse
Kepler。请帮助我的朋友。


阅读 247

收藏
2020-06-20

共1个答案

一尘不染

更新到Tiles 2.2。

Spring 3.0要求Tiles 2.1.2或更高版本,并明确支持Tiles 2.2。

缺少的方法:TilesInitializer.destroy()存在@since 2.2.0

或者,也许您忘记部署其中一个瓦罐,或者您使用的是其他版本

  • tiles-core
  • Tiles-api
  • tiles-jsp
  • tile-servlet
2020-06-20