Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[quarkus-main] Native build may fail with ClassNotFoundException when quarkus-jaxb is on the classpath #5650

Closed
jamesnetherton opened this issue Jan 16, 2024 · 9 comments
Assignees
Milestone

Comments

@jamesnetherton
Copy link
Contributor

jamesnetherton commented Jan 16, 2024

Bug description

A recent change was committed to the Quarkus main branch in the jaxb extension that has started registering the full type hierarchy for JAXB annotated types for reflection:

quarkusio/quarkus@24b321e

This has led to native build failures due to ClassNotFoundException in integration test modules:

  • azure-grouped
  • cxf-grouped
  • http-grouped
  • soap
  • xmlsecurity

https://github.com/apache/camel-quarkus/actions/runs/7536166981/job/20513823436

@jamesnetherton
Copy link
Contributor Author

Not sure if the Quarkus JAXB fix is flawed, or whether it has uncovered some issues on our side. It need to be investigated.

@jamesnetherton
Copy link
Contributor Author

A lot of the Camel core (and various other third party stuff) now gets registered for reflection with this change. Taking the azure-grouped test as an example:

Before:

7,979 types, 3,981 fields, and 18,055 methods registered for reflection

After:

10,684 types, 9,888 fields, and 34,668 methods registered for reflection

@gsmet
Copy link
Contributor

gsmet commented Jan 16, 2024

Any chance you could give more details about why types are leaking? I suspect some class should be ignored somehow but it’s hard to know with the information provided in the issue.

@jamesnetherton
Copy link
Contributor Author

Any chance you could give more details about why types are leaking? I suspect some class should be ignored somehow but it’s hard to know with the information provided in the issue.

I've not really done much a deep dive into it all yet, but, various parts of the Camel core model have JAXB annotations. With ReflectiveHierarchyBuildItem now being used, I guess the scope of what's registered for reflection is widened somewhat.

For example, I now see classes like org.apache.camel.spi.Registryand org.apache.camel.TypeConverterbeing registered for reflection. I don't think that should be necessary, because the Camel registry setup and type converter discovery is done at build time.

I also see some third party classes being registered for reflection like com.azure.storage.queue.QueueServiceClient & com.azure.storage.blob.BlobServiceClient, which I also don't think is necessary.

Taking the Azure tests as an example, here's what I see being registered for reflection from the processing of ReflectiveHierarchyBuildItem:

https://gist.github.com/jamesnetherton/8d00791f61c610a89b30e67a79c4d23b

On the flipside, maybe this change has uncovered some potential issues in CQ. E.g the failure in the azure-grouped test is:

java.lang.ClassNotFoundException: io.micrometer.core.instrument.Tags

Micrometer is an optional dependency of reactor-core (transitive of azure-core), so I'm surprised we've not run into this previously.

What worries me a bit is that only a small fraction of the CQ itests have jaxb on the classpath. I wonder what other failures would be uncovered if all of the test modules had it as a dependency....

@gsmet
Copy link
Contributor

gsmet commented Jan 16, 2024

@jamesnetherton could you try with: quarkusio/quarkus#38217 ?

The important information is this output you can see in the log:

