1

I'm trying to import a simple code sample in STS from https://spring.io/guides/gs/rest-service/

I have configured maven in my system. However whenever I try to run mvn install from command line or STS it throws following errors -

Stack Trace:

[INFO] Scanning for projects...
[INFO]                                                                         
[INFO] ------------------------------------------------------------------------
[INFO] Building gs-consuming-rest 0.1.0
[INFO] ------------------------------------------------------------------------
[WARNING] The POM for org.slf4j:slf4j-api:jar:1.7.24 is invalid, transitive dependencies (if any) will not be available, enable debug logging for more details
[WARNING] The POM for org.slf4j:jcl-over-slf4j:jar:1.7.24 is invalid, transitive dependencies (if any) will not be available, enable debug logging for more details
[WARNING] The POM for org.slf4j:jul-to-slf4j:jar:1.7.24 is invalid, transitive dependencies (if any) will not be available, enable debug logging for more details
[WARNING] The POM for org.slf4j:log4j-over-slf4j:jar:1.7.24 is invalid, transitive dependencies (if any) will not be available, enable debug logging for more details
[INFO] 
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ gs-consuming-rest ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory H:\SecondSemester\CMPE275\Lab2Spring\sts workspace\gs-consuming-rest-complete\src\main\resources
[INFO] skip non existing resourceDirectory H:\SecondSemester\CMPE275\Lab2Spring\sts workspace\gs-consuming-rest-complete\src\main\resources
[INFO] 
[INFO] --- maven-compiler-plugin:3.1:compile (default-compile) @ gs-consuming-rest ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 3 source files to H:\SecondSemester\CMPE275\Lab2Spring\sts workspace\gs-consuming-rest-complete\target\classes
[WARNING] error reading C:\Users\Pavan Shah\.m2\repository\org\springframework\boot\spring-boot\1.5.2.RELEASE\spring-boot-1.5.2.RELEASE.jar; invalid LOC header (bad signature)
[WARNING] error reading C:\Users\Pavan Shah\.m2\repository\org\springframework\boot\spring-boot-autoconfigure\1.5.2.RELEASE\spring-boot-autoconfigure-1.5.2.RELEASE.jar; invalid CEN header (bad signature)
[WARNING] error reading C:\Users\Pavan Shah\.m2\repository\org\springframework\spring-core\4.3.7.RELEASE\spring-core-4.3.7.RELEASE.jar; invalid LOC header (bad signature)
[WARNING] error reading C:\Users\Pavan Shah\.m2\repository\org\springframework\spring-web\4.3.7.RELEASE\spring-web-4.3.7.RELEASE.jar; invalid LOC header (bad signature)
[WARNING] error reading C:\Users\Pavan Shah\.m2\repository\org\springframework\spring-beans\4.3.7.RELEASE\spring-beans-4.3.7.RELEASE.jar; invalid LOC header (bad signature)
[WARNING] error reading C:\Users\Pavan Shah\.m2\repository\org\springframework\spring-context\4.3.7.RELEASE\spring-context-4.3.7.RELEASE.jar; invalid LOC header (bad signature)
[WARNING] error reading C:\Users\Pavan Shah\.m2\repository\com\fasterxml\jackson\core\jackson-databind\2.8.7\jackson-databind-2.8.7.jar; invalid LOC header (bad signature)
[WARNING] error reading C:\Users\Pavan Shah\.m2\repository\com\fasterxml\jackson\core\jackson-core\2.8.7\jackson-core-2.8.7.jar; invalid LOC header (bad signature)
[INFO] 
[INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) @ gs-consuming-rest ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory H:\SecondSemester\CMPE275\Lab2Spring\sts workspace\gs-consuming-rest-complete\src\test\resources
[INFO] 
[INFO] --- maven-compiler-plugin:3.1:testCompile (default-testCompile) @ gs-consuming-rest ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 1 source file to H:\SecondSemester\CMPE275\Lab2Spring\sts workspace\gs-consuming-rest-complete\target\test-classes
[WARNING] error reading C:\Users\Pavan Shah\.m2\repository\org\springframework\boot\spring-boot\1.5.2.RELEASE\spring-boot-1.5.2.RELEASE.jar; invalid LOC header (bad signature)
[WARNING] error reading C:\Users\Pavan Shah\.m2\repository\org\springframework\boot\spring-boot-autoconfigure\1.5.2.RELEASE\spring-boot-autoconfigure-1.5.2.RELEASE.jar; invalid CEN header (bad signature)
[WARNING] error reading C:\Users\Pavan Shah\.m2\repository\org\springframework\spring-core\4.3.7.RELEASE\spring-core-4.3.7.RELEASE.jar; invalid LOC header (bad signature)
[WARNING] error reading C:\Users\Pavan Shah\.m2\repository\org\springframework\spring-web\4.3.7.RELEASE\spring-web-4.3.7.RELEASE.jar; invalid LOC header (bad signature)
[WARNING] error reading C:\Users\Pavan Shah\.m2\repository\org\springframework\spring-beans\4.3.7.RELEASE\spring-beans-4.3.7.RELEASE.jar; invalid LOC header (bad signature)
[WARNING] error reading C:\Users\Pavan Shah\.m2\repository\org\springframework\spring-context\4.3.7.RELEASE\spring-context-4.3.7.RELEASE.jar; invalid LOC header (bad signature)
[WARNING] error reading C:\Users\Pavan Shah\.m2\repository\com\fasterxml\jackson\core\jackson-databind\2.8.7\jackson-databind-2.8.7.jar; invalid LOC header (bad signature)
[WARNING] error reading C:\Users\Pavan Shah\.m2\repository\com\fasterxml\jackson\core\jackson-core\2.8.7\jackson-core-2.8.7.jar; invalid LOC header (bad signature)
[WARNING] error reading C:\Users\Pavan Shah\.m2\repository\org\assertj\assertj-core\2.6.0\assertj-core-2.6.0.jar; invalid LOC header (bad signature)
[WARNING] error reading C:\Users\Pavan Shah\.m2\repository\org\springframework\spring-test\4.3.7.RELEASE\spring-test-4.3.7.RELEASE.jar; invalid LOC header (bad signature)
[INFO] 
[INFO] --- maven-surefire-plugin:2.18.1:test (default-test) @ gs-consuming-rest ---
[INFO] Surefire report directory: H:\SecondSemester\CMPE275\Lab2Spring\sts workspace\gs-consuming-rest-complete\target\surefire-reports

