jbangdev / jbang

Unleash the power of Java - JBang Lets Students, Educators and Professional Developers create, edit and run self-contained source-only Java programs with unprecedented ease.
https://jbang.dev
MIT License
1.43k stars 159 forks source link

(quarkus) integration wont work when java used to run jbang is lower than the java version defined in file #953

Open maxandersen opened 3 years ago

maxandersen commented 3 years ago

Describe the bug

have a jbang app with //JAVA 15 in source file using quarkus and then have default java be java 11 then quarkus complains about classes compiled with too new a version as it it finds java 11 and use it instead of the actual java 15 running .

Expected behavior

quarkus should at least tell if there is a mismatch but optimally pick up the actual used java before default java.

stacktrace below using https://github.com/maxandersen/quarkus-insights-effective-persistence/blob/master/db.java using 2.0.0 dependencies

[jbang] Deleting folder /Users/max/.jbang/cache/jars/db.java.79cdb71a332e54a91d8141a76a3908011fb1be0accc84d8b32df1077564fd551.jar.tmp
[jbang] [ERROR] Issue running postBuild()
dev.jbang.cli.ExitException: Issue running postBuild()
    at dev.jbang.spi.IntegrationManager.runIntegration(IntegrationManager.java:147)
    at dev.jbang.cli.BaseBuildCommand.buildJar(BaseBuildCommand.java:180)
    at dev.jbang.cli.BaseBuildCommand.build(BaseBuildCommand.java:122)
    at dev.jbang.cli.BaseBuildCommand.buildIfNeeded(BaseBuildCommand.java:82)
    at dev.jbang.cli.Run.prepareArtifacts(Run.java:86)
    at dev.jbang.cli.Run.doCall(Run.java:76)
    at dev.jbang.cli.BaseCommand.call(BaseCommand.java:85)
    at dev.jbang.cli.BaseCommand.call(BaseCommand.java:12)
    at picocli.CommandLine.executeUserObject(CommandLine.java:1953)
    at picocli.CommandLine.access$1300(CommandLine.java:145)
    at picocli.CommandLine$RunLast.executeUserObjectOfLastSubcommandWithSameParent(CommandLine.java:2352)
    at picocli.CommandLine$RunLast.handle(CommandLine.java:2346)
    at dev.jbang.cli.Jbang$3.handle(Jbang.java:135)
    at dev.jbang.cli.Jbang$3.handle(Jbang.java:130)
    at picocli.CommandLine$AbstractParseResultHandler.execute(CommandLine.java:2179)
    at picocli.CommandLine.execute(CommandLine.java:2078)
    at dev.jbang.Main.main(Main.java:14)
Caused by: java.lang.reflect.InvocationTargetException
    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 dev.jbang.spi.IntegrationManager.runIntegration(IntegrationManager.java:111)
    ... 16 more
Caused by: java.lang.RuntimeException: java.lang.reflect.InvocationTargetException
    at io.quarkus.launcher.JBangIntegration.postBuild(JBangIntegration.java:128)
    ... 21 more
Caused by: java.lang.reflect.InvocationTargetException
    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.launcher.JBangIntegration.postBuild(JBangIntegration.java:120)
    ... 21 more
Caused by: java.lang.RuntimeException: java.lang.RuntimeException: java.lang.RuntimeException: io.quarkus.builder.BuildException: Build failure: Build failed due to errors
    [error]: Build step io.quarkus.hibernate.orm.deployment.HibernateOrmProcessor#pregenProxies threw an exception: java.lang.UnsupportedClassVersionError: db$Language has been compiled by a more recent version of the Java Runtime (class file version 59.0), this version of the Java Runtime only recognizes class file versions up to 55.0
    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:437)
    at io.quarkus.bootstrap.classloading.QuarkusClassLoader.loadClass(QuarkusClassLoader.java:397)
    at java.base/java.lang.Class.forName0(Native Method)
    at java.base/java.lang.Class.forName(Class.java:398)
    at io.quarkus.hibernate.orm.deployment.ProxyBuildingHelper.isProxiable(ProxyBuildingHelper.java:57)
    at io.quarkus.hibernate.orm.deployment.HibernateOrmProcessor.generatedProxies(HibernateOrmProcessor.java:1340)
    at io.quarkus.hibernate.orm.deployment.HibernateOrmProcessor.pregenProxies(HibernateOrmProcessor.java:378)
    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.deployment.ExtensionLoader$2.execute(ExtensionLoader.java:820)
    at io.quarkus.builder.BuildContext.run(BuildContext.java:277)
    at org.jboss.threads.ContextHandler$1.runWith(ContextHandler.java:18)
    at org.jboss.threads.EnhancedQueueExecutor$Task.run(EnhancedQueueExecutor.java:2442)
    at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.run(EnhancedQueueExecutor.java:1476)
    at java.base/java.lang.Thread.run(Thread.java:834)
    at org.jboss.threads.JBossThread.run(JBossThread.java:501)

    at io.quarkus.bootstrap.jbang.JBangBuilderImpl.postBuild(JBangBuilderImpl.java:86)
    ... 26 more
