Announcement Announcement Module
Collapse
No announcement yet.
Error creating bean with name 'daoAuthenticationProvider' Page Title Module
Move Remove Collapse
This topic is closed
X
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Error creating bean with name 'daoAuthenticationProvider'

    I am getting a:
    SEVERE: Context initialization failed
    error when Tomcat failed to start my webapp.

    I am using acegi. I believe the error occurs when creating this bean:

    <bean id="authenticationDao"
    class="net.sf.acegisecurity.providers.dao.jdbc.Jdb cDaoImpl">
    <property name="dataSource">
    <ref bean="dataSource"/>
    </property>
    <property name="usersByUsernameQuery">
    <value>select login,password,'true' from User where login = ?</value>
    </property>
    <property name="authoritiesByUsernameQuery">
    <value>SELECT u.login, a.authority FROM user u, authorities a WHERE u.login = ? and u.UserId = a.loginId</value>
    </property>

    </bean>

    The tomcat log reveals:
    Error creating bean with name 'daoAuthenticationProvider' defined in resource [/WEB-INF/proto-security.xml] of Servlet Context: initialization of bean failed; nested exception is java.lang.NoClassDefFoundError: org/springframework/util/Assert...

    Does anyone have an idea what is causing this to occur?

    Thanks for any help.

  • #2
    Hi, you are probably missing required Spring classes from your classpath. Try including spring.jar on your classpath.

    Comment


    • #3
      Thanks for responding.

      I have spring.jar in both the Web-inf/lib directory and the <tomcat-home>/server/lib directory.

      Comment


      • #4
        You do not need it in your server/lib folder. It might even give your problems if you have it in both locations.

        If that does not help I would try it first without the two queries, just to see if these two properties give the problem.

        Comment


        • #5
          yeah, including same .jar twice (with same name) is just asking for trouble

          looks like you're using Acegi version < 1.0? package path's imply so. If not, change those
          to org.acegisecurity.

          Comment


          • #6
            I removed spring.jar from <tomcat-home>/server/lib and removed the 2 queries from <bean id="authenticationDao"...>.

            I still get the same exception. Here is part of the exception:

            nit>
            INFO: SQLErrorCodes loaded: [HSQL Database Engine, Oracle, Sybase SQL Server, Mi
            crosoft SQL Server, Informix Dynamic Server, PostgreSQL, DB2*, MySQL]
            Dec 28, 2005 9:27:05 AM org.springframework.jdbc.support.SQLErrorCodesFact ory ge
            tErrorCodes
            INFO: Looking up default SQLErrorCodes for DataSource
            Dec 28, 2005 9:27:05 AM org.springframework.jdbc.support.SQLErrorCodesFact ory ge
            tErrorCodes
            INFO: Database Product Name is MySQL
            Dec 28, 2005 9:27:05 AM org.springframework.jdbc.support.SQLErrorCodesFact ory ge
            tErrorCodes
            INFO: Driver Version is mysql-connector-java-3.0.15-ga ( $Date: 2004/08/09 22:15
            :11 $, $Revision: 1.27.2.43 $ )
            Dec 28, 2005 9:27:05 AM org.springframework.beans.factory.support.Abstract BeanFa
            ctory getBean
            INFO: Creating shared instance of singleton bean 'requirementDaoManager'
            Dec 28, 2005 9:27:05 AM org.springframework.beans.factory.support.Abstract BeanFa
            ctory getBean
            INFO: Creating shared instance of singleton bean 'securityEnforcementFilter'
            Dec 28, 2005 9:27:05 AM org.springframework.beans.factory.support.Abstract BeanFa
            ctory getBean
            INFO: Creating shared instance of singleton bean 'filterInvocationInterceptor'
            Dec 28, 2005 9:27:05 AM org.springframework.beans.factory.support.Abstract BeanFa
            ctory getBean
            INFO: Creating shared instance of singleton bean 'authenticationManager'
            Dec 28, 2005 9:27:05 AM org.springframework.beans.factory.support.Abstract BeanFa
            ctory getBean
            INFO: Creating shared instance of singleton bean 'daoAuthenticationProvider'
            Dec 28, 2005 9:27:05 AM org.springframework.beans.factory.support.Abstract BeanFa
            ctory getBean
            INFO: Creating shared instance of singleton bean 'authenticationDao'
            Dec 28, 2005 9:27:05 AM org.springframework.jdbc.support.SQLErrorCodesFact ory ge
            tErrorCodes
            INFO: Looking up default SQLErrorCodes for DataSource
            Dec 28, 2005 9:27:05 AM org.springframework.jdbc.support.SQLErrorCodesFact ory ge
            tErrorCodes
            INFO: Database product name found in cache for DataSource [org.springframework.j
            dbc.datasource.DriverManagerDataSource@15d616e]. Name is 'MySQL'.
            Dec 28, 2005 9:27:05 AM org.springframework.jdbc.support.SQLErrorCodesFact ory ge
            tErrorCodes
            INFO: Looking up default SQLErrorCodes for DataSource
            Dec 28, 2005 9:27:05 AM org.springframework.jdbc.support.SQLErrorCodesFact ory ge
            tErrorCodes
            INFO: Database product name found in cache for DataSource [org.springframework.j
            dbc.datasource.DriverManagerDataSource@15d616e]. Name is 'MySQL'.
            Dec 28, 2005 9:27:05 AM org.springframework.jdbc.object.RdbmsOperation compile
            INFO: RdbmsOperation with SQL [SELECT username,password,enabled FROM users WHERE
            username = ?] compiled
            Dec 28, 2005 9:27:05 AM org.springframework.jdbc.support.SQLErrorCodesFact ory ge
            tErrorCodes
            INFO: Looking up default SQLErrorCodes for DataSource
            Dec 28, 2005 9:27:05 AM org.springframework.jdbc.support.SQLErrorCodesFact ory ge
            tErrorCodes
            INFO: Database product name found in cache for DataSource [org.springframework.j
            dbc.datasource.DriverManagerDataSource@15d616e]. Name is 'MySQL'.
            Dec 28, 2005 9:27:05 AM org.springframework.jdbc.object.RdbmsOperation compile
            INFO: RdbmsOperation with SQL [SELECT username,authority FROM authorities WHERE
            username = ?] compiled
            Dec 28, 2005 9:27:05 AM org.springframework.beans.factory.support.Abstract BeanFa
            ctory destroySingletons
            INFO: Destroying singletons in factory {org.springframework.beans.factory.suppor
            t.DefaultListableBeanFactory defining beans [dataSource,sessionFactory,transacti
            onManager,requirementDao,requirementDaoManager,mes sageSource,securityEnforcement
            Filter,authenticationProcessingFilter,integrationF ilter,authenticationEntryPoint
            ,filterInvocationInterceptor,authenticationManager ,daoAuthenticationProvider,aut
            henticationDao,accessDecisionManager,roleVoter]; Root of BeanFactory hierarchy}
            Dec 28, 2005 9:27:05 AM org.springframework.orm.hibernate.LocalSessionFact oryBea
            n destroy
            INFO: Closing Hibernate SessionFactory
            Dec 28, 2005 9:27:05 AM net.sf.hibernate.impl.SessionFactoryImpl close
            INFO: closing
            Dec 28, 2005 9:27:05 AM org.springframework.web.context.ContextLoader initWebApp
            licationContext
            SEVERE: Context initialization failed
            org.springframework.beans.factory.BeanCreationExce ption: Error creating bean wit
            h name 'securityEnforcementFilter' defined in resource [/WEB-INF/proto-security.
            xml] of ServletContext: Can't resolve reference to bean 'filterInvocationInterce
            ptor' while setting property 'filterSecurityInterceptor'; nested exception is or
            g.springframework.beans.factory.BeanCreationExcept ion: Error creating bean with
            name 'filterInvocationInterceptor' defined in resource [/WEB-INF/proto-security.
            xml] of ServletContext: Can't resolve reference to bean 'authenticationManager'
            while setting property 'authenticationManager'; nested exception is org.springfr
            amework.beans.factory.BeanCreationException: Error creating bean with name 'auth
            enticationManager' defined in resource [/WEB-INF/proto-security.xml] of ServletC
            ontext: Can't resolve reference to bean 'daoAuthenticationProvider' while settin
            g property 'providers[0]'; nested exception is org.springframework.beans.factory
            .BeanCreationException: Error creating bean with name 'daoAuthenticationProvider
            ' defined in resource [/WEB-INF/proto-security.xml] of ServletContext: Initializ
            ation of bean failed; nested exception is java.lang.NoClassDefFoundError: org/sp
            ringframework/util/Assert
            org.springframework.beans.factory.BeanCreationExce ption: Error creating bean wit
            h name 'filterInvocationInterceptor' defined in resource [/WEB-INF/proto-securit
            y.xml] of ServletContext: Can't resolve reference to bean 'authenticationManager
            ' while setting property 'authenticationManager'; nested exception is org.spring
            framework.beans.factory.BeanCreationException: Error creating bean with name 'au
            thenticationManager' defined in resource [/WEB-INF/proto-security.xml] of Servle
            tContext: Can't resolve reference to bean 'daoAuthenticationProvider' while sett
            ing property 'providers[0]'; nested exception is org.springframework.beans.facto
            ry.BeanCreationException: Error creating bean with name 'daoAuthenticationProvid
            er' defined in resource [/WEB-INF/proto-security.xml] of ServletContext: Initial
            ization of bean failed; nested exception is java.lang.NoClassDefFoundError: org/
            springframework/util/Assert
            org.springframework.beans.factory.BeanCreationExce ption: Error creating bean wit
            h name 'authenticationManager' defined in resource [/WEB-INF/proto-security.xml]
            of ServletContext: Can't resolve reference to bean 'daoAuthenticationProvider'
            while setting property 'providers[0]'; nested exception is org.springframework.b
            eans.factory.BeanCreationException: Error creating bean with name 'daoAuthentica
            tionProvider' defined in resource [/WEB-INF/proto-security.xml] of ServletContex
            t: Initialization of bean failed; nested exception is java.lang.NoClassDefFoundE
            rror: org/springframework/util/Assert
            org.springframework.beans.factory.BeanCreationExce ption: Error creating bean wit
            h name 'daoAuthenticationProvider' defined in resource [/WEB-INF/proto-security.
            xml] of ServletContext: Initialization of bean failed; nested exception is java.
            lang.NoClassDefFoundError: org/springframework/util/Assert
            java.lang.NoClassDefFoundError: org/springframework/util/Assert
            at net.sf.acegisecurity.providers.dao.DaoAuthenticati onProvider.afterPro
            pertiesSet(DaoAuthenticationProvider.java:200)
            at org.springframework.beans.factory.support.Abstract AutowireCapableBean
            Factory.invokeInitMethods(AbstractAutowireCapableB eanFactory.java:991)
            at org.springframework.beans.factory.support.Abstract AutowireCapableBean
            Factory.createBean(AbstractAutowireCapableBeanFact ory.java:288)
            at org.springframework.beans.factory.support.Abstract AutowireCapableBean
            Factory.createBean(AbstractAutowireCapableBeanFact ory.java:208)
            at org.springframework.beans.factory.support.Abstract BeanFactory.getBean
            (AbstractBeanFactory.java:204)
            at org.springframework.beans.factory.support.Abstract BeanFactory.getBean
            (AbstractBeanFactory.java:136)
            at org.springframework.beans.factory.support.Abstract AutowireCapableBean
            Factory.resolveReference(AbstractAutowireCapableBe anFactory.java:903)
            at org.springframework.beans.factory.support.Abstract AutowireCapableBean
            Factory.resolveValueIfNecessary(AbstractAutowireCa pableBeanFactory.java:844)
            at org.springframework.beans.factory.support.Abstract AutowireCapableBean
            Factory.resolveManagedList(AbstractAutowireCapable BeanFactory.java:921)
            at org.springframework.beans.factory.support.Abstract AutowireCapableBean
            Factory.resolveValueIfNecessary(AbstractAutowireCa pableBeanFactory.java:849)
            at org.springframework.beans.factory.support.Abstract AutowireCapableBean
            Factory.applyPropertyValues(AbstractAutowireCapabl eBeanFactory.java:785)
            at org.springframework.beans.factory.support.Abstract AutowireCapableBean
            Factory.populateBean(AbstractAutowireCapableBeanFa ctory.java:637)
            at org.springframework.beans.factory.support.Abstract AutowireCapableBean
            Factory.createBean(AbstractAutowireCapableBeanFact ory.java:271)
            at org.springframework.beans.factory.support.Abstract AutowireCapableBean
            Factory.createBean(AbstractAutowireCapableBeanFact ory.java:208)
            at org.springframework.beans.factory.support.Abstract BeanFactory.getBean
            (AbstractBeanFactory.java:204)
            at org.springframework.beans.factory.support.Abstract BeanFactory.getBean
            (AbstractBeanFactory.java:136)
            at org.springframework.beans.factory.support.Abstract AutowireCapableBean
            Factory.resolveReference(AbstractAutowireCapableBe anFactory.java:903)
            at ...

            Comment


            • #7
              Here is a snippet of my proto-security.xml file:

              <!-- = = = = = = = = AUTHENTICATION = = = = = = = -->

              <bean id="authenticationManager"
              class="net.sf.acegisecurity.providers.ProviderMana ger">
              <property name="providers">
              <list>
              <ref bean="daoAuthenticationProvider"/>
              </list>
              </property>
              </bean>

              <bean id="daoAuthenticationProvider"
              class="net.sf.acegisecurity.providers.dao.DaoAuthe nticationProvider">
              <property name="authenticationDao"><ref bean="authenticationDao"/></property>
              </bean>

              <bean id="authenticationDao"
              class="net.sf.acegisecurity.providers.dao.jdbc.Jdb cDaoImpl">
              <property name="dataSource">
              <ref bean="dataSource"/>
              </property>
              <!--
              <property name="usersByUsernameQuery">
              <value>select login,password,enabled as 'true' from User where login = ?</value>
              </property>
              <property name="authoritiesByUsernameQuery">
              <value>SELECT u.login, a.authority FROM user u, authorities a WHERE u.login = ? and u.UserId = a.loginId</value>
              </property>
              -->
              </bean>

              I have acegi-security-0.8.2.jar in my web-inf/lib directory. This jar has package names beginning with: net\sf\acegisecurity\...

              I also have acegi-security.jar and acegi-security-catalina-server.jar in my <tomcat-home>/server/lib directory. The acegi-security.jar has package names also beginning with: net\sf\acegisecurity\...

              Is there a newer jar file I should be using which supports package: org.acegisecurity ?

              Thanks for your help.

              Comment


              • #8
                I would definitely start with acegi 1.0.0rc1, another thing I would NOT do is place jars into the server/lib folder. I would always place them into your web-inf lib folder. This is much easier to deploy and use. If you want to run multiple applications in your server you could run into problems if you must use different versions.

                Comment


                • #9
                  I am now using acegi-security-1.0.0.0-RC1.jar. I modified my xml file to the new package name: org.acegisecurity.*. Tomcat throws the following exception when it is trying to load the spring context:

                  SEVERE: Context initialization failed
                  org.springframework.beans.factory.BeanDefinitionSt oreException: Error registerin
                  g bean with name 'authenticationDao' defined in ServletContext resource [/WEB-IN
                  F/proto-security.xml]: Bean class [org.acegisecurity.providers.dao.jdbc.JdbcDaoI
                  mpl] not found; nested exception is java.lang.ClassNotFoundException: org.acegis
                  ecurity.providers.dao.jdbc.JdbcDaoImpl
                  java.lang.ClassNotFoundException: org.acegisecurity.providers.dao.jdbc.JdbcDaoIm
                  pl
                  at org.apache.catalina.loader.WebappClassLoader.loadC lass(WebappClassLoa
                  der.java:1332)
                  at org.apache.catalina.loader.WebappClassLoader.loadC lass(WebappClassLoa
                  der.java:1181)
                  at java.lang.ClassLoader.loadClassInternal(Unknown Source)
                  at java.lang.Class.forName0(Native Method)


                  Are you guys seeing the org.acegisecurity.providers.dao.jdbc.JdbcDaoImpl class file in the acegi-security-1.0.0.0-RC1.jar file?

                  Your help is appreciated.

                  Comment


                  • #10
                    JdbcDaoImpl's package is relocated as org.acegisecurity.userdetails.jdbc

                    see also
                    http://acegisecurity.sourceforge.net...e-080-090.html
                    http://acegisecurity.sourceforge.net...e-090-100.html

                    Comment


                    • #11
                      Hi Feenixx,

                      Thanks for links. That was very helpful. I have gotten further. I now get the following exception when Tomcat tries to bring up the webapp:

                      ++++++++++++++++++++++++++++++++++++++++++++

                      SEVERE: Context initialization failed
                      org.springframework.beans.factory.BeanCreationExce ption: Error creating bean wit
                      h name 'securityEnforcementFilter' defined in ServletContext resource [/WEB-INF/
                      proto-security.xml]: Can't resolve reference to bean 'filterInvocationIntercepto
                      r' while setting property 'filterSecurityInterceptor'
                      ; nested exception is org.s
                      pringframework.beans.factory.BeanCreationException : Error creating bean with nam
                      e 'filterInvocationInterceptor' defined in ServletContext resource [/WEB-INF/pro
                      to-security.xml]: Initialization of bean failed; nested exception is java.lang.N
                      oClassDefFoundError: org/apache/oro/text/regex/PatternMatcher
                      org.springframework.beans.factory.BeanCreationExce ption: Error creating bean wit
                      h name 'filterInvocationInterceptor' defined in ServletContext resource [/WEB-IN
                      F/proto-security.xml]: Initialization of bean failed; nested exception is java.l
                      ang.NoClassDefFoundError: org/apache/oro/text/regex/PatternMatcher
                      java.lang.NoClassDefFoundError: org/apache/oro/text/regex/PatternMatcher

                      ++++++++++++++++++++++++++++++++++++++++++++

                      My xml file which configures acegi is as follows:

                      ++++++++++++++++++++++++++++++++++++++++++++

                      <?xml version="1.0" encoding="UTF-8"?>
                      <!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN"
                      "http://www.springframework.org/dtd/spring-beans.dtd">


                      <beans>


                      <bean id="securityEnforcementFilter"
                      class="org.acegisecurity.intercept.web.SecurityEnf orcementFilter">
                      <property name="filterSecurityInterceptor"> <ref bean="filterInvocationInterceptor"/>
                      </property>
                      <property name="authenticationEntryPoint">
                      <ref bean="authenticationEntryPoint"/>
                      </property>
                      </bean>

                      <bean id="authenticationProcessingFilter"
                      class="org.acegisecurity.ui.webapp.AuthenticationP rocessingFilter">
                      <property name="filterProcessesUrl">
                      <value>/j_acegi_security_check</value>
                      </property>
                      <property name="authenticationFailureUrl">
                      <value>/jsp/login.jsp?failed=true</value>
                      </property>
                      <property name="defaultTargetUrl">
                      <value>/</value>
                      </property>
                      <property name="authenticationManager">
                      <ref bean="authenticationManager"/>
                      </property>
                      </bean>


                      <bean id="httpSessionContextIntegrationFilter"
                      class="org.acegisecurity.context.HttpSessionContex tIntegrationFilter">
                      <property name="context">
                      <value>org.acegisecurity.context.SecureContextImpl </value>
                      </property>
                      </bean>

                      <bean id="authenticationEntryPoint"
                      class="org.acegisecurity.ui.webapp.AuthenticationP rocessingFilterEntryPoint">
                      <property name="loginFormUrl">
                      <value>/jsp/login.jsp</value>
                      </property>
                      </bean>



                      <bean id="filterInvocationInterceptor"
                      class="org.acegisecurity.intercept.web.FilterSecur ityInterceptor">
                      <property name="authenticationManager">
                      <ref bean="authenticationManager"/>
                      </property>
                      <property name="accessDecisionManager">
                      <ref bean="accessDecisionManager"/>
                      </property>

                      <property name="objectDefinitionSource">
                      <value>
                      CONVERT_URL_TO_LOWERCASE_BEFORE_COMPARISON
                      \A/admin/.*\Z=ROLE_ADMIN
                      \A/com/.*\Z=ROLE_COM
                      </value>
                      </property>

                      </bean>



                      <bean id="authenticationManager"
                      class="org.acegisecurity.providers.ProviderManager ">
                      <property name="providers">
                      <list>
                      <ref bean="daoAuthenticationProvider"/>
                      </list>
                      </property>
                      </bean>

                      <bean id="daoAuthenticationProvider"
                      class="org.acegisecurity.providers.dao.DaoAuthenti cationProvider">
                      <property name="userDetailsService"><ref bean="authenticationDao"/></property>
                      </bean>

                      <bean id="authenticationDao"
                      class="org.acegisecurity.userdetails.jdbc.JdbcDaoI mpl">
                      <property name="dataSource">
                      <ref bean="dataSource"/>
                      </property>

                      <property name="usersByUsernameQuery">
                      <value>select login,password,enabled as 'true' from User where login = ?</value>
                      </property>
                      <property name="authoritiesByUsernameQuery">
                      <value>SELECT u.login, a.authority FROM user u, authorities a WHERE u.login = ? and u.UserId = a.loginId</value>
                      </property>

                      </bean>

                      <bean id="accessDecisionManager"
                      class="org.acegisecurity.vote.AffirmativeBased">
                      <property name="allowIfAllAbstainDecisions"><value>false</value></property>
                      <property name="decisionVoters">
                      <list>
                      <ref bean="roleVoter"/>
                      </list>
                      </property>
                      </bean>

                      <bean id="roleVoter" class="org.acegisecurity.vote.RoleVoter"/>
                      </beans>

                      ++++++++++++++++++++++++++++++++++++++++++++

                      Comment


                      • #12
                        PatternMatcher is part of jakarta-oro package. Acegi seems do have dependency with this one? I dunno if this dependency is documented somewhere, but try including jakarta-oro in your
                        classpath aswell.
                        Last edited by feenixx; Dec 29th, 2005, 02:05 AM.

                        Comment


                        • #13
                          Thanks Feenixx,

                          This seemed to get me going using acegi security. I do have another problem when upgrading from hibernate2 to hibernate3, though.

                          Thanks again.

                          Comment


                          • #14
                            Originally posted by pdecker
                            Thanks Feenixx,

                            This seemed to get me going using acegi security. I do have another problem when upgrading from hibernate2 to hibernate3, though.

                            Thanks again.
                            No problem. What's your problem with hibernate, is it acegi or spring related?

                            Comment


                            • #15
                              Hi Feenixx,

                              Thanks for asking. I found out that I had to change some springframework package names from ...hibernate.. to ...hibernate3... in some of the xml files and source code itself.

                              Comment

                              Working...
                              X