我有使用Spring Security 3.1保护的GWT 2.5应用程序。当我想添加Spring Beans来使用DB时,我遇到了奇怪的异常。
当我添加到appcontext.xml行<context:component-scan base-package="com.server" />
时
,部署后我得到了
java.io.FileNotFoundException: class path resource [javax/servlet/http/HttpServlet.class] cannot be opened because it does not exist
或
java.io.FileNotFoundException: class path resource [java/lang/Object.class] cannot be opened because it does not exist
所有人都使用maven成功构建。部署到Tomcat 7.0.37 x64时出现问题。当我评论此行时,错误消失。我尝试重新安装Tomcat / Java,所以情况并非如此。可能是什么原因?
UPD 我可以发布我的xml配置文件,如果这可以帮助。
因此, com.server 包含我的所有服务器类,spring bean和servlet。
Spring XML文件
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:p="http://www.springframework.org/schema/p"
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/context
http://www.springframework.org/schema/context/spring-context-3.1.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">
<import resource="security.xml" />
<context:annotation-config />
<context:component-scan base-package="com.server" />
</beans>
安全xml
<?xml version="1.0" encoding="UTF-8"?>
<beans:beans xmlns="http://www.springframework.org/schema/security"
xmlns:beans="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.1.xsd
http://www.springframework.org/schema/security http://www.springframework.org/schema/security/spring-security-3.1.xsd">
<http use-expressions="true">
<form-login login-page="/login.jsp" default-target-url="/"
always-use-default-target="false" authentication-failure-url="/login.jsp?error=true"
username-parameter="username" password-parameter="password"
login-processing-url="/login" />
<logout logout-success-url="/login.jsp?logout" logout-url="/logout" />
<intercept-url pattern="/static/**" access="permitAll" />
<intercept-url pattern="/login.jsp" access="permitAll" />
<intercept-url pattern="/sk/" access="hasRole('ROLE_USER')" />
<intercept-url pattern="/sk" access="hasRole('ROLE_USER')" />
<intercept-url pattern="/" access="hasRole('ROLE_USER')" />
<intercept-url pattern="/**" access="hasRole('ROLE_USER')" />
</http>
<authentication-manager>
<authentication-provider>
<password-encoder hash="md5" />
<jdbc-user-service data-source-ref="dataSource" />
</authentication-provider>
</authentication-manager>
</beans:beans>
Web XML
<?xml version="1.0" encoding="UTF-8"?>
<web-app 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"
version="2.5" xmlns="http://java.sun.com/xml/ns/javaee">
<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>
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
<servlet>
<servlet-name>userService</servlet-name>
<servlet-class>com.server.servlet.CUserServiceImpl</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>userService</servlet-name>
<url-pattern>/sk/userService</url-pattern>
</servlet-mapping>
<session-config>
<session-timeout>15</session-timeout>
</session-config>
<security-constraint>
<web-resource-collection>
<web-resource-name>Everything in the webapp</web-resource-name>
<url-pattern>/*</url-pattern>
</web-resource-collection>
<user-data-constraint>
<transport-guarantee>CONFIDENTIAL</transport-guarantee>
</user-data-constraint>
</security-constraint>
<welcome-file-list>
<welcome-file>skmain.html</welcome-file>
</welcome-file-list>
</web-app>
@Srinivas 我在pom中有这种依赖性。但无论如何,如果是这样,为什么没有找到普通的Javas Object.class?
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<version>3.0.1</version>
</dependency>