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

class-loading issue with fast-jar #16102

Closed
lburgazzoli opened this issue Mar 29, 2021 · 7 comments
Closed

class-loading issue with fast-jar #16102

lburgazzoli opened this issue Mar 29, 2021 · 7 comments
Labels
area/core kind/bug Something isn't working triage/out-of-date This issue/PR is no longer valid or relevant

Comments

@lburgazzoli
Copy link
Contributor

Describe the bug

While upgrade camel-k to the latest camel-quarkus (1.8.0) and quarkus (1.13.0.Final) I've notice an issue that appears with fast-jar but not with the legacy-jar

Here the exception:

2021-03-29 18:31:58,018 ERROR [org.apa.cam.qua.mai.CamelMainRuntime] (main) Failed to start application: org.apache.camel.RuntimeCamelException: java.lang.IllegalArgumentException: org.apache.camel.util.function.ThrowingBiConsumer referenced from a method is not visible from class loader
	at org.apache.camel.RuntimeCamelException.wrapRuntimeCamelException(RuntimeCamelException.java:51)
	at org.apache.camel.k.support.SourcesSupport.load(SourcesSupport.java:116)
	at org.apache.camel.k.support.SourcesSupport.loadSources(SourcesSupport.java:75)
	at org.apache.camel.k.listener.SourcesConfigurer.accept(SourcesConfigurer.java:57)
	at org.apache.camel.k.listener.AbstractPhaseListener.accept(AbstractPhaseListener.java:32)
	at org.apache.camel.k.quarkus.Application$ListenerAdapter.invokeListeners(Application.java:135)
	at org.apache.camel.k.quarkus.Application$ListenerAdapter.beforeConfigure(Application.java:97)
	at org.apache.camel.main.BaseMainSupport.postProcessCamelContext(BaseMainSupport.java:533)
	at org.apache.camel.quarkus.main.CamelMain.initCamelContext(CamelMain.java:116)
	at org.apache.camel.quarkus.main.CamelMain.doInit(CamelMain.java:86)
	at org.apache.camel.support.service.BaseService.init(BaseService.java:83)
	at org.apache.camel.quarkus.main.CamelMain.startEngine(CamelMain.java:137)
	at org.apache.camel.quarkus.main.CamelMainRuntime.start(CamelMainRuntime.java:49)
	at org.apache.camel.quarkus.core.CamelBootstrapRecorder.start(CamelBootstrapRecorder.java:45)
	at io.quarkus.deployment.steps.CamelBootstrapProcessor$boot-173480958.deploy_0(CamelBootstrapProcessor$boot-173480958.zig:101)
	at io.quarkus.deployment.steps.CamelBootstrapProcessor$boot-173480958.deploy(CamelBootstrapProcessor$boot-173480958.zig:40)
	at io.quarkus.runner.ApplicationImpl.doStart(ApplicationImpl.zig:545)
	at io.quarkus.runtime.Application.start(Application.java:90)
	at io.quarkus.runtime.ApplicationLifecycleManager.run(ApplicationLifecycleManager.java:100)
	at io.quarkus.runtime.Quarkus.run(Quarkus.java:66)
	at io.quarkus.runtime.Quarkus.run(Quarkus.java:42)
	at io.quarkus.runtime.Quarkus.run(Quarkus.java:119)
	at io.quarkus.runner.GeneratedMain.main(GeneratedMain.zig:29)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.base/java.lang.reflect.Method.invoke(Method.java:566)
	at io.quarkus.bootstrap.runner.QuarkusEntryPoint.doRun(QuarkusEntryPoint.java:48)
	at io.quarkus.bootstrap.runner.QuarkusEntryPoint.main(QuarkusEntryPoint.java:25)
