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

LinkageError when hot reloading project using classes in external dependencies #23167

Closed
Postremus opened this issue Jan 25, 2022 · 6 comments · Fixed by #23185
Closed

LinkageError when hot reloading project using classes in external dependencies #23167

Postremus opened this issue Jan 25, 2022 · 6 comments · Fixed by #23185
Assignees
Labels
area/arc Issue related to ARC (dependency injection) area/devmode kind/bug Something isn't working
Milestone

Comments

@Postremus
Copy link
Member

Describe the bug

I have following structure in my reproducer project:

External dependency:

  • A class called Configuration. This is a simple pojo, no cdi bean
  • META-INF/beans.xml file

Quarkus project:

  • ConfigurationProducer - a cdi producer, creating an applicationscoped instance of the Configuration
  • ConfigurationValidator - Startup bean, which validates the produced Configuration in an PostConstruct
  • GreetingResource - a simple inject of the Configuration

On first quarkus:dev, this app starts flawlessly.
If I now hot reload, I get the exception from below.

This only happens with 2.7.0.CR1.
With 2.6.3.Final, this exception did not happen.

Expected behavior

No exceptions when hot reloading, like in 2.6.3.Final

Actual behavior

2022-01-25 09:30:46,446 INFO  [io.quarkus] (Quarkus Main Thread) hot-reload-producer stopped in 0.013s
__  ____  __  _____   ___  __ ____  ______
 --/ __ \/ / / / _ | / _ \/ //_/ / / / __/
 -/ /_/ / /_/ / __ |/ , _/ ,< / /_/ /\ \
--\___\_\____/_/ |_/_/|_/_/|_|\____/___/
2022-01-25 09:30:48,222 ERROR [io.qua.run.Application] (Quarkus Main Thread) Failed to start application (with profile dev): java.lang.LinkageError: loader constraint violation: when r
esolving method 'void com.acme.spi.ConfigurationProducer_ProducerMethod_configure_583a1d0f9a47125f3f16fd0e1923dbf7b49ecb1a_ClientProxy.<init>(org.acme.ConfigurationProducer_ProducerMet
hod_configure_583a1d0f9a47125f3f16fd0e1923dbf7b49ecb1a_Bean)' the class loader io.quarkus.bootstrap.classloading.QuarkusClassLoader @73843e83 of the current class, org/acme/Configurati
onProducer_ProducerMethod_configure_583a1d0f9a47125f3f16fd0e1923dbf7b49ecb1a_Bean, and the class loader io.quarkus.bootstrap.classloading.QuarkusClassLoader @4461c7e3 for the method's 
defining class, com/acme/spi/ConfigurationProducer_ProducerMethod_configure_583a1d0f9a47125f3f16fd0e1923dbf7b49ecb1a_ClientProxy, have different Class objects for the type org/acme/Con
figurationProducer_ProducerMethod_configure_583a1d0f9a47125f3f16fd0e1923dbf7b49ecb1a_Bean used in the signature (org.acme.ConfigurationProducer_ProducerMethod_configure_583a1d0f9a47125
f3f16fd0e1923dbf7b49ecb1a_Bean is in unnamed module of loader io.quarkus.bootstrap.classloading.QuarkusClassLoader @73843e83, parent loader io.quarkus.bootstrap.classloading.QuarkusCla
ssLoader @4461c7e3; com.acme.spi.ConfigurationProducer_ProducerMethod_configure_583a1d0f9a47125f3f16fd0e1923dbf7b49ecb1a_ClientProxy is in unnamed module of loader io.quarkus.bootstrap
.classloading.QuarkusClassLoader @4461c7e3, parent loader 'app')
        at org.acme.ConfigurationProducer_ProducerMethod_configure_583a1d0f9a47125f3f16fd0e1923dbf7b49ecb1a_Bean.proxy(Unknown Source)
        at org.acme.ConfigurationProducer_ProducerMethod_configure_583a1d0f9a47125f3f16fd0e1923dbf7b49ecb1a_Bean.get(Unknown Source)
        at org.acme.ConfigurationProducer_ProducerMethod_configure_583a1d0f9a47125f3f16fd0e1923dbf7b49ecb1a_Bean.get(Unknown Source)
        at org.acme.ConfigurationValidator_Bean.create(Unknown Source)
        at org.acme.ConfigurationValidator_Bean.create(Unknown Source)
        at io.quarkus.arc.impl.AbstractSharedContext.createInstanceHandle(AbstractSharedContext.java:101)
        at io.quarkus.arc.impl.AbstractSharedContext$1.get(AbstractSharedContext.java:29)
        at io.quarkus.arc.impl.AbstractSharedContext$1.get(AbstractSharedContext.java:26)
        at io.quarkus.arc.impl.LazyValue.get(LazyValue.java:26)
        at io.quarkus.arc.impl.ComputingCache.computeIfAbsent(ComputingCache.java:69)
        at io.quarkus.arc.impl.AbstractSharedContext.get(AbstractSharedContext.java:26)
        at io.quarkus.arc.impl.ClientProxies.getApplicationScopedDelegate(ClientProxies.java:18)
        at org.acme.ConfigurationValidator_ClientProxy.arc$delegate(Unknown Source)
        at org.acme.ConfigurationValidator_ClientProxy.arc_contextualInstance(Unknown Source)
        at org.acme.ConfigurationValidator_Observer_Synthetic_d70cd75bf32ab6598217b9a64a8473d65e248c05.notify(Unknown Source)
        at io.quarkus.arc.impl.EventImpl$Notifier.notifyObservers(EventImpl.java:320)
        at io.quarkus.arc.impl.EventImpl$Notifier.notify(EventImpl.java:302)
        at io.quarkus.arc.impl.EventImpl.fire(EventImpl.java:73)
        at io.quarkus.arc.runtime.ArcRecorder.fireLifecycleEvent(ArcRecorder.java:128)
        at io.quarkus.arc.runtime.ArcRecorder.handleLifecycleEvents(ArcRecorder.java:97)
        at io.quarkus.deployment.steps.LifecycleEventsBuildStep$startupEvent1144526294.deploy_0(Unknown Source)
        at io.quarkus.deployment.steps.LifecycleEventsBuildStep$startupEvent1144526294.deploy(Unknown Source)
        at io.quarkus.runner.ApplicationImpl.doStart(Unknown Source)
        at io.quarkus.runtime.Application.start(Application.java:101)
        at io.quarkus.runtime.ApplicationLifecycleManager.run(ApplicationLifecycleManager.java:104)
        at io.quarkus.runtime.Quarkus.run(Quarkus.java:67)
        at io.quarkus.runtime.Quarkus.run(Quarkus.java:41)
        at io.quarkus.runtime.Quarkus.run(Quarkus.java:120)
        at io.quarkus.runner.GeneratedMain.main(Unknown Source)
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
        at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.base/java.lang.reflect.Method.invoke(Method.java:568)
        at io.quarkus.runner.bootstrap.StartupActionImpl$1.run(StartupActionImpl.java:103)
        at java.base/java.lang.Thread.run(Thread.java:833)


