Kamon icon indicating copy to clipboard operation
Kamon copied to clipboard

Kamon AspecJWeaver dependency not working with allinone jar

Open Akrome opened this issue 9 years ago • 3 comments

I'm using Kamon (0.6.6) with akka (2.4.11) (remote included).

This means that I need to include a -javaagent option to launch as specified by the Kamon doc.

The issue is that my Maven is building an allinone jar, as required by the Akka guidelines for mvn shading:

    <packaging>jar</packaging>
    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <configuration>
                    <source>1.8</source>
                    <target>1.8</target>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-shade-plugin</artifactId>
                <version>2.4.1</version>
                <executions>
                    <execution>
                        <phase>package</phase>
                        <goals>
                            <goal>shade</goal>
                        </goals>
                        <configuration>
                            <shadedArtifactAttached>true</shadedArtifactAttached>
                            <shadedClassifierName>allinone</shadedClassifierName>
                            <artifactSet>
                                <includes>
                                    <include>*:*</include>
                                </includes>
                            </artifactSet>
                            <transformers>
                                <transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
                                    <resource>reference.conf</resource>
                                </transformer>
                                <transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
                                    <main-Class>my.main.Program</main-Class>
                                </transformer>
                            </transformers>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>

If I run things from within the IDE (Intellij), it works fine by adding either:

-javaagent:full\path\to\aspectjweaver-1.8.10.jar

or these 2 to the pom:

    <dependency>
        <groupId>io.kamon</groupId>
        <artifactId>kamon-autoweave_2.11</artifactId>
        <version>0.6.5</version>
    </dependency>
    <dependency>
        <groupId>org.aspectj</groupId>
        <artifactId>aspectjweaver</artifactId>
        <version>1.8.10</version>
    </dependency>

The problem is that once I actually build the jar (mvn clean package), and I run it with (or without) the -javaagent option (java -javaagent... -jar app.jar) , the weaving does not happen, and no metric are reported when running outside the IDE.

I find it hard to debug the issue because even with

kamon.metric.disable-aspectj-weaver-missing-error = false

Kamon does not tell me that weaving is missing.

I believe this to be due to Java not finding the Weaver classes in the path, but I'm at my wit's end.

Any help? The goal is to run the jar externally with weaving

Akrome avatar Apr 24 '17 11:04 Akrome

Same question on SO: link

Akrome avatar Apr 24 '17 11:04 Akrome

This was resolved via this user group post (https://groups.google.com/forum/#!msg/kamon-user/WdwOUYVlq6M/o7O46bm6AwAJ ).

I needed to add

META-INF/aop.xml

To my transformers. Thanks @ivantopo for spotting it

Akrome avatar Apr 26 '17 14:04 Akrome

I'm closing this issue because it is either too old to be relevant or stale. Stop by our Github Discussions section and drop a message if you need any additional help with the topic.

Have a nice day!

ivantopo avatar Sep 10 '20 07:09 ivantopo