1

I am trying to automatically create the database schema and populate it with reference data.

To do this, I set up the sessionFactory bean int the hibernate-context.xml files as follows:

<beans:bean id="sessionFactory" class="org.springframework.orm.hibernate4.LocalSessionFactoryBean">
    <beans:property name="dataSource" ref="dataSource"/>
    <beans:property name="packagesToScan" value="com.pp" />
    <beans:property name="hibernateProperties">
        <beans:props>
            <beans:prop key="hibernate.dialect">org.hibernate.dialect.Oracle10gDialect</beans:prop>

            <beans:prop key="hibernate.show_sql">true</beans:prop>
            <beans:prop key="hibernate.format_sql">true</beans:prop>
            <beans:prop key="hibernate.use_sql_comments">true</beans:prop>
            <beans:prop key="hibernate.hbm2ddl.auto">create-drop</beans:prop>
            <beans:prop key="hibernate.hbm2ddl.import_files_sql_extractor">org.hibe‌​rnate.tool.hbm2ddl.M‌​ultipleLinesSqlComma‌​ndExtractor</beans:prop>

            <beans:prop key="entitymanager.packages.to.scan">com.pp.model</beans:prop>
            <beans:prop key="hibernate.default_schema">USER_PP_SCHEMA</beans:prop>
        </beans:props> 
    </beans:property>
</beans:bean>

I have the following error:

[localhost-startStop-1] 10:21:20,192 ERROR org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:319) - Context initialization failed org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.security.filterChains': Cannot resolve reference to bean 'org.springframework.security.web.DefaultSecurityFilterChain#4' while setting bean property 'sourceList' with key [4]; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.security.web.DefaultSecurityFilterChain#4': Cannot resolve reference to bean 'org.springframework.security.web.authentication.UsernamePasswordAuthenticationFilter#0' while setting constructor argument with key [3]; 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 'customAuthenticationProvider' while setting constructor argument with key [0]; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'customAuthenticationProvider': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private com.pp.dao.UserDAO com.immochan.mercure.service.CustomAuthenticationProvider.userDAO; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'userDAOImpl': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: protected org.hibernate.SessionFactory com.immochan.mercure.dao.MercureDAOImpl.sessionFactory; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory' defined in ServletContext resource [/WEB-INF/spring/hibernate-context.xml]: Invocation of init method failed; nested exception is org.hibernate.service.spi.ServiceException: Unable to create requested service [org.hibernate.tool.hbm2ddl.ImportSqlCommandExtractor] at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:329) ...

This error is due to the multipleLinesSqlCommandExtractor bean property, because when I pipe this line out, it works properly.

<beans:prop key="hibernate.hbm2ddl.import_files_sql_extractor">org.hibe‌​rnate.tool.hbm2ddl.M‌​ultipleLinesSqlComma‌​ndExtractor</beans:prop>

Any idea?

ROMANIA_engineer
  • 54,432
  • 29
  • 203
  • 199

0 Answers0