@@ -97,8 +97,7 @@ public DefaultTypeManager(DatabaseConfig config, BootupClasses bootupClasses) {
9797 this .offlineMigrationGeneration = DbOffline .isGenerateMigration ();
9898 this .defaultEnumType = config .getDefaultEnumType ();
9999
100- ServiceLoader <ScalarJsonMapper > mappers = ServiceLoader .load (ScalarJsonMapper .class );
101- jsonMapper = mappers .findFirst ().orElse (null );
100+ jsonMapper = findJsonMapper ();
102101
103102 initialiseStandard (config );
104103 initialiseJavaTimeTypes (config );
@@ -112,6 +111,28 @@ public DefaultTypeManager(DatabaseConfig config, BootupClasses bootupClasses) {
112111 }
113112 }
114113
114+ /**
115+ * Searches the JsonMapper and checks if markerAnnotation is on class path.
116+ */
117+ private static ScalarJsonMapper findJsonMapper () {
118+ ServiceLoader <ScalarJsonMapper > mappers = ServiceLoader .load (ScalarJsonMapper .class );
119+ ScalarJsonMapper mapper = mappers .findFirst ().orElse (null );
120+ if (mapper != null ) {
121+ try {
122+ if (mapper .markerAnnotation () != null ) {
123+ return mapper ;
124+ } else {
125+ log .log (System .Logger .Level .WARNING , "Not using {0}, because no marker annotation was provided. " +
126+ "Please check, if there is a supported json library (e.g. jackson) on your classpath" , mapper .getClass ().getName ());
127+ }
128+ } catch (NoClassDefFoundError e ) {
129+ log .log (System .Logger .Level .WARNING , "Can not use {0}. An error occured: {1}. " +
130+ "Please check, if there is a supported json library (e.g. jackson) on your classpath" , mapper .getClass ().getName (), e .getMessage ());
131+ }
132+ }
133+ return null ;
134+ }
135+
115136 private void loadGeoTypeBinder (DatabaseConfig config ) {
116137 GeoTypeProvider provider = config .getServiceObject (GeoTypeProvider .class );
117138 if (provider == null ) {
0 commit comments