springframework: Error creating bean with name 

2019-09-11 03:27发布

I have a maven project which has spring framework integrated in it and i used this project to build web services for the mobile app. The project gives BeanCreationException when i deploy it on AWS ubuntu server and it fails to run on tomcat7. Where as it works fine when i run it in local environment. Below is the error log of tomcat7.

WARN [localhost-startStop-1] DirectoryProviderHelper.makeSanityCheckedDirectory(258) | HSEARCH000041: Index directory not found, creating: '/usr/share/tomcat7/baseapp-1.0/index'
ERROR [localhost-startStop-1] ContextLoader.initWebApplicationContext(318) | 
Context initialization failed
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'userService': Cannot resolve reference to bean 'userManager' while setting constructor argument; nested exception is org.springframework.beans.factory.BeanCreationException: 
Error creating bean with name 'userManager': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire method: public void com.washkart.www.service.impl.UserManagerImpl.setUserDao(com.washkart.www.dao.UserDao); nested exception is org.springframework.beans.factory.BeanCreationException: 
Error creating bean with name 'userDao': Injection of resource dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory' defined in class path resource [applicationContext-dao.xml]: Invocation of init method failed; nested exception is org.hibernate.search.SearchException: HSEARCH000103: Unable to initialize IndexManager com.washkart.www.model.User

My hibernate.cfg looks like this:

<!DOCTYPE hibernate-configuration PUBLIC "-//Hibernate/Hibernate Configuration DTD 3.0//EN"
"http://www.hibernate.org/dtd/hibernate-configuration-3.0.dtd">

<hibernate-configuration>
<session-factory>
    <mapping class="com.washkart.www.model.User"/>
    <mapping class="com.washkart.www.model.Role"/>
    <mapping class="com.washkart.www.model.WashUser"/>
    <mapping class="com.washkart.www.model.WashOrder"/>
    <mapping class="com.washkart.www.model.Service"/>
    <mapping class="com.washkart.www.model.Item"/>
    <mapping class="com.washkart.www.model.Device"/>
    <mapping class="com.washkart.www.model.Offer"/>
    <mapping class="com.washkart.www.model.Employee"/>
    <mapping class="com.washkart.www.model.Attendance"/>

    <mapping class="com.washkart.www.model.Rates"/>
</session-factory>
</hibernate-configuration>

And the applicationContext-dao.xml is:

<?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:context="http://www.springframework.org/schema/context"
   xsi:schemaLocation="http://www.springframework.org/schema/beans 
http://www.springframework.org/schema/beans/spring-beans-3.1.xsd
        http://www.springframework.org/schema/context 
http://www.springframework.org/schema/context/spring-context-3.1.xsd"
   default-lazy-init="true">

<bean class="org.springframework.orm.hibernate4.HibernateExceptionTranslator"/>
<bean class="org.springframework.dao.annotation.PersistenceExceptionTranslationPostProcessor"/>

<!-- Hibernate SessionFactory -->
<bean id="sessionFactory" class="org.springframework.orm.hibernate4.LocalSessionFactoryBean" destroy-method="destroy">
    <property name="dataSource" ref="dataSource"/>
    <property name="configLocation" value="classpath:hibernate.cfg.xml"/>
    <property name="hibernateProperties">
        <props>
            <prop key="hibernate.dialect">${hibernate.dialect}</prop>
            <prop key="hibernate.query.substitutions">true 'Y', false 'N'</prop>
            <prop key="hibernate.cache.use_second_level_cache">true</prop>
            <prop key="hibernate.cache.provider_class">org.hibernate.cache.EhCacheProvider</prop>
            <!-- Hibernate Search index directory -->
            <prop key="hibernate.search.default.indexBase">${app.search.index.basedir}</prop>
        </props>
        <!-- Turn batching off for better error messages under PostgreSQL -->
        <!-- hibernate.jdbc.batch_size=0 -->
    </property>
</bean>

<!-- Transaction manager for a single Hibernate SessionFactory (alternative to JTA) -->
<bean id="transactionManager" class="org.springframework.orm.hibernate4.HibernateTransactionManager">
    <property name="sessionFactory" ref="sessionFactory"/>
</bean>

<!-- Activates scanning of @Autowired -->
<context:annotation-config/>

<!-- Activates scanning of @Repository -->
<context:component-scan base-package="com.washkart.www.dao"/>

</beans>

The project works fine in one of the old AWS server but it crashes on new server. I am very new to spring security framework and don't have much idea about. The base project had spring security integrated.

Help me to resolve the error.

TIA

0条回答
登录 后发表回答