2024-01-16 02:55:51,275 WARN  [io.qua.dep.ste.ReflectiveHierarchyStep] (build-29) Unable to properly register the hierarchy of the following classes for reflection as they are not in the Jandex index:
	- com.sun.istack.FinalArrayList (sources: JaxbProcessor > jakarta.xml.ws.wsaddressing.W3CEndpointReference, JaxbProcessor > org.apache.camel.model.FromDefinition)
	- com.sun.istack.Pool (source: JaxbProcessor > jakarta.xml.ws.wsaddressing.W3CEndpointReference)
	- com.sun.xml.fastinfoset.stax.StAXDocumentSerializer (source: JaxbProcessor > org.apache.camel.model.FromDefinition)
	- io.netty.buffer.ByteBuf (source: JaxbProcessor > org.apache.camel.model.ToDynamicDefinition)
	- io.netty.buffer.ByteBufAllocator (source: JaxbProcessor > org.apache.camel.model.ToDynamicDefinition)
	- io.netty.buffer.CompositeByteBuf (source: JaxbProcessor > org.apache.camel.model.ToDynamicDefinition)
	- io.quarkus.vertx.http.runtime.VertxInputStream (source: JaxbProcessor > org.apache.camel.model.ToDynamicDefinition)
	- io.vertx.core.http.HttpServerRequest (source: JaxbProcessor > org.apache.camel.model.ToDynamicDefinition)
	- io.vertx.core.http.HttpServerResponse (source: JaxbProcessor > org.apache.camel.model.ToDynamicDefinition)
	- io.vertx.ext.web.RoutingContext (source: JaxbProcessor > org.apache.camel.model.ToDynamicDefinition)
	- jakarta.jws.WebService (source: JaxbProcessor > org.apache.camel.model.ToDynamicDefinition)
	- jakarta.servlet.AsyncContext (source: JaxbProcessor > org.apache.camel.model.ToDynamicDefinition)
	- jakarta.servlet.DispatcherType (source: JaxbProcessor > org.apache.camel.model.ToDynamicDefinition)
	- jakarta.servlet.ServletConnection (source: JaxbProcessor > org.apache.camel.model.ToDynamicDefinition)
	- jakarta.servlet.ServletContext (sources: JaxbProcessor > org.apache.camel.model.FromDefinition, JaxbProcessor > org.apache.camel.model.ToDynamicDefinition)
	- jakarta.servlet.ServletInputStream (source: JaxbProcessor > org.apache.camel.model.ToDynamicDefinition)
	- jakarta.servlet.ServletOutputStream (source: JaxbProcessor > org.apache.camel.model.ToDynamicDefinition)
	- jakarta.servlet.http.Cookie (source: JaxbProcessor > org.apache.camel.model.ToDynamicDefinition)
	- jakarta.servlet.http.HttpServletRequest (source: JaxbProcessor > org.apache.camel.model.ToDynamicDefinition)
	- jakarta.servlet.http.HttpServletResponse (source: JaxbProcessor > org.apache.camel.model.ToDynamicDefinition)
	- jakarta.servlet.http.HttpSession (source: JaxbProcessor > org.apache.camel.model.ToDynamicDefinition)
	- jakarta.servlet.http.Part (source: JaxbProcessor > org.apache.camel.model.ToDynamicDefinition)
	- jakarta.validation.Validator (source: JaxbProcessor > org.apache.camel.model.FromDefinition)
	- jakarta.xml.bind.Binder (source: JaxbProcessor > jakarta.xml.ws.wsaddressing.W3CEndpointReference)
	- jakarta.xml.bind.JAXBContext (sources: JaxbProcessor > jakarta.xml.ws.wsaddressing.W3CEndpointReference, JaxbProcessor > org.apache.camel.model.FromDefinition)

@jamesnetherton
Copy link
Contributor Author

@jamesnetherton could you try with: quarkusio/quarkus#38217 ?

It seems to fix our soap integration test. The others I mentioned above still fail.

Taking the Azure itest as an example again. There's the output:

