snowdrop-zen / quarkus

Quarkus: Supersonic Subatomic Java.
https://quarkus.io
Apache License 2.0
1 stars 0 forks source link

ClassNotFoundException in dev mode with @MessageBundle and properties file #154

Closed snowdrop-bot closed 4 years ago

snowdrop-bot commented 4 years ago

Describe the bug java.lang.ClassNotFoundException in dev mode (mvn quarkus:dev) when using @MessageBundle with properties files.

The same code works when bundling the application with mvn package and launching the JAR.

Expected behavior The properties from msg_de.properties are loaded into the ApplicationMessages in dev mode.

Actual behavior An exception is thrown.

java.lang.ClassNotFoundException: at.porscheinformatik.bazaar.ApplicationMessages
    at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:581)
    at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:178)
    at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:522)
    at io.quarkus.bootstrap.classloading.QuarkusClassLoader.loadClass(QuarkusClassLoader.java:426)
    at io.quarkus.bootstrap.classloading.QuarkusClassLoader.loadClass(QuarkusClassLoader.java:363)
    at java.base/java.lang.ClassLoader.defineClass1(Native Method)
    at java.base/java.lang.ClassLoader.defineClass(ClassLoader.java:1017)
    at io.quarkus.bootstrap.classloading.QuarkusClassLoader.loadClass(QuarkusClassLoader.java:420)
    at io.quarkus.bootstrap.classloading.QuarkusClassLoader.loadClass(QuarkusClassLoader.java:363)
    at io.quarkus.bootstrap.classloading.QuarkusClassLoader.loadClass(QuarkusClassLoader.java:426)
    at io.quarkus.bootstrap.classloading.QuarkusClassLoader.loadClass(QuarkusClassLoader.java:363)
    at at.porscheinformatik.bazaar.ApplicationMessages_6c2e17da52e74fd894575403e6dbcf3fc2744ee9_Synthetic_Bean.create(ApplicationMessages_6c2e17da52e74fd894575403e6dbcf3fc2744ee9_Synthetic_Bean.zig:137)
    at at.porscheinformatik.bazaar.ApplicationMessages_6c2e17da52e74fd894575403e6dbcf3fc2744ee9_Synthetic_Bean.create(ApplicationMessages_6c2e17da52e74fd894575403e6dbcf3fc2744ee9_Synthetic_Bean.zig:156)
    at io.quarkus.arc.impl.AbstractSharedContext.createInstanceHandle(AbstractSharedContext.java:88)
    at io.quarkus.arc.impl.ComputingCache$CacheFunction.lambda$apply$0(ComputingCache.java:99)
    at io.quarkus.arc.impl.LazyValue.get(LazyValue.java:26)
    at io.quarkus.arc.impl.ComputingCache.getValue(ComputingCache.java:41)
    at io.quarkus.arc.impl.AbstractSharedContext.get(AbstractSharedContext.java:25)
    at at.porscheinformatik.bazaar.ApplicationMessages_6c2e17da52e74fd894575403e6dbcf3fc2744ee9_Synthetic_Bean.get(ApplicationMessages_6c2e17da52e74fd894575403e6dbcf3fc2744ee9_Synthetic_Bean.zig:188)
    at at.porscheinformatik.bazaar.ApplicationMessages_6c2e17da52e74fd894575403e6dbcf3fc2744ee9_Synthetic_Bean.get(ApplicationMessages_6c2e17da52e74fd894575403e6dbcf3fc2744ee9_Synthetic_Bean.zig:204)
    at io.quarkus.arc.impl.InstanceImpl.getBeanInstance(InstanceImpl.java:210)
    at io.quarkus.arc.impl.InstanceImpl.getInternal(InstanceImpl.java:196)
    at io.quarkus.arc.impl.InstanceImpl.get(InstanceImpl.java:93)
    at io.quarkus.qute.i18n.MessageBundles.setupNamespaceResolvers(MessageBundles.java:73)
    at io.quarkus.qute.i18n.MessageBundles_Observer_setupNamespaceResolvers_4f71b9cf1ad0f31200829efc11f16a310a169db8.notify(MessageBundles_Observer_setupNamespaceResolvers_4f71b9cf1ad0f31200829efc11f16a310a169db8.zig:264)
    at io.quarkus.arc.impl.EventImpl$Notifier.notifyObservers(EventImpl.java:282)
    at io.quarkus.arc.impl.EventImpl$Notifier.notify(EventImpl.java:263)
    at io.quarkus.arc.impl.EventImpl.fire(EventImpl.java:69)
    at io.quarkus.qute.runtime.EngineProducer.<init>(EngineProducer.java:87)
    at io.quarkus.qute.runtime.EngineProducer_Bean.create(EngineProducer_Bean.zig:414)
    at io.quarkus.qute.runtime.EngineProducer_Bean.create(EngineProducer_Bean.zig:429)
    at io.quarkus.arc.impl.AbstractSharedContext.createInstanceHandle(AbstractSharedContext.java:88)
    at io.quarkus.arc.impl.ComputingCache$CacheFunction.lambda$apply$0(ComputingCache.java:99)
    at io.quarkus.arc.impl.LazyValue.get(LazyValue.java:26)
    at io.quarkus.arc.impl.ComputingCache.getValue(ComputingCache.java:41)
    at io.quarkus.arc.impl.AbstractSharedContext.get(AbstractSharedContext.java:25)
    at io.quarkus.qute.runtime.EngineProducer_Bean.get(EngineProducer_Bean.zig:461)
    at io.quarkus.qute.runtime.EngineProducer_Bean.get(EngineProducer_Bean.zig:477)
    at io.quarkus.arc.impl.ArcContainerImpl.beanInstanceHandle(ArcContainerImpl.java:408)
    at io.quarkus.arc.impl.ArcContainerImpl.beanInstanceHandle(ArcContainerImpl.java:421)
    at io.quarkus.arc.impl.ArcContainerImpl.instance(ArcContainerImpl.java:258)
    at io.quarkus.qute.runtime.EngineProducer_Observer_Synthetic_5ca7449e3ab1631e7e8ed910338051c00d29a79b.notify(EngineProducer_Observer_Synthetic_5ca7449e3ab1631e7e8ed910338051c00d29a79b.zig:89)
    at io.quarkus.arc.impl.EventImpl$Notifier.notifyObservers(EventImpl.java:282)
    at io.quarkus.arc.impl.EventImpl$Notifier.notify(EventImpl.java:267)
    at io.quarkus.arc.impl.EventImpl.fire(EventImpl.java:69)
    at io.quarkus.arc.runtime.LifecycleEventRunner.fireStartupEvent(LifecycleEventRunner.java:23)
    at io.quarkus.arc.runtime.ArcRecorder.handleLifecycleEvents(ArcRecorder.java:113)
    at io.quarkus.deployment.steps.LifecycleEventsBuildStep$startupEvent-858218658.deploy_0(LifecycleEventsBuildStep$startupEvent-858218658.zig:81)
    at io.quarkus.deployment.steps.LifecycleEventsBuildStep$startupEvent-858218658.deploy(LifecycleEventsBuildStep$startupEvent-858218658.zig:40)
    at io.quarkus.runner.ApplicationImpl.doStart(ApplicationImpl.zig:751)
    at io.quarkus.runtime.Application.start(Application.java:90)
    at io.quarkus.runtime.ApplicationLifecycleManager.run(ApplicationLifecycleManager.java:91)
    at io.quarkus.runtime.Quarkus.run(Quarkus.java:61)
    at io.quarkus.runtime.Quarkus.run(Quarkus.java:38)
    at io.quarkus.runtime.Quarkus.run(Quarkus.java:106)
    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.runner.bootstrap.StartupActionImpl$3.run(StartupActionImpl.java:145)
    at java.base/java.lang.Thread.run(Thread.java:834)
