How to enable aspectj compile time weaving with Java 7 and maven - java

I have a project which currently works with java 6 and compile time weaving.
We use the following pom to enable spring aspects and our own ones:
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>aspectj-maven-plugin</artifactId>
<version>1.4</version>
<configuration>
<showWeaveInfo>true</showWeaveInfo>
<source>1.6</source>
<target>1.6</target>
<Xlint>ignore</Xlint>
<complianceLevel>1.6</complianceLevel>
<encoding>UTF-8</encoding>
<verbose>false</verbose>
<aspectLibraries>
<aspectLibrary>
<groupId>org.springframework</groupId>
<artifactId>spring-aspects</artifactId>
</aspectLibrary>
</aspectLibraries>
</configuration>
<executions>
<execution>
<goals>
<goal>compile</goal>
<goal>test-compile</goal>
</goals>
</execution>
</executions>
</plugin>
I've tried various configuration but can't make it work with java 7.
If someone could share a working pom or leads it would be great.

After moving to version 1.7.0 of the aspectjtools it works fine. In addition you need to pass the compiler the version parameter as -1.7 (using the target parameter caused problems). If someone needs more details leave a comment and I'll add more configuration specific information.
You can take a working example from here: Spring, AspectJ and Maven example
Here is the working plugin definition from the pom (compiler-version="1.7", aspectj.version="1.7.0")
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>aspectj-maven-plugin</artifactId>
<version>1.4</version>
<configuration>
<showWeaveInfo>true</showWeaveInfo>
<source>${compiler.version}</source>
<target>${compiler.version}</target>
<Xlint>ignore</Xlint>
<complianceLevel>${compiler.version}</complianceLevel>
<encoding>UTF-8</encoding>
<verbose>false</verbose>
<aspectLibraries>
<aspectLibrary>
<groupId>org.springframework</groupId>
<artifactId>spring-aspects</artifactId>
</aspectLibrary>
</aspectLibraries>
</configuration>
<executions>
<execution>
<goals>
<goal>compile</goal>
<goal>test-compile</goal>
</goals>
</execution>
</executions>
<dependencies>
<dependency>
<groupId>org.aspectj</groupId>
<artifactId>aspectjrt</artifactId>
<version>${aspectj.version}</version>
</dependency>
<dependency>
<groupId>org.aspectj</groupId>
<artifactId>aspectjtools</artifactId>
<version>${aspectj.version}</version>
</dependency>
</dependencies>
</plugin>

Related

Maven dependency declaration triggers changes in compilation procedure?

