jetty-maven-plugin and loadTimeWeaver jetty-maven-plugin and loadTimeWeaver spring spring

jetty-maven-plugin and loadTimeWeaver


Probably you are missing few jars aspectjweaver aspectjrt spring-instrument

Additionally you may want to try explicitly defining the bean loadTimeWeaver in applicationcontext.xml file.

    <property name="loadTimeWeaver">        <bean id="instrumentationLoadTimeWeaver" class="org.springframework.instrument.classloading.InstrumentationLoadTimeWeaver"/>    </property>


When launching Jetty from Maven (using mvn jetty:run), Jetty will run in the same JVM as maven does, so you'll need to pass any options using MAVEN_OPTS.

(Be sure to include the minus sign before javaagent, as I didn't see that in your snippet).

export MAVEN_OPTS=-javaagent:org.springframework.instrument-3.0.5.RELEASE.jar

A complete example of load time weaving in jetty using Maven can be found on Github.

https://github.com/zzantozz/testbed/tree/master/spring-aspectj-load-time-weaving-in-jetty


Without more details about your pom.xml file... it's not easy. But one common issue with jetty plugin are the dependencies.

One rule that always worked for me is to put all dependencies of your war with scope provided as direct dependencies of the maven-jetty-plugin.

I suggest you to put spring-instrument and spring-aspects as direct dependencies of the maven-jetty-plugin too.

According my understanding:

set MAVEN_OPTS to javaagent:/Users/blabla/.m2/repository/org/springframework/spring-instrument/3.1.3.RELEASE/spring-instrument-3.1.3.RELEASE.jar

is the correct way to pass jvm args to the jetty JVM (since jetty run in the same JVM as maven)