Quarkus Native executable fails - quarkus

I am trying to build a Quarkus native executable using docker using the following command "mvn clean package "-Pnative" "-Dquarkus.native.container-build=true" "-Dquarkus.native.container-runtime=docker"
Quarkus version: 2.2.1.Final
Maven version : 3.8.1
Java version: 11
and I get the below error:
Error: Annotated class must be final: class io.quarkus.amazon.lambda.http.graal.LambdaContainerHandlerSubstitution
com.oracle.svm.core.util.UserError$UserException: Annotated class must be final: class io.quarkus.amazon.lambda.http.graal.LambdaContainerHandlerSubstitution
at com.oracle.svm.core.util.UserError.abort(UserError.java:68)
at com.oracle.svm.core.util.UserError.guarantee(UserError.java:96)
at com.oracle.svm.hosted.substitute.AnnotationSubstitutionProcessor.handleClass(AnnotationSubstitutionProcessor.java:280)
at com.oracle.svm.hosted.substitute.AnnotationSubstitutionProcessor.init(AnnotationSubstitutionProcessor.java:266)
at com.oracle.svm.hosted.NativeImageGenerator.createDeclarativeSubstitutionProcessor(NativeImageGenerator.java:936)
at com.oracle.svm.hosted.NativeImageGenerator.setupNativeImage(NativeImageGenerator.java:868)
at com.oracle.svm.hosted.NativeImageGenerator.doRun(NativeImageGenerator.java:530)
at com.oracle.svm.hosted.NativeImageGenerator.run(NativeImageGenerator.java:491)
at com.oracle.svm.hosted.NativeImageGeneratorRunner.buildImage(NativeImageGeneratorRunner.java:380)
at com.oracle.svm.hosted.NativeImageGeneratorRunner.build(NativeImageGeneratorRunner.java:543)
at com.oracle.svm.hosted.NativeImageGeneratorRunner.main(NativeImageGeneratorRunner.java:119)
at com.oracle.svm.hosted.NativeImageGeneratorRunner$JDK9Plus.main(NativeImageGeneratorRunner.java:573)

It's a bug, please open an issue on https://github.com/quarkusio/quarkus/issues

Related

Java 17 gradle 7.3.3 Intellij Cannot cast org.gradle.api.file.Directory to java.io.File

