Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

Java Weather App in Need of Tests

I am getting 500 and IndexOutOfBoundsException, any help?

I modified Weather API that is not in the notes to be:

Weather API

weather.api.name = darksky.net API weather.api.key = pasted my key here weather.api.host = api.darksky.net

bootRun started OK

At the search box entered zip code and got status 500

message Request processing failed; nested exception is java.lang.IndexOutOfBoundsException: Index: 0, Size: 0

description The server encountered an internal error that prevented it from fulfilling this request.


org.springframework.web.util.NestedServletException: Request processing failed; nested exception is java.lang.IndexOutOfBoundsException: Index: 0, Size: 0 org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:981) org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:860) javax.servlet.http.HttpServlet.service(HttpServlet.java:622)

... root cause

java.lang.IndexOutOfBoundsException: Index: 0, Size: 0 java.util.ArrayList.rangeCheck(Unknown Source) java.util.ArrayList.get(Unknown Source) com.teamtreehouse.service.resttemplate.geocoding.GeocodingServiceImpl.findBySearchTerm(GeocodingServiceImpl.java:38) com.teamtreehouse.web.controller.WeatherController.getWeatherForSearchTerm(WeatherController.java:40)

Can anyone provide the clue?

2 Answers

Eli P
Eli P
5,552 Points

So there have been changes since the initial release.

  1. As you've mentioned in the api.properties darksky api changes to be made are as follows:
weather.api.name = darksky API
weather.api.key = YOUR_DARKSKY_API_HERE
weather.api.host = api.darksky.net

2.Now the reason you're getting that error is this: Calling google APIs.

You're now required to enable billing on Geocoding API, unfortunately, to make this spring unit testing lessons practical. There's a limit of 1 request to this API without billing enabled. Google offers $300 free credit when you sign up at the time of writing.

Teamtreehouse, could you please maybe find other viable options without us having to enter debit/credit card details just so we could follow along these lessons?

10,448 Points

O got this Exception too. Did you get the solution?