2022-01-25 09:30:48,223 ERROR [io.qua.dep.dev.IsolatedDevModeMain] (Aesh InputStream Reader) Failed to start quarkus: java.lang.RuntimeException: java.lang.RuntimeException: Failed to 
start quarkus
        at io.quarkus.dev.appstate.ApplicationStateNotification.waitForApplicationStart(ApplicationStateNotification.java:51)
        at io.quarkus.runner.bootstrap.StartupActionImpl.runMainClass(StartupActionImpl.java:122)
        at io.quarkus.deployment.dev.IsolatedDevModeMain.restartApp(IsolatedDevModeMain.java:233)
        at io.quarkus.deployment.dev.IsolatedDevModeMain.restartCallback(IsolatedDevModeMain.java:214)
        at io.quarkus.deployment.dev.RuntimeUpdatesProcessor.doScan(RuntimeUpdatesProcessor.java:522)
        at io.quarkus.deployment.console.ConsoleStateManager.forceRestart(ConsoleStateManager.java:141)
        at io.quarkus.deployment.console.ConsoleStateManager.lambda$installBuiltins$0(ConsoleStateManager.java:98)
        at io.quarkus.deployment.console.ConsoleStateManager$1.accept(ConsoleStateManager.java:73)
        at io.quarkus.deployment.console.ConsoleStateManager$1.accept(ConsoleStateManager.java:46)
        at io.quarkus.deployment.console.AeshConsole.lambda$setup$1(AeshConsole.java:249)
        at org.aesh.terminal.EventDecoder.accept(EventDecoder.java:118)
        at org.aesh.terminal.EventDecoder.accept(EventDecoder.java:31)
        at org.aesh.terminal.io.Decoder.write(Decoder.java:133)
        at org.aesh.readline.tty.terminal.TerminalConnection.openBlocking(TerminalConnection.java:216)
        at org.aesh.readline.tty.terminal.TerminalConnection.openBlocking(TerminalConnection.java:203)
        at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136)
        at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635)
        at java.base/java.lang.Thread.run(Thread.java:833)
