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

[native-image] should not reach here with jooby+undertow+others #749

Closed
asm0dey opened this issue Oct 21, 2018 · 7 comments
Closed

[native-image] should not reach here with jooby+undertow+others #749

asm0dey opened this issue Oct 21, 2018 · 7 comments
Assignees

Comments

@asm0dey
Copy link

asm0dey commented Oct 21, 2018

I'm trying to build native image from this project: https://github.com/asm0dey/school-crm

Build log is following:

/usr/lib/jvm/java-8-graal/bin/native-image -jar target/crm-1.5.0.jar
Build on Server(pid: 16916, port: 37973)*
[crm-1.5.0:16916]    classlist:   8,884.80 ms
[crm-1.5.0:16916]        (cap):     776.87 ms
[crm-1.5.0:16916]        setup:   2,364.10 ms
[crm-1.5.0:16916]     analysis:   6,765.95 ms
fatal error: com.oracle.svm.core.util.VMError$HostedError: should not reach here
        at com.oracle.svm.core.util.VMError.shouldNotReachHere(VMError.java:62)
        at com.oracle.svm.hosted.SVMHost.dynamicHub(SVMHost.java:205)
        at com.oracle.svm.hosted.analysis.Inflation.checkType(Inflation.java:139)
        at java.lang.Iterable.forEach(Iterable.java:75)
        at java.util.Collections$UnmodifiableCollection.forEach(Collections.java:1080)
        at com.oracle.svm.hosted.analysis.Inflation.checkObjectGraph(Inflation.java:130)
        at com.oracle.graal.pointsto.BigBang.checkObjectGraph(BigBang.java:590)
        at com.oracle.graal.pointsto.BigBang.finish(BigBang.java:562)
        at com.oracle.svm.hosted.NativeImageGenerator.doRun(NativeImageGenerator.java:691)
        at com.oracle.svm.hosted.NativeImageGenerator.lambda$run$0(NativeImageGenerator.java:402)
        at java.util.concurrent.ForkJoinTask$AdaptedRunnableAction.exec(ForkJoinTask.java:1386)
        at java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:289)
        at java.util.concurrent.ForkJoinPool$WorkQueue.runTask(ForkJoinPool.java:1056)
        at java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1692)
        at java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:157)
Error: Processing image build request failed

To reproduce you need to perform following steps;

  1. git clone git@github.com:asm0dey/school-crm.git
  2. cd school-crm
  3. mvn clean package (optionally you can add -Dmaven.test.skip=true or, vice versa add verify to be sure that everything works in your environment (it should), but I'd stuck with default option)
  4. call native-image -jar target/crm-1.5.0.jar

My env:

Apache Maven 3.5.4 (NON-CANONICAL_2018-09-08T01:02:16+02:00_root; 2018-09-08T02:02:16+03:00)
Maven home: /opt/maven
Java version: 1.8.0_172, vendor: Oracle Corporation, runtime: /usr/lib/jvm/java-8-graal/jre
Default locale: en_US, platform encoding: UTF-8
OS name: "linux", version: "4.18.12-1-manjaro", arch: "amd64", family: "unix"

JVM version is graal rc8 ee

@asm0dey asm0dey changed the title should not reach here while trying to create native-image from project [native-image] should not reach here with jooby+undertow+others Oct 21, 2018
@cstancu
Copy link
Member

cstancu commented Oct 23, 2018

Thank you for your report.This problem is caused by trying to build the native image with an incomplete class path, i.e., the app that you are trying to build the image from has some optional library dependencies which you probably don't use. We are currently working on a general solution for these issues and plan to release it in rc9. (For reference this seems to generate the same trace as #754.)

@cstancu cstancu self-assigned this Oct 23, 2018
@asm0dey
Copy link
Author

asm0dey commented Oct 23, 2018

@cstancu thank you for reply! Is there any way do find this dependency?
May be there is any option to display such dependency in stacktrace (or class name)?

@cstancu
Copy link
Member

cstancu commented Oct 23, 2018

For your app the missing class seems to be: org.apache.log4j.Logger reached from:

	at parsing org.jooq.tools.JooqLogger.isInfoEnabled(JooqLogger.java:311)
	at parsing org.jooq.tools.JooqLogger.getLogger(JooqLogger.java:123)
	at parsing org.jooq.tools.jdbc.JDBCUtils.<clinit>(JDBCUtils.java:104)

There is no option unfortunately to give you this information, you need to run in debug mode and know where to look or modify the source and catch the exception close to where it happens. What I did was to add:

        } catch (Throwable t) {
            t.printStackTrace();
            throw t;

just before the } finally { in AnalysisUniverse.createType(). The issue happens when we create a new type and eagerly resolve its dependencies, some of which are missing resulting in a java.lang.NoClassDefFoundError.

@asm0dey
Copy link
Author

asm0dey commented Oct 23, 2018

@cstancu looks like it makes sense to add this at least until release. Looks like nothing bad can happen because at this place native image is going to crash anyways.

@asm0dey
Copy link
Author

asm0dey commented Oct 24, 2018

@cstancu I've added following dependencies to classpath: /tmp/log4j-over-slf4j-1.5.11.jar:/tmp/OSGi_R4_v4.2_core_spec-4.2.0.200908310645.jar:/tmp/janino-3.0.10.jar:/tmp/spring-jdbc-1.2.9.jar:/tmp/spring-beans-4.3.20.RELEASE.jar and got error again:

Build on Server(pid: 16249, port: 40151)
[crm-1.5.0:16249]    classlist:   7,084.08 ms
[crm-1.5.0:16249]        (cap):     707.69 ms
[crm-1.5.0:16249]        setup:   1,209.33 ms
[crm-1.5.0:16249]     analysis:   7,582.15 ms
fatal error: com.oracle.svm.core.util.VMError$HostedError: should not reach here
        at com.oracle.svm.core.util.VMError.shouldNotReachHere(VMError.java:62)
        at com.oracle.svm.hosted.SVMHost.dynamicHub(SVMHost.java:205)
        at com.oracle.svm.hosted.analysis.Inflation.checkType(Inflation.java:139)
        at java.lang.Iterable.forEach(Iterable.java:75)
        at java.util.Collections$UnmodifiableCollection.forEach(Collections.java:1080)
        at com.oracle.svm.hosted.analysis.Inflation.checkObjectGraph(Inflation.java:130)
        at com.oracle.graal.pointsto.BigBang.checkObjectGraph(BigBang.java:590)
        at com.oracle.graal.pointsto.BigBang.finish(BigBang.java:562)
        at com.oracle.svm.hosted.NativeImageGenerator.doRun(NativeImageGenerator.java:691)
        at com.oracle.svm.hosted.NativeImageGenerator.lambda$run$0(NativeImageGenerator.java:402)
        at java.util.concurrent.ForkJoinTask$AdaptedRunnableAction.exec(ForkJoinTask.java:1386)
        at java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:289)
        at java.util.concurrent.ForkJoinPool$WorkQueue.runTask(ForkJoinPool.java:1056)
        at java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1692)
        at java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:157)
Error: Processing image build request failed

@asm0dey
Copy link
Author

asm0dey commented Oct 24, 2018

Also I've tried just to create empty org.apache.log4j.Logger class and gained the same error

@asm0dey
Copy link
Author

asm0dey commented Nov 6, 2018

Closing in favor of #778

@asm0dey asm0dey closed this as completed Nov 6, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants