-
Notifications
You must be signed in to change notification settings - Fork 15
This page contains frequently encountered issues/problems and their solutions.
1. I am getting a java.lang.NoSuchMethodException: cz.cvut.kbss.termit.aspect.ChangeTrackingAspect.aspectOf()
or java.lang.ClassCastException: X cannot be cast to cz.cvut.kbss.jopa.model.BeanListenerAspect$Manageable
This means that the code has not been correctly processed by the AspectJ compiler. JOPA uses AspectJ aspects to realize some of its critical functionality (change tracking, for instance). Usually, the easiest way to achieve this is by using the AspectJ Maven plugin, which processes the built byte-code and enhances it with the aspect-related instructions. However, often when running a JOPA-based application from an IDE, it can happen that the IDE will use just the Javac compiler to build the source code and then run the application, leading to the aforementioned exceptions.
The same exception can also be thrown when project is not cleaned before build. In this case, weaving sometimes does not happen correctly.
The first exception usually occurs in connection with Spring.
Solution: A solution to this problem is rebuilding the project again and ensuring AspectJ has been used to process the code (e.g., via the Maven plugin). The safest way is thus to run mvn clean package
to rebuild the project from scratch. In IntelliJ IDEA, it is also possible to set the AspectJ compiler (ajc
) as the Java compiler IDEA will use (this applies for running an application from the IDE).
Note: This applies to JOPA prior to version 2.0.0. Later versions do not use AspectJ.