Caused by: java.lang.RuntimeException: java.lang.RuntimeException: io.quarkus.builder.BuildException: Build failure: Build failed due to errors
    [error]: Build step io.quarkus.hibernate.orm.deployment.HibernateOrmProcessor#pregenProxies threw an exception: java.lang.UnsupportedClassVersionError: db$Language has been compiled by a more recent version of the Java Runtime (class file version 59.0), this version of the Java Runtime only recognizes class file versions up to 55.0
    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:437)
    at io.quarkus.bootstrap.classloading.QuarkusClassLoader.loadClass(QuarkusClassLoader.java:397)
    at java.base/java.lang.Class.forName0(Native Method)
    at java.base/java.lang.Class.forName(Class.java:398)
    at io.quarkus.hibernate.orm.deployment.ProxyBuildingHelper.isProxiable(ProxyBuildingHelper.java:57)
    at io.quarkus.hibernate.orm.deployment.HibernateOrmProcessor.generatedProxies(HibernateOrmProcessor.java:1340)
    at io.quarkus.hibernate.orm.deployment.HibernateOrmProcessor.pregenProxies(HibernateOrmProcessor.java:378)
    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.deployment.ExtensionLoader$2.execute(ExtensionLoader.java:820)
    at io.quarkus.builder.BuildContext.run(BuildContext.java:277)
    at org.jboss.threads.ContextHandler$1.runWith(ContextHandler.java:18)
    at org.jboss.threads.EnhancedQueueExecutor$Task.run(EnhancedQueueExecutor.java:2442)
    at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.run(EnhancedQueueExecutor.java:1476)
    at java.base/java.lang.Thread.run(Thread.java:834)
    at org.jboss.threads.JBossThread.run(JBossThread.java:501)

    at io.quarkus.bootstrap.app.CuratedApplication.runInCl(CuratedApplication.java:135)
    at io.quarkus.bootstrap.app.CuratedApplication.runInAugmentClassLoader(CuratedApplication.java:89)
    at io.quarkus.bootstrap.jbang.JBangBuilderImpl.postBuild(JBangBuilderImpl.java:83)
    ... 26 more
Caused by: java.lang.RuntimeException: io.quarkus.builder.BuildException: Build failure: Build failed due to errors
    [error]: Build step io.quarkus.hibernate.orm.deployment.HibernateOrmProcessor#pregenProxies threw an exception: java.lang.UnsupportedClassVersionError: db$Language has been compiled by a more recent version of the Java Runtime (class file version 59.0), this version of the Java Runtime only recognizes class file versions up to 55.0
    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:437)
    at io.quarkus.bootstrap.classloading.QuarkusClassLoader.loadClass(QuarkusClassLoader.java:397)
    at java.base/java.lang.Class.forName0(Native Method)
    at java.base/java.lang.Class.forName(Class.java:398)
    at io.quarkus.hibernate.orm.deployment.ProxyBuildingHelper.isProxiable(ProxyBuildingHelper.java:57)
    at io.quarkus.hibernate.orm.deployment.HibernateOrmProcessor.generatedProxies(HibernateOrmProcessor.java:1340)
    at io.quarkus.hibernate.orm.deployment.HibernateOrmProcessor.pregenProxies(HibernateOrmProcessor.java:378)
    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.deployment.ExtensionLoader$2.execute(ExtensionLoader.java:820)
    at io.quarkus.builder.BuildContext.run(BuildContext.java:277)
    at org.jboss.threads.ContextHandler$1.runWith(ContextHandler.java:18)
    at org.jboss.threads.EnhancedQueueExecutor$Task.run(EnhancedQueueExecutor.java:2442)
    at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.run(EnhancedQueueExecutor.java:1476)
    at java.base/java.lang.Thread.run(Thread.java:834)
    at org.jboss.threads.JBossThread.run(JBossThread.java:501)

    at io.quarkus.deployment.jbang.JBangAugmentorImpl.accept(JBangAugmentorImpl.java:117)
    at io.quarkus.deployment.jbang.JBangAugmentorImpl.accept(JBangAugmentorImpl.java:32)
    at io.quarkus.bootstrap.app.CuratedApplication.runInCl(CuratedApplication.java:132)
    ... 28 more
