我已经花了好几个小时来解决这个问题。我正在制作一个关于spring mvc tiles的web应用教程,其中包括所有必要的spring和tiles jar。但是我也无法运行该项目。堆栈跟踪如下: -
Caused by: java.lang.NoClassDefFoundError: org/jboss/virtual/VirtualFileVisitor
at org.springframework.core.io.support.PathMatchingResourcePatternResolver.findPathMatchingResources(PathMatchingResourcePatternResolver.java:348) [org.springframework.core-3.0.1.RELEASE-A.jar:3.0.1.RELEASE-A]
at org.springframework.core.io.support.PathMatchingResourcePatternResolver.getResources(PathMatchingResourcePatternResolver.java:269) [org.springframework.core-3.0.1.RELEASE-A.jar:3.0.1.RELEASE-A]
at org.springframework.context.support.AbstractApplicationContext.getResources(AbstractApplicationContext.java:1196) [org.springframework.context-3.0.1.RELEASE-A.jar:3.0.1.RELEASE-A]
at org.springframework.context.annotation.ClassPathScanningCandidateComponentProvider.findCandidateComponents(ClassPathScanningCandidateComponentProvider.java:204) [org.springframework.context-3.0.1.RELEASE-A.jar:3.0.1.RELEASE-A]
at org.springframework.context.annotation.ClassPathBeanDefinitionScanner.doScan(ClassPathBeanDefinitionScanner.java:204) [org.springframework.context-3.0.1.RELEASE-A.jar:3.0.1.RELEASE-A]
at org.springframework.context.annotation.ComponentScanBeanDefinitionParser.parse(ComponentScanBeanDefinitionParser.java:84) [org.springframework.context-3.0.1.RELEASE-A.jar:3.0.1.RELEASE-A]
at org.springframework.beans.factory.xml.NamespaceHandlerSupport.parse(NamespaceHandlerSupport.java:73) [org.springframework.beans-3.0.1.RELEASE-A.jar:3.0.1.RELEASE-A]
at org.springframework.beans.factory.xml.BeanDefinitionParserDelegate.parseCustomElement(BeanDefinitionParserDelegate.java:1335) [org.springframework.beans-3.0.1.RELEASE-A.jar:3.0.1.RELEASE-A]
at org.springframework.beans.factory.xml.BeanDefinitionParserDelegate.parseCustomElement(BeanDefinitionParserDelegate.java:1325) [org.springframework.beans-3.0.1.RELEASE-A.jar:3.0.1.RELEASE-A]
at org.springframework.beans.factory.xml.DefaultBeanDefinitionDocumentReader.parseBeanDefinitions(DefaultBeanDefinitionDocumentReader.java:136) [org.springframework.beans-3.0.1.RELEASE-A.jar:3.0.1.RELEASE-A]
at org.springframework.beans.factory.xml.DefaultBeanDefinitionDocumentReader.registerBeanDefinitions(DefaultBeanDefinitionDocumentReader.java:93) [org.springframework.beans-3.0.1.RELEASE-A.jar:3.0.1.RELEASE-A]
at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.registerBeanDefinitions(XmlBeanDefinitionReader.java:493) [org.springframework.beans-3.0.1.RELEASE-A.jar:3.0.1.RELEASE-A]
at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.doLoadBeanDefinitions(XmlBeanDefinitionReader.java:390) [org.springframework.beans-3.0.1.RELEASE-A.jar:3.0.1.RELEASE-A]
... 29 more
Caused by: java.lang.ClassNotFoundException: org.jboss.virtual.VirtualFileVisitor from [Module "deployment.springtilesdemo.war:main" from Service Module Loader]
at org.jboss.modules.ModuleClassLoader.findClass(ModuleClassLoader.java:213) [jboss-modules.jar:1.3.3.Final]
at org.jboss.modules.ConcurrentClassLoader.performLoadClassUnchecked(ConcurrentClassLoader.java:459) [jboss-modules.jar:1.3.3.Final]
at org.jboss.modules.ConcurrentClassLoader.performLoadClassChecked(ConcurrentClassLoader.java:408) [jboss-modules.jar:1.3.3.Final]
at org.jboss.modules.ConcurrentClassLoader.performLoadClass(ConcurrentClassLoader.java:389) [jboss-modules.jar:1.3.3.Final]
at org.jboss.modules.ConcurrentClassLoader.loadClass(ConcurrentClassLoader.java:134) [jboss-modules.jar:1.3.3.Final]
... 42 more
13:03:45,236 ERROR [org.jboss.msc.service.fail] (MSC service thread 1-2) MSC000001: Failed to start service jboss.undertow.deployment.default-server.default-host./springtilesdemo: org.jboss.msc.service.StartException in service jboss.undertow.deployment.default-server.default-host./springtilesdemo: Failed to start service
at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1904) [jboss-msc-1.2.2.Final.jar:1.2.2.Final]
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145) [rt.jar:1.7.0_55]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615) [rt.jar:1.7.0_55]
at java.lang.Thread.run(Thread.java:745) [rt.jar:1.7.0_55]
Caused by: org.springframework.beans.factory.BeanDefinitionStoreException: Unexpected exception parsing XML document from ServletContext resource [/WEB-INF/spring-servlet.xml]; nested exception is java.lang.NoClassDefFoundError: org/jboss/virtual/VirtualFileVisitor
at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.doLoadBeanDefinitions(XmlBeanDefinitionReader.java:412)
at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:334)
at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:302)
at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:143)
at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:178)
at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:149)
at org.springframework.web.context.support.XmlWebApplicationContext.loadBeanDefinitions(XmlWebApplicationContext.java:124)
at org.springframework.web.context.support.XmlWebApplicationContext.loadBeanDefinitions(XmlWebApplicationContext.java:93)
at org.springframework.context.support.AbstractRefreshableApplicationContext.refreshBeanFactory(AbstractRefreshableApplicationContext.java:130)
at org.springframework.context.support.AbstractApplicationContext.obtainFreshBeanFactory(AbstractApplicationContext.java:465)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:395)
at org.springframework.web.servlet.FrameworkServlet.createWebApplicationContext(FrameworkServlet.java:443)
at org.springframework.web.servlet.FrameworkServlet.createWebApplicationContext(FrameworkServlet.java:459)
at org.springframework.web.servlet.FrameworkServlet.initWebApplicationContext(FrameworkServlet.java:340)
at org.springframework.web.servlet.FrameworkServlet.initServletBean(FrameworkServlet.java:307)
at org.springframework.web.servlet.HttpServletBean.init(HttpServletBean.java:127)
at javax.servlet.GenericServlet.init(GenericServlet.java:244)
at io.undertow.servlet.core.LifecyleInterceptorInvocation.proceed(LifecyleInterceptorInvocation.java:117)
at org.wildfly.extension.undertow.security.RunAsLifecycleInterceptor.init(RunAsLifecycleInterceptor.java:79)
at io.undertow.servlet.core.LifecyleInterceptorInvocation.proceed(LifecyleInterceptorInvocation.java:103)
at io.undertow.servlet.core.ManagedServlet$DefaultInstanceStrategy.start(ManagedServlet.java:220)
at io.undertow.servlet.core.ManagedServlet.createServlet(ManagedServlet.java:125)
at io.undertow.servlet.core.DeploymentManagerImpl.start(DeploymentManagerImpl.java:508)
at org.wildfly.extension.undertow.deployment.UndertowDeploymentService.startContext(UndertowDeploymentService.java:88)
at org.wildfly.extension.undertow.deployment.UndertowDeploymentService.start(UndertowDeploymentService.java:72)
at org.jboss.msc.service.ServiceControllerImpl$StartTask.startService(ServiceControllerImpl.java:1948) [jboss-msc-1.2.2.Final.jar:1.2.2.Final]
at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1881) [jboss-msc-1.2.2.Final.jar:1.2.2.Final]
... 3 more
Caused by: java.lang.NoClassDefFoundError: org/jboss/virtual/VirtualFileVisitor
at org.springframework.core.io.support.PathMatchingResourcePatternResolver.findPathMatchingResources(PathMatchingResourcePatternResolver.java:348)
at org.springframework.core.io.support.PathMatchingResourcePatternResolver.getResources(PathMatchingResourcePatternResolver.java:269)
at org.springframework.context.support.AbstractApplicationContext.getResources(AbstractApplicationContext.java:1196)
at org.springframework.context.annotation.ClassPathScanningCandidateComponentProvider.findCandidateComponents(ClassPathScanningCandidateComponentProvider.java:204)
at org.springframework.context.annotation.ClassPathBeanDefinitionScanner.doScan(ClassPathBeanDefinitionScanner.java:204)
at org.springframework.context.annotation.ComponentScanBeanDefinitionParser.parse(ComponentScanBeanDefinitionParser.java:84)
at org.springframework.beans.factory.xml.NamespaceHandlerSupport.parse(NamespaceHandlerSupport.java:73)
at org.springframework.beans.factory.xml.BeanDefinitionParserDelegate.parseCustomElement(BeanDefinitionParserDelegate.java:1335)
at org.springframework.beans.factory.xml.BeanDefinitionParserDelegate.parseCustomElement(BeanDefinitionParserDelegate.java:1325)
at org.springframework.beans.factory.xml.DefaultBeanDefinitionDocumentReader.parseBeanDefinitions(DefaultBeanDefinitionDocumentReader.java:136)
at org.springframework.beans.factory.xml.DefaultBeanDefinitionDocumentReader.registerBeanDefinitions(DefaultBeanDefinitionDocumentReader.java:93)
at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.registerBeanDefinitions(XmlBeanDefinitionReader.java:493)
at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.doLoadBeanDefinitions(XmlBeanDefinitionReader.java:390)
... 29 more
Caused by: java.lang.ClassNotFoundException: org.jboss.virtual.VirtualFileVisitor from [Module "deployment.springtilesdemo.war:main" from Service Module Loader]
at org.jboss.modules.ModuleClassLoader.findClass(ModuleClassLoader.java:213) [jboss-modules.jar:1.3.3.Final]
at org.jboss.modules.ConcurrentClassLoader.performLoadClassUnchecked(ConcurrentClassLoader.java:459) [jboss-modules.jar:1.3.3.Final]
at org.jboss.modules.ConcurrentClassLoader.performLoadClassChecked(ConcurrentClassLoader.java:408) [jboss-modules.jar:1.3.3.Final]
at org.jboss.modules.ConcurrentClassLoader.performLoadClass(ConcurrentClassLoader.java:389) [jboss-modules.jar:1.3.3.Final]
at org.jboss.modules.ConcurrentClassLoader.loadClass(ConcurrentClassLoader.java:134) [jboss-modules.jar:1.3.3.Final]
... 42 more
13:03:45,272 ERROR [org.jboss.as.controller.management-operation] (management-handler-thread - 48) JBAS014613: Operation ("deploy") failed - address: ([("deployment" => "springtilesdemo")]) - failure description: {"JBAS014671: Failed services" => {"jboss.undertow.deployment.default-server.default-host./springtilesdemo" => "org.jboss.msc.service.StartException in service jboss.undertow.deployment.default-server.default-host./springtilesdemo: Failed to start service
Caused by: org.springframework.beans.factory.BeanDefinitionStoreException: Unexpected exception parsing XML document from ServletContext resource [/WEB-INF/spring-servlet.xml]; nested exception is java.lang.NoClassDefFoundError: org/jboss/virtual/VirtualFileVisitor
Caused by: java.lang.NoClassDefFoundError: org/jboss/virtual/VirtualFileVisitor
Caused by: java.lang.ClassNotFoundException: org.jboss.virtual.VirtualFileVisitor from [Module \"deployment.springtilesdemo.war:main\" from Service Module Loader]"}}
13:03:45,273 ERROR [org.jboss.as.server] (management-handler-thread - 48) JBAS015870: Deploy of deployment "springtilesdemo.war" was rolled back with the following failure message:
{"JBAS014671: Failed services" => {"jboss.undertow.deployment.default-server.default-host./springtilesdemo" => "org.jboss.msc.service.StartException in service jboss.undertow.deployment.default-server.default-host./springtilesdemo: Failed to start service
Caused by: org.springframework.beans.factory.BeanDefinitionStoreException: Unexpected exception parsing XML document from ServletContext resource [/WEB-INF/spring-servlet.xml]; nested exception is java.lang.NoClassDefFoundError: org/jboss/virtual/VirtualFileVisitor
Caused by: java.lang.NoClassDefFoundError: org/jboss/virtual/VirtualFileVisitor
Caused by: java.lang.ClassNotFoundException: org.jboss.virtual.VirtualFileVisitor from [Module \"deployment.springtilesdemo.war:main\" from Service Module Loader]"}}
13:03:45,950 INFO [org.jboss.as.server.deployment] (MSC service thread 1-4) JBAS015877: Stopped deployment springtilesdemo (runtime-name: springtilesdemo.war) in 676ms
13:03:45,950 INFO [org.jboss.as.controller] (management-handler-thread - 48) JBAS014774: Service status report
JBAS014777: Services which failed to start: service jboss.undertow.deployment.default-server.default-host./springtilesdemo
[2016-06-15 01:03:46,508] Artifact springtilesdemo:war exploded: Error during artifact deployment. See server log for details.
[2016-06-15 01:03:46,508] Artifact springtilesdemo:war exploded: java.lang.Exception: {"JBAS014671: Failed services" => {"jboss.undertow.deployment.default-server.default-host./springtilesdemo" => "org.jboss.msc.service.StartException in service jboss.undertow.deployment.default-server.default-host./springtilesdemo: Failed to start service
Caused by: org.springframework.beans.factory.BeanDefinitionStoreException: Unexpected exception parsing XML document from ServletContext resource [/WEB-INF/spring-servlet.xml]; nested exception is java.lang.NoClassDefFoundError: org/jboss/virtual/VirtualFileVisitor
Caused by: java.lang.NoClassDefFoundError: org/jboss/virtual/VirtualFileVisitor
Caused by: java.lang.ClassNotFoundException: org.jboss.virtual.VirtualFileVisitor from [Module \"deployment.springtilesdemo.war:main\" from Service Module Loader]"}}
pom.xml如下: -
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.abhishek</groupId>
<artifactId>springtilesdemo</artifactId>
<packaging>war</packaging>
<version>1.0-SNAPSHOT</version>
<name>springtilesdemo Maven Webapp</name>
<url>http://maven.apache.org</url>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-core</artifactId>
<version>4.2.6.RELEASE</version>
</dependency>
<!-- http://mvnrepository.com/artifact/org.springframework/spring-context -->
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
<version>4.2.6.RELEASE</version>
</dependency>
<!-- http://mvnrepository.com/artifact/org.springframework/spring-beans -->
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-beans</artifactId>
<version>4.2.6.RELEASE</version>
</dependency>
<!-- http://mvnrepository.com/artifact/org.springframework/spring-web -->
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-web</artifactId>
<version>4.2.6.RELEASE</version>
</dependency>
<!-- http://mvnrepository.com/artifact/org.springframework/spring-webmvc -->
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-webmvc</artifactId>
<version>4.2.6.RELEASE</version>
</dependency>
<!-- http://mvnrepository.com/artifact/javax.servlet/jstl -->
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>jstl</artifactId>
<version>1.2</version>
</dependency>
<!-- http://mvnrepository.com/artifact/org.apache.tiles/tiles-jsp -->
<dependency>
<groupId>org.apache.tiles</groupId>
<artifactId>tiles-jsp</artifactId>
<version>3.0.5</version>
</dependency>
<!-- http://mvnrepository.com/artifact/org.apache.tiles/tiles-core -->
<dependency>
<groupId>org.apache.tiles</groupId>
<artifactId>tiles-core</artifactId>
<version>3.0.5</version>
</dependency>
<!-- http://mvnrepository.com/artifact/org.apache.tiles/tiles-api -->
<dependency>
<groupId>org.apache.tiles</groupId>
<artifactId>tiles-api</artifactId>
<version>3.0.5</version>
</dependency>
<!-- http://mvnrepository.com/artifact/org.apache.tiles/tiles-servlet -->
<dependency>
<groupId>org.apache.tiles</groupId>
<artifactId>tiles-servlet</artifactId>
<version>3.0.5</version>
</dependency>
<!-- http://mvnrepository.com/artifact/org.apache.tiles/tiles-template -->
<dependency>
<groupId>org.apache.tiles</groupId>
<artifactId>tiles-template</artifactId>
<version>3.0.5</version>
</dependency>
<!-- http://mvnrepository.com/artifact/org.apache.tiles/tiles-request-api -->
<dependency>
<groupId>org.apache.tiles</groupId>
<artifactId>tiles-request-api</artifactId>
<version>1.0.6</version>
</dependency>
<!-- http://mvnrepository.com/artifact/org.apache.tiles/tiles-request-servlet -->
<dependency>
<groupId>org.apache.tiles</groupId>
<artifactId>tiles-request-servlet</artifactId>
<version>1.0.6</version>
</dependency>
<!-- http://mvnrepository.com/artifact/org.apache.tiles/tiles-extras -->
<dependency>
<groupId>org.apache.tiles</groupId>
<artifactId>tiles-extras</artifactId>
<version>3.0.5</version>
</dependency>
<!-- http://mvnrepository.com/artifact/org.apache.tiles/tiles-el -->
<dependency>
<groupId>org.apache.tiles</groupId>
<artifactId>tiles-el</artifactId>
<version>3.0.5</version>
</dependency>
<!-- http://mvnrepository.com/artifact/org.apache.tiles/tiles-servlet-wildcard -->
<dependency>
<groupId>org.apache.tiles</groupId>
<artifactId>tiles-servlet-wildcard</artifactId>
<version>2.2.2</version>
</dependency>
<!-- http://mvnrepository.com/artifact/org.apache.tiles/tiles-compat -->
<dependency>
<groupId>org.apache.tiles</groupId>
<artifactId>tiles-compat</artifactId>
<version>3.0.5</version>
</dependency>
<!-- http://mvnrepository.com/artifact/org.apache.tiles/tiles-autotag-core-runtime -->
<dependency>
<groupId>org.apache.tiles</groupId>
<artifactId>tiles-autotag-core-runtime</artifactId>
<version>1.1.0</version>
</dependency>
<!-- http://mvnrepository.com/artifact/org.apache.tiles/tiles-portlet -->
<dependency>
<groupId>org.apache.tiles</groupId>
<artifactId>tiles-portlet</artifactId>
<version>2.2.2</version>
</dependency>
<!-- http://mvnrepository.com/artifact/org.apache.tiles/tiles-autotag-core -->
<dependency>
<groupId>org.apache.tiles</groupId>
<artifactId>tiles-autotag-core</artifactId>
<version>1.1.0</version>
</dependency>
<!-- http://mvnrepository.com/artifact/org.apache.tiles/tiles-test-common -->
<dependency>
<groupId>org.apache.tiles</groupId>
<artifactId>tiles-test-common</artifactId>
<version>3.0.5</version>
</dependency>
<!-- http://mvnrepository.com/artifact/org.apache.tiles/tiles-request-portlet -->
<dependency>
<groupId>org.apache.tiles</groupId>
<artifactId>tiles-request-portlet</artifactId>
<version>1.0.6</version>
</dependency>
<!-- http://mvnrepository.com/artifact/org.apache.tiles/tiles-ognl -->
<dependency>
<groupId>org.apache.tiles</groupId>
<artifactId>tiles-ognl</artifactId>
<version>3.0.5</version>
</dependency>
<!-- http://mvnrepository.com/artifact/org.apache.tiles/tiles-velocity -->
<dependency>
<groupId>org.apache.tiles</groupId>
<artifactId>tiles-velocity</artifactId>
<version>3.0.5</version>
</dependency>
<!-- http://mvnrepository.com/artifact/org.apache.tiles/tiles-request-jsp -->
<dependency>
<groupId>org.apache.tiles</groupId>
<artifactId>tiles-request-jsp</artifactId>
<version>1.0.6</version>
</dependency>
<!-- http://mvnrepository.com/artifact/org.apache.tiles/tiles-mvel -->
<dependency>
<groupId>org.apache.tiles</groupId>
<artifactId>tiles-mvel</artifactId>
<version>3.0.5</version>
</dependency>
</dependencies>
<build>
<finalName>springtilesdemo</finalName>
</build>
</project>
spring-servlet.xml如下: -
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:p="http://www.springframework.org/schema/p"
xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context.xsd">
<context:component-scan
base-package="com.abhishek" />
<bean id="viewResolver"
class="org.springframework.web.servlet.view.UrlBasedViewResolver">
<property name="viewClass">
<value>
org.springframework.web.servlet.view.tiles2.TilesView
</value>
</property>
</bean>
<bean id="tilesConfigurer"
class="org.springframework.web.servlet.view.tiles2.TilesConfigurer">
<property name="definitions">
<list>
<value>/WEB-INF/tiles.xml</value>
</list>
</property>
</bean>
</beans>
web.xml文件如下: -
<?xml version="1.0" encoding="UTF-8"?>
<web-app version="2.5"
xmlns="http://java.sun.com/xml/ns/javaee"
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">
<welcome-file-list>
<welcome-file>index.jsp</welcome-file>
</welcome-file-list>
<servlet>
<servlet-name>spring</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>spring</servlet-name>
<url-pattern>*.html</url-pattern>
</servlet-mapping>
</web-app>