So I have an application that uses both, Java and Kotlin sourcefiles (all placed in the /src/main/kotlin directory because we eventually want to migrate to kotlin anyway) and that generates an hibernate metamodel.
So our maven compile plugins look like this:
<build>
<sourceDirectory>${project.basedir}/src/main/kotlin</sourceDirectory>
<testSourceDirectory>${project.basedir}/src/test/kotlin</testSourceDirectory>
<finalName>${project.artifactId}</finalName>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
<!--COMPILATION-->
<plugin>
<groupId>org.jetbrains.kotlin</groupId>
<artifactId>kotlin-maven-plugin</artifactId>
<version>${kotlin.version}</version>
<executions>
<execution>
<id>kapt</id>
<goals>
<goal>kapt</goal>
</goals>
<configuration>
<sourceDirs>
<sourceDir>src/main/kotlin</sourceDir>
</sourceDirs>
<annotationProcessorPaths>
<annotationProcessorPath>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-jpamodelgen</artifactId>
<version>${hibernate.version}</version>
</annotationProcessorPath>
</annotationProcessorPaths>
</configuration>
</execution>
<execution>
<id>compile</id>
<phase>compile</phase>
<goals>
<goal>compile</goal>
</goals>
</execution>
<execution>
<id>test-compile</id>
<phase>test-compile</phase>
<goals>
<goal>test-compile</goal>
</goals>
</execution>
</executions>
<configuration>
<jvmTarget>1.8</jvmTarget>
<compilerPlugins>
<plugin>all-open</plugin>
<plugin>jpa</plugin>
<plugin>spring</plugin>
<plugin>no-arg</plugin>
</compilerPlugins>
<args>
<arg>-Xjsr305=strict</arg>
</args>
<pluginOptions>
<!-- Each annotation is placed on its own line -->
<option>all-open:annotation=javax.ejb.Stateless</option>
<option>no-arg:annotation=javax.ejb.Stateless</option>
<option>all-open:annotation=javax.ws.rs.ext.Provider</option>
<option>no-arg:annotation=javax.ws.rs.ext.Provider</option>
</pluginOptions>
</configuration>
<dependencies>
<dependency>
<groupId>org.jetbrains.kotlin</groupId>
<artifactId>kotlin-maven-allopen</artifactId>
<version>${kotlin.version}</version>
</dependency>
<dependency>
<groupId>org.jetbrains.kotlin</groupId>
<artifactId>kotlin-maven-noarg</artifactId>
<version>${kotlin.version}</version>
</dependency>
</dependencies>
</plugin>
<plugin>
<!-- Check https://kotlinlang.org/docs/reference/using-maven.html#compiling-kotlin-and-java-sources -->
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.5.1</version>
<executions>
<!-- Replacing default-compile as it is treated specially by maven -->
<execution>
<id>default-compile</id>
<phase>none</phase>
</execution>
<!-- Replacing default-testCompile as it is treated specially by maven -->
<execution>
<id>default-testCompile</id>
<phase>none</phase>
</execution>
<execution>
<id>java-compile</id>
<phase>compile</phase>
<goals> <goal>compile</goal> </goals>
</execution>
<execution>
<id>java-test-compile</id>
<phase>test-compile</phase>
<goals> <goal>testCompile</goal> </goals>
</execution>
</executions>
</plugin>
<!--END COMPILATION-->
<!-- ... -->
</plugins>
</build>
this results in
[WARNING] Duplicate source root: /home/cypherk/code/myapp/target/generated-sources/kapt/compile
[WARNING] Duplicate source root: /home/cypherk/code/myapp/target/generated-sources/kaptKotlin/compile
which I have no idea why but may be related.
If I do not declare a dependency to
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-jpamodelgen</artifactId>
<version>${hibernate.version}</version>
</dependency>
under <dependencies>, that's alright, everything gets generated the way it's supposed to get generated in /target/generated-sources/kapt/compile/. (/target/generated-sources-kaptKotlin/compile gets generated but remains empty).
However, if I do declare the dependency under <dependencies>, the java (but not kotlin) entities will get generated a second time in /target/generated-sources/annotations/, which will trigger a compilation error because all Java-based generated classes have a duplicate class in the kapt folder.
I'm no expert on Maven, I just use it because that's what we are supposed to use for the project. As such, I find simply declaring a dependency having such an effect exceedingly unintuitive.
Could anybody explain to me why this is happening?
I don't know why, but when you change the compile execution to:
<execution>
<id>compile</id>
<phase>compile</phase>
<goals>
<goal>compile</goal>
</goals>
<configuration>
<sourceDirs>
<sourceDir>src/main/kotlin</sourceDir>
</sourceDirs>
</configuration>
</execution>
It should work. Same with test-compile.

Maven AspectJ plugin fails to build with Java 9 due to missing tools.jar

