Announcement Announcement Module
Collapse
No announcement yet.
Exception by using <aop:config> Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Exception by using <aop:config>

    I have the following Spring 2.0 config file:

    <?xml version="1.0" encoding="Shift_JIS"?>
    <beans xmlns="http://www.springframework.org/schema/beans"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns:aop="http://www.springframework.org/schema/aop"
    xmlns:tx="http://www.springframework.org/schema/tx"
    xmlns:jee="http://www.springframework.org/schema/jee"
    xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schem...-beans-2.0.xsd
    http://www.springframework.org/schema/aop http://www.springframework.org/schem...ng-aop-2.0.xsd
    http://www.springframework.org/schema/tx http://www.springframework.org/schem...ing-tx-2.0.xsd
    http://www.springframework.org/schema/jee http://www.springframework.org/schema/jee/spring-jee-2.0.xsd">



    <!-- Pooling JMS connection provider -->
    <bean id="jmsFactory" class="org.apache.activemq.pool.PooledConnectionFa ctory" init-method="start" destroy-method="stop">
    <property name="connectionFactory">
    <bean class="org.apache.activemq.ActiveMQConnectionFacto ry">
    <property name="brokerURL">
    <value>tcp://localhost:61616</value>
    </property>
    </bean>
    </property>
    </bean>

    <bean id="jmsTransactionManager" class="org.springframework.jms.connection.JmsTrans actionManager">
    <property name="connectionFactory">
    <ref bean="jmsFactory"/>
    </property>
    </bean>

    <!-- Defaults to PROPAGATION_REQUIRED -->
    <tx:advice id="jmsTxAdvice" transaction-manager="jmsTransactionManager">
    <tx:attributes>
    <tx:method name="transSend*"/>
    </tx:attributes>
    </tx:advice>

    <aop:config>
    <aopointcut id="jmsBlo" expression="execution(* *..jms.*.*(..))"/>
    <aop:advisor pointcut-ref="jmsBlo" advice-ref="jmsTxAdvice"/>
    </aop:config>

    </beans>



    When I startedtmy app, I got the following exceptions.

    2007-10-25 15:05:15,775 [main] ERROR - Context initialization failed
    org.springframework.beans.factory.BeanCreationExce ption: Error creating bean with name 'jmsFactory' defined in ServletContext resource [/WEB-INF/applicationContext.xml]: Error setting property values; nested exception is org.springframework.beans.PropertyBatchUpdateExcep tion; nested PropertyAccessExceptions (1) are:
    PropertyAccessException 1: org.springframework.beans.TypeMismatchException: Failed to convert property value of type [$Proxy8] to required type [org.apache.activemq.ActiveMQConnectionFactory] for property 'connectionFactory'; nested exception is java.lang.IllegalArgumentException: Cannot convert value of type [$Proxy8] to required type [org.apache.activemq.ActiveMQConnectionFactory] for property 'connectionFactory': no matching editors or conversion strategy found
    Caused by:
    org.springframework.beans.PropertyBatchUpdateExcep tion; nested PropertyAccessException details (1) are:
    PropertyAccessException 1:
    org.springframework.beans.TypeMismatchException: Failed to convert property value of type [$Proxy8] to required type [org.apache.activemq.ActiveMQConnectionFactory] for property 'connectionFactory'; nested exception is java.lang.IllegalArgumentException: Cannot convert value of type [$Proxy8] to required type [org.apache.activemq.ActiveMQConnectionFactory] for property 'connectionFactory': no matching editors or conversion strategy found
    Caused by:
    java.lang.IllegalArgumentException: Cannot convert value of type [$Proxy8] to required type [org.apache.activemq.ActiveMQConnectionFactory] for property 'connectionFactory': no matching editors or conversion strategy found

    But when I remove <aop:config> segment from the config file, No exception happens.

    What is the problem?

  • #2
    In this case, it looks like your pointcut expression is causing the ActiveMQConnectionFactory object to be proxied, because it is an implementation of the javax.jms.ConnectionFactory interface (which matches your pointcut). You need to modify your pointcut definition to better restrict matching to the application classes you want to advise.

    Comment

    Working...
    X