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 fails to compile PostgreSQL JDBC client. #727

Closed
katox opened this issue Oct 8, 2018 · 8 comments

Comments

3 participants
@katox
Copy link

commented Oct 8, 2018

When I try to create a native image of a trivial app that connects to postgres I get somewhat cryptic errors "Parameter X of method has declared type classImpl which is incompatible with types in state:".

error: unsupported features in 48 methods
Detailed message:
Error: Parameter 0 of org.postgresql.core.SetupQueryRunner.run(QueryExecutor, String, boolean) has declared type org.postgresql.core.QueryExecutor which is incompatible with types in state: 1TypeMObject<[0x0000096E00008CDF:!S:QueryExecutorImpl]>
Call path from entry point to org.postgresql.core.SetupQueryRunner.run(QueryExecutor, String, boolean): 
	at org.postgresql.core.SetupQueryRunner.run(SetupQueryRunner.java:43)
	at org.postgresql.core.v3.ConnectionFactoryImpl.isMaster(ConnectionFactoryImpl.java:745)
	at org.postgresql.core.v3.ConnectionFactoryImpl.openConnectionImpl(ConnectionFactoryImpl.java:256)
	at org.postgresql.core.ConnectionFactory.openConnection(ConnectionFactory.java:49)
	at org.postgresql.jdbc.PgConnection.<init>(PgConnection.java:195)
	at org.postgresql.Driver.makeConnection(Driver.java:454)
	at org.postgresql.Driver.connect(Driver.java:256)
	at java.sql.DriverManager.getConnection(DriverManager.java:664)
	at java.sql.DriverManager.getConnection(DriverManager.java:270)
	at lumgraal.App.main(App.java:18)
	at com.oracle.svm.core.JavaMainWrapper.run(JavaMainWrapper.java:163)
	at com.oracle.svm.core.code.CEntryPointCallStubs.com_002eoracle_002esvm_002ecore_002eJavaMainWrapper_002erun_0028int_002corg_002egraalvm_002enativeimage_002ec_002etype_002eCCharPointerPointer_0029(generated:0)
...

What is the problem and what is a suggested workaround?

The repo to reproduce the issue: https://github.com/katox/graal-pg-client

@cstancu cstancu self-assigned this Oct 8, 2018

@cstancu cstancu added the native-image label Oct 8, 2018

@cstancu

This comment has been minimized.

Copy link
Member

commented Oct 8, 2018

@katox the repo to reproduce is missing pom.xml.

@katox

This comment has been minimized.

Copy link
Author

commented Oct 8, 2018

@cstancu I copied wrong .gitignore into the repo. pom.xml re-added, sorry.

@cstancu

This comment has been minimized.

Copy link
Member

commented Oct 8, 2018

@katox the issue is a side effect of the problems we currently have with building native images from apps with an incomplete class path, i.e., the code references a library that is missing from the classpath. The underlying exception that is the cause of the issue you see is: java.lang.ClassNotFoundException: waffle.windows.auth.IWindowsCredentialsHandle. This exception is not correctly captured by --report-unsupported-elements-at-runtime currently. We are working on a solution for incomplete classpaths, in the meantime you can try adding the missing dependency to the classpath, if your code doesn't actually need it, as a workaround.

@cstancu cstancu added the bug label Oct 8, 2018

katox added a commit to katox/graal-pg-client that referenced this issue Oct 9, 2018

@katox

This comment has been minimized.

Copy link
Author

commented Oct 9, 2018

@cstancu thank you. How can I log the underlying exception? I added waffle-jna and its dependencies but I ended up in the same situation with the same error message. Something else is probably missing as well.

There is only one place that needs IWindowsCredentialsHandle and that is SSPIClient. The SSPIClient is instanciated in a single place (dynamically via Class.forName), in org.postgresql.core.v3.ConnectionFactoryImpl/createSSPI(...).

I'm sure that the code is not needed because I run it on Linux and the code depends on win32-only JNA library. I tried to @Substitute the createSSPI method (see `stub.InternalConnectionFactoryImpl) in order to prune all code in this path but it doesn't seem to work that way.

@katox

This comment has been minimized.

Copy link
Author

commented Oct 9, 2018

I updated the repo with a new image creation script and extended logging in the App.

@katox

This comment has been minimized.

Copy link
Author

commented Oct 9, 2018

Update: unlike rc7 it seems to generate a working image when using the current git master native-image (using the suggested workaround). Nice!

@emrul

This comment has been minimized.

Copy link

commented Mar 4, 2019

@katox thanks for your work on this which helped me get started. I have found one problem which is if I make a static native image then the binary will segault when trying to establish the Postgres connection - org.postgresql.core.v3.ConnectionFactoryImpl.tryConnect().

If I leave off the static flag then it works.

Test repo here: https://github.com/emrul/testjdbc

@katox katox closed this Mar 11, 2019

@katox

This comment has been minimized.

Copy link
Author

commented Mar 11, 2019

@emrul yes, the static linking still doesn't work.

It's a separate issue, I opened #1054, closing this one.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.