Using tile in struts2

匿名 (未验证) 提交于 2019-12-03 00:56:02

问题:

I am following a tutorial of Tile in Struts2, but ran into the following error:

SEVERE: Error configuring application listener of class org.apache.struts2.tiles.StrutsTilesListener java.lang.NoClassDefFoundError: org/slf4j/LoggerFactory at org.apache.tiles.web.startup.AbstractTilesListener.<init>(AbstractTilesListener.java:44) at org.apache.tiles.web.startup.TilesListener.<init>(TilesListener.java:38) at org.apache.struts2.tiles.StrutsTilesListener.<init>(StrutsTilesListener.java:48) at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) at  sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39) at     sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)     at java.lang.reflect.Constructor.newInstance(Constructor.java:513)     at java.lang.Class.newInstance0(Class.java:355)     at java.lang.Class.newInstance(Class.java:308)     at org.apache.catalina.core.DefaultInstanceManager.newInstance(DefaultInstanceManager.java:125)     at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4715)     at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5273)     at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)     at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1566)     at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1556)     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:680)     Caused by: java.lang.ClassNotFoundException: org.slf4j.LoggerFactory     at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1711)     at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1556)     ... 20 more Sep 1, 2012 6:43:25 PM org.apache.catalina.core.StandardContext listenerStart SEVERE: Skipped installing application listeners due to previous error(s) Sep 1, 2012 6:43:25 PM org.apache.catalina.core.StandardContext startInternal SEVERE: Error listenerStart Sep 1, 2012 6:43:25 PM org.apache.catalina.core.StandardContext startInternal SEVERE: Context [/Tiles] startup failed due to previous errors Sep 1, 2012 6:43:25 PM org.apache.coyote.AbstractProtocol start INFO: Starting ProtocolHandler ["http-bio-2005"] Sep 1, 2012 6:43:25 PM org.apache.coyote.AbstractProtocol start INFO: Starting ProtocolHandler ["ajp-bio-8009"] Sep 1, 2012 6:43:25 PM org.apache.catalina.startup.Catalina start INFO: Server startup in 1990 ms 

All jar files that I have in my Web-Content/lib folder are as following:

axis.jar axis2.war axis2-1.6.2-bin.zip axis2-1.6.2-src.zip commons-beanutils-1.8.0.jar commons-collections-3.2.1.jar commons-digester-2.1.jar commons-discovery-0.2.jar commons-fileupload-1.2.1.jar commons-io-1.3.2.jar commons-lang-2.3.jar commons-logging.jar commons-logging-api-1.1.jar commons-validator-1.3.1.jar freemarker-2.3.15.jar freemarker-2.3.16.jar javassist-3.7.1.GA.jar jaxrpc.jar jdom-1.1.jar json-lib-2.1-jdk15.jar junit-4.8.2.jar mysql-connector-java-5.1.17.jar ognl-3.0.jar saaj.jar saaj-api-1.3.jar spring-beans-2.5.6.jar spring-context-2.5.6.jar spring-core-2.5.6.jar spring-test-2.5.6.jar spring-web-2.5.6.jar sqlitejdbc-v056.jar struts2-core-2.2.1.jar struts2-dojo-plugin-2.2.1.jar struts2-json-plugin-2.2.1.jar struts2-junit-plugin-2.2.1.jar struts2-spring-plugin-2.2.1.jar struts2-tiles-plugin-2.2.1.jar tiles-api-2.2.1.jar tiles-compat-2.2.1.jar tiles-core-2.2.1.jar tiles-extras-2.2.1.jar tiles-jsp-2.2.1.jar tiles-portlet-2.2.1.jar tiles-servlet-2.2.1.jar wsdl4j.jar xstream-1.2.2.jar xwork-core-2.2.1.jar 

What do I do to fix this?

回答1:

You add the library the error message says is missing; Slf4J.

It looks like you're trying to do dependency management by hand--IMO that is a Very Bad Idea. It makes upgrading difficult, deployment difficult, understanding the differences between compile, test, and deployment requirements difficult, and so on.

For example, why deploy a source jar, or junit?



回答2:

if you get the following error: java.lang.NoClassDefFoundError: org/slf4j/LoggerFactory at org.apache.tiles.web.startup.AbstractTilesListener.

add this dependency

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

or add this jar : slf4j-api-1.5.8.jar jcl-over-slf4j-1.5.8.jar



文章来源: Using tile in struts2
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!