I switched my JDK version from 8 to 9 and the AspectJ plugin no longer works due to missing tools.jar:
Execution default of goal org.codehaus.mojo:aspectj-maven-plugin:1.10:compile failed: Plugin org.codehaus.mojo:aspectj-maven-plugin:1.10 or one of its dependencies could not be resolved: Could not find artifact com.sun:tools:jar:9.0.1 at specified path C:\Program Files\Java\jdk-9.0.1/../lib/tools.jar
I understand that tools.jar (and rt.jar) were removed from Java 9 JDK. I am wondering if there a way to get Maven AspectJ plugin to work with Java 9 without tools.jar?
Here is my plugin definition with version info:
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>aspectj-maven-plugin</artifactId>
<version>1.10</version>
<configuration>
<encoding>${project.build.sourceEncoding}</encoding>
<complianceLevel>1.9</complianceLevel>
<showWeaveInfo>true</showWeaveInfo>
<XnoInline>true</XnoInline>
</configuration>
<executions>
<execution>
<goals>
<goal>compile</goal>
<goal>test-compile</goal>
</goals>
</execution>
</executions>
<dependencies>
<dependency>
<groupId>org.aspectj</groupId>
<artifactId>aspectjrt</artifactId>
<version>1.9.0.RC2</version>
</dependency>
<dependency>
<groupId>org.aspectj</groupId>
<artifactId>aspectjtools</artifactId>
<version>1.9.0.RC2</version>
</dependency>
</dependencies>
</plugin>
I just found an ugly trick to make aspectj working with Java 9, just point com.sun:tools to the pom.xml and the compiler just run.
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>aspectj-maven-plugin</artifactId>
<version>1.11</version>
<executions>
<execution>
<goals>
<goal>compile</goal>
<goal>test-compile</goal>
</goals>
<configuration>
<source>1.8</source>
<target>1.8</target>
<complianceLevel>1.8</complianceLevel>
<encoding>UTF-8</encoding>
<verbose>true</verbose>
<weaveDependencies>
<weaveDependency>
<groupId>io.grpc</groupId>
<artifactId>grpc-netty</artifactId>
</weaveDependency>
</weaveDependencies>
<showWeaveInfo>true</showWeaveInfo>
<XnoInline>true</XnoInline>
</configuration>
</execution>
</executions>
<dependencies>
<dependency>
<groupId>org.aspectj</groupId>
<artifactId>aspectjrt</artifactId>
<version>${aspectj.version}</version>
</dependency>
<dependency>
<groupId>org.aspectj</groupId>
<artifactId>aspectjtools</artifactId>
<version>${aspectj.version}</version>
</dependency>
<dependency>
<groupId>com.sun</groupId>
<artifactId>tools</artifactId>
<version>${java.version}</version>
<scope>system</scope>
<systemPath>${project.basedir}/pom.xml</systemPath>
</dependency>
</dependencies>
</plugin>
Until version 1.11.1 is released into Maven Central by org.codehaus.mojo use the snapshot build instead:
<groupId>com.github.m50d</groupId>
<artifactId>aspectj-maven-plugin</artifactId>
<version>1.11.1</version>
Ran into the same issue, the problem is that this transitive dependency is active by default in the aspectj-maven-plugin.
Fixed it for me with this PR
https://github.com/mojohaus/aspectj-maven-plugin/pull/35
Have you checked the newest plugin version?
<groupId>org.codehaus.mojo</groupId>
<artifactId>aspectj-maven-plugin</artifactId>
<version>1.11</version>

Lombok and AspectJ