Caused by: io.quarkus.builder.BuildException: Build failure: Build failed due to errors
    [error]: Build step io.quarkus.hibernate.orm.deployment.HibernateOrmProcessor#pregenProxies threw an exception: java.lang.UnsupportedClassVersionError: db$Language has been compiled by a more recent version of the Java Runtime (class file version 59.0), this version of the Java Runtime only recognizes class file versions up to 55.0
    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:437)
    at io.quarkus.bootstrap.classloading.QuarkusClassLoader.loadClass(QuarkusClassLoader.java:397)
    at java.base/java.lang.Class.forName0(Native Method)
    at java.base/java.lang.Class.forName(Class.java:398)
    at io.quarkus.hibernate.orm.deployment.ProxyBuildingHelper.isProxiable(ProxyBuildingHelper.java:57)
    at io.quarkus.hibernate.orm.deployment.HibernateOrmProcessor.generatedProxies(HibernateOrmProcessor.java:1340)
    at io.quarkus.hibernate.orm.deployment.HibernateOrmProcessor.pregenProxies(HibernateOrmProcessor.java:378)
    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.deployment.ExtensionLoader$2.execute(ExtensionLoader.java:820)
    at io.quarkus.builder.BuildContext.run(BuildContext.java:277)
    at org.jboss.threads.ContextHandler$1.runWith(ContextHandler.java:18)
    at org.jboss.threads.EnhancedQueueExecutor$Task.run(EnhancedQueueExecutor.java:2442)
    at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.run(EnhancedQueueExecutor.java:1476)
    at java.base/java.lang.Thread.run(Thread.java:834)
    at org.jboss.threads.JBossThread.run(JBossThread.java:501)

    at io.quarkus.builder.Execution.run(Execution.java:116)
    at io.quarkus.builder.BuildExecutionBuilder.execute(BuildExecutionBuilder.java:79)
    at io.quarkus.deployment.QuarkusAugmentor.run(QuarkusAugmentor.java:153)
    at io.quarkus.deployment.jbang.JBangAugmentorImpl.accept(JBangAugmentorImpl.java:94)
    ... 30 more
Caused by: java.lang.UnsupportedClassVersionError: db$Language has been compiled by a more recent version of the Java Runtime (class file version 59.0), this version of the Java Runtime only recognizes class file versions up to 55.0
    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:437)
    at io.quarkus.bootstrap.classloading.QuarkusClassLoader.loadClass(QuarkusClassLoader.java:397)
    at java.base/java.lang.Class.forName0(Native Method)
    at java.base/java.lang.Class.forName(Class.java:398)
    at io.quarkus.hibernate.orm.deployment.ProxyBuildingHelper.isProxiable(ProxyBuildingHelper.java:57)
    at io.quarkus.hibernate.orm.deployment.HibernateOrmProcessor.generatedProxies(HibernateOrmProcessor.java:1340)
    at io.quarkus.hibernate.orm.deployment.HibernateOrmProcessor.pregenProxies(HibernateOrmProcessor.java:378)
    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.deployment.ExtensionLoader$2.execute(ExtensionLoader.java:820)
    at io.quarkus.builder.BuildContext.run(BuildContext.java:277)
    at org.jboss.threads.ContextHandler$1.runWith(ContextHandler.java:18)
    at org.jboss.threads.EnhancedQueueExecutor$Task.run(EnhancedQueueExecutor.java:2442)
    at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.run(EnhancedQueueExecutor.java:1476)
    at java.base/java.lang.Thread.run(Thread.java:834)
    at org.jboss.threads.JBossThread.run(JBossThread.java:501)
[jbang] If you believe this a bug in jbang open issue at https://github.com/jbangdev/jbang/issues
maxandersen commented 3 years ago

one "fix" is to do integration in separate process in this specific case

quintesse commented 3 years ago

THe separate process for integrations is a good idea anyway if we ever want to have native binaries of jbang... :-)