0

I have my build running locally with jetty, but when I try deploying the war on my aws server through tomcat6, I receive the error below. Originally, I was getting the Cannot create PoolableConnectionFactory, but I've since fixed my url to the db. Unfortunately, I don't see any other errors in my verbose logs other than the trace below. What else could be the issue? Or what else can I try instead? Any thoughts are appreciated!

ERROR org.springframework.web.context.ContextLoader - Context initialization failed org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'userManager' defined in ServletContext resource [/WEB-INF/applicationContext.xml]: Unsatisfied dependency expressed through constructor argument with index 0 of type [UserDaoImpl]: : No matching bean of type [UserDaoImpl] found for dependency: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: {}; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No matching bean of type [UserDaoImpl] found for dependency: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: {} at org.springframework.beans.factory.support.ConstructorResolver.createArgumentArray(ConstructorResolver.java:718) at org.springframework.beans.factory.support.ConstructorResolver.autowireConstructor(ConstructorResolver.java:194) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.autowireConstructor(AbstractAutowireCapableBeanFactory.java:993) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:897) at

UPDATE

I found the following in my logs and wonder if the way I've created my beans won't be processed properly on the server:

org.springframework.web.context.support.XmlWebApplicationContext - Bean 'sessionFactory' is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)

My 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:p="http://www.springframework.org/schema/p"  
    xmlns:context="http://www.springframework.org/schema/context"
    xmlns:tx="http://www.springframework.org/schema/tx" 
    xmlns:aop="http://www.springframework.org/schema/aop" 
    xmlns:jee="http://www.springframework.org/schema/jee" 
    xsi:schemaLocation="http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-3.0.xsd         http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd         http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd         http://www.springframework.org/schema/jee http://www.springframework.org/schema/jee/spring-jee-3.0.xsd         http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.0.xsd">


    <!--  to deal w/hibernate transaction types -->
    <aop:config>
        <aop:pointcut id="managerPC" expression="execution(* com.jmt.service..*Manager.*(..))"/>
        <aop:advisor id="managerTx" advice-ref="txManagerAdvice" pointcut-ref="managerPC" order="10"/>
    </aop:config>
    <tx:advice id="txManagerAdvice">
        <tx:attributes>            
            <tx:method name="save*" rollback-for="DuplicateNameException,UserExistsException" isolation="READ_COMMITTED"/>
            <tx:method name="create*" rollback-for="DuplicateNameException,UserExistsException" isolation="READ_COMMITTED"/>            
            <tx:method name="add*" rollback-for="DuplicateNameException,UserExistsException" isolation="READ_COMMITTED"/>            
            <tx:method name="update*" rollback-for="DuplicateNameException,UserExistsException" isolation="READ_COMMITTED"/>  
            <tx:method name="import*" rollback-for="DuplicateNameException,UserExistsException" isolation="READ_COMMITTED"/>          
            <tx:method name="change*"  isolation="READ_COMMITTED"/>
            <tx:method name="copy*"  isolation="READ_COMMITTED"/>
            <tx:method name="remove*" isolation="READ_COMMITTED"/>
            <tx:method name="delete*" isolation="READ_COMMITTED"/>
            <tx:method name="send*" isolation="READ_COMMITTED"/>            
            <tx:method name="set*" propagation="NOT_SUPPORTED"/>
            <tx:method name="batch*" propagation="NEVER"/>
            <tx:method name="wipe*" propagation="NEVER"/>
            <tx:method name="*" propagation="SUPPORTS" read-only="true"/>            
        </tx:attributes>
    </tx:advice>      
    <!-- end aop for hibernate transactions-->

    <context:property-placeholder location="classpath*:META-INF/spring/*.properties"/>
    <context:spring-configured/>
    <context:component-scan base-package="com.jmt">
        <context:exclude-filter expression="org.springframework.stereotype.Controller" type="annotation"/>
    </context:component-scan>


    <bean class="com.jmt.model.PinEntity"/>
    <bean class="com.jmt.model.UserEntity"/>

    <!--bean id="messageSource" class="org.springframework.context.support.ResourceBundleMessageSource">
            <property name="basename" value="messages"/>
    </bean-->
    <bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close">
        <property name="driverClassName" value="org.postgresql.Driver"/>
        <property name="url" value="${jdbc.url}"/>
        <property name="username" value="${jdbc.username}"/>
        <property name="password" value="${jdbc.password}"/>
        <property name="poolPreparedStatements" value="true"/>
        <property name="defaultAutoCommit" value="true"/>
        <property name="maxActive" value="100"/>
        <property name="maxIdle" value="30"/>
        <property name="maxWait" value="1000"/>
        <property name="removeAbandoned" value="true"/>
        <property name="removeAbandonedTimeout" value="60"/>
        <property name="logAbandoned" value="true"/>
        <property name="testOnBorrow" value="false"/>
        <property name="testWhileIdle" value="true"/>
        <property name="timeBetweenEvictionRunsMillis" value="10000"/>
        <property name="minEvictableIdleTimeMillis" value="60000"/>        
    </bean>   




    <tx:annotation-driven mode="aspectj" transaction-manager="transactionManager"/>
    <bean id="sessionFactory" class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean">
        <property name="dataSource" ref="dataSource"/>


        <property name="hibernateProperties">
            <props>
                <prop key="hibernate.dialect">org.hibernate.dialect.PostgreSQLDialect</prop>
                <prop key="hibernate.query.substitutions">true 'Y', false 'N'</prop>
                <prop key="hibernate.jdbc.batch_size">15</prop>   
                <prop key="hibernate.connection.isolation">2</prop>
            </props>       
        </property>
         <property name="packagesToScan">
            <list>
                <value>com.jmt.model</value>
            </list>
        </property>        
    </bean> 
    <bean id="hibernateDaoSupport" abstract="true"
