load-time-weaving

How can Spring AspectJ weaving work without the -javaagent vm option?

点点圈 提交于 2019-12-20 15:25:56
问题 I understand Spring avoids using the -javaagent vm option in order to get its AspectJ load time weaving to work and relies instead on a classloader to start the agent. I thought that the Java specification dictated that the only way to use a Java agent was through the -javaagent vm option. Am I wrong? Can someone please direct me to the official Java specification/documentation that would clarify my interrogation? 回答1: I found some information about loading java agents in this interesting

How to configure load-time weaving with AspectJ and Tomcat?

好久不见. 提交于 2019-12-20 12:39:04
问题 I tried to configure load-time weaving (for doing profiling with Perf4J) in the next way: 1) I added aop.xml to META-INF folder. When deployed, META-INF is placed in the artifact root directory (i.e. MyAppDeployed/META-INF ). 2) I put aspectjrt-1.6.1.jar , aspectjweaver-1.6.1.jar , commons-jexl-1.1.jar , commons-logging.jar to the Tomcat/lib folder (at first I tried MyAppDeployed/WEB-INF/libs but it also didn't work). 3) I added -javaagent:C:\apache-tomcat-6.0.33\lib\aspectjweaver-1.6.1.jar

AspectJ aspect is not applied in LTW scenario

怎甘沉沦 提交于 2019-12-20 07:42:38
问题 I am trying to use AspectJ in a standalone application but does not seem to work. Here are the classes I created- package oata.aspect; import org.aspectj.lang.ProceedingJoinPoint; import org.aspectj.lang.annotation.Around; import org.aspectj.lang.annotation.Aspect; @Aspect public class AspectJTest { @Around("execution(* *..*(..))") public void around(ProceedingJoinPoint jp) throws Throwable { System.out.println("around fired"); jp.proceed(); } } package oata; import java.lang.annotation

AspectJ aspect is not applied in LTW scenario

我与影子孤独终老i 提交于 2019-12-20 07:42:07
问题 I am trying to use AspectJ in a standalone application but does not seem to work. Here are the classes I created- package oata.aspect; import org.aspectj.lang.ProceedingJoinPoint; import org.aspectj.lang.annotation.Around; import org.aspectj.lang.annotation.Aspect; @Aspect public class AspectJTest { @Around("execution(* *..*(..))") public void around(ProceedingJoinPoint jp) throws Throwable { System.out.println("around fired"); jp.proceed(); } } package oata; import java.lang.annotation

aop.xml name and location?

点点圈 提交于 2019-12-20 04:52:44
问题 Is there a way to specify the name of the aop.xml file with LTW? or define another name and location? I have several software modules that I use and that all use META-INF/aop.xml with different settings. I include these modules in a web application and then it all dependens how it's deployed/unpacked, which aop.xml file is used .. So I discovered after long time of searching that not all LTW weaving toke place correcting as it depends with aop.xml was used ... Basically I need to use both aop

Load time weaving for non-spring beans in a spring application

帅比萌擦擦* 提交于 2019-12-11 03:34:49
问题 I have a spring boot application with some REST controllers, service classes and helper classes. The controllers and service classes are spring managed while helper classes are not spring managed and mostly contain static methods. The AspectJ configuration is present in java configuration as follows @Configuration @EnableLoadTimeWeaving(aspectjWeaving = AspectJWeaving.ENABLED) public class AspectConfig { @Bean public LoggingAspect loggingAspect() { return new LoggingAspect(); } } The

How to set Spring weaver options in Java config class?

做~自己de王妃 提交于 2019-12-10 17:09:36
问题 I am using Spring AOP with the provided default DefaultContextLoadTimeWeaver . I would like to be able to weave persisted entities and I know I have to set a weaver option (warning from console): warning javax.* types are not being woven because the weaver option '-Xset:weaveJavaxPackages=true' has not been specified My search only found examples for the configuration in a .xml file, but I would really prefer this to be in my Java configuration class, where all my configurations are. Is there

Spring Boot AOP load time weaving

China☆狼群 提交于 2019-12-10 14:54:19
问题 Not sure what is going wrong, but AOP just doesn't seem to be working in my setup with spring boot (v1.1.6). @Configuration @ComponentScan @EnableJpaRepositories @EnableTransactionManagement @EnableAutoConfiguration @EnableCaching @EnableLoadTimeWeaving public class Application { public static void main(String[] args) { SpringApplication.run(Application.class, args); } } And in the aspect class @Aspect public class MyAspect { @AfterReturning(pointcut = "execution(private * com.myapp.service

Load time weaving in AspectJ using aop.xml

心已入冬 提交于 2019-12-10 13:36:42
问题 From what I understand, for load time weaving to work using an aop.xml file, it must be placed in META-INF. Is there a way to get around this and use an aop.xml (or any xml file) in any directory? Thanks. 回答1: You can use the system property org.aspectj.weaver.loadtime.configuration to point to another AspectJ config file. For example: -D org.aspectj.weaver.loadtime.configuration=META-INF/myaop.xml 来源: https://stackoverflow.com/questions/3314953/load-time-weaving-in-aspectj-using-aop-xml

jetty-maven-plugin and loadTimeWeaver

折月煮酒 提交于 2019-12-09 09:03:59
问题 can't seem to have my spring webapp working with jetty-maven pluging i always get org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'loadTimeWeaver': Initialization of bean failed; nested exception is java.lang.IllegalStateException: ClassLoader [org.eclipse.jetty.webapp.WebAppClassLoader] does NOT provide an 'addTransformer(ClassFileTransformer)' method. Specify a custom LoadTimeWeaver or start your Java virtual machine with Spring's agent: -javaagent:org