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

[GraalVM] java.lang.ClassNotFoundException: org.newsclub.net.mysql.AFUNIXDatabaseSocketFactoryCJ #156

Closed
kohlschuetter opened this issue Apr 19, 2024 · 5 comments
Assignees
Labels
bug The issue describes a bug in the code compatibility issue An issue with a particular runtime environment merged A fix has been merged to main verify The issue is considered fixed/done, and reassigned to the originator to verify.
Milestone

Comments

@kohlschuetter
Copy link
Member

As per @czp3009 in #152

Caused by: java.lang.ClassNotFoundException: org.newsclub.net.mysql.AFUNIXDatabaseSocketFactoryCJ
        at org.graalvm.nativeimage.builder/com.oracle.svm.core.hub.ClassForNameSupport.forName(ClassForNameSupport.java:123) ~[na:na]
        at org.graalvm.nativeimage.builder/com.oracle.svm.core.hub.ClassForNameSupport.forName(ClassForNameSupport.java:87) ~[na:na]
        at [email protected]/java.lang.Class.forName(DynamicHub.java:1322) ~[identity-service:na]
        at [email protected]/java.lang.Class.forName(DynamicHub.java:1311) ~[identity-service:na]
        at com.mysql.cj.util.Util.getInstance(Util.java:187) ~[na:na]
        ... 142 common frames omitted
@kohlschuetter kohlschuetter added this to the 2.10.0 milestone Apr 19, 2024
@kohlschuetter kohlschuetter added bug The issue describes a bug in the code merged A fix has been merged to main compatibility issue An issue with a particular runtime environment labels Apr 19, 2024
@kohlschuetter
Copy link
Member Author

@czp3009 Thanks for bringing this up!

I have fixed the cause and improved the tooling to prevent mysql-specific bugs with GraalVM.
Please verify with the latest junixsocket-2.10.0-SNAPSHOT version.

@kohlschuetter kohlschuetter added the verify The issue is considered fixed/done, and reassigned to the originator to verify. label Apr 19, 2024
@czp3009
Copy link

czp3009 commented Apr 19, 2024

If I'm not mistaken, the latest code should be on the master branch. But after looking at the source code, I'm confused

reflect-config.json in junixsocket-mysql only add reflection hints for class in mysql package, not include AFUNIXDatabaseSocketFactoryCJ in junixsocket. In many cases, user use junixsockets via a JDBC url(it's string), in which case graalvm needs to dynamically reflect to a specific SocketFactory implementation class such as AFUNIXDatabaseSocketFactoryCJ. So I think it's important to at least include a reflection hint for this class

Another point of confusion is that, AFUNIXDatabaseSocketFactoryTest only test legacy SocketFactory, not CJ style SocketFactory. AFUNIXDatabaseSocketFactory and AFUNIXDatabaseSocketFactoryCJ are two different classes, and both may be used by user via JDBC url

A typical JDBC Url Usage: "jdbc:mysql://localhost/db?socketFactory=org.newsclub.net.mysql.AFUNIXDatabaseSocketFactoryCJ&junixsocket.file=/tmp/mysql.sock"

In summary, i think should add reflective hints for AFUNIXDatabaseSocketFactory and AFUNIXDatabaseSocketFactoryCJ to cover JDBC url usage

kohlschuetter added a commit that referenced this issue Apr 19, 2024
Test resolving the junixsocket-specific MySQL connectors via
DriverManager, and try to connect to a non-existing socket.

Also update reflect-config.json for these connectors.

#156
@kohlschuetter
Copy link
Member Author

Ah, good point, you're right, @czp3009

I've updated the config file. Please re-test. Thanks!

@czp3009
Copy link

czp3009 commented Apr 20, 2024

i read the new https://github.com/kohlschutter/junixsocket/blob/main/junixsocket-mysql/src/main/resources/META-INF/native-image/com.kohlschutter.junixsocket/junixsocket-mysql/reflect-config.json, it looks very well, thanks your work!

@kohlschuetter kohlschuetter self-assigned this Apr 20, 2024
@kohlschuetter
Copy link
Member Author

junixsocket 2.10.0 has been released. Please verify and re-open if necessary. Thanks again for reporting , @czp3009 !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug The issue describes a bug in the code compatibility issue An issue with a particular runtime environment merged A fix has been merged to main verify The issue is considered fixed/done, and reassigned to the originator to verify.
Projects
None yet
Development

No branches or pull requests

2 participants