0

我需要在基于 Spring 3.2 的应用程序上设置 Perf4j。我有以下 Spring 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:context="http://www.springframework.org/schema/context"
xmlns:p="http://www.springframework.org/schema/p"
xmlns:aop="http://www.springframework.org/schema/aop"
xmlns:jee="http://www.springframework.org/schema/jee"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.1.xsd
http://www.springframework.org/schema/jee http://www.springframework.org/schema/jee/spring-jee-3.1.xsd
http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-3.1.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.1.xsd">

<context:component-scan base-package="com.xxx.yyy.services" />

<jee:jndi-lookup id="jmsConnectionFactory" jndi-name="java:/JmsXA" lookup-on-startup="true"/>

<bean id="jmsTemplate" class="org.springframework.jms.core.JmsTemplate">
    <property name="connectionFactory" ref="jmsConnectionFactory"/>
    <property name="deliveryPersistent" value="false"/>
    <property name="receiveTimeout" value="30000"/>
</bean>

<bean id="eventConsumer" class="com.motive.kmp.event.JmsEventConsumer"/>

<bean id="eventProducer" class="com.motive.kmp.event.JmsEventProducer">
    <constructor-arg ref="jmsTemplate"/>
</bean>


<aop:aspectj-autoproxy>
      <aop:include name="timingAspect" />
</aop:aspectj-autoproxy>

<bean id="timingAspect" class="org.perf4j.slf4j.aop.TimingAspect" />

在 JBoss AS 7.1.0.Final 上部署应用程序时出现以下错误:

 Exception sending context initialized event to listener instance of class   
  org.springframework.web.context.ContextLoaderListener: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'jmsTemplate' defined in class path resource [service-common-context.xml]: Cannot resolve reference to bean 'jmsConnectionFactory' while setting bean property 'connectionFactory'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'jmsConnectionFactory': Post-processing of the FactoryBean's object failed; nested exception is java.lang.IllegalArgumentException: error Type referred to is not an annotation type: org.perf4j.aop.Profiled

 Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'jmsConnectionFactory': Post-processing of the FactoryBean's object failed; nested exception is java.lang.IllegalArgumentException: error Type referred to is not an annotation type: org.perf4j.aop.Profiled
    at org.springframework.beans.factory.support.FactoryBeanRegistrySupport.doGetObjectFromFactoryBean(FactoryBeanRegistrySupport.java:165) [spring-beans-3.2.0.RELEASE.jar:3.2.0.RELEASE]
    at org.springframework.beans.factory.support.FactoryBeanRegistrySupport.getObjectFromFactoryBean(FactoryBeanRegistrySupport.java:102) [spring-beans-3.2.0.RELEASE.jar:3.2.0.RELEASE]
    at org.springframework.beans.factory.support.AbstractBeanFactory.getObjectForBeanInstance(AbstractBeanFactory.java:1443) [spring-beans-3.2.0.RELEASE.jar:3.2.0.RELEASE]
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:249) [spring-beans-3.2.0.RELEASE.jar:3.2.0.RELEASE]
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:194) [spring-beans-3.2.0.RELEASE.jar:3.2.0.RELEASE]
    at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:323) [spring-beans-3.2.0.RELEASE.jar:3.2.0.RELEASE]

Profiled 注释应用于服务 bean 方法。有没有办法指定一个实际使用 Profiled 注释的 bean 列表?

提前致谢。

4

1 回答 1

0

更改 JMS 资源的 jee:jndi-lookup 定义后:指定代理接口,问题就解决了。

<jee:jndi-lookup id="jmsConnectionFactory" 
                 jndi-name="java:/JmsXA" 
                 lookup-on-startup="true"
                 proxy-interface="javax.jms.ConnectionFactory"/>
于 2013-04-25T08:35:56.037 回答