我需要在基于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列表?
提前致谢。
答案 0 :(得分:0)
更改je资源的jee:jndi-lookup定义后:指定代理接口,问题就解决了。
<jee:jndi-lookup id="jmsConnectionFactory"
jndi-name="java:/JmsXA"
lookup-on-startup="true"
proxy-interface="javax.jms.ConnectionFactory"/>