I got ClassNotFoundException when i tried to switch spring to use load time weaving

697 Views Asked by At

I've added a <context:load-time-weaver/> in my application context. And i've added necessary libraries and javaagent to my pom.xml

Then i got following error

2014-05-23T17:48:11.549+0600  SEVERE  Unable to find class 'com.myproject.dao.impl.BlobDataDaoTest$' in repository
java.lang.ClassNotFoundException: com.myproject.dao.impl.BlobDataDaoTest$ not found - unable to determine URL
    at org.aspectj.apache.bcel.util.ClassLoaderRepository.loadClass(ClassLoaderRepository.java:292)
    at org.aspectj.weaver.bcel.BcelWorld.lookupJavaClass(BcelWorld.java:402)
    at org.aspectj.weaver.bcel.BcelWorld.resolveDelegate(BcelWorld.java:376)
    at org.aspectj.weaver.ltw.LTWWorld.resolveDelegate(LTWWorld.java:107)
    at org.aspectj.weaver.World.resolveToReferenceType(World.java:485)
    at org.aspectj.weaver.World.resolve(World.java:326)

How can i resolve it?

3

There are 3 best solutions below

0
On BEST ANSWER

It was resolved when i've updated aspectj version from 1.6.12 to 1.8

2
On

Obviously the weaver cannot find at least some of your application classes. This must be a class-loading issue. Maybe your aop.xml is not in the right location or configured in a wrong way - hard to tell with so little information.

0
On

There are external dependencies in my tests. They imported because in my tests i mock its. This Unable to find class errors all about this external classes.

2014-05-27T14:26:37.517+0600  SEVERE  Unable to find class 'com.aydar.pj.model.refbook.RefBook$' in repository
java.lang.ClassNotFoundException: com.aydar.pj.model.refbook.RefBook$ not found - unable to determine URL
    at org.aspectj.apache.bcel.util.ClassLoaderRepository.loadClass(ClassLoaderRepository.java:292)
    at org.aspectj.weaver.bcel.BcelWorld.lookupJavaClass(BcelWorld.java:402)

...

2014-05-27T14:26:37.517+0600  SEVERE  Unable to find class 'com.aydar.pj.model.refbook.RefBook$$EnhancerByMockitoWithCGLIB' in repository
java.lang.ClassNotFoundException: com.aydar.pj.model.refbook.RefBook$$EnhancerByMockitoWithCGLIB not found - unable to determine URL
    at org.aspectj.apache.bcel.util.ClassLoaderRepository.loadClass(ClassLoaderRepository.java:292)
    at org.aspectj.weaver.bcel.BcelWorld.lookupJavaClass(BcelWorld.java:402)
    at org.aspectj.weaver.bcel.BcelWorld.resolveDelegate(BcelWorld.java:376)

...

2014-05-27T14:26:37.516+0600  SEVERE  Unable to find class 'com.aydar.pj.model.refbook.RefBook$$EnhancerByMockitoWithCGLIB$' in repository
java.lang.ClassNotFoundException: com.aydar.pj.model.refbook.RefBook$$EnhancerByMockitoWithCGLIB$ not found - unable to determine URL
    at org.aspectj.apache.bcel.util.ClassLoaderRepository.loadClass(ClassLoaderRepository.java:292)
    at org.aspectj.weaver.bcel.BcelWorld.lookupJavaClass(BcelWorld.java:402)