class="org.springframework.orm.hibernate3.support.HibernateDaoSupport">
<property name="sessionFactory" ref="sessionFactory"/>
</bean>
    <bean id="hibernateHelper" class="org.springframework.orm.hibernate3.HibernateTemplate" >
        <constructor-arg ref="sessionFactory"/>
    </bean>

    <bean id="transactionManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager">
        <property name="sessionFactory" ref="sessionFactory"/>
        <property name="hibernateManagedSession" value="true"/>
    </bean>

    <bean id="pinDao" class="com.jmt.hibernate.dao.PinDaoImpl">
        <property name="sessionFactory" ref="sessionFactory"/>
    </bean>
    <bean id="userDao" class="com.jmt.hibernate.dao.UserDaoImpl">
        <property name="sessionFactory" ref="sessionFactory"/>
    </bean>

      <bean id="pinManager" class="com.jmt.service.PinManagerImpl"  autowire="byName" />
      <bean id="userManager" class="com.jmt.service.UserManagerImpl"  autowire="byName" />

      <bean id="homeController" class="com.jmt.controller.HomeController" scope="prototype"  autowire="byName" />
      <bean id="mapCreationForm" class="com.jmt.controller.forms.MapCreationForm" scope="prototype"  autowire="byName" />


</beans>
enter code here
kalinear
  • 21
  • 5
  • I had a workaround by taking out autowiring...However, the same sort of errors started showing up from trying to load the servlet/webpage, after the server was started up properly. – kalinear Jun 25 '12 at 04:12

1 Answers1

0

Seems like taking out the Autowiring annotation and adding aop:scoped-proxy to my bean in applicationContext.xml fixed the issue!

<bean id="userDao" class="com.jmt.hibernate.dao.UserDaoImpl">
<aop:scoped-proxy proxy-target-class="false" />             
<constructor-arg ref="sessionFactory"/>
</bean>
kalinear
  • 21
  • 5