Spring MVCを使用してWebアプリケーションを作成しています。 Spring Securityライブラリの組み込みを開始しました。 EclipseでTomcatにデプロイしようとすると、Tomcatログに次のエラーが表示されます。
ライブラリで次のjarバージョンを使用しています
また、Eclipse、maven、およびvmware vfabric tcサーバー(stsにバンドルされています)のSTSバージョンを使用しています。
これがTomcatログです
SEVERE: Exception starting filter springSecurityFilterChain
Java.lang.NoClassDefFoundError: org/springframework/context/EnvironmentAware
at Java.lang.ClassLoader.defineClass1(Native Method)
at Java.lang.ClassLoader.defineClassCond(ClassLoader.Java:631)
at Java.lang.ClassLoader.defineClass(ClassLoader.Java:615)
at Java.security.SecureClassLoader.defineClass(SecureClassLoader.Java:141)
at org.Apache.catalina.loader.WebappClassLoader.findClassInternal(WebappClassLoader.Java:2820)
at org.Apache.catalina.loader.WebappClassLoader.findClass(WebappClassLoader.Java:1150)
at org.Apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.Java:1645)
at org.Apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.Java:1523)
at Java.lang.ClassLoader.defineClass1(Native Method)
at Java.lang.ClassLoader.defineClassCond(ClassLoader.Java:631)
at Java.lang.ClassLoader.defineClass(ClassLoader.Java:615)
at Java.security.SecureClassLoader.defineClass(SecureClassLoader.Java:141)
at org.Apache.catalina.loader.WebappClassLoader.findClassInternal(WebappClassLoader.Java:2820)
at org.Apache.catalina.loader.WebappClassLoader.findClass(WebappClassLoader.Java:1150)
at org.Apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.Java:1645)
at org.Apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.Java:1523)
at org.Apache.catalina.core.DefaultInstanceManager.loadClass(DefaultInstanceManager.Java:415)
at org.Apache.catalina.core.DefaultInstanceManager.loadClassMaybePrivileged(DefaultInstanceManager.Java:397)
at org.Apache.catalina.core.DefaultInstanceManager.newInstance(DefaultInstanceManager.Java:118)
at org.Apache.catalina.core.ApplicationFilterConfig.getFilter(ApplicationFilterConfig.Java:252)
at org.Apache.catalina.core.ApplicationFilterConfig.setFilterDef(ApplicationFilterConfig.Java:372)
at org.Apache.catalina.core.ApplicationFilterConfig.<init>(ApplicationFilterConfig.Java:98)
at org.Apache.catalina.core.StandardContext.filterStart(StandardContext.Java:4584)
at org.Apache.catalina.core.StandardContext$2.call(StandardContext.Java:5262)
at org.Apache.catalina.core.StandardContext$2.call(StandardContext.Java:5257)
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.springframework.context.EnvironmentAware
at org.Apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.Java:1678)
at org.Apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.Java:1523)
... 30 more
そして、これが私のweb.xmlファイルです
<?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_2_5.xsd"
id="WebApp_ID" version="2.5">
<!--
Display Name is used vides a short name for the application,
which will be displayed in the Tomcat Manager application.
When used in <security-constraint>, this tag provides a name
for the security constraint.
-->
<display-name>ImaginateFramework</display-name>
<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>/</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>spring</servlet-name>
<url-pattern>*.html|*.htm|*.xhtm|*.jsp|*.jsf|*.php|*.pl|*.cf</url-pattern>
</servlet-mapping>
<!-- Security Config -->
<filter>
<filter-name>springSecurityFilterChain</filter-name>
<filter-class>org.springframework.web.filter.DelegatingFilterProxy</filter-class>
</filter>
<filter-mapping>
<filter-name>springSecurityFilterChain</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
そして、これが私のspring-servlet.xmlファイルです
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:security="http://www.springframework.org/schema/security"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:aop="http://www.springframework.org/schema/aop"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:jee="http://www.springframework.org/schema/jee" xmlns:lang="http://www.springframework.org/schema/lang"
xmlns:p="http://www.springframework.org/schema/p" xmlns:tx="http://www.springframework.org/schema/tx"
xmlns:util="http://www.springframework.org/schema/util" xmlns:mvc="http://www.springframework.org/schema/mvc"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.1.xsd
http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd
http://www.springframework.org/schema/jee http://www.springframework.org/schema/jee/spring-jee.xsd
http://www.springframework.org/schema/lang http://www.springframework.org/schema/lang/spring-lang.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx.xsd
http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util.xsd
http://www.springframework.org/schema/mvc
http://www.springframework.org/schema/mvc/spring-mvc-3.1.xsd
http://www.springframework.org/schema/security
http://www.springframework.org/schema/security/spring-security-3.1.xsd">
<security:ldap-server />
<security:http auto-config='true'>
<security:intercept-url pattern="/**" access="ROLE_USER" />
</security:http>
<security:authentication-manager>
<security:authentication-provider>
<security:user-service>
<security:user name="admin" password="password"
authorities="ROLE_USER, ROLE_ADMIN" />
<security:user name="bob" password="bob" authorities="ROLE_USER" />
</security:user-service>
</security:authentication-provider>
</security:authentication-manager>
<context:annotation-config />
<context:component-scan base-package="com.imaginatelabs.imaginate_framework.mvc" />
<mvc:annotation-driven />
<mvc:resources location="/images/" mapping="/images/**" />
<mvc:resources location="/scripts/" mapping="/scripts/**" />
<mvc:resources location="/themes/" mapping="/themes/**" />
<mvc:interceptors>
<bean id="localeChangeInterceptor"
class="org.springframework.web.servlet.i18n.LocaleChangeInterceptor">
<property name="paramName" value="lang" />
</bean>
<bean id="themeChangeInterceptor"
class="org.springframework.web.servlet.theme.ThemeChangeInterceptor">
<property name="paramName" value="theme" />
</bean>
</mvc:interceptors>
<bean id="jspViewResolver"
class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<property name="viewClass"
value="org.springframework.web.servlet.view.JstlView" />
<property name="prefix" value="/WEB-INF/jsp/" />
<property name="suffix" value=".jsp" />
<property name="order" value="1" />
</bean>
<bean id="propertyConfigurer"
class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer"
p:location="/WEB-INF/jdbc.properties" />
<bean id="dataSource" class="org.Apache.commons.dbcp.BasicDataSource"
destroy-method="close" p:driverClassName="${jdbc.driverClassName}"
p:url="${jdbc.databaseurl}" p:username="${jdbc.username}" p:password="${jdbc.password}" />
<!-- Hibernate Components -->
<bean id="sessionFactory"
class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
<property name="dataSource" ref="dataSource" />
<property name="configLocation">
<value>classpath:hibernate.cfg.xml</value>
</property>
<property name="configurationClass">
<value>org.hibernate.cfg.AnnotationConfiguration</value>
</property>
<property name="hibernateProperties">
<props>
<prop key="hibernate.dialect">${jdbc.dialect}</prop>
<prop key="hibernate.show_sql">true</prop>
</props>
</property>
</bean>
<tx:annotation-driven />
<bean id="transactionManager"
class="org.springframework.orm.hibernate3.HibernateTransactionManager">
<property name="sessionFactory" ref="sessionFactory" />
</bean>
<!-- Tiles Components -->
<bean id="tilesViewResolver"
class="org.springframework.web.servlet.view.UrlBasedViewResolver">
<property name="viewClass"
value="org.springframework.web.servlet.view.tiles2.TilesView" />
<property name="order" value="0" />
</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>
<!-- Language Components -->
<bean id="messageSource"
class="org.springframework.context.support.ReloadableResourceBundleMessageSource">
<property name="basename" value="classpath:messages" />
<property name="defaultEncoding" value="UTF-8" />
</bean>
<bean id="localeResolver"
class="org.springframework.web.servlet.i18n.CookieLocaleResolver">
<property name="defaultLocale" value="en" />
</bean>
<!-- Theme Components -->
<bean id="themeSource"
class="org.springframework.ui.context.support.ResourceBundleThemeSource">
<property name="basenamePrefix" value="theme-" />
<!-- Can I configure this to look in a directory on the server? -->
</bean>
<bean id="themeResolver"
class="org.springframework.web.servlet.theme.CookieThemeResolver">
<property name="defaultThemeName" value="default" />
</bean>
(編集)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/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>myapp</groupId>
<artifactId>MyApp</artifactId>
<packaging>war</packaging>
<version>0.0.1-SNAPSHOT</version>
<name>App</name>
<build>
<plugins>
<plugin>
<groupId>org.Apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>2.1.1</version>
</plugin>
<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>
</configuration>
</plugin>
</plugins>
</build>
<properties>
<org.springframework.version>3.1.1.RELEASE</org.springframework.version>
<org.springframework.security.version>3.1.0.RELEASE</org.springframework.security.version>
<org.Apache.tiles>3.0.0</org.Apache.tiles>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>
<dependency>
<groupId>commons-beanutils</groupId>
<artifactId>commons-beanutils</artifactId>
<version>1.8.0</version>
</dependency>
<dependency>
<groupId>commons-digester</groupId>
<artifactId>commons-digester</artifactId>
<version>2.0</version>
</dependency>
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<version>1.2.16</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>1.5.8</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
<version>1.4.2</version>
</dependency>
<dependency>
<groupId>org.Apache.tiles</groupId>
<artifactId>tiles-api</artifactId>
<version>${org.Apache.tiles}</version>
</dependency>
<dependency>
<groupId>org.Apache.tiles</groupId>
<artifactId>tiles-core</artifactId>
<version>${org.Apache.tiles}</version>
</dependency>
<dependency>
<groupId>org.Apache.tiles</groupId>
<artifactId>tiles-jsp</artifactId>
<version>${org.Apache.tiles}</version>
</dependency>
<dependency>
<groupId>org.Apache.tiles</groupId>
<artifactId>tiles-servlet</artifactId>
<version>${org.Apache.tiles}</version>
</dependency>
<dependency>
<groupId>org.Apache.tiles</groupId>
<artifactId>tiles-template</artifactId>
<version>${org.Apache.tiles}</version>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>servlet-api</artifactId>
<version>2.5</version>
</dependency>
<!--
<dependency>
<groupId>org.springframework.webflow</groupId>
<artifactId>spring-webflow</artifactId>
<version>2.3.1.RELEASE</version>
</dependency>
-->
<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-web</artifactId>
<version>${org.springframework.security.version}</version>
</dependency>
<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-config</artifactId>
<version>${org.springframework.security.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-beans</artifactId>
<version>${org.springframework.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-jdbc</artifactId>
<version>${org.springframework.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-web</artifactId>
<version>${org.springframework.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-webmvc</artifactId>
<version>${org.springframework.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-orm</artifactId>
<version>${org.springframework.version}</version>
</dependency>
<dependency>
<groupId>hibernate</groupId>
<artifactId>hibernate-entitymanager</artifactId>
<version>3.4.0.GA</version>
</dependency>
<dependency>
<groupId>taglibs</groupId>
<artifactId>standard</artifactId>
<version>1.1.2</version>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>jstl</artifactId>
<version>1.2</version>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-Java</artifactId>
<version>5.1.10</version>
</dependency>
<dependency>
<groupId>commons-dbcp</groupId>
<artifactId>commons-dbcp</artifactId>
<version>20030825.184428</version>
</dependency>
<dependency>
<groupId>commons-pool</groupId>
<artifactId>commons-pool</artifactId>
<version>20030825.183949</version>
</dependency>
<dependency>
<groupId>org.Apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
<version>3.1</version>
</dependency>
</dependencies>
EnvironmentAwareは、spring-context-3.1.1.RELEASE.jarにあるため、欠落しています。
また、Maven POMファイルを再確認して、spring-web、spring-webmvc(DispatcherServletクラスが見つかった場合はこれらが存在する可能性があります)、Hibernate、springなどのORMを使用している場合はspring-ormなどの他のSpringライブラリが欠落していないことを確認します-jms(JMSを使用する場合など).
プロジェクトをクリーンアップして、プロジェクトを再デプロイしてください。それでも機能しない場合は、ライブラリが残っているかどうか、春のライブラリを慎重に確認してください。
ランタイムクラスパスにspring-mvc jarがありません。展開されたwarに移動し、spring-webmvc-3.1.1.RELEASE.jarがlib
ディレクトリに存在することを確認します。