From 14a4413f5a368f960afca00d3faa9912e916faf2 Mon Sep 17 00:00:00 2001 From: cmontpetit Date: Thu, 7 Jan 2016 14:47:43 -0500 Subject: [PATCH] try/catch usage of sql classes in serializer static initializer to allow it to be used in embedded compact1 configurations. --- .../databind/ser/BasicSerializerFactory.java | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/src/main/java/com/fasterxml/jackson/databind/ser/BasicSerializerFactory.java b/src/main/java/com/fasterxml/jackson/databind/ser/BasicSerializerFactory.java index d485fc21f8..556805f7b0 100644 --- a/src/main/java/com/fasterxml/jackson/databind/ser/BasicSerializerFactory.java +++ b/src/main/java/com/fasterxml/jackson/databind/ser/BasicSerializerFactory.java @@ -84,13 +84,18 @@ public abstract class BasicSerializerFactory _concrete.put(Calendar.class.getName(), CalendarSerializer.instance); DateSerializer dateSer = DateSerializer.instance; _concrete.put(java.util.Date.class.getName(), dateSer); - // note: timestamps are very similar to java.util.Date, thus serialized as such - _concrete.put(java.sql.Timestamp.class.getName(), dateSer); - // leave some of less commonly used ones as lazy, no point in proactive construction - _concreteLazy.put(java.sql.Date.class.getName(), SqlDateSerializer.class); - _concreteLazy.put(java.sql.Time.class.getName(), SqlTimeSerializer.class); - + try { + // note: timestamps are very similar to java.util.Date, thus serialized as such + _concrete.put(java.sql.Timestamp.class.getName(), dateSer); + + // leave some of less commonly used ones as lazy, no point in proactive construction + _concreteLazy.put(java.sql.Date.class.getName(), SqlDateSerializer.class); + _concreteLazy.put(java.sql.Time.class.getName(), SqlTimeSerializer.class); + } catch(NoClassDefFoundError e) { + //java.sql is not standard in embedded compact configurations. + } + // And then other standard non-structured JDK types for (Map.Entry,Object> en : StdJdkSerializers.all()) { Object value = en.getValue();