Can't make my project compile with Aspectj
. There's an issue with Apache CXF
that ResourceContext.getResource(SomeClass.class)
creates a simple object not a Spring-managed one. So I would like to use weaving and @Configurable
to come over this hardship. I got it to work in my test Spring Boot application (I could provide a link on the Github if needed) with the following set up using @Configurable
itself and @EnableSpringConfigured
:
Here is a snapshot of my pom.xml (Spring version is 4.3.3.RELEASE):
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-aspects</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-tx</artifactId>
<version>${spring.version}</version>
</dependency>
and the aspectj-maven-plugin
plugin configuration:
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>aspectj-maven-plugin</artifactId>
<version>1.8</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
<complianceLevel>1.8</complianceLevel>
<showWeaveInfo>true</showWeaveInfo>
<aspectLibraries>
<aspectLibrary>
<groupId>org.springframework</groupId>
<artifactId>spring-aspects</artifactId>
</aspectLibrary>
</aspectLibraries>
</configuration>
<executions>
<execution>
<goals>
<goal>compile</goal>
</goals>
</execution>
</executions>
</plugin>
However, when I try to apply the configuration above in the real project in my company I get this weird error:
[ERROR] *path to the java file being weaving* can't determine annotations of missing type javax.transaction.Transactional
[ERROR] when weaving type *the full java class name*
[ERROR] when weaving classes
[ERROR] when weaving
[ERROR] when batch building BuildConfig[null] #Files=27 AopXmls=#0
[ERROR] [Xlint:cantFindType]
[ERROR] error at (no source information available)
My test project doesn't use @Transactional
but the real one does. So I've tried to add spring-tx
and persistence-api
dependencies but nothing works. And the last note: the project is built successful the second time I run mvn install
and unsuccessful every time I run mvn clean install
.
Any help is much appreciated as I'm really stuck with this error.
Adding the following dependency to the classpath should solve the issue:
<dependency>
<groupId>javax.transaction</groupId>
<artifactId>javax.transaction-api</artifactId>
<version>1.2</version>
<scope>provided</scope>
</dependency>