guice 7 / jakarta inject support?
josephlbarnett opened this issue · 1 comments
Trying to migrate an app using the guice module to guice 7 which uses jakarta.inject package/namespace, and seeing this error:
java.lang.NoClassDefFoundError: javax/inject/Inject
at com.fasterxml.jackson.module.guice.GuiceAnnotationIntrospector._findGuiceInjectId(GuiceAnnotationIntrospector.java:44)
at com.fasterxml.jackson.module.guice.GuiceAnnotationIntrospector.findInjectableValue(GuiceAnnotationIntrospector.java:18)
at com.fasterxml.jackson.databind.introspect.AnnotationIntrospectorPair.findInjectableValue(AnnotationIntrospectorPair.java:309)
at com.fasterxml.jackson.databind.introspect.POJOPropertiesCollector._addInjectables(POJOPropertiesCollector.java:902)
at com.fasterxml.jackson.databind.introspect.POJOPropertiesCollector.collectAll(POJOPropertiesCollector.java:464)
at com.fasterxml.jackson.databind.introspect.POJOPropertiesCollector.getJsonValueAccessor(POJOPropertiesCollector.java:286)
at com.fasterxml.jackson.databind.introspect.BasicBeanDescription.findJsonValueAccessor(BasicBeanDescription.java:258)
at com.fasterxml.jackson.databind.ser.BasicSerializerFactory.findSerializerByAnnotations(BasicSerializerFactory.java:393)
at com.fasterxml.jackson.databind.ser.BeanSerializerFactory._createSerializer2(BeanSerializerFactory.java:225)
at com.fasterxml.jackson.databind.ser.BeanSerializerFactory.createSerializer(BeanSerializerFactory.java:174)
at com.fasterxml.jackson.databind.SerializerProvider._createUntypedSerializer(SerializerProvider.java:1507)
at com.fasterxml.jackson.databind.SerializerProvider._createAndCacheUntypedSerializer(SerializerProvider.java:1455)
at com.fasterxml.jackson.databind.SerializerProvider.findValueSerializer(SerializerProvider.java:556)
at com.fasterxml.jackson.databind.SerializerProvider.findTypedValueSerializer(SerializerProvider.java:834)
at com.fasterxml.jackson.databind.ser.DefaultSerializerProvider.serializeValue(DefaultSerializerProvider.java:307)
at com.fasterxml.jackson.databind.ObjectMapper._writeValueAndClose(ObjectMapper.java:4719)
at com.fasterxml.jackson.databind.ObjectMapper.writeValueAsString(ObjectMapper.java:3964)
Assuming something would need to be done to support javax.inject.Inject and/or jakarta.inject.Inject based on runtime dependency availability? seems like a mess but is there an existing workaround I'm missing?
Jackson project does not support automagic selection between javax and jakarta dependencies: instead, there should be 2 separate implementations (see README of this repo wrt JAXB-vs-Jakarta-Xml-Bind annotations module).
So we'd probably need second alternate Guice module here.
But note, too, that the module as-is only supports Guice 4.x. So someone would need to, I think, first figure out what work is needed to get later versions might need.
It is possible it might only require adding javax API dependency but that is just guessing.
I don't know enough to be able to resolve this but if you or anyone else have time and itch to dig in, I'd be happy to help however I can wrt code reviews, getting PR(s) merged and so on.