java.lang.NoClassDefFoundError:javax/servlet/Filter?

发布于 2024-12-04 00:53:22 字数 2057 浏览 0 评论 0原文

我正在将 spring-security 用于桌面应用程序,下面是我的 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"
xsi:schemaLocation="http://www.springframework.org/schema/beans      
           http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
           http://www.springframework.org/schema/security
           http://www.springframework.org/schema/security/spring-security-3.1.xsd" >

<bean id='myProvider' class='MyAuthenticationProvider'/>
<security:authentication-manager>
    <security:authentication-provider ref='MyAuthenticationProvider' />
</security:authentication-manager>  

<bean id='authenticationHolder' class='AuthenticationHolder' />
<bean scope="request" factory-bean="authenticationHolder" factory-method="getAuthentication" >
    <security:user-service id="userDetailsService">
        <security:user name="testUser" password="testPassword" authorities="ROLE_USER"/>
    </security:user-service>
</bean>
<bean class="org.springframework.security.authentication.encoding.Md5PasswordEncoder" id="passwordEncoder"/>

<bean id="accessDecisionManager" class="org.springframework.security.vote.AffirmativeBased">
    <property name="decisionVoters">
        <list>
            <bean class="org.springframework.security.vote.RoleVoter">
                <property name="rolePrefix" value="MY_PREFIX_" />
            </bean>
        </list>
    </property>
</bean>

<security:global-method-security secured-annotations="enabled" 
            access-decision-manager-ref="accessDecisionManager" />

运行时我收到此异常

SEVERE: Failed to load required web classes
java.lang.NoClassDefFoundError: javax/servlet/Filter

有帮助吗?谢谢

[编辑] 忘记将 jar 添加到项目中!

I am using spring-security for a desktop application, below is my XML file

<?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"
xsi:schemaLocation="http://www.springframework.org/schema/beans      
           http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
           http://www.springframework.org/schema/security
           http://www.springframework.org/schema/security/spring-security-3.1.xsd" >

<bean id='myProvider' class='MyAuthenticationProvider'/>
<security:authentication-manager>
    <security:authentication-provider ref='MyAuthenticationProvider' />
</security:authentication-manager>  

<bean id='authenticationHolder' class='AuthenticationHolder' />
<bean scope="request" factory-bean="authenticationHolder" factory-method="getAuthentication" >
    <security:user-service id="userDetailsService">
        <security:user name="testUser" password="testPassword" authorities="ROLE_USER"/>
    </security:user-service>
</bean>
<bean class="org.springframework.security.authentication.encoding.Md5PasswordEncoder" id="passwordEncoder"/>

<bean id="accessDecisionManager" class="org.springframework.security.vote.AffirmativeBased">
    <property name="decisionVoters">
        <list>
            <bean class="org.springframework.security.vote.RoleVoter">
                <property name="rolePrefix" value="MY_PREFIX_" />
            </bean>
        </list>
    </property>
</bean>

<security:global-method-security secured-annotations="enabled" 
            access-decision-manager-ref="accessDecisionManager" />

When running I am getting this exception

SEVERE: Failed to load required web classes
java.lang.NoClassDefFoundError: javax/servlet/Filter

Any help? thanks

[EDIT]
forgot to add jar to project!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文