aspectj

线上的一次栈溢出问题排查 StackOverflowError

痞子三分冷 提交于 2019-12-05 16:59:14
栈溢出的原因 在解决栈溢出问题之前,我们首先需要知道一般引起栈溢出的原因,主要有以下几点: 是否有递归调用,循环依赖调用 是否有大量循环或死循环 全局变量是否过多 局部变量过大,如:数组、List、Map数据过大 问题现象 我们一个很老的接口(近一年没有动过)在线上运行一段时间后报了 StackOverflowError 栈溢出,其他接口又能正常提供服务,错误日志: java.lang.StackOverflowError org.springframework.web.servlet.DispatcherServlet.triggerAfterCompletionWithError(DispatcherServlet.java:1303) org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:977) org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:893) org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:970) org

Use aspectj to profile selected methods

六眼飞鱼酱① 提交于 2019-12-05 16:57:18
I'd like to use aspectj to profile a library. My plan was to mark methods that require profiling with an annotation: @Profiled("logicalUnitOfWork") And then have an aspect that would fire before and after methods that would use the logicalUnitOfWork to highlight the profiled content. So, my pointcut to start with looks like this. Note that I don't have the argument for the annotation here; that's one of the things I'm not sure how to do: pointcut profiled() : execution(@Profiled * *()); before() : profiled () { // : the profiled logical name is in this variable: String logicalEventType;

Knowing caller class with AspectJ

牧云@^-^@ 提交于 2019-12-05 16:23:43
I'm trying to imitate Spring's AspectJ @Async support but with a message bus. The issue is I need to know if my Message Bus (RabbitMQ MessageListener) is calling the method or a normal (all others) caller where the method will return instantly. My annotation is called @MQAsync instead of Springs @Async. package com.snaphop.mqueue; import org.apache.log4j.Logger; import com.snaphop.mqueue.MQAsync; public aspect MQAsyncAspect { //pointcut asyncTypeMarkedMethod() : execution(@MQAsync void *(..)); pointcut asyncTypeMarkedMethod() : call(@MQAsync void *(..)); private static final Logger log =

Integration tests for AspectJ

醉酒当歌 提交于 2019-12-05 15:52:19
I am trying to write Integratation tests for Custom Aspect. Here is the Aspect Class Snippet. @Aspect @Component public class SampleAspect { private static Logger log = LoggerFactory.getLogger(SampleAspect.class); private int count; public int getCount(){ return count; } public void setCount(){ this.count= count; } @Around("execution(* org.springframework.data.mongodb.core.MongoOperations.*(..)) || execution(* org.springframework.web.client.RestOperations.*(..))") public Object intercept(final ProceedingJoinPoint point) throws Throwable { logger.info("invoked Cutom aspect"); setCount(1);

Spring's LoadTimeWeaver Agent not starting up

北城余情 提交于 2019-12-05 15:02:22
问题 I'm attempting to implement Load time weaving using Spring and AspectJ. To the best of my knowledge I have everything configured properly but I keep getting the error when I try to run my integration tests: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.context.weaving.AspectJWeavingEnabler#0': Initialization of bean failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name

Code Analysis Tools and Inter-Type-Declarations

吃可爱长大的小学妹 提交于 2019-12-05 11:39:24
问题 I have a maven project generated by Spring Roo and use several tools (checkstyle, pmd etc.) to collect information about my project. (namely I am using codehaus' sonar for this) Roo makes heavy use of AspectJ Inter Type Declarations (ITD) to seperate concerns like persistence, javabeans-getter/setters etc. These ITDs are woven in at compile-time so tools like checkstyle and pmd (who work on source-level) have a lot of false positives. The only solution I currently see, is to deactivate checks

Spring load time weaving not detecting class annotated with @configurable

旧城冷巷雨未停 提交于 2019-12-05 10:47:37
I'm having trouble getting AspectJ to perform load time weaving on a class annotated with @configurable in my main project. No fields get set and none of the setters are touched. I don't think there's trouble with the configuration itself, because I've extracted the configuration and tested it on a smaller sandbox project. Just for the sake of it, I'll include it in this question though. So, I'm wondering: Is there anything in the larger project that might be hindering Spring/AspectJ from detecting the this particular class? Is there any way of checking if spring is even aware of the class in

AspectJ - Weaving with custom ClassLoader at runtime

拟墨画扇 提交于 2019-12-05 10:20:59
I'm trying to load classes at runtime and weave them with some AspectJ aspects at this point. I have load-time weaving enabled, and it works when I use it more conventionally. I have the following in my @Aspect class: @Before("call(* mypackage.MyInterface.*())") public void myInterfaceExecuteCall(JoinPoint thisJoinPoint, JoinPoint.StaticPart thisJoinPointStaticPart, JoinPoint.EnclosingStaticPart thisEnclosingJoinPointStaticPart) { System.out.println(thisJoinPoint.getSignature().getDeclaringType()); System.out.println(thisJoinPoint.getSignature().getName()); } Then I'm scanning the jars and

Mixing AspectJ and Scala in an Eclipse Project

久未见 提交于 2019-12-05 10:14:13
Any one been able to get a Scala and AspectJ (AJDT) to play nicely together in Eclipse 3.6? It seems Scala's weaver conflicts with AspectJ's weaver. I'm hoping I'm just missing something. Edit: Play nicely in the same project Based on your comment above, it looks like you want a single project to use both the AspectJ builder and the Scala builder. This is not possible. Each one delegates to its own compiler and the two compilers are not (yet) compatible. The Scala compiler can build Java and Scala code together, and the AspectJ compiler can build AspectJ and Java code together, but that's it.

Maven, Scala, Spring, AspectJ

泪湿孤枕 提交于 2019-12-05 10:07:07
Does anyone know if you can weave scala classes at compile time with aspectJ & spring. I have compile time weaving working for all my java classes but I can't seem to get it to work for my scala classes that use @Configurable. For background I have been working on this for a couple of days. What a pain. Anyways here's the answer. Yes it can be done, you just can't use the aspectj maven plugin. You have to use the antrun maven plugin. Happy Scala Coding! <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-antrun-plugin</artifactId> <version>1.6</version> <executions>