Workaround for LoadTimeWeaver issue with JBoss 6 and Spring 3


A possible workaround for the LTW issue that appeared in JBoss 6 using Spring 3 (SPR-7887) is to add an empty jboss-scanning.xml file to EAR and WAR files.

The reason to this issue as explained by one comment that JBoss pre-loads classes when scanning for annotations. Which triggers the class loader before Spring has a chance to add the AspectJ transformer to the class loader. The LTW support of Spring loads fine but after all classes are loaded.

Adding the empty jboss-scanning.xml to EAR and WAR files will skip the scanning for the modules and trigger the transformer later.

Example for jboss-scanning.xml:

<?xml version="1.0" encoding="UTF-8"?>

<scanning xmlns="urn:jboss:scanning:1.0">  
</scanning>  

Thanks to Marius Bogoevici and Costin Leau for looking into this issue.