-------------------------------------------------------
 T E S T S
-------------------------------------------------------
Running hello.ApplicationTest
Tests run: 1, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 0.003 sec <<< FAILURE! - in hello.ApplicationTest
initializationError(hello.ApplicationTest)  Time elapsed: 0.002 sec  <<< ERROR!
java.lang.TypeNotPresentException: Type org.springframework.test.context.junit4.SpringRunner not present
    at sun.reflect.annotation.TypeNotPresentExceptionProxy.generateException(TypeNotPresentExceptionProxy.java:46)
    at sun.reflect.annotation.AnnotationInvocationHandler.invoke(AnnotationInvocationHandler.java:84)
    at com.sun.proxy.$Proxy2.value(Unknown Source)
    at org.junit.internal.builders.AnnotatedBuilder.runnerForClass(AnnotatedBuilder.java:86)
    at org.junit.runners.model.RunnerBuilder.safeRunnerForClass(RunnerBuilder.java:59)
    at org.junit.internal.builders.AllDefaultPossibilitiesBuilder.runnerForClass(AllDefaultPossibilitiesBuilder.java:26)
    at org.junit.runners.model.RunnerBuilder.safeRunnerForClass(RunnerBuilder.java:59)
    at org.junit.internal.requests.ClassRequest.getRunner(ClassRequest.java:33)
    at org.apache.maven.surefire.junit4.JUnit4Provider.execute(JUnit4Provider.java:283)
    at org.apache.maven.surefire.junit4.JUnit4Provider.executeWithRerun(JUnit4Provider.java:173)
    at org.apache.maven.surefire.junit4.JUnit4Provider.executeTestSet(JUnit4Provider.java:153)
    at org.apache.maven.surefire.junit4.JUnit4Provider.invoke(JUnit4Provider.java:128)
    at org.apache.maven.surefire.booter.ForkedBooter.invokeProviderInSameClassLoader(ForkedBooter.java:203)
    at org.apache.maven.surefire.booter.ForkedBooter.runSuitesInProcess(ForkedBooter.java:155)
    at org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:103)
