0

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

Aashish Gulabani
  • 141
  • 6
  • 24
  • your problem is with the DB connection, verify from the new server the DB is accessible and the DB-URL you are using its correct – cralfaro Apr 26 '17 at 15:43
  • My DB is accessible the putty ssh terminal. If you meant that then i think its not a problem. Or can you suggest me some way me re verify it – Aashish Gulabani Apr 26 '17 at 15:58
  • you need to verify that since the server where the webapp is running can access the DB ip, you can execute a ping to verify it – cralfaro Apr 27 '17 at 08:29
  • id DB ip different from server ip? Sorry for naive questions..i am new to spring. – Aashish Gulabani Apr 27 '17 at 08:33
  • no worries. Your first step is verify from the server where is running your webapp, have access to the DB, usuarlly your spring DB connection its an IP, then connect by ssh to the amazon server, and run "ping DB-IP" with your IP from the datasource, and verify if its ping working – cralfaro Apr 27 '17 at 08:39
  • Yes..that seems to work fine. I don't think there is issue with DB. I think http://stackoverflow.com/a/32332231/4248165 might help me, according to which i am trying to create a target directory under my /webapps/ROOT/ folder, but i am facing permission issues. – Aashish Gulabani Apr 27 '17 at 08:46
  • I think the exception message would be different, but yeah maybe, try to debug the stacktrace maybe you are in the right way – cralfaro Apr 27 '17 at 08:57
  • i tried to create a directory target/index directory but it didn't help. Still the same error – Aashish Gulabani Apr 27 '17 at 09:04
  • Let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/142809/discussion-between-cralfaro-and-aashish-gulabani). – cralfaro Apr 27 '17 at 09:08

0 Answers0