Announcement Announcement Module
Collapse
No announcement yet.
Spring BeanCreationException, maven2 & cobertura Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Spring BeanCreationException, maven2 & cobertura

    My application has some JUnit tests and Spring integration tests (with the help of org.springframework.test package). I ran the tests in maven2 by "mvn surefire:test" and they worked fine. Now I am trying to run Cobertura for test coverage by "mvn cobertura:cobertura" but find test failures. The failures only happened on Spring integration tests. What I don't understand is why cobertura failed at surefire tests, which succeeded in the first place. I don't know if this is the right forum to ask this question, but I did some Google search and still have no clue. I have jdk 1.5.0, maven 2.0.4 and spring 1.2.6. Thanks in advance.

    The following is in surefire test log.
    org.springframework.beans.factory.BeanCreationExce ption: Error creating bean with name 'userFilter' defined in class path resource [applicationContext.xml]: Error setting property values; nested exception is org.springframework.beans.PropertyAccessExceptions Exception: PropertyAccessExceptionsException (1 errors); nested propertyAccessExceptions are: [org.springframework.beans.TypeMismatchException: Failed to convert property value of type [$Proxy1] to required type [com.acme.myapp.service.MyManager] for property 'myManager']
    PropertyAccessExceptionsException (1 errors)

    The bean definitions are in applicationContext.xml.
    <bean id="userFilter" class="com.acme.myapp.web.UserFilter">
    <property name="myManager" ref="myManager"/>
    </bean>

    <bean id="myManager" class="org.springframework.transaction.interceptor .TransactionProxyFactoryBean">
    <property name="transactionManager" ref="transactionManager"/>
    <property name="target" ref="myManagerTarget"/>
    <property name="transactionAttributes">
    <props>
    ...
    </props>
    </property>
    </bean>


    public class UserFilter implements Filter {
    private MyManager myManager;

    ...
    }

  • #2
    Does your 'myManagerTarget' class implements the 'myManager' interface? If it does (it should) try adding this to your 'myManager' bean:

    <property name="proxyInterfaces"
    value="package.name.MyManager " />

    Comment


    • #3
      "myManagerTarget" does not implement any interface. Then I realized it should, after reading your post. So I refactored the code to create interface "MyManager" and its implementation "MyManagerImpl". IT WORKS!

      The configuration is like
      <bean id="myManager" class="org.springframework.transaction.interceptor .TransactionProxyFactoryBean">

      <bean id="myManagerTarget" class="com.xxx.MyManagerImpl">

      I noticed that I don't need to set property "proxyInterfaces" for "myManager" after the refactor. The TransactionProxyFactoryBean API said this will leave it to Spring AOP.

      Thanks a lot!

      Comment


      • #4
        Spring BeanCreationException, maven2 &amp; cobertura

        I am facing similar problem with my application.
        my error
        I would appreciate any kind of help in these regards.

        Thanks in advance.

        Regards,
        Sumedh
        Last edited by sumedhsakdeo; Mar 2nd, 2010, 12:04 AM.

        Comment

        Working...
        X