I am migrating project from Java 8 to newer version.
I am not using module info.
springBootVersion=2.5.7
springCloudVersion=2020.0.5
I have an error in Intellij during build:
Cannot cast object 'property(org.gradle.api.file.Directory, undefined)' with class 'org.gradle.api.internal.file.DefaultFilePropertyFactory$DefaultDirectoryVar' to class 'java.io.File'
* Exception is:
com.intellij.openapi.externalSystem.model.ExternalSystemException: Cannot cast object 'property(org.gradle.api.file.Directory, undefined)' with class 'org.gradle.api.internal.file.DefaultFilePropertyFactory$DefaultDirectoryVar' to class 'java.io.File'
This issue occurs while using gradle-7.3.3,
when changed to gradle-7.4 issue changes to:
Cannot query the value of this property because it has no value available.
On gradle 7.3 the issue is:
class org.gradle.api.internal.file.DefaultFilePropertyFactory$DefaultDirectoryVar cannot be cast to class java.io.File (org.gradle.api.internal.file.DefaultFilePropertyFactory$DefaultDirectoryVar is in unnamed module of loader org.gradle.internal.classloader.VisitableURLClassLoader #6a4f787b; java.io.File is in module java.base of loader 'bootstrap')
class org.gradle.api.internal.file.DefaultFilePropertyFactory$DefaultDirectoryVar cannot be cast to class java.io.File (org.gradle.api.internal.file.DefaultFilePropertyFactory$DefaultDirectoryVar is in unnamed module of loader org.gradle.internal.classloader.VisitableURLClassLoader #6a4f787b; java.io.File is in module java.base of loader 'bootstrap')
I think the issue comes from this gradle block (idea part) that worked fine before:
afterEvaluate {
contracts {
baseClassForTests = "(...).contract.ContractBaseSpec"
basePackageForTests = '(...).contract.tests'
//targetFramework = TestFramework.SPOCK some other error here
testMode = 'EXPLICIT'
baseClassMappings {
baseClassMapping('.*event.*', '(...).contract.EventContractBaseSpec')
}
}
idea {
module {
testSourceDirs += project.contracts.generatedTestSourcesDir
generatedSourceDirs += project.contracts.generatedTestSourcesDir
}
}
}
After commenting it - build is ok.
Intellij 2022.1 EAP,
the same in 2021.3.2.
Java version setting in IntelliJ's Project setting does not make difference, I tried both: java 11 and java 17.
The same with build tools - gradle JVM java version setting.
As of https://docs.gradle.org/current/userguide/compatibility.html
Java 17 is compatible from gradle 7.3.
Running from terminal and from jenkins i see other issue:
sdk use java 17.0.2-open
Using java version 17.0.2-open in this shell.
./gradlew --version
------------------------------------------------------------
Gradle 7.3
------------------------------------------------------------
./gradlew clean build
Issue:
> BUG! exception in phase 'semantic analysis' in source unit '(.some-path-here...)/contract/ClientBuilder.groovy' Unsupported class file major version 61
Stacktrace: https://pastebin.pl/view/1449e795
in gradle:
jacoco {
toolVersion = "0.8.7"
}
as for this issue updating groovy from 3.0.3 to 3.0.9 fixes it and shows another issue.
Still why IntelliJ shows different issue?

Use withType() for configuring Gradle task not compiling in IntelliJ

I'm trying to configure the Test task inside a custom Gradle plugin written in Java.
Applying the plugins I need like so in build.gradle.kts:
plugins {
`java-gradle-plugin`
`maven-publish`
}
I can compile the code successfully through the command line as in ./gradlew clean build
But, IntelliJ complains about Test.class in the following code:
public static void configureTesting(final Project project) {
project.getTasks().withType(Test.class).configureEach(task -> {
});
}
Saying:
Required type: java.lang.Class <S>
Provided: java.lang.Class <Test>
reason: no instance(s) of type variable(s) exist so that T conforms to Task
I import the Test class like this:
import org.gradle.api.tasks.testing.Test;
Gradle version: 6.7.1
IntelliJ: 2020.2.3
I spent some (a lot of) time googling this. Eventually I found a comment somewhere saying that one could try to use the internal SDK (jbr) that ships with IntelliJ instead of a manually downloaded SDK. That made it work. The internal SDK is Java 11 and I've also installed the latest version of Java 11 from Oracle. Even though they are both Java 11, the internal SDK (jbr) is working as it should, but not the external SDK. For other projects the external SDK is working fine, but not for building a Gradle plugin.

Gradle with JDK 9 Can't Build

I'm running a build using Gradle with open JDK 9.
The gradlew shadow command fails with the exception:
java.lang.IllegalAccessException: class org.gradle.api.internal.tasks.compile.reflect.SourcepathIgnoringInvocationHandler cannot access class com.sun.tools.javac.file.BaseFileManager (in module jdk.compiler) because module jdk.compiler does not export com.sun.tools.javac.file to unnamed module #1c5af20
But I am running the java command with the option to export this module to all unnamed modules. My full java command:
exec /docker-java-home/bin/java --add-exports=jdk.compiler/com.sun.tools.javac.file=ALL-UNNAMED -Dorg.gradle.appname=gradlew -classpath /test/IotDevice/Applications/AppInsightsDocker/gradle/wrapper/gradle-wrapper.jar org.gradle.wrapper.GradleWrapperMain --stacktrace shadow
Why am I still getting this exception?

Gradle Incompatible Return Types

When I run the gradle tasks command using the following gradle.build file:
import org.gradle.api.reporting.Report
import org.gradle.api.reporting.ReportContainer
import org.gradle.api.reporting.internal.TaskReportContainer
interface MyReportContainer extends ReportContainer<Report> {}
class MyDefaultReportContainer extends TaskReportContainer<Report> implements MyReportContainer {}
I receive the following fatal exception during script compilation:
The return type of org.gradle.api.NamedDomainObjectCollection
matching(groovy.lang.Closure) in
org.gradle.api.internal.DefaultNamedDomainObjectCollection is
incompatible with org.gradle.api.NamedDomainObjectSet in
org.gradle.api.NamedDomainObjectSet
This seems odd to me, as NamedDomainObjectSet directly extends NamedDomainObjectCollection ...so how could it be incompatible?
I came across this while trying to write a custom reporting task, following along the example of DefaultDependencyReportContainer in the Gradle source which seems to follow exactly this pattern!
Oddly enough, if I switch to:
interface MyReportContainer extends org.gradle.api.DomainObjectCollection<Report> {}
everything works just fine!
I'm using:
Gradle 2.2.1
Build time: 2014-11-24 09:45:35 UTC
Build number: none
Revision: 6fcb59c06f43a4e6b1bcb401f7686a8601a1fb4a
JVM: 1.8.0 (Oracle Corporation 25.0-b70)
Groovy: 2.3.6
So can anyone tell me why this is failing?

EJB application won't deploy in OC4J with Java7

An EJB application which works using Java6 JRE fails to deploy with Java7, it throws the following error:
14/01/13 13:33:23 WARNING: Application.setConfig Application:
accesscontrolapp is in failed state as initialization failed.
oracle.classloader.util.AnnotatedNoClassDefFoundError:
Missing class: org.apache.crimson.tree.ElementNode
Dependent class: com.sun.enterprise.deployment.xml.EjbBundleNode
Loader: oc4j:10.1.3
Code-Source: .../oc4j_standalone/j2ee/home/lib/oc4j-internal.jar
Configuration: in META-INF/boot.xml in
...\oc4j_standalone\j2ee\home\oc4j.jar
The missing class is not available from any code-source or loader in
the system.
I located the missing class in j2ee/home/lib/crimson_1_1_3.jar so I don't understand, why the error?
The error message refers to META-INF/boot.xml within oc4j.jar, if you look at that file it reads:
<code-source path="lib/crimson_1_1_3.jar" if="java.specification.version == /1\.[5-6]/"/>
This was apparently done to prevent loading of crimson in java 1.4. If you change this to read '[5-9]' then this works for Java 1.7 and presumably 1.8 and 1.9 as well.

Resources