Resulted in: java.lang.NoClassDefFoundError: at/porscheinformatik/bazaar/ApplicationMessages
    ... 57 more
Resulted in: java.lang.RuntimeException: Failed to start quarkus
    at io.quarkus.runner.ApplicationImpl.doStart(ApplicationImpl.zig:824)
    ... 12 more
Resulted in: 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:156)
    at io.quarkus.deployment.dev.IsolatedDevModeMain.restartApp(IsolatedDevModeMain.java:173)
    at io.quarkus.deployment.dev.RuntimeUpdatesProcessor.doScan(RuntimeUpdatesProcessor.java:183)
    at io.quarkus.vertx.http.runtime.devmode.VertxHttpHotReplacementSetup$2.handle(VertxHttpHotReplacementSetup.java:61)
    at io.quarkus.vertx.http.runtime.devmode.VertxHttpHotReplacementSetup$2.handle(VertxHttpHotReplacementSetup.java:51)
    at io.vertx.core.impl.ContextImpl.lambda$executeBlocking$2(ContextImpl.java:313)
    at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
    at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
    at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30)
    ... 1 more

To Reproduce Steps to reproduce the behavior:

  1. Create a class ApplicationMessages
    @MessageBundle(defaultKey = Message.HYPHENATED_ELEMENT_NAME)
    public interface ApplicationMessages {
     @Message(value = "Hello, {name} !")
     String helloName(String name);
    }
  2. Create a file src/main/resources/messages/msg_de.properties with the following content
    helloName=Hallo {name}!
  3. Run the app in dev mode: mvn compile quarkus:dev

Environment (please complete the following information):

Additional context Also interesting is that the key in the msg_de.properties has to be named helloName and not hello-name. When using hello-name an error is shown. I had expected the key to use the hyphenated name.

io.quarkus.qute.deployment.MessageBundleException: Message bundle method hello-name() not found on: at.porscheinformatik.bazaar.ApplicationMessages
    - file: /home/koc/git/github.com/porscheinformatik/bazaar/target/classes/messages/msg_de.properties

https://github.com/quarkusio/quarkus/issues/11188


$upstream:11188$