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

Fix broken native build of generated projects #5005

Merged
merged 1 commit into from Oct 29, 2019

Conversation

@geoand
Copy link
Contributor

geoand commented Oct 29, 2019

I honestly don't know why stacktraces need to be enabled for the generated native image to work properly.

Without this fix, the native image build of the generated (via the maven tooling) projects would fail:

  1. First with a NPE
  2. But even going past the NPE, the generated native image when run gave output like this:
Exception in thread "Thread-1" java.lang.Error: java.lang.NullPointerException
Caused by: java.lang.NullPointerException
java.lang.NoClassDefFoundError: Could not initialize class java.util.concurrent.ThreadLocalRandom
java.lang.NoClassDefFoundError: Could not initialize class java.util.concurrent.ThreadLocalRandom
2019-10-29 20:17:38,761 ERROR [io.ver.cor.imp.ContextImpl] (vert.x-eventloop-thread-0) Unhandled exception: java.lang.NullPointerException: channel

Exception in thread "main" java.lang.RuntimeException: Failed to start quarkus
Caused by: java.lang.NoClassDefFoundError: Could not initialize class java.util.concurrent.ThreadLocalRandom
@geoand

This comment has been minimized.

Copy link
Contributor Author

geoand commented Oct 29, 2019

@gsmet can you try it out? Asking because I know you could reproduce the issue

@gsmet

This comment has been minimized.

Copy link
Member

gsmet commented Oct 29, 2019

I sure will.

@gsmet

This comment has been minimized.

Copy link
Member

gsmet commented Oct 29, 2019

One thing we need is to move one of the current IT to the new way of doing things. It’s not acceptable to discover this by pure luck.

@dmlloyd

This comment has been minimized.

Copy link
Member

dmlloyd commented Oct 29, 2019

My hypothesis is that this fails because the class is reinitialized, but the static init does some things that are disallowed during native image run time.

I think this class cannot be reinitialized at run time. Instead I think we'll have to reinitialize specific fields manually.

@geoand

This comment has been minimized.

Copy link
Contributor Author

geoand commented Oct 29, 2019

One thing we need is to move one of the current IT to the new way of doing things. It’s not acceptable to discover this by pure luck.

I can do that in a follow up

Copy link
Member

gsmet left a comment

So I confirm it fixes the issue for me too and with a newly created simple project, I'm now able to create a native image.

I think we need Stuart to confirm if that's the right fix though.

For Stuart:

  • create a project with mvn io.quarkus:quarkus-maven-plugin:999-SNAPSHOT:create -DprojectGroupId=org.acme -DprojectArtifactId=getting-started -DclassName="org.acme.quickstart.GreetingResource" -Dpath="/hello" -Dextensions="openapi"
  • cd getting-started
  • mvn clean install -Dnative will fail with a NPE in BuildMojo at line 190
  • with the if Georgios added, we pass this step but then we have another NPE that the change of default value for the full stacktrace somehow fixes.
@@ -165,7 +165,7 @@
/**
* If full stack traces are enabled in the resulting image
*/
@ConfigItem(defaultValue = "false")
@ConfigItem(defaultValue = "true")

This comment has been minimized.

Copy link
@gsmet

gsmet Oct 29, 2019

Member

Yes, this is definitely dark magic.

This comment has been minimized.

Copy link
@stuartwdouglas

stuartwdouglas Oct 29, 2019

Member