Caused by: java.lang.ClassNotFoundException: org.springframework.test.context.junit4.SpringRunner
    at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
    at java.lang.Class.forName0(Native Method)
    at java.lang.Class.forName(Class.java:348)
    at sun.reflect.generics.factory.CoreReflectionFactory.makeNamedType(CoreReflectionFactory.java:114)
    at sun.reflect.generics.visitor.Reifier.visitClassTypeSignature(Reifier.java:125)
    at sun.reflect.generics.tree.ClassTypeSignature.accept(ClassTypeSignature.java:49)
    at sun.reflect.annotation.AnnotationParser.parseSig(AnnotationParser.java:439)
    at sun.reflect.annotation.AnnotationParser.parseClassValue(AnnotationParser.java:420)
    at sun.reflect.annotation.AnnotationParser.parseMemberValue(AnnotationParser.java:349)
    at sun.reflect.annotation.AnnotationParser.parseAnnotation2(AnnotationParser.java:286)
    at sun.reflect.annotation.AnnotationParser.parseAnnotations2(AnnotationParser.java:120)
    at sun.reflect.annotation.AnnotationParser.parseAnnotations(AnnotationParser.java:72)
    at java.lang.Class.createAnnotationData(Class.java:3521)
    at java.lang.Class.annotationData(Class.java:3510)
    at java.lang.Class.getAnnotation(Class.java:3415)
    at org.apache.maven.surefire.common.junit4.JUnit4TestChecker.isValidJUnit4Test(JUnit4TestChecker.java:65)
    at org.apache.maven.surefire.common.junit4.JUnit4TestChecker.accept(JUnit4TestChecker.java:52)
    at org.apache.maven.surefire.util.DefaultScanResult.applyFilter(DefaultScanResult.java:97)
    at org.apache.maven.surefire.junit4.JUnit4Provider.scanClassPath(JUnit4Provider.java:222)
    at org.apache.maven.surefire.junit4.JUnit4Provider.invoke(JUnit4Provider.java:107)
    at org.apache.maven.surefire.booter.ForkedBooter.invokeProviderInSameClassLoader(ForkedBooter.java:203)
    at org.apache.maven.surefire.booter.ForkedBooter.runSuitesInProcess(ForkedBooter.java:155)
    at org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:103)


Results :

Tests in error: 
  ApplicationTest.initializationError ยป TypeNotPresent Type org.springframework....

Tests run: 1, Failures: 0, Errors: 1, Skipped: 0

[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 16.592 s
[INFO] Finished at: 2017-04-15T20:20:09-07:00
[INFO] Final Memory: 24M/183M
[INFO] ------------------------------------------------------------------------
[WARNING] The requested profile "pom.xml" could not be activated because it does not exist.
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.18.1:test (default-test) on project gs-consuming-rest: There are test failures.
[ERROR] 
[ERROR] Please refer to H:\SecondSemester\CMPE275\Lab2Spring\sts workspace\gs-consuming-rest-complete\target\surefire-reports for the individual test results.
[ERROR] -> [Help 1]
[ERROR] 
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR] 
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException

Below is my pom.xml

    <?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <groupId>org.springframework</groupId>
    <artifactId>gs-consuming-rest</artifactId>
    <version>0.1.0</version>

    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>1.5.2.RELEASE</version>
    </parent>

    <properties>
        <java.version>1.8</java.version>
    </properties>

    <dependencies>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-web</artifactId>
        </dependency>
        <dependency>
            <groupId>com.fasterxml.jackson.core</groupId>
            <artifactId>jackson-databind</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-test</artifactId>
            <scope>test</scope>
        </dependency>
    </dependencies>


    <build>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
            </plugin>
        </plugins>
    </build>

</project>

There seems to be some issue with my configuration but I'm unable to locate it. Any help is welcome.

pavan shah
  • 129
  • 2
  • 13
  • suppose this [post](http://stackoverflow.com/questions/13932928/springjunit4classrunner-class-not-found) may help you to get the issue fixed. โ€“ Rajith Pemabandu Apr 16 '17 at 04:39

1 Answers1

2

Couple of things

  1. spring-boot-1.5.2.RELEASE.jar,spring-core-4.3.7.RELEASE.jar seems to be corrupted, can u please try deleting it & Let it be downloaded again.

  2. It seems to be running with profile "pom.xml".

    The requested profile "pom.xml" could not be activated because it does not exist.

Make sure it should run without any profile, You can see in figure where u can change it. enter image description here

Parth Ghiya
  • 6,929
  • 2
  • 30
  • 37