# API Gateway ins't created ok in Java project

**URL:** <https://forum.serverless.com/t/api-gateway-inst-created-ok-in-java-project/551>\
**Category:** Serverless Framework\
**Created:** [October 15, 2016, 6:12pm UTC](https://forum.serverless.com/t/api-gateway-inst-created-ok-in-java-project/551 "2016-10-15T18:12:45Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![miman](https://avatars.discourse-cdn.com/v4/letter/m/e47774/32.png) [@miman](https://forum.serverless.com/u/miman)\
**Post date:** [October 15, 2016, 6:12pm UTC](https://forum.serverless.com/t/api-gateway-inst-created-ok-in-java-project/551/1 "2016-10-15T18:12:45Z")

</div>

Hello,

A newbie question for the Java-version of serverless (doing the same for NodeJS works fine).

I just created a test project in Java with serverless, but it doesn’t work.  
I get this as a response:  
**_{“message”: “Internal server error”}_**

I created/built/deployed the project using the following steps:

> serverless create --template aws-java-maven

I changed the serverless.yml, removing the # for the following rows:

> ```
> events:
> - http:
> path: users/create
> method: get
> 
> ```

I then built & deployed the application:

> mvn install  
> serverless deploy

What seems to be the problem is that the API gatway is created as a LAMBDA\_PROXY, which doesn’t work.

If I create a new GET function (NOT selecting _Use Lambda Proxy integration_) in the AWS console for the API and points it to the created Lambda everything works great.

Any ideas on how to get this to work directly after serverless deploy ?

// Mikael

---

<div class="post-metadata">

**Author:** ![Ben](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.serverless.com/ben/32/310_2.png) [@Ben](https://forum.serverless.com/u/Ben)\
**Post date:** [November 25, 2016, 5:03pm UTC](https://forum.serverless.com/t/api-gateway-inst-created-ok-in-java-project/551/2 "2016-11-25T17:03:16Z")

</div>

I have the exact same problem and can also only resolve it by adding `integration: lambda` to the serverless.yml file.

Any insights would be greatly appreciated!

---

<div class="post-metadata">

**Author:** ![bbilger](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.serverless.com/bbilger/32/1066_2.png) [@bbilger](https://forum.serverless.com/u/bbilger)\
**Post date:** [November 26, 2016, 3:36pm UTC](https://forum.serverless.com/t/api-gateway-inst-created-ok-in-java-project/551/3 "2016-11-26T15:36:42Z")

</div>

The Java templates (Gradle and maven) aren’t designed for Lambda Proxy Integration. If you want to make them work with Lambda Proxy Integration you have to return a **response object** like the JavaScript template does. This means you have to return an object with getters for statusCode (int), body (String) and headers (Map\<String, String ) - a response object could look like this: [https://github.com/bbilger/jrestless/blob/master/aws/gateway/jrestless-aws-gateway-handler/src/main/java/com/jrestless/aws/gateway/io/GatewayResponse.java](https://github.com/bbilger/jrestless/blob/master/aws/gateway/jrestless-aws-gateway-handler/src/main/java/com/jrestless/aws/gateway/io/GatewayResponse.java).  
The body must be a string! So make sure to serialize your actual response body to a string - if you want a JSON response you can use Jackson for serialization, for example.

You might want to check out my framework _jrestless_: [https://github.com/bbilger/jrestless](https://github.com/bbilger/jrestless). It’s a Jersey container for AWS Lambda and provides JAX-RS functionality through Jersey - the reference implementation for JAX-RS. This allows usage of most JAX-RS features and gives Spring integration, too. You can use serverless to configure and deploy your Lambda functions.

---

<div class="post-metadata">

**Author:** ![Ben](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.serverless.com/ben/32/310_2.png) [@Ben](https://forum.serverless.com/u/Ben)\
**Post date:** [December 5, 2016, 8:18am UTC](https://forum.serverless.com/t/api-gateway-inst-created-ok-in-java-project/551/4 "2016-12-05T08:18:58Z")

</div>

Thanks for the hint, I could get it to work now. jrestless looks great!

---

<div class="post-metadata">

**Author:** ![bbilger](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.serverless.com/bbilger/32/1066_2.png) [@bbilger](https://forum.serverless.com/u/bbilger)\
**Post date:** [January 6, 2017, 1:27am UTC](https://forum.serverless.com/t/api-gateway-inst-created-ok-in-java-project/551/5 "2017-01-06T01:27:34Z")

</div>

FYI: Since it wasn’t mentioned in the release notes: serverless v1.5.0 has updated Java templates that work with lambda-proxy.
