spring-guides / gs-consuming-rest

Consuming a RESTful Web Service :: Learn how to retrieve web page data with Spring's RestTemplate.
https://spring.io/guides/gs/consuming-rest/
Apache License 2.0
195 stars 287 forks source link

Error when building in SpringTool with Maven #44

Closed Whisper40 closed 4 years ago

Whisper40 commented 4 years ago

Hello, this error happens on my side, and i don't have found a solution for this problem.

Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled.
2020-02-04 11:36:39.036 ERROR 276 --- [           main] o.s.boot.SpringApplication               : Application run failed

java.lang.IllegalStateException: Failed to execute CommandLineRunner
    at org.springframework.boot.SpringApplication.callRunner(SpringApplication.java:787) ~[spring-boot-2.2.2.RELEASE.jar:2.2.2.RELEASE]
    at org.springframework.boot.SpringApplication.callRunners(SpringApplication.java:768) ~[spring-boot-2.2.2.RELEASE.jar:2.2.2.RELEASE]
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:322) ~[spring-boot-2.2.2.RELEASE.jar:2.2.2.RELEASE]
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:1226) ~[spring-boot-2.2.2.RELEASE.jar:2.2.2.RELEASE]
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:1215) ~[spring-boot-2.2.2.RELEASE.jar:2.2.2.RELEASE]
    at com.example.consumingrest.ConsumingRestApplication.main(ConsumingRestApplication.java:18) ~[classes/:na]
dsyer commented 4 years ago

I think you missed the most important part of the stack trace (what caused it). Works for me, so we'll need more information and steps to reproduce.

Whisper40 commented 4 years ago

Other spring tool code works without any problem. But this one not, the " java.lang.IllegalStateException: Failed to execute CommandLineRunner" is my error.

Are you sure you have tested it on a fresh install, without any other configuration ? No Vm argument..

dsyer commented 4 years ago

The cause of the exception is still missing from the stack trace. Does it work for you from the command line (e.g. ./mvnw spring-boot:run)?

Whisper40 commented 4 years ago

It does not works from the Run button and not from the command line, same error. ( This error has been reported on stackoverflow, but the response does not works for me ) https://stackoverflow.com/questions/50190952/failed-to-execute-commandlinerunner-spring-batch

dsyer commented 4 years ago

In the stack overflow link did you see the Caused by: java.lang.IndexOutOfBoundsException: Index: 0, Size: 0? That's the kind of detail we are missing here. It's quite unlikely to be the same cause, so unsurprising if the same solution does not apply. Please provide more information if you want any help with this.

Whisper40 commented 4 years ago

Ok i come back tomorrow with full report ;) Thanks

Whisper40 commented 4 years ago

Hello, this is the full report : https://privatebin.net/?196b7ecc4d665399#5pxrwnCe3SiDTXV2qLQfNbKeZHcjpcRHF59CDbeo4Ayp

Caused by: org.springframework.web.client.ResourceAccessException: I/O error on GET request for "https://gturnquist-quoters.cfapps.io/api/random": gturnquist-quoters.cfapps.io; nested exception is java.net.UnknownHostException: gturnquist-quoters.cfapps.io

dsyer commented 4 years ago

There you go then. You don't have access to that URL. Are you behind a firewall or a proxy? If you are you can try and get it opened up, or you can run your own server and point the app at that.

Whisper40 commented 4 years ago

I have access to it with chrome browser. I have configured a proxy in the .m2 directory that was working (it has downloaded maven, before that config it was not possible ). Is there other configuration needed with Spring ?

dsyer commented 4 years ago

Is there other configuration needed with Spring ?

No. But the HTTP client isn't working, so it's that which needs a hint probably. Your Chrome browser is working so it must have some settings for a proxy or something. You could try and copy those. Google "How do I set the proxy to be used by the JVM" for help, or ask your own question on StackOverflow.

Whisper40 commented 4 years ago

Thanks ! Solved with the add of -Djava.net.useSystemProxies=true