lucas johnston
lucas johnston

Reputation: 31

Spring Boot Jetty not supported on GAE, but causes my tests to fail when removed?

I am building out an API using Spring Boot, which is being deployed to Google App Engine with Travis CI.

I started my code from Google's Starter Project (https://github.com/GoogleCloudPlatform/getting-started-java/tree/master/appengine-standard-java8/springboot-appengine-standard), which doesn't use the spring-boot-starter-jetty dependency. As such, my project also did not not require it, and everything was deploying fine.

That was until I decided to add a test that uses Spring's TestRestTemplate.getForEntity() method to hit a basic endpoint I could assert on, just to give me some peace of mind that the endpoint could be reached end-to-end. However, I got the following error when running the test locally:

java.lang.IllegalStateException: Failed to load ApplicationContext
[stacktrace]
Caused by: org.springframework.context.ApplicationContextException: Unable to start web server; nested exception is org.springframework.context.ApplicationContextException: Unable to start ServletWebServerApplicationContext due to missing ServletWebServerFactory bean.
[stacktrace]
Caused by: org.springframework.context.ApplicationContextException: Unable to start ServletWebServerApplicationContext due to missing ServletWebServerFactory bean.

Looking around, it became apparent that I should add the spring-boot-starter-jetty, and the test started passing! Everything looked fine.

However, after committing and deploying to GAE, I now get a 500 Error when trying to hit the endpoint. I did some digging in Stackdriver, and this is the error that's thrown:

java.lang.RuntimeException: javax.servlet.ServletException: Not running on Jetty, JSR-356 support unavailable

I presume that JSR-356 support is required by spring-boot-starter-jetty, which I presume GAE doesn't support, hence the error. I have reported this upstream here: https://issuetracker.google.com/issues/79235250

Is there a way I can add the dependency without JSR-356 support, or is there another way I can get some form of HTTP End-To-End test to pass?

You can view my source code here: https://github.com/bytelucas/nohold - the test in question is HTTPRequestTest.java.

Upvotes: 0

Views: 536

Answers (1)

wonderlearner
wonderlearner

Reputation: 90

Looks like Spring boot defaults the starter jetty to 9.1, can you try overriding the default to earlier versions of jetty by adding it (in POM) which uses JSR-353 to see if that fixes the issue instead.

Upvotes: 1

Related Questions