Closed kjq closed 11 months ago
Thanks for the report, @kjq! It is quite possible that the class needs to be registered for reflections, which would be an omission on our side. I wonder whether you could give a hint how to reproduce this, so that we can add a test to see that the fix really works?
The following could work as a quick workaround on your side: just add a class like this to your application:
@RegisterForReflection(classNames = "com.fasterxml.jackson.databind.ext.CoreXMLSerializers")
class ReflectionRegistrations {}
Working on getting you a reproducer.
Interestingly enough, when I add @RegisterForReflection(classNames = "com.fasterxml.jackson.databind.ext.CoreXMLSerializers")
seems to blow the native build out of the water with OOM.
Removing it builds natively successfully / including it, no matter what XMX, throws an OOM.
I could not replicate it using a simple example using a public Calculator service, ill have to work on it some more but i was able to get a better error - around this com.sun.org.apache.xerces.internal.jaxp.datatype.XMLGregorianCalendarImpl
which may be the culprit.
Failed to find class `com.fasterxml.jackson.databind.ext.CoreXMLSerializers` for handling values of type `com.sun.org.apache.xerces.internal.jaxp.datatype.XMLGregorianCalendarImpl`, problem: (java.lang.ClassNotFoundException) com.fasterxml.jackson.databind.ext.CoreXMLSerializers: java.lang.IllegalStateException: Failed to find class `com.fasterxml.jackson.databind.ext.CoreXMLSerializers` for handling values of type `com.sun.org.apache.xerces.internal.jaxp.datatype.XMLGregorianCalendarImpl`, problem: (java.lang.ClassNotFoundException) com.fasterxml.jackson.databind.ext.CoreXMLSerializers
For whatever reason today, adding the suggested work-around, works now so I probably just messed something up before.
@RegisterForReflection(
classNames = "com.fasterxml.jackson.databind.ext.CoreXMLSerializers")
class ExampleRegistration {
}
I'd still be interested to know how to reproduce this. Do you happen to have JAXB entities with some sort of date/time fields? What type are they exactly?
I think it does have to do with the entities but i need to whittle it down to give you a reproducer.
I have added a service with with java.util.Calendar
and java.time.LocalDateTime
params in https://github.com/quarkiverse/quarkus-cxf/pull/1144 and they work just fine.
Still working through trying to get you a reproducer (balancing with getting a first cut of this service out).
There are generated types like this:
@XmlElement(name = "Source", required = true)
protected String source;
@XmlElement(name = "ProvidedOn")
@XmlSchemaType(name = "dateTime")
protected XMLGregorianCalendar providedOn;
Lining up to this in the XSD
<xs:complexType name="LabelDataSource">
<xs:sequence>
<xs:element name="Source" type="fssi:String15" minOccurs="1" maxOccurs="1" />
<xs:element name="ProvidedOn" type="xs:dateTime" minOccurs="0" maxOccurs="1" />
</xs:sequence>
</xs:complexType>
Interestingly enough, I did the following because I was either having issues compiling natively (blowing the heap) or serialization issues as well but it seems I can create a shared API (where I do the WSDL generation), a gateway service that calls the SOAP service using a RESTClient, and the Quarkus SOAP service. End-to-end they all work in jvm/native mode now.
I moved my WSDL generation to another dependency so I could share it between project. Marked CXF as optional in this POM and generated the service/entities.
Created a gateway that uses a RESTClient to talk to the Quarkus CXF SOAP service. Included the CXF extension.
I had to add this to the gateway service and now it works JVM/native:
@RegisterForReflection(
classNames = {
"com.fasterxml.jackson.databind.ext.CoreXMLSerializers",
"com.fasterxml.jackson.databind.ext.CoreXMLDeserializers"})
class GatewayApplication {
}
@RegisterForReflection(
classNames = "com.fasterxml.jackson.databind.ext.CoreXMLSerializers")
class SOAPApplication {
}
The error is pretty much the same as before but adding the @RegisterForReflection
did get me past it.
For whatever reason also, depending on how I included the Quarkus CXF extension in the POM mixed with the
@RegisterForReflection
it would blow up consistently when compiling natively on the heap (and I have more than enough allocated to it). Ill pay attention to this later and see if I can produce an example as well.
I have added a test that serializes javax.xml.datatype.XMLGregorianCalendar
in https://github.com/quarkiverse/quarkus-cxf/pull/1159 and it works as expected.
Looking once again at your original stack trace, the exception is thrown when RESTeasy serializes your entity to JSON. I believe this is not something we should fix in Quarkus CXF. Indeed the issue is reproducible on plain Quarkus. I have filed https://github.com/quarkusio/quarkus/issues/37934 and submitted a reproducer https://github.com/quarkusio/quarkus/pull/37935
Makes sense. Thank you for your help, I appreciated it.
I am more than likely missing something I think.
JVM mode runs fine / Native executable fails with this:
Quarkus: 3.6.1 (and using CXF BOM from there)