Caused by: java.lang.RuntimeException: Failed to start quarkus
        at io.quarkus.runner.ApplicationImpl.doStart(Unknown Source)
        at io.quarkus.runtime.Application.start(Application.java:101)
        at io.quarkus.runtime.ApplicationLifecycleManager.run(ApplicationLifecycleManager.java:104)
        at io.quarkus.runtime.Quarkus.run(Quarkus.java:67)
        at io.quarkus.runtime.Quarkus.run(Quarkus.java:41)
        at io.quarkus.runtime.Quarkus.run(Quarkus.java:120)
        at io.quarkus.runner.GeneratedMain.main(Unknown Source)
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
        at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.base/java.lang.reflect.Method.invoke(Method.java:568)
        at io.quarkus.runner.bootstrap.StartupActionImpl$1.run(StartupActionImpl.java:103)
        ... 1 more
Caused by: java.lang.LinkageError: loader constraint violation: when resolving method 'void com.acme.spi.ConfigurationProducer_ProducerMethod_configure_583a1d0f9a47125f3f16fd0e1923dbf7
b49ecb1a_ClientProxy.<init>(org.acme.ConfigurationProducer_ProducerMethod_configure_583a1d0f9a47125f3f16fd0e1923dbf7b49ecb1a_Bean)' the class loader io.quarkus.bootstrap.classloading.Q
uarkusClassLoader @73843e83 of the current class, org/acme/ConfigurationProducer_ProducerMethod_configure_583a1d0f9a47125f3f16fd0e1923dbf7b49ecb1a_Bean, and the class loader io.quarkus
.bootstrap.classloading.QuarkusClassLoader @4461c7e3 for the method's defining class, com/acme/spi/ConfigurationProducer_ProducerMethod_configure_583a1d0f9a47125f3f16fd0e1923dbf7b49ecb
1a_ClientProxy, have different Class objects for the type org/acme/ConfigurationProducer_ProducerMethod_configure_583a1d0f9a47125f3f16fd0e1923dbf7b49ecb1a_Bean used in the signature (o
rg.acme.ConfigurationProducer_ProducerMethod_configure_583a1d0f9a47125f3f16fd0e1923dbf7b49ecb1a_Bean is in unnamed module of loader io.quarkus.bootstrap.classloading.QuarkusClassLoader
 @73843e83, parent loader io.quarkus.bootstrap.classloading.QuarkusClassLoader @4461c7e3; com.acme.spi.ConfigurationProducer_ProducerMethod_configure_583a1d0f9a47125f3f16fd0e1923dbf7b4
9ecb1a_ClientProxy is in unnamed module of loader io.quarkus.bootstrap.classloading.QuarkusClassLoader @4461c7e3, parent loader 'app')
        at org.acme.ConfigurationProducer_ProducerMethod_configure_583a1d0f9a47125f3f16fd0e1923dbf7b49ecb1a_Bean.proxy(Unknown Source)
        at org.acme.ConfigurationProducer_ProducerMethod_configure_583a1d0f9a47125f3f16fd0e1923dbf7b49ecb1a_Bean.get(Unknown Source)
        at org.acme.ConfigurationProducer_ProducerMethod_configure_583a1d0f9a47125f3f16fd0e1923dbf7b49ecb1a_Bean.get(Unknown Source)
        at org.acme.ConfigurationValidator_Bean.create(Unknown Source)
        at org.acme.ConfigurationValidator_Bean.create(Unknown Source)
        at io.quarkus.arc.impl.AbstractSharedContext.createInstanceHandle(AbstractSharedContext.java:101)
        at io.quarkus.arc.impl.AbstractSharedContext$1.get(AbstractSharedContext.java:29)
        at io.quarkus.arc.impl.AbstractSharedContext$1.get(AbstractSharedContext.java:26)
        at io.quarkus.arc.impl.LazyValue.get(LazyValue.java:26)
        at io.quarkus.arc.impl.ComputingCache.computeIfAbsent(ComputingCache.java:69)
        at io.quarkus.arc.impl.AbstractSharedContext.get(AbstractSharedContext.java:26)
        at io.quarkus.arc.impl.ClientProxies.getApplicationScopedDelegate(ClientProxies.java:18)
        at org.acme.ConfigurationValidator_ClientProxy.arc$delegate(Unknown Source)
        at org.acme.ConfigurationValidator_ClientProxy.arc_contextualInstance(Unknown Source)
        at org.acme.ConfigurationValidator_Observer_Synthetic_d70cd75bf32ab6598217b9a64a8473d65e248c05.notify(Unknown Source)
        at io.quarkus.arc.impl.EventImpl$Notifier.notifyObservers(EventImpl.java:320)
        at io.quarkus.arc.impl.EventImpl$Notifier.notify(EventImpl.java:302)
        at io.quarkus.arc.impl.EventImpl.fire(EventImpl.java:73)
        at io.quarkus.arc.runtime.ArcRecorder.fireLifecycleEvent(ArcRecorder.java:128)
        at io.quarkus.arc.runtime.ArcRecorder.handleLifecycleEvents(ArcRecorder.java:97)
        at io.quarkus.deployment.steps.LifecycleEventsBuildStep$startupEvent1144526294.deploy_0(Unknown Source)
        at io.quarkus.deployment.steps.LifecycleEventsBuildStep$startupEvent1144526294.deploy(Unknown Source)
        ... 13 more


