Maven has lots of useful features but m2e eclipse plugin is really poor. Beacuse of weird issues with m2e plugin and aspectj-maven-plugin, I decided to switch from CTW (Compile Time Weaving) to LTW (Load Time Weaving).
First of all I removed the aspectj-maven-plugin configuration from project's pom.xml. Than I added the required spring-tomcat-weaver.jar under the Tomcat common lib directory. This library provides an instrumentable classloader for tomcat and we need to tell to the tomcat to use the TomcatInstrumentableClassLoader with the following context.xml file.
<Context path="/webapppath" >
<Loader
loaderClass="org.springframework.instrument.classloading.tomcat.TomcatInstrumentableClassLoader"
useSystemClassLoaderAsParent="false" />
</Context>
context.xml file should be located under META-INF directory of our web app.
In weblogic we don't need a library like this. Spring loadtime weaver does all the job for us. Of course we need to activate spring load time weaver by adding <context:load-time-weaver /> to our project's app context.
After all of these configuration process our spring project has started to weave classes on loadtime and we don't need m2e and aspectj-maven-plugin synchronization anymore.
Finally I added the following config lines to my pom.xml to execute the unit and integration tests with maven successfuly.
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<argLine>
-javaagent:"${settings.localRepository}/org/springframework/spring-instrument/${spring.version}/spring-instrument-${spring.version}.jar"
</argLine>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-failsafe-plugin</artifactId>
<configuration>
<argLine>
-javaagent:"${settings.localRepository}/org/springframework/spring-instrument/${spring.version}/spring-instrument-${spring.version}.jar"
</argLine>
</configuration>
</plugin>
5 comments:
Newer doesnt always mean better. It is especially true for maven and its associates. This is the second post I read this morning complaining about m2e. The other was from Nicolas It seems that things havent changed in m2e when I left it with bare dependency resolution problems...
I'm happy with maven. Especially happy with it's plugins but m2e is really poor and needs time to mature...
How much time? I left it about 4-5 years ago. Still hearing such silly bugs around community...
For m2e I don't know and I don't care. For maven you can use it safely :)
I am using its dependency mechanism during my trainings already in order to provide people with libraries necessary for lab sessions. Unfortunately, it still somehow fails handling transitive dependency mechanism fully. If you wonder about the problem, I can send you the pom.xml and you can try to exclude spring 3.0.3 from dependency graph, or you can show the "trick" to achieve this :-) In short, it won't make me feel safe enough when I see two different versions of same library in my project :-)
Post a Comment