File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Ant, Maven and Other Build Tools and the fly likes Maven in Spring test Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » Ant, Maven and Other Build Tools
Bookmark "Maven in Spring test" Watch "Maven in Spring test" New topic
Author

Maven in Spring test

pkinuk Buler
Ranch Hand

Joined: May 22, 2009
Posts: 63
Hi all,

I learned the Maven & Spring a few days ago.

I used Eclipse to run the test class called TestSpring and it passed. It also passed if run the mvn clean compile. However, it failed when I run Maven command in Eclipse. It showed the following error messages:


Running com.xyz.myapp.domain.TestSpring
org.apache.maven.surefire.booter.SurefireExecutionException: org.junit.runner.notification.RunNotifier.testAborted(Lorg/junit/runner/Description;Ljava/lang/Throwable;)V; nested exception is java.lang.NoSuchMethodError: org.junit.runner.notification.RunNotifier.testAborted(Lorg/junit/runner/Description;Ljava/lang/Throwable;)V
java.lang.NoSuchMethodError: org.junit.runner.notification.RunNotifier.testAborted(Lorg/junit/runner/Description;Ljava/lang/Throwable;)V
at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.invokeTestMethod(SpringJUnit4ClassRunner.java:155)
at org.junit.internal.runners.JUnit4ClassRunner.runMethods(JUnit4ClassRunner.java:61)
at org.junit.internal.runners.JUnit4ClassRunner$1.run(JUnit4ClassRunner.java:54)
at org.junit.internal.runners.ClassRoadie.runUnprotected(ClassRoadie.java:34)
at org.junit.internal.runners.ClassRoadie.runProtected(ClassRoadie.java:44)
at org.junit.internal.runners.JUnit4ClassRunner.run(JUnit4ClassRunner.java:52)
at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.run(SpringJUnit4ClassRunner.java:97)
at org.apache.maven.surefire.junit4.JUnit4TestSet.execute(JUnit4TestSet.java:62)
at org.apache.maven.surefire.suite.AbstractDirectoryTestSuite.executeTestSet(AbstractDirectoryTestSuite.java:140)
at org.apache.maven.surefire.suite.AbstractDirectoryTestSuite.execute(AbstractDirectoryTestSuite.java:127)
at org.apache.maven.surefire.Surefire.run(Surefire.java:177)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.apache.maven.surefire.booter.SurefireBooter.runSuitesInProcess(SurefireBooter.java:345)
at org.apache.maven.surefire.booter.SurefireBooter.main(SurefireBooter.java:1009)


The Maven command I used to create the project


The pom.xml file


Here is my test class:


Here is the test xml which stored in src/test/java/com.xyz.myapp.domain


The following two classes stored in src/main/java/com.xyz.myapp.domain







Anyone can tell me why? Thank you in advance.
Hongli Li
Ranch Hand

Joined: Oct 29, 2006
Posts: 124
artifactId=spring-hello is in your maven archetype:generate command, and why in pom.xml. you have <artifactId>aspectJHello</artifactId> <name>aspectJHello</name>


Do you know why this cup is useful? Because it is empty.
pkinuk Buler
Ranch Hand

Joined: May 22, 2009
Posts: 63
Sorry, I copied the wrong artifact ID, please use 'aspectJHello' as the artifactID in the Maven quick start command.
Martijn Verburg
author
Bartender

Joined: Jun 24, 2003
Posts: 3274
    
    5

You're also missing the -D when specifying the version


Cheers, Martijn - Blog,
Twitter, PCGen, Ikasan, My The Well-Grounded Java Developer book!,
My start-up.
pkinuk Buler
Ranch Hand

Joined: May 22, 2009
Posts: 63
Sorry angain. I copied wrong again。 Here is the right command:

Martijn Verburg
author
Bartender

Joined: Jun 24, 2003
Posts: 3274
    
    5

--DartifactId? Not -D?
Dhivya Alex
Greenhorn

Joined: Apr 09, 2014
Posts: 1
Dont know if anyuone is still facing issues with this.

You are using older spring. You will need spring 3 or above for junit4

<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring</artifactId>
<version>2.5.6</version>
</dependency>

Jaikiran Pai
Marshal

Joined: Jul 20, 2005
Posts: 10046
    
163

Dhivya, welcome to CodeRanch and thank you for posting that probable solution!

[My Blog] [JavaRanch Journal]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Maven in Spring test