开发者

AspectJ :: Surefire tests gives NoSuchMethodError

开发者 https://www.devze.com 2023-02-17 08:25 出处:网络
I\'m doing the compile time AspectJ weaving on existing classes, that is working beautifully in eclipse(AJDT). But when I run test in in maven using surefire , the test cases of this class where the a

I'm doing the compile time AspectJ weaving on existing classes, that is working beautifully in eclipse(AJDT). But when I run test in in maven using surefire , the test cases of this class where the aspects are applied are failing. I'm quite sure the weaving is happening correctly, it looks like a class path issue. Following is the error when I execute the surefire test.

java.lang.NoSuchMethodError: com.online.station.OBSDescriptorBrokerageMortgageRemovalAspect.aspectOf()Lcom/online/station/OBSDescriptorBrokerageMortgageRemovalAspect; at com.online.station.delegate.fundstransfer.AuthorizeAccForTransfDelegImpl.unpackResponse(AuthorizeAccForTransfDelegImpl.java:111)

Following is my surefire plugin config in pom.xml

        <plugin>
            <artifactId>maven-surefire-plugin</artifactId>
            <configuration>
                <forkMode>once</forkMode>
                <argLine>
                    -javaagent:"${settings.localRepository}/org/aspectj/aspectjweaver/${aspectj.version}/aspectjweaver-${aspectj.version}.jar"
                </argLine>
                <useSystemClassloader>true</useSystemClassloader>
                <includes>
                    <include>**/*Test.java</include>
                </includes>
                <excludes>
                    <exclude>**/WebTestCase.java</exclude>
                </excludes>
         开发者_Python百科   </configuration>
        </plugin>

I tried various things but it didn't work, any suggestions will be greately appreciated !!

Is there any need to have a aop.xml for this to work ? Following is the aspectj plugin info.

<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>aspectj-maven-plugin</artifactId>
<version>1.3</version>
<configuration>
    <verbose>true</verbose>
    <complianceLevel>${jdk.source.version}</complianceLevel>
    <target>${jdk.target.version}</target>
    <showWeaveInfo>true</showWeaveInfo>
    <weaveMainSourceFolder>true</weaveMainSourceFolder>
    <includes>
        <!-- Class AspectClass1 and dependencies -->
        <include>**/AspectClass1*</include>
        <include>**/Class2*</include>
        <include>**/Class3*</include>
        <include>**/Class4*</include>
        <include>**/Class5*</include>
        <include>**/Class6*</include>
        <include>**/Class7*</include>
        <include>**/Class8*</include>

    </includes>
</configuration>
<executions>
    <execution>
    <goals>
        <goal>compile</goal>                <goal>test-compile</goal>       </goals>
    </execution>
   </executions>

As I need compile time weaving only, I have no aop.xml configured.

Any help on tjis please !

Thanks !! Girish


Three suggestions:

  1. Make sure that your aspectj plugin for maven is configured correctly. If you have any questions about that, paste that part of your pom.xml in your question above.
  2. Make sure that your aop.xml references all of the required aspects.
  3. Make sure that your aspect-path/in-path is configured properly.
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号