I'm using AspectJ and Spring AOP to advice the same beans (applicationservices) , and get an error when I try to add 2 different styles aspects (weaving aspects-AspectJ, proxy aspects-SpringAOP)
This is the bean configuration for the transaction aspect:Code:at oracle.oc4j.admin.internal.DeployerBase.execute(DeployerBase.java:126) [java] at com.evermind.server.administration.DefaultApplicationServerAdministrator.internalDeploy(DefaultApplicationServerAdministrator.java:446) [java] ... 8 more [java] Error: Deploy error: deploy failed!: ; nested exception is: [java] oracle.oc4j.admin.internal.DeployerException: Error creating bean with name 'authorisationAppService' defined in ServletContext resource [/WEB-INF/applicationcontext-authorization-appservice.xml]: Cannot resolve reference to bean 'userRepository' while setting constructor argument with index 0; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'userRepository' defined in ServletContext resource [/WEB-INF/applicationcontext-database.xml]: Cannot resolve reference to bean 'sessionFactory' while setting bean property 'sessionFactory'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory' defined in ServletContext resource [/WEB-INF/applicationcontext-database.xml]: Cannot resolve reference to bean 'dataSource' while setting bean property 'dataSource'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.aop.aspectj.AspectJPointcutAdvisor': Cannot create inner bean '(inner bean)' while setting constructor argument; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name '(inner bean)': Cannot resolve reference to bean 'applicationServiceCallPointcut' while setting constructor argument with index 1; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'applicationServiceCallPointcut': Instantiation of bean failed; nested exception is org.springframework.beans.BeanInstantiationException: Could not instantiate bean class [org.springframework.aop.aspectj.AspectJExpressionPointcut]: Constructor threw exception; nested exception is oracle.classloader.util.AnnotatedLinkageError: Class org/aspectj/weaver/reflect/AnnotationFinder violates loader constraints [java] Invalid class: org.aspectj.weaver.reflect.AnnotationFinder [java] Loader: oc4j:10.1.3 [java] Code-Source: /java/servers/oc4j/j2ee/home/applib/aspectjweaver.jar [java] Configuration: system property java.class.path [java] Dependent class: org.aspectj.weaver.reflect.ReflectionWorld [java] Loader: oc4j:10.1.3 [java] Code-Source: /java/servers/oc4j/j2ee/home/applib/aspectjweaver.jar [java] Configuration: system property java.class.path
Code:<bean class="org.springframework.transaction.aspectj.AnnotationTransactionAspect" factory-method="aspectOf"> <property name="transactionManager" ref="transactionManager"/> </bean>
OC4J is started with the AspectJ agent, and I'm using a aop.xml to prevent all classes from being inspected:
If I use only the AspectJ part to set up my @transactional aspects, everything is ok. I have added the @transactional annotations to my applicationservice-implementations.Code:<aspectj> <weaver> <include within="foo.appservices..*"/> </weaver> </aspectj>
This is one of my application services:
If I add profiling by Spring AOP, I get an error:Code:public class QueryIntakeAppServiceImpl implements QueryIntakeAppService { private final static Logger logger = Logger.getLogger(QueryIntakeAppServiceImpl.class); public QueryIntakeAppServiceImpl() { } @Transactional(readOnly = false, propagation = Propagation.REQUIRES_NEW) public QueryProgress submit(String query, Credentials credentials) throws NotAuthorizedException { ... junk } }
This is the configuration for the profiling:
This is the aspect:Code:<aop:config> <aop:pointcut id="applicationServiceCallPointcut" expression="execution(* foo.appservices.*.*AppService+.*(..))"/> <aop:aspect id="loggingAspect" ref="profiler"> <aop:around method="profile" pointcut-ref="applicationServiceCallPointcut"/> </aop:aspect> </aop:config> <!-- the profiler that does the actual profiling --> <bean id="profiler" class="foo.aspects.JamonProfiler"/>
Code:public class JamonProfiler { public Object profile(ProceedingJoinPoint jp) throws Throwable { String name = jp.getSignature().getDeclaringTypeName() + "." + jp.getSignature().getName(); Monitor mon = MonitorFactory.start(name); try { return jp.proceed(); } finally { mon.stop(); } } }


Reply With Quote