This change was unintentional. I must have made a mistake when creating this, or maybe it got missed in one of the many rebases.

}
if (result.getJar().isUberJar()) {
projectHelper.attachArtifact(project, result.getJar().getPath().toFile(), "runner");
if (result.getJar() != null) {

This comment has been minimized.

Copy link
@gsmet

gsmet Oct 29, 2019

Member

I'm not sure if the issue is the null test or the fact that result.getJar() is empty. When using XML config, it's not as we don't have the NPE so I think we need Stuart to say if it's normal or not.

This comment has been minimized.

Copy link
@stuartwdouglas

stuartwdouglas Oct 29, 2019

Member

This is ok, the NativeImageMojo does not attempt to look at the jar result.

@@ -165,7 +165,7 @@
/**
* If full stack traces are enabled in the resulting image
*/
@ConfigItem(defaultValue = "false")
@ConfigItem(defaultValue = "true")
public boolean fullStackTraces;

This comment has been minimized.

Copy link
@gsmet

gsmet Oct 29, 2019

Member

What bugs me a bit too is that now, the output when creating the native image is very scarce. I don't know if it's normal or not but we used to have a couple of Quarkus lines and now we have:

21:02:57,864 INFO  [org.jbo.threads] JBoss Threads version 3.0.0.Final

and that's it.

This comment has been minimized.

Copy link
@stuartwdouglas

stuartwdouglas Oct 29, 2019

Member

I will look into this

@geoand geoand merged commit cf8ea35 into quarkusio:master Oct 29, 2019
24 checks passed
24 checks passed
WIP Ready for review
Details
quarkusio.quarkus Build #20191029.105 succeeded
Details
quarkusio.quarkus (Build for Native Build JDK8 Linux) Build for Native Build JDK8 Linux succeeded
Details
quarkusio.quarkus (Maven Cache Linux Maven Repo) Maven Cache Linux Maven Repo succeeded
Details
quarkusio.quarkus (Maven Cache Windows Maven Repo) Maven Cache Windows Maven Repo succeeded
Details
quarkusio.quarkus (Native Tests amazon-dynamodb, amazon-lambda, amazon-lambda-http-it) Native Tests amazon-dynamodb, amazon-lambda, amazon-lambda-http-it succeeded
Details
quarkusio.quarkus (Native Tests artemis-core, artemis-jms, kafka) Native Tests artemis-core, artemis-jms, kafka succeeded
Details
quarkusio.quarkus (Native Tests elytron-resteasy, oidc, oidc-code-flow, vault-app, keycloak-authorization) Native Tests elytron-resteasy, oidc, oidc-code-flow, vault-app, keycloak-authorization succeeded
Details
quarkusio.quarkus (Native Tests elytron-security-oauth2, elytron-security, elytron-security-jdbc, elytron-undertow) Native Tests elytron-security-oauth2, elytron-security, elytron-security-jdbc, elytron-undertow succeeded
Details
quarkusio.quarkus (Native Tests flyway, hibernate-orm-panache, reactive-pg-client) Native Tests flyway, hibernate-orm-panache, reactive-pg-client succeeded
Details
quarkusio.quarkus (Native Tests hibernate-search-elasticsearch, narayana-stm, narayana-jta) Native Tests hibernate-search-elasticsearch, narayana-stm, narayana-jta succeeded
Details
quarkusio.quarkus (Native Tests infinispan-cache-jpa, infinispan-client) Native Tests infinispan-cache-jpa, infinispan-client succeeded
Details
quarkusio.quarkus (Native Tests jackson, jsonb, jgit, kogito, kubernetes-client) Native Tests jackson, jsonb, jgit, kogito, kubernetes-client succeeded
Details
quarkusio.quarkus (Native Tests jpa, jpa-postgresql, jpa-mysql, reactive-mysql-client) Native Tests jpa, jpa-postgresql, jpa-mysql, reactive-mysql-client succeeded
Details
quarkusio.quarkus (Native Tests jpa-h2, jpa-mariadb, jpa-mssql, jpa-derby) Native Tests jpa-h2, jpa-mariadb, jpa-mssql, jpa-derby succeeded
Details
quarkusio.quarkus (Native Tests main) Native Tests main succeeded
Details
quarkusio.quarkus (Native Tests mongodb-client, mongodb-panache, neo4j) Native Tests mongodb-client, mongodb-panache, neo4j succeeded
Details
quarkusio.quarkus (Native Tests resteasy-jackson, vertx, vertx-http, virtual-http) Native Tests resteasy-jackson, vertx, vertx-http, virtual-http succeeded
Details
quarkusio.quarkus (Native Tests spring-di, spring-web, spring-data-jpa) Native Tests spring-di, spring-web, spring-data-jpa succeeded
Details
quarkusio.quarkus (Native Tests tika, hibernate-validator, test-extension) Native Tests tika, hibernate-validator, test-extension succeeded
Details
quarkusio.quarkus (Run JVM Tests Linux JDK11 Build) Run JVM Tests Linux JDK11 Build succeeded
Details
quarkusio.quarkus (Run JVM Tests Linux JDK12 Build) Run JVM Tests Linux JDK12 Build succeeded
Details
quarkusio.quarkus (Run JVM Tests Run_TCKs) Run JVM Tests Run_TCKs succeeded
Details
quarkusio.quarkus (Run JVM Tests Windows JVM Build) Run JVM Tests Windows JVM Build succeeded
Details
@geoand geoand added this to the 0.27.0 milestone Oct 29, 2019
@geoand geoand deleted the geoand:generated-native-fix branch Oct 30, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
4 participants
You can’t perform that action at this time.