Skip to content

Commit 1fd3cac

Browse files
committed
Cleaned up samples pom files and added logging dependency to address #80. Also added a call int the exception handler for applications that don't include an appender or run in sam-local
1 parent 674b454 commit 1fd3cac

File tree

6 files changed

+22
-48
lines changed

6 files changed

+22
-48
lines changed

aws-serverless-java-container-core/src/main/java/com/amazonaws/serverless/proxy/AwsProxyExceptionHandler.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,10 @@ public class AwsProxyExceptionHandler
7676
@Override
7777
public AwsProxyResponse handle(Throwable ex) {
7878
log.error("Called exception handler for:", ex);
79+
80+
// adding a print stack trace in case we have no appender or we are running inside SAM local, where need the
81+
// output to go to the stderr.
82+
ex.printStackTrace();
7983
if (ex instanceof InvalidRequestEventException) {
8084
return new AwsProxyResponse(500, headers, getErrorJson(INTERNAL_SERVER_ERROR));
8185
} else {

samples/jersey/pet-store/pom.xml

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -49,16 +49,13 @@
4949
<version>${jersey.version}</version>
5050
</dependency>
5151

52+
<!-- https://mvnrepository.com/artifact/io.symphonia/lambda-logging -->
5253
<dependency>
53-
<groupId>com.amazonaws</groupId>
54-
<artifactId>aws-lambda-java-log4j</artifactId>
54+
<groupId>io.symphonia</groupId>
55+
<artifactId>lambda-logging</artifactId>
5556
<version>1.0.0</version>
5657
</dependency>
57-
<dependency>
58-
<groupId>org.slf4j</groupId>
59-
<artifactId>slf4j-log4j12</artifactId>
60-
<version>1.7.21</version>
61-
</dependency>
58+
6259
</dependencies>
6360

6461
<build>

samples/jersey/pet-store/src/main/java/com/amazonaws/serverless/sample/jersey/PetsResource.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@
1515
import com.amazonaws.serverless.sample.jersey.model.Pet;
1616
import com.amazonaws.serverless.sample.jersey.model.PetData;
1717

18+
import org.slf4j.Logger;
19+
import org.slf4j.LoggerFactory;
20+
1821
import javax.ws.rs.*;
1922
import javax.ws.rs.core.MediaType;
2023
import javax.ws.rs.core.Response;

samples/spark/pet-store/pom.xml

Lines changed: 4 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -37,18 +37,6 @@
3737
<version>[0.1,)</version>
3838
</dependency>
3939

40-
<dependency>
41-
<groupId>com.amazonaws</groupId>
42-
<artifactId>aws-lambda-java-core</artifactId>
43-
<version>1.1.0</version>
44-
</dependency>
45-
46-
<dependency>
47-
<groupId>com.amazonaws</groupId>
48-
<artifactId>aws-lambda-java-log4j</artifactId>
49-
<version>1.0.0</version>
50-
</dependency>
51-
5240
<!-- https://mvnrepository.com/artifact/com.sparkjava/spark-core -->
5341
<dependency>
5442
<groupId>com.sparkjava</groupId>
@@ -77,10 +65,11 @@
7765
<version>${jackson.version}</version>
7866
</dependency>
7967

68+
<!-- https://mvnrepository.com/artifact/io.symphonia/lambda-logging -->
8069
<dependency>
81-
<groupId>org.slf4j</groupId>
82-
<artifactId>slf4j-log4j12</artifactId>
83-
<version>1.7.21</version>
70+
<groupId>io.symphonia</groupId>
71+
<artifactId>lambda-logging</artifactId>
72+
<version>1.0.0</version>
8473
</dependency>
8574
</dependencies>
8675

samples/spring/pet-store/pom.xml

Lines changed: 3 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -56,32 +56,12 @@
5656
<version>${spring.version}</version>
5757
</dependency>
5858

59+
<!-- https://mvnrepository.com/artifact/io.symphonia/lambda-logging -->
5960
<dependency>
60-
<groupId>com.fasterxml.jackson.core</groupId>
61-
<artifactId>jackson-annotations</artifactId>
62-
<version>${jackson.version}</version>
63-
</dependency>
64-
<dependency>
65-
<groupId>com.fasterxml.jackson.core</groupId>
66-
<artifactId>jackson-core</artifactId>
67-
<version>${jackson.version}</version>
68-
</dependency>
69-
<dependency>
70-
<groupId>com.fasterxml.jackson.core</groupId>
71-
<artifactId>jackson-databind</artifactId>
72-
<version>${jackson.version}</version>
73-
</dependency>
74-
75-
<dependency>
76-
<groupId>com.amazonaws</groupId>
77-
<artifactId>aws-lambda-java-log4j</artifactId>
61+
<groupId>io.symphonia</groupId>
62+
<artifactId>lambda-logging</artifactId>
7863
<version>1.0.0</version>
7964
</dependency>
80-
<dependency>
81-
<groupId>org.slf4j</groupId>
82-
<artifactId>slf4j-log4j12</artifactId>
83-
<version>1.7.21</version>
84-
</dependency>
8565
</dependencies>
8666

8767
<build>

samples/springboot/pet-store/pom.xml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,11 @@
2525
<version>[0.1,)</version>
2626
</dependency>
2727

28+
<!-- https://mvnrepository.com/artifact/io.symphonia/lambda-logging -->
2829
<dependency>
29-
<groupId>com.amazonaws</groupId>
30-
<artifactId>aws-lambda-java-core</artifactId>
31-
<version>1.1.0</version>
30+
<groupId>io.symphonia</groupId>
31+
<artifactId>lambda-logging</artifactId>
32+
<version>1.0.0</version>
3233
</dependency>
3334
</dependencies>
3435

0 commit comments

Comments
 (0)