I'm trying to use Lombok in combination with AspectJ and Maven.
So, what's the problem?
When I use the AspectJ Maven Plugin (www.mojohaus.org/aspectj-maven-plugin/), it takes the sources and compiles them and ignores changes made by Lombok. I followed this tutorial and came up with this code and AspectJ works, but Lombok dies with this message:
[WARNING] You aren't using a compiler supported by lombok, so lombok will not work and has been disabled.
Your processor is: org.aspectj.org.eclipse.jdt.internal.compiler.apt.dispatch.BatchProcessingEnvImpl
Lombok supports: sun/apple javac 1.6, ECJ
So, does anyone know how to get Lombok in combination with AspectJ working?
Use ajc to process classes.
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>aspectj-maven-plugin</artifactId>
<version>1.11</version>
<configuration>
<complianceLevel>8</complianceLevel>
<source>8</source>
<target>8</target>
<showWeaveInfo>true</showWeaveInfo>
<verbose>true</verbose>
<Xlint>ignore</Xlint>
<encoding>UTF-8</encoding>
<!-- IMPORTANT-->
<excludes>
<exclude>**/*.java</exclude>
</excludes>
<forceAjcCompile>true</forceAjcCompile>
<sources/>
<!-- IMPORTANT-->
<aspectLibraries>
<aspectLibrary>
<groupId>you.own.aspect.libary</groupId>
<artifactId>your-library</artifactId>
</aspectLibrary>
</aspectLibraries>
</configuration>
<executions>
<execution>
<id>default-compile</id>
<phase>process-classes</phase>
<goals>
<!-- use this goal to weave all your main classes -->
<goal>compile</goal>
</goals>
<configuration>
<weaveDirectories>
<weaveDirectory>${project.build.directory}/classes</weaveDirectory>
</weaveDirectories>
</configuration>
</execution>
<execution>
<id>default-testCompile</id>
<phase>process-test-classes</phase>
<goals>
<!-- use this goal to weave all your test classes -->
<goal>test-compile</goal>
</goals>
<configuration>
<weaveDirectories>
<weaveDirectory>${project.build.directory}/test-classes</weaveDirectory>
</weaveDirectories>
</configuration>
</execution>
</executions>
</plugin>
Use delombok to generate normal source code. And then proceed as you would if Lombok were not being used.
Store your Lombok-annotated code in main/src/lombok (for example) and then have the delombok plugin convert these annotations into normal code and into the directory /delomboked (for example).
I tried various solutions, finally specifying the javac compiler option like the below one worked
This works for me with command line mvn clean install, but in Eclipse IDE, the problem is not solved, eg. log is not correctly recognized for #Slf4j.
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>aspectj-maven-plugin</artifactId>
<version>1.10</version>
<configuration>
<verbose>true</verbose>
<showWeaveInfo>true</showWeaveInfo>
<source>1.7</source>
<target>1.7</target>
<complianceLevel>1.7</complianceLevel>
<!-- <encoding>UTF-8</encoding> -->
<verbose>false</verbose>
<Xlint>ignore</Xlint>
<outxml>true</outxml>
<forceAjcCompile>true</forceAjcCompile>
<reweavable>false</reweavable>
<aspectLibraries>
<aspectLibrary>
<groupId>com.aspectj.library.yours</groupId>
<artifactId>your-library</artifactId>
</aspectLibrary>
</aspectLibraries>
<!-- this is important: start-->
<sources/>
<weaveDirectories>
<weaveDirectory>${project.build.directory}/classes</weaveDirectory>
</weaveDirectories>
<!-- this is important: end-->
</configuration>
<executions>
<execution>
<!-- The right phase is very important! Compile and weave aspects after all classes compiled by javac -->
<phase>process-classes</phase>
<goals>
<goal>compile</goal>
</goals>
</execution>
</executions>
<dependencies>
<dependency>
<groupId>org.aspectj</groupId>
<artifactId>aspectjweaver</artifactId>
<version>1.8.9</version>
</dependency>
<dependency>
<groupId>org.aspectj</groupId>
<artifactId>aspectjtools</artifactId>
<version>1.8.9</version>
</dependency>
</dependencies>
</plugin>
I had a configuration/excludes/exclude section with the spring-boot-maven-plugin where the "aspectjweaver" dependency had been declared. The exclude section had "org.projectlombok" in it, and looks like that's why none of my lombok annotations were being processed while building using "mvn clean install"
I initially had this:
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<dependencies>
<dependency>
<groupId>org.aspectj</groupId>
<artifactId>aspectjweaver</artifactId>
<version>${aspectj.version}</version>
</dependency>
</dependencies>
<configuration>
<excludes> <!------- THIS IS WHERE my problem started by exluding lombok -->
<exclude>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
</exclude>
</excludes>
</configuration>
</plugin>
When I removed the excludes part, then the build started taking the lombok annotations and worked. This is my section now:
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<dependencies>
<dependency>
<groupId>org.aspectj</groupId>
<artifactId>aspectjweaver</artifactId>
<version>${aspectj.version}</version>
</dependency>
</dependencies>
</plugin>
SpringBoot AND Java: 16
At this moment (19-11-2022) aspectJ plugin not support 17
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.7.5</version>
<relativePath/>
</parent>
...
YOUR GROUP, ARTIFACT NAME, VERSION ETC HERE
...
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.aspectj</groupId>
<artifactId>aspectjweaver</artifactId>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>1.18.24</version>
</dependency>
<dependency>
<groupId>kkl.lib.dev.tools</groupId>
<artifactId>lib-dev-tools</artifactId>
<version>1.0-SNAPSHOT</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<excludes>
<exclude>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
</exclude>
</excludes>
</configuration>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>aspectj-maven-plugin</artifactId>
<version>1.14.0</version>
<configuration>
<showWeaveInfo/>
<sources/>
<weaveDirectories>
<weaveDirectory>${project.build.directory}/classes</weaveDirectory>
</weaveDirectories>
<forceAjcCompile>true</forceAjcCompile>
<source>16</source>
<target>16</target>
<proc>none</proc>
<complianceLevel>16</complianceLevel>
</configuration>
<executions>
<execution>
<phase>process-classes</phase>
<goals>
<goal>compile</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
After reseach and testing all day, here is my success build.
Main idea is using javac to compile code first (compliance with lombok) and after that use aspectj only for weaving class.
<build>
<extensions>
<extension>
<groupId>kr.motd.maven</groupId>
<artifactId>os-maven-plugin</artifactId>
<version>1.6.1</version>
</extension>
</extensions>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-antrun-plugin</artifactId>
<version>1.8</version>
<executions>
<execution>
<id>unwovenClassesFolder</id>
<phase>generate-resources</phase>
<configuration>
<tasks>
<delete dir="${project.build.directory}/unwoven-classes"/>
<mkdir dir="${project.build.directory}/unwoven-classes"/>
</tasks>
</configuration>
<goals>
<goal>run</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.1</version>
<executions>
<execution>
<!-- Modifying output directory of default compile because non-weaved classes must be stored
in separate folder to not confuse ajc by reweaving already woven classes (which leads to
to ajc error message like "bad weaverState.Kind: -115") -->
<id>default-compile</id>
<configuration>
<source>16</source>
<target>16</target>
<outputDirectory>${project.build.directory}/unwoven-classes</outputDirectory>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>aspectj-maven-plugin</artifactId>
<version>1.14.0</version>
<dependencies>
<dependency>
<groupId>org.aspectj</groupId>
<artifactId>aspectjtools</artifactId>
<version>${aspectj.version}</version>
</dependency>
</dependencies>
<configuration>
<showWeaveInfo>true</showWeaveInfo>
<verbose>true</verbose>
<Xlint>ignore</Xlint>
<encoding>UTF-8</encoding>
<weaveDirectories>
<weaveDirectory>${project.build.directory}/unwoven-classes</weaveDirectory>
</weaveDirectories>
<!-- IMPORTANT-->
<excludes>
<exclude>**/*.java</exclude>
</excludes>
<forceAjcCompile>true</forceAjcCompile>
<sources/>
<!-- IMPORTANT-->
<complianceLevel>16</complianceLevel>
<source>16</source>
<target>16</target>
</configuration>
<executions>
<execution>
<!-- Compile and weave aspects after all classes compiled by javac -->
<phase>process-classes</phase>
<goals>
<goal>compile</goal>
</goals>
<configuration>
<complianceLevel>16</complianceLevel>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.22.2</version>
</plugin>
</plugins>
</build>

