代码之家  ›  专栏  ›  技术社区  ›  Tiago Duque

春豆工厂看不到类

  •  0
  • Tiago Duque  · 技术社区  · 6 年前

    我正在开发一个使用jsf(mojarra)来控制de-mvc流的应用程序,但我也希望集成spring security以实现其身份验证和授权过程。

    但是,我遇到了一个问题,SpringBeanFactory无法实例化我为进行自定义登录而构建的类等等。从那里开始,系统甚至都不在线。

    stacktrace的开头是:

    java.lang.ClassNotFoundException: com.tfduque.fieldAssist.manager.LoginBean
    

    然后

    org.springframework.beans.factory.CannotLoadBeanClassException: Cannot find class [com.tfduque.fieldAssist.manager.LoginBean] for bean with name 'authenticationEntryPoint' defined in ServletContext resource [/WEB-INF/applicationContext.xml]; nested exception is java.lang.ClassNotFoundException: com.tfduque.fieldAssist.manager.LoginBean
    

    等等…

    ( Full stacktrace )

    如果重要的话,这就是我的文件夹的组织方式: Folder Organization

    我的应用程序上下文(用于Spring安全配置):

    <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.0.xsd
               http://www.springframework.org/schema/security
               http://www.springframework.org/schema/security/spring-security-3.1.xsd">
    
    
    
        <http pattern="/login*" security="none" />
        <http pattern="/css/**" security="none" />
        <http pattern="/images/**" security="none" />
        <http pattern="/javascript/**" security="none" />
    
        <http pattern="/Secured/**" create-session="stateless"
            use-expressions="true">
            <intercept-url pattern="/**" access="isFullyAuthenticated()" />
            <http-basic />
        </http>
    
        <http auto-config="true" use-expressions="true"
            access-decision-manager-ref="accessDecisionManager">
            <intercept-url pattern="/**" access="isFullyAuthenticated()" />
    
            <form-login login-page="/login.xhtml" login-processing-url="/j_login"
                authentication-failure-url="/login.xhtml" always-use-default-target="false"
                default-target-url="/" />
    
            <logout invalidate-session="true" logout-success-url="/login.xhtml"
                logout-url="/j_logout" delete-cookies="JSESSIONID" />
    
        </http>
    
        <authentication-manager>
            <authentication-provider user-service-ref="authenticationEntryPoint">
                <password-encoder hash="md5" />
            </authentication-provider>
        </authentication-manager>
    
        <beans:bean id="appUserDetailsService"
            class="com.tfduque.fieldAssist.security.AppUserDetailsService" />
    
        <beans:bean id="authenticationEntryPoint"
            class=" com.tfduque.fieldAssist.manager.LoginBean">
            <beans:property name="loginFormUrl" value="/Login.xhtml" />
            <beans:property name="redirectStrategy" ref="jsfRedirectStrategy" />
        </beans:bean>
    
    
    </beans:beans>
    

    我的一些web.xml配置(顺便说一句,我也在使用weld进行注入):

    <servlet>
            <servlet-name>Faces Servlet</servlet-name>
            <servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
            <load-on-startup>1</load-on-startup>
        </servlet>
        <servlet-mapping>
            <servlet-name>Faces Servlet</servlet-name>
            <url-pattern>*.xhtml</url-pattern>
        </servlet-mapping>
    
    
        <!-- Listeners -->
        <listener>
    
            <listener-class>org.jboss.weld.environment.servlet.Listener</listener-class>
    
        </listener>
    
        <resource-env-ref>
            <resource-env-ref-name>BeanManager</resource-env-ref-name>
            <resource-env-ref-type>javax.enterprise.inject.spi.BeanManager</resource-env-ref-type>
        </resource-env-ref>
    
        <!-- Security -->
    
        <listener>
            <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
        </listener>
    
        <listener>
            <listener-class>
                org.springframework.security.web.session.HttpSessionEventPublisher</listener-class>
        </listener>
    
        <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>
            <dispatcher>FORWARD</dispatcher>
            <dispatcher>REQUEST</dispatcher>
        </filter-mapping>
    

    登录bean的注释如下:

    @Named("login")
    @RequestScoped
    public class LoginBean {
    
    
        public String doLogin() throws IOException, ServletException {
           [...]
        }
    

    我认为这是理解问题的全部必要条件。

    0 回复  |  直到 6 年前