Caused by: java.lang.IllegalArgumentException: org.apache.camel.util.function.ThrowingBiConsumer referenced from a method is not visible from class loader
	at java.base/java.lang.reflect.Proxy$ProxyBuilder.ensureVisible(Proxy.java:858)
	at java.base/java.lang.reflect.Proxy$ProxyBuilder.validateProxyInterfaces(Proxy.java:681)
	at java.base/java.lang.reflect.Proxy$ProxyBuilder.<init>(Proxy.java:627)
	at java.base/java.lang.reflect.Proxy$ProxyBuilder.<init>(Proxy.java:635)
	at java.base/java.lang.reflect.Proxy.lambda$getProxyConstructor$0(Proxy.java:415)
	at java.base/jdk.internal.loader.AbstractClassLoaderValue$Memoizer.get(AbstractClassLoaderValue.java:329)
	at java.base/jdk.internal.loader.AbstractClassLoaderValue.computeIfAbsent(AbstractClassLoaderValue.java:205)
	at java.base/java.lang.reflect.Proxy.getProxyConstructor(Proxy.java:413)
	at java.base/java.lang.reflect.Proxy.newProxyInstance(Proxy.java:1006)
	at org.codehaus.groovy.vmplugin.v8.IndyInterface.fromCache(IndyInterface.java:318)
	at org.apache.camel.dsl.groovy.GroovyRoutesBuilderLoader.loadRoutesBuilder(GroovyRoutesBuilderLoader.groovy:63)
	at org.apache.camel.impl.engine.DefaultRoutesLoader.findRoutesBuilders(DefaultRoutesLoader.java:100)
	at org.apache.camel.spi.RoutesLoader.findRoutesBuilders(RoutesLoader.java:66)
	at org.apache.camel.k.support.SourcesSupport.load(SourcesSupport.java:104)
	... 27 more

There some groovy code that load a camel route at runtime, which looks like:

@Experimental
class GroovyRoutesBuilderLoader  extends RoutesBuilderLoaderSupport {
    @Override
    public RoutesBuilder loadRoutesBuilder(Resource resource) throws Exception {
        return EndpointRouteBuilder.loadEndpointRoutesBuilder(resource, this::load)
    }

    // this is the `ThrowingBiConsumer` impl.
    private void load(Reader reader, EndpointRouteBuilder builder) {
        def ic = new ImportCustomizer()
        ic.addStarImports('org.apache.camel')
        ic.addStarImports('org.apache.camel.spi')

        def cc = new CompilerConfiguration()
        cc.addCompilationCustomizers(ic)
        cc.setScriptBaseClass(DelegatingScript.class.getName())

        def sh = new GroovyShell(new Binding(), cc)
        def script = (DelegatingScript) sh.parse(reader)

        // set the delegate target
        script.setDelegate(new GroovyDSL(builder))
        script.run()
    }
}

The problem disappear if:

  • legacy-jar is configured instead of fast-jar
  • the GroovyRoutesBuilderLoader is registered to the camel context at runtime (by default the GroovyRoutesBuilderLoader class is loaded at build time)

I don't have a reproducer at the moment since I'm still working on the migration but can help reproducing the issue with my current code base.

@lburgazzoli lburgazzoli added the kind/bug Something isn't working label Mar 29, 2021
@geoand
Copy link
Contributor

geoand commented Mar 30, 2021

@stuartwdouglas I wonder if this is due to #15399

@stuartwdouglas
Copy link
Member

Can you push your current code base to a branch so I can look into it?

@geoand
Copy link
Contributor

geoand commented Apr 27, 2021

I think that #16791 should take care of this. The original fix in #12498 was incorrect.

Can you give it a shot with main @lburgazzoli ?

@lburgazzoli
Copy link
Contributor Author

I'll have a look but it is likely to take a while as I need to rebuild the whole dependency tree. Feel free to close this and I'll reopen if it is still an issue

@geoand
Copy link
Contributor

geoand commented Apr 27, 2021

No worries.

Let's just keep this issue and you can update it when you have the time

@geoand
Copy link
Contributor

geoand commented Sep 28, 2021

Closing for now.

Please reopen if the issue arises again

@geoand geoand closed this as completed Sep 28, 2021
@geoand geoand added the triage/out-of-date This issue/PR is no longer valid or relevant label Sep 28, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/core kind/bug Something isn't working triage/out-of-date This issue/PR is no longer valid or relevant
Projects
None yet
Development

No branches or pull requests

3 participants