2022-01-25 09:30:48,243 INFO  [io.qua.dep.dev.RuntimeUpdatesProcessor] (Aesh InputStream Reader) Live reload total time: 1.817s

How to Reproduce?

  1. Download the reproducer:
    hot-reload-reproducer-spi.zip

  2. cd spi

  3. mvn clean install

  4. cd ../hot-reload-producer

  5. mvn clean compile quarkus:dev

  6. press s for a force restart

  7. exception form above happens. The same exception happens on a normal hot reload as well.

  8. downgrade to 2.6.3.Final, and start again

  9. No exception on force restart

Output of uname -a or ver

MSYS_NT-10.0-19043 NANB7NLNVP2 3.1.7-340.x86_64 2021-03-26 22:17 UTC x86_64 Msys

Output of java -version

openjdk 17 2021-09-14 OpenJDK Runtime Environment Temurin-17+35 (build 17+35) OpenJDK 64-Bit Server VM Temurin-17+35 (build 17+35, mixed mode, sharing)

GraalVM version (if different from Java)

No response

Quarkus version or git rev

2.7.0.CR1

Build tool (ie. output of mvnw --version or gradlew --version)

Apache Maven 3.8.3 (ff8e977a158738155dc465c6a97ffaf31982d739) Maven home: C:\eclipse\tools\apache-maven Java version: 17, vendor: Eclipse Adoptium, runtime: C:\eclipse\tools\java\17 Default locale: de_DE, platform encoding: Cp1252 OS name: "windows 10", version: "10.0", arch: "amd64", family: "windows"

Additional information

No response

@Postremus Postremus added the kind/bug Something isn't working label Jan 25, 2022
@quarkus-bot quarkus-bot bot added env/windows Impacts Windows machines triage/needs-triage labels Jan 25, 2022
@Postremus
Copy link
Member Author

/cc @aloubyansky

@aloubyansky aloubyansky self-assigned this Jan 25, 2022
@aloubyansky
Copy link
Member

This issue is caused by #22828 (and its follow up #22893)
If I backport these to 2.6, it breaks it.

@aloubyansky
Copy link
Member

@mkouba fyi

@mkouba
Copy link
Contributor

mkouba commented Jan 25, 2022

You can add quarkus.class-loading.reloadable-artifacts=org.acme:spi in the application.properties config file as a workaround.

Another workaround is to use @javax.inject.Singleton instead of @ApplicationScoped:

   @Produces
   @Singleton 
   Configuration configure() {
       Configuration model = new Configuration();
       model.setValue("NONE");
       return model;
   }

CC @Postremus

@mkouba mkouba added area/arc Issue related to ARC (dependency injection) area/devmode and removed env/windows Impacts Windows machines triage/needs-triage labels Jan 25, 2022
@quarkus-bot
Copy link

quarkus-bot bot commented Jan 25, 2022

/cc @manovotn

@quarkus-bot quarkus-bot bot added this to the 2.8 - main milestone Jan 25, 2022
@gsmet gsmet modified the milestones: 2.8 - main, 2.7.0.Final Jan 25, 2022
@mkouba
Copy link
Contributor

mkouba commented Feb 11, 2022

Hm, I'm not able to reproduce the problem with the main branch and the reverted commit anymore. CC @aloubyansky

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/arc Issue related to ARC (dependency injection) area/devmode kind/bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants