Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [aspectj-users] How to load the aspectj files only once?

AspectJ deliberately stays away from being clever with class loading and just relies on the environment in which it finds itself to do the right thing when loading. If the class loaders are trying to be clever themselves, that can trip things up. If you are running load time weaving via -javaagent:pathto/aspectjweaver.jar I’m surprised the same CFlowCounter class isn’t being loaded at the top level and shared amongst everything below it - but I’m no expert on class loading in tomcat. If they are trying to do ‘child first’ loading then you may need to avoid any extra occurrences of aspectjrt.jar/aspectjweaver.jar anywhere else since they’d conflict with the one loaded from the agent jar (weaving infrastructure classes like Container and friends may be using the CFlowCounter from the agent jar)

Andy

> On Oct 13, 2015, at 5:59 AM, ants <anto.aravinth.cse@xxxxxxxxx> wrote:
> 
> Hi All, 
> 
> I'm very new to aspectJ and I started with load time weaving in aspectJ. I
> created a very simple aspectJ point cut, and loaded my jar when server get
> started up. It was working perfectly fine in the apache tomcat examples war. 
> 
> However when trying to deploy an application from the github repo over here:
> https://github.com/benas/todolist-mvc
> 
> with my load time weaving its giving me wired error messages. The aspectJ
> point cut looks like this:
> 
> 	protected pointcut traceMethods() :(execution(* *(..)) &&
> !cflow(within(LoggingAspect)) && !cflow(within(DbInternalServer)) &&
> !cflow(within(fi.iki.elonen.*)) && !cflow(within(RunTimeElements))&&
> !cflow(within(Container))&& !cflow(within(com.mongodb.*)));
> 
> and when I start my tomcat server, it does throw the error message like
> this:
> 
> Caused by: java.lang.LinkageError: loader constraint violation: loader
> (instance of org/apache/catalina/loader/WebappClassLoader) previously
> initiated loading for a different type with name
> "org/aspectj/runtime/internal/CFlowCounter"
>        at java.lang.ClassLoader.defineClass1(Native Method)
>        at java.lang.ClassLoader.defineClass(ClassLoader.java:800)
>        at
> java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
>        at
> org.apache.catalina.loader.WebappClassLoaderBase.findClassInternal(WebappClassLoaderBase.java:2496)
>        at
> org.apache.catalina.loader.WebappClassLoaderBase.findClass(WebappClassLoaderBase.java:860)
>        at
> org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1302)
>        at
> org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1167)
>        at
> org.springframework.web.SpringServletContainerInitializer.onStartup(SpringServletContainerInitializer.java:153)
>        at
> org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5170)
>        at
> org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
>        ... 10 more
> 
> Looks like both times the CFlowCounter is being loaded and that's what this
> error message says so. 
> 
> Now my question is how do I solve these sort of issues? How to force the
> aspectjweaver to load the classes only once? 
> 
> Thanks for all your reply's. 
> 
> 
> 
> --
> View this message in context: http://aspectj.2085585.n4.nabble.com/How-to-load-the-aspectj-files-only-once-tp4651956.html
> Sent from the AspectJ - users mailing list archive at Nabble.com.
> _______________________________________________
> aspectj-users mailing list
> aspectj-users@xxxxxxxxxxx
> To change your delivery options, retrieve your password, or unsubscribe from this list, visit
> https://dev.eclipse.org/mailman/listinfo/aspectj-users



Back to the top