How to make AspectJ work on the server

I am using AspectJ (not Spring) to implement AOP in my Java Web application. It works fine when built by Maven project in Eclipse.
But putting and deploying the war package on the remote server, the AOP won't execute.
here's part of pom.xml:
<dependencies>
<dependency>
<groupId>org.aspectj</groupId>
<artifactId>aspectjrt</artifactId>
<version>1.8.9</version>
<!--<properties>
<war.bundle>true</war.bundle>
</properties>
-->
</dependency>
<dependency>
<groupId>org.aspectj</groupId>
<artifactId>aspectjtools</artifactId>
<version>1.8.9</version>
<!--<properties>
<war.bundle>true</war.bundle>
</properties>
-->
</dependency>
<dependency>
<groupId>org.aspectj</groupId>
<artifactId>aspectjweaver</artifactId>
<version>1.6.8</version>
<!--<properties>
<war.bundle>true</war.bundle>
</properties>
-->
</dependency>
</dependencies>
<build>
<finalName>${project.artifactId}</finalName>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>aspectj-maven-plugin</artifactId>
<configuration>
<verbose>true</verbose>
<privateScope>true</privateScope>
<showWeaveInfo>true</showWeaveInfo>
<source>1.7</source>
<target>1.7</target>
<complianceLevel>1.7</complianceLevel>
<!-- <encoding>UTF-8</encoding> -->
<verbose>false</verbose>
<outxml>true</outxml>
<aspectLibraries>
</aspectLibraries>
</configuration>
<executions>
<execution>
<goals>
<goal>compile</goal>
<goal>test-compile</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-clean-plugin</artifactId>
<version>2.5</version>
<configuration>
<filesets>
<fileset>
<directory>${project.basedir}/src/main/webapp/WEB-INF/lib</directory>
</fileset>
<fileset>
<directory>${project.basedir}/../deploy</directory>
<includes>
<include>${project.artifactId}.war</include>
</includes>
</fileset>
</filesets>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<version>2.4</version>
<executions>
<execution>
<id>copy-installed</id>
<phase>install</phase>
<goals>
<goal>copy</goal>
</goals>
<configuration>
<artifactItems>
<artifactItem>
<groupId>${project.groupId}</groupId>
<artifactId>${project.artifactId}</artifactId>
<version>${project.version}</version>
<type>${project.packaging}</type>
<destFileName>rm-cloud-web.war</destFileName>
</artifactItem>
</artifactItems>
<outputDirectory>${project.basedir}/../deploy</outputDirectory>
<overWriteReleases>true</overWriteReleases>
<overWriteSnapshots>true</overWriteSnapshots>
</configuration>
</execution>
<execution>
<id>unpack-dependencies</id>
<goals>
<goal>unpack-dependencies</goal>
</goals>
<configuration>
<outputDirectory>${project.build.directory}/test-classes</outputDirectory>
<overWriteReleases>true</overWriteReleases>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
Any advice?
Sorry guys, AspectJ did work on the server side and it does NOT need to add any extra jar file. I tried to log some info in an aspect method by using a enum that been advised, means the advise will be called recursively that caused stackoverflowexception.
Now I cant exclude Enum whthin the curtain class:
LogLevel is a enum in the class: xxx.xx.Utility
The compile info:
[INFO] Join point 'method-execution(int[] xxx.xx.Utility.$SWITCH_TABLE$xxx$xx$Utility$LogLevel())' in Type 'xxx.xx.Utility' (Utility.java:49) advised by before advice from 'zzz.zz.AAAA' (AAAA.aj:5)
my aspect content:
pointcut pc() : (execution(* xxx.xx..(..)) && !within(is(EnumType)));
before() : pc() {
...
}