[WARNING] [io.quarkus.deployment.steps.ReflectiveHierarchyStep] Unable to properly register the hierarchy of the following classes for reflection as they are not in the Jandex index:
	- com.azure.core.amqp.AmqpRetryOptions (source: JaxbProcessor > org.apache.camel.model.ToDynamicDefinition)
	- com.azure.core.amqp.AmqpTransportType (source: JaxbProcessor > org.apache.camel.model.ToDynamicDefinition)
	- com.azure.core.amqp.ProxyOptions (source: JaxbProcessor > org.apache.camel.model.ToDynamicDefinition)
	- com.azure.core.amqp.implementation.AmqpChannelProcessor (source: JaxbProcessor > org.apache.camel.model.ToDynamicDefinition)
	- com.azure.core.amqp.implementation.AmqpReceiveLink (source: JaxbProcessor > org.apache.camel.model.ToDynamicDefinition)
	- com.azure.core.amqp.implementation.ConnectionOptions (source: JaxbProcessor > org.apache.camel.model.ToDynamicDefinition)
	- com.azure.core.amqp.implementation.ErrorContextProvider (source: JaxbProcessor > org.apache.camel.model.ToDynamicDefinition)
	- com.azure.core.amqp.implementation.MessageSerializer (source: JaxbProcessor > org.apache.camel.model.ToDynamicDefinition)
	- com.azure.core.amqp.models.AmqpAnnotatedMessage (source: JaxbProcessor > org.apache.camel.model.ToDynamicDefinition)
	- com.azure.storage.blob.changefeed.BlobChangefeedClient (source: JaxbProcessor > org.apache.camel.model.ToDynamicDefinition)
	- com.azure.storage.blob.changefeed.models.BlobChangefeedEvent (source: JaxbProcessor > org.apache.camel.model.ToDynamicDefinition)
	- com.azure.storage.common.StorageSharedKeyCredential (sources: JaxbProcessor > org.apache.camel.model.FromDefinition, JaxbProcessor > org.apache.camel.model.ToDynamicDefinition)
	- javax.crypto.spec.SecretKeySpec (source: JaxbProcessor > org.apache.camel.model.ToDynamicDefinition)
	- javax.management.MBeanServer (source: JaxbProcessor > org.apache.camel.model.RoutesDefinition)
	- javax.naming.Context (source: JaxbProcessor > org.apache.camel.model.RouteDefinition)
	- javax.net.ssl.KeyManager (source: JaxbProcessor > org.apache.camel.model.cloud.ServiceCallServiceDiscoveryConfiguration)
	- javax.net.ssl.SNIServerName (source: JaxbProcessor > org.apache.camel.model.cloud.ServiceCallServiceDiscoveryConfiguration)
	- javax.net.ssl.TrustManager (source: JaxbProcessor > org.apache.camel.model.cloud.ServiceCallServiceDiscoveryConfiguration)
	- javax.xml.xpath.XPathFactory (sources: JaxbProcessor > org.apache.camel.model.RoutesDefinition, JaxbProcessor > org.apache.camel.model.language.ExpressionDefinition)
	- org.apache.camel.tooling.model.MainModel (source: JaxbProcessor > org.apache.camel.model.RoutesDefinition)
	- org.apache.qpid.proton.engine.SslDomain$VerifyMode (source: JaxbProcessor > org.apache.camel.model.ToDynamicDefinition)
	- org.apache.qpid.proton.message.Message (source: JaxbProcessor > org.apache.camel.model.ToDynamicDefinition)
	- org.w3c.dom.Element (source: JaxbProcessor > org.apache.camel.model.app.BeansDefinition)
	- reactor.core.CoreSubscriber (source: JaxbProcessor > org.apache.camel.model.ToDynamicDefinition)
	- reactor.core.Disposable (source: JaxbProcessor > org.apache.camel.model.ToDynamicDefinition)
	- reactor.core.publisher.Flux (sources: JaxbProcessor > org.apache.camel.model.FromDefinition, JaxbProcessor > org.apache.camel.model.ToDynamicDefinition)
	- reactor.core.publisher.FluxProcessor (source: JaxbProcessor > org.apache.camel.model.ToDynamicDefinition)
	- reactor.core.publisher.Mono (sources: JaxbProcessor > org.apache.camel.model.FromDefinition, JaxbProcessor > org.apache.camel.model.ToDynamicDefinition)
	- reactor.core.publisher.Sinks$One (source: JaxbProcessor > org.apache.camel.model.FromDefinition)
	- reactor.core.scheduler.Scheduler (source: JaxbProcessor > org.apache.camel.model.ToDynamicDefinition)
	- reactor.util.context.Context (source: JaxbProcessor > org.apache.camel.model.ToDynamicDefinition)

@gsmet
Copy link
Contributor

gsmet commented Jan 16, 2024

So a ton of things are leaking from ToDynamicDefinition. Let me have a look.

@gsmet
Copy link
Contributor

gsmet commented Jan 16, 2024

Yeah so the problem is with the getters. I'll try to come up with something more sophisticated...

@jamesnetherton
Copy link
Contributor Author

Confirmed as fixed in the recent nightly builds.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants