Reputation: 17327
I'm getting the error below while trying to deploy my jsf project with spring security integrated. I just started using Spring security today since the java ee security with the security realms were too much of an hassle. I watched this tutorial. So I'm not sure what this error means really. I also started gradle today so I included the dependencies I put there just in case.
(I'll put the error as quote at the bottom of the page).
cannot Deploy InscriptionTemp2 deploy is failing=Error occurred during deployment: Exception while loading the app : java.lang.IllegalStateException: ContainerBase.addChild: start: org.apache.catalina.LifecycleException: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.security.filterChains': Cannot resolve reference to bean 'org.springframework.security.web.DefaultSecurityFilterChain#1' while setting bean property 'sourceList' with key [1]; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.security.web.DefaultSecurityFilterChain#1': Cannot resolve reference to bean 'org.springframework.security.web.authentication.UsernamePasswordAuthenticationFilter#0' while setting constructor argument with key [6]; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.security.web.authentication.UsernamePasswordAuthenticationFilter#0': Cannot resolve reference to bean 'org.springframework.security.authentication.ProviderManager#0' while setting bean property 'authenticationManager'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.security.authentication.ProviderManager#0': Cannot resolve reference to bean 'org.springframework.security.config.authentication.AuthenticationManagerFactoryBean#0' while setting constructor argument; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.security.config.authentication.AuthenticationManagerFactoryBean#0': FactoryBean threw exception on object creation; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.security.authenticationManager': Cannot resolve reference to bean 'org.springframework.security.authentication.dao.DaoAuthenticationProvider#0' while setting constructor argument with key [0]; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.security.authentication.dao.DaoAuthenticationProvider#0': Cannot resolve reference to bean 'org.springframework.security.provisioning.JdbcUserDetailsManager#0' while setting bean property 'userDetailsService'; nested exception is org.springframework.beans.factory.CannotLoadBeanClassException: Error loading class [org.springframework.security.provisioning.JdbcUserDetailsManager] for bean with name 'org.springframework.security.provisioning.JdbcUserDetailsManager#0' defined in null: problem with class file or dependent class; nested exception is java.lang.NoClassDefFoundError: org/springframework/jdbc/core/support/JdbcDaoSupport. Please see server.log for more details.
applicationContext.xml
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
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:util="http://www.springframework.org/schema/util"
xmlns:task="http://www.springframework.org/schema/task"
xmlns:sec="http://www.springframework.org/schema/security"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.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/util http://www.springframework.org/schema/util/spring-util.xsd
http://www.springframework.org/schema/task http://www.springframework.org/schema/task/spring-task.xsd
http://www.springframework.org/schema/security http://www.springframework.org/schema/security/spring-security.xsd">
<!-- begin Spring Security config -->
<sec:global-method-security secured-annotations="enabled" />
<!-- Don't SSL encrypt static resources -->
<sec:http pattern="/resources/**" security="none"/>
<sec:http auto-config="true" >
<!-- On Glassfish, dev ports are 8080 and 8181, whereas on
production its 80 and 443 -->
<sec:port-mappings>
<sec:port-mapping http="8080" https="8181"/>
</sec:port-mappings>
<sec:intercept-url
pattern="/faces/restricted/user/**"
access="ROLE_ADMIN, ROLE_ADMIN" requires-channel="https" />
<sec:intercept-url
pattern="/faces/restricted/admins/**"
access="ROLE_ADMIN" requires-channel="https" />
<sec:intercept-url
pattern="/**"
access="IS_AUTHENTICATED_ANONYMOUSLY"/>
<!-- Use O/S provided login window
<http-basic />
-->
<!-- Use custom form for login -->
<sec:form-login
login-processing-url="/j_spring_security_check"
login-page="/faces/login.xhtml"
authentication-success-handler-ref="myAuthenticationHandler"
authentication-failure-url="/faces/loginerror.xhtml"/>
<sec:logout logout-url="/j_spring_security_logout"
invalidate-session="true"
logout-success-url="/faces/index.xhtml" />
</sec:http>
<sec:authentication-manager alias="authenticationManager">
<sec:authentication-provider>
<sec:password-encoder ref="encoderBean">
<sec:salt-source user-property="username"/>
</sec:password-encoder>
<sec:jdbc-user-service data-source-ref="dataSource" />
<!-- if not using a database for accounts, hard-code them here
<sec:user-service>
<sec:user name="admin" password="admin" authorities="ROLE_ADMIN, ROLE_MEMBER" />
<sec:user name="member" password="member" authorities="ROLE_MEMBER" />
</sec:user-service>
-->
</sec:authentication-provider>
</sec:authentication-manager>
<bean id="myAuthenticationHandler" class="com.activee.utils.MyAuthenticationHandler" />
<bean id="encoderBean" class="org.springframework.security.authentication.encoding.ShaPasswordEncoder">
<constructor-arg value="512" />
<property name="iterations" value="1024"/>
</bean>
<!-- Server managed connection pool accessed via JNDI -->
<jee:jndi-lookup id="dataSource" jndi-name="jdbc/inscriptiontestDS"/>
</beans>
my gradle dependencies:
dependencies {
compile 'org.springframework.security:spring-security-web:4.0.1.RELEASE'
compile 'org.springframework.security:spring-security-config:4.0.1.RELEASE'
compile 'org.springframework.security:spring-security-core:4.0.1.RELEASE'
}
my web.xml
<!-- Security configuration
<listener>
<listener-class>org.springframework.web.context.request.RequestContextListener</listener-class>
</listener> -->
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>classpath:applicationContext.xml</param-value>
</context-param>
<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>
<!-- end spring configuration -->
and as promised for your greatest pleasure, the error as quote :
cannot Deploy InscriptionTemp2 deploy is failing=Error occurred during deployment: Exception while loading the app : java.lang.IllegalStateException: ContainerBase.addChild: start: org.apache.catalina.LifecycleException: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.security.filterChains': Cannot resolve reference to bean 'org.springframework.security.web.DefaultSecurityFilterChain#1' while setting bean property 'sourceList' with key 1; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.security.web.DefaultSecurityFilterChain#1': Cannot resolve reference to bean 'org.springframework.security.web.authentication.UsernamePasswordAuthenticationFilter#0' while setting constructor argument with key [6]; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.security.web.authentication.UsernamePasswordAuthenticationFilter#0': Cannot resolve reference to bean 'org.springframework.security.authentication.ProviderManager#0' while setting bean property 'authenticationManager'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.security.authentication.ProviderManager#0': Cannot resolve reference to bean 'org.springframework.security.config.authentication.AuthenticationManagerFactoryBean#0' while setting constructor argument; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.security.config.authentication.AuthenticationManagerFactoryBean#0': FactoryBean threw exception on object creation; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.security.authenticationManager': Cannot resolve reference to bean 'org.springframework.security.authentication.dao.DaoAuthenticationProvider#0' while setting constructor argument with key [0]; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.security.authentication.dao.DaoAuthenticationProvider#0': Cannot resolve reference to bean 'org.springframework.security.provisioning.JdbcUserDetailsManager#0' while setting bean property 'userDetailsService'; nested exception is org.springframework.beans.factory.CannotLoadBeanClassException: Error loading class [org.springframework.security.provisioning.JdbcUserDetailsManager] for bean with name 'org.springframework.security.provisioning.JdbcUserDetailsManager#0' defined in null: problem with class file or dependent class; nested exception is java.lang.NoClassDefFoundError: org/springframework/jdbc/core/support/JdbcDaoSupport. Please see server.log for more details.
and I'll put my login bean here because I find it weird.
public LoginBean() {
}
public String doLogin() throws IOException, ServletException {
ExternalContext context = FacesContext.getCurrentInstance()
.getExternalContext();
RequestDispatcher dispatcher = ((ServletRequest) context.getRequest())
.getRequestDispatcher("/j_spring_security_check?j_username="
+ userName + "&j_password=" + password);
// Forwards to original destination or to error page
dispatcher.forward((ServletRequest) context.getRequest(),
(ServletResponse) context.getResponse());
FacesContext.getCurrentInstance().responseComplete();
// It's OK to return null here because Faces is just going to exit.
return null;
}
//get&sets
}
Upvotes: 0
Views: 6409
Reputation: 12337
Your 'reasoning' of the cause is wrong. Yes, the reference to the bean cannot be respolved because the bean cannot be created which in turn is caused by:
java.lang.NoClassDefFoundError: org/springframework/jdbc/core/support/JdbcDaoSupport. Please see server.log for more details.
Which can be found in the last line of your stacktrace
Upvotes: 1