Can't access moskito-inspect webui

I am trying to use moskito-inspect tool in embedded mode, here is my pom.xml
<properties>
<moskito.version>2.5.5</moskito.version>
<moskito-central.version>1.1.0</moskito-central.version>
</properties>
...
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>aspectj-maven-plugin</artifactId>
<version>1.5</version>
<configuration>
<aspectLibraries>
<aspectLibrary>
<groupId>net.anotheria</groupId>
<artifactId>moskito-aop</artifactId>
</aspectLibrary>
</aspectLibraries>
<complianceLevel>1.7</complianceLevel>
<source>1.7</source>
<target>1.7</target>
</configuration>
<executions>
<execution>
<goals>
<goal>compile</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.7</source>
<target>1.7</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<configuration>
<artifactItems><artifactItem>
<groupId>net.anotheria</groupId>
<artifactId>moskito-webui</artifactId>
<version>${moskito.version}</version>
<type>jar</type>
<overWrite>true</overWrite>
<outputDirectory>${project.build.directory}/tmp</outputDirectory>
<includes>moskito/**,**/*.jsp</includes>
</artifactItem></artifactItems>
</configuration>
<executions>
<execution>
<phase>compile</phase>
<goals>
<goal>unpack</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-war-plugin</artifactId>
<version>2.1</version>
<configuration>
<webResources>
<resource>
<directory>${project.build.directory}/tmp</directory>
</resource>
</webResources>
</configuration>
</plugin>
</plugins>
...
<dependencies>
<dependency>
<groupId>net.anotheria</groupId>
<artifactId>moskito-core</artifactId>
<version>${moskito.version}</version>
</dependency>
<dependency>
<groupId>net.anotheria</groupId>
<artifactId>moskito-aop</artifactId>
<version>${moskito.version}</version>
</dependency>
<dependency>
<groupId>net.anotheria</groupId>
<artifactId>moskito-web</artifactId>
<version>${moskito.version}</version>
</dependency>
<dependency>
<groupId>net.anotheria</groupId>
<artifactId>moskito-webui</artifactId>
<version>${moskito.version}</version>
</dependency>
<dependency>
<groupId>net.anotheria</groupId>
<artifactId>moskito-inspect-embedded</artifactId>
<version>${moskito.version}</version>
</dependency>
<dependency>
<groupId>net.anotheria</groupId>
<artifactId>moskito-inspect-jersey</artifactId>
<version>${moskito.version}</version>
</dependency>
<dependency>
<groupId>org.moskito</groupId>
<artifactId>moskito-central-embedded-connector</artifactId>
<version>${moskito-central.version}</version>
</dependency>
<dependency>
<groupId>org.moskito</groupId>
<artifactId>moskito-central-storages</artifactId>
<version>${moskito-central.version}</version>
</dependency>
</dependencies>
When I am running maven clean install I am getting war-file, which has the next inner structure:
When I deploy this war-file in tomcat, I can access my application by this URL:
http://localhost:8080/ada
(where ada - application name)
so I have tried to access moskito-inspect webui by this URLs:
http://localhost:8080/ada/moskito
http://localhost:8080/moskito
http://localhost:8080/ada/mui
http://localhost:8080/mui
However, tomcat response for all these links in 404 [Not found].
What am I doing wrong, may be someone faced the same problem?
Thanks in advance
I have figure out that you should add to your web.xml Moskito filters configuration - like in this article.
But author also said in this article that
With version 2.4.0 and servlet spec 3.0 no changes of the web.xml are
needed.
That's why I ignored that guide - very misleading advice!

Categories