0

我正在尝试将 CTW 与 aspectj 一起使用,以使用 perf4j 分析我的应用程序(cumulusrdf)。

我可以用maven编译一切就好了。控制台输出包含我用于使分析工作的方法的条目:

[INFO] --- aspectj-maven-plugin:1.5:compile (default-cli) @ cumulusrdf ---
[INFO] Join point 'method-execution(void edu.kit.aifb.cumulus.store.AbstractCassandraRdfHector.bulkLoad(java.io.File, java.lang.String, int))' in Type 'edu.kit.aifb.cumulus.store.AbstractCassandraRdfHector' (AbstractCassandraRdfHector.java:373) advised by around advice from 'org.perf4j.log4j.aop.TimingAspect' (perf4j-0.9.16-log4jonly.jar!AbstractTimingAspect.class(from AbstractTimingAspect.java))

我正在使用aspectj:compile package构建目标。当我尝试运行生成的 one-jar 时,出现以下异常:

java.lang.reflect.InvocationTargetException
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:606)
        at edu.kit.aifb.cumulus.cli.Main.main(Main.java:40)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:606)
        at com.simontuffs.onejar.Boot.run(Boot.java:340)
        at com.simontuffs.onejar.Boot.main(Boot.java:166)
Caused by: java.lang.NoSuchMethodError: org.perf4j.log4j.aop.TimingAspect.aspectOf()Lorg/perf4j/log4j/aop/TimingAspect;
        at edu.kit.aifb.cumulus.store.AbstractCassandraRdfHector.bulkLoad(AbstractCassandraRdfHector.java:373)
        at edu.kit.aifb.cumulus.cli.Load.main(Load.java:161)
        ... 11 more

我不使用任何参数,除了我的应用程序的参数。

在我的 pom.xml 中,我有以下相关部分:

aspectj插件的定义:

<plugins>
    <plugin>
        <groupId>org.codehaus.mojo</groupId>
        <artifactId>aspectj-maven-plugin</artifactId>
        <version>1.5</version>

        <configuration>
            <aspectLibraries>
                <aspectLibrary>
                    <groupId>org.perf4j</groupId>
                    <artifactId>perf4j</artifactId>
                    <classifier>log4jonly</classifier>
                </aspectLibrary>
            </aspectLibraries>
            <source>1.6</source>
            <target>1.6</target>
            <complianceLevel>1.6</complianceLevel>
            <verbose>true</verbose>
            <showWeaveInfo>true</showWeaveInfo>
            <weaveMainSourceFolder>true</weaveMainSourceFolder>
        </configuration>

        <!--<executions>
            <execution>
                <goals>
                    <goal>compile</goal>       <! use this goal to weave all your main classes >
                </goals>
                <configuration>
                    <showWeaveInfo>true</showWeaveInfo>
                </configuration>
            </execution>
        </executions>-->
    </plugin>

    <!-- ... -->
</plugins>

相关工件的依赖关系:

<dependencies>
    <dependency>
        <groupId>org.perf4j</groupId>
        <artifactId>perf4j</artifactId>
        <version>0.9.16</version>
        <classifier>log4jonly</classifier>
    </dependency>
    <dependency>
        <groupId>org.perf4j</groupId>
        <artifactId>perf4j</artifactId>
        <version>0.9.16</version>
    </dependency>
    <dependency>
        <groupId>org.aspectj</groupId>
        <artifactId>aspectjweaver</artifactId>
        <version>1.7.3</version>
    </dependency>
    <dependency>
        <groupId>org.aspectj</groupId>
        <artifactId>aspectjrt</artifactId>
        <version>1.7.3</version>
    </dependency>
    <dependency>
        <groupId>commons-jexl</groupId>
        <artifactId>commons-jexl</artifactId>
        <version>1.1</version>
    </dependency>

    <!-- ... -->
</dependencies>

one-jar插件的定义:

<plugins>
    <plugin>
        <groupId>org.dstovall</groupId>
        <artifactId>onejar-maven-plugin</artifactId>
        <version>1.4.4</version>
        <executions>
            <execution>
                <configuration>
                    <mainClass>edu.kit.aifb.cumulus.cli.Main</mainClass>
                    <onejarVersion>0.97</onejarVersion>
                    <attachToBuild>true</attachToBuild>
                    <classifier>onejar</classifier>
                </configuration>
                <goals>
                    <goal>one-jar</goal>
                </goals>
            </execution>
        </executions>
    </plugin>

    <!-- ... -->
</plugins>

有人知道我做错了什么吗?

4

1 回答 1

1

尝试

<plugin>
    <groupId>org.codehaus.mojo</groupId>
    <artifactId>aspectj-maven-plugin</artifactId>
    <version>1.4</version>
    <configuration>
        <source>1.6</source>
        <target>1.6</target>
        <complianceLevel>1.6</complianceLevel>
        <verbose>true</verbose>
        <showWeaveInfo>true</showWeaveInfo>
        <weaveMainSourceFolder>true</weaveMainSourceFolder>                    

        <weaveDependencies>
            <dependency>
                <groupId>org.perf4j</groupId>
                <artifactId>perf4j</artifactId>
                <classifier>log4jonly</classifier>
            </dependency>
        </weaveDependencies>

    </configuration>
    <executions>
        <execution>
            <id>aspectj-compile</id>
            <goals>
                <goal>compile</goal>
                <goal>test-compile</goal>
            </goals>
        </execution>
    </executions>
</plugin>
于 2014-03-04T06:57:23.267 回答