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

Incorrect Platform.RESOURCE_PREFIX leads to UnsatisfiedLinkError in one of my gradle projects #2742

Closed
cbtum opened this issue Aug 28, 2021 · 5 comments
Assignees
Labels
Bug Help Needed Modeling/Usage problem Lang: Java Java wrapper issue OS: Mac MacOS
Projects
Milestone

Comments

@cbtum
Copy link

cbtum commented Aug 28, 2021

Thank you very much for making ortools-java available as maven project, it is much easier to use now! While experimenting with it, I ran into the following problem:

What version of OR-Tools and what language are you using?
'com.google.ortools:ortools-java:9.0.9048'

What operating system (Linux, Windows, ...) and version?
MacOS, Java Gradle Project

What did you do?
I am experimenting with ortools-java in two different gradle projects.

What did you expect to see
Since both projects have the same dependency as specified above, both projects should behave the same way.

What did you see instead?
While ortools-java works fine in one project, I get an UnsatisfiedLinkError in the other.

Anything else we should know about your project / environment

  • Debugging into the Loader.loadNativeLibraries(), I noticed that the Platform.RESOURCE_PREFIX differs between both projects.
  • In the implementation that is working fine, the class loader uses darwin-x86-64/ as resource to be loaded.
  • In contrast, the project with the UnsatisfiedLinkError uses darwin/ as resource. While a resource is found for darwin/, it seems to clash with some other library.
  • When I copy your class loader and replace Platform.RESOURCE_PREFIX with darwin-x86-64/, both projects are working without any problem.
@Mizux
Copy link
Collaborator

Mizux commented Aug 30, 2021

Seems to be linked to #2519 i.e. you must use the jna-platform 5.8.0

Which version of ortools-java did you use ?
Same question with g:net.java.dev.jna a:jna-platform ?

note: You may also be interested by #2575 (currently on master for v9.1)

@Mizux Mizux self-assigned this Aug 30, 2021
@Mizux Mizux added Bug Help Needed Modeling/Usage problem Lang: Java Java wrapper issue OS: Mac MacOS labels Aug 30, 2021
@Mizux Mizux added this to the v9.1 milestone Aug 30, 2021
@Mizux Mizux added this to To do in ToDo via automation Aug 30, 2021
@Mizux Mizux closed this as completed Aug 30, 2021
ToDo automation moved this from To do to Done Aug 30, 2021
@cbtum
Copy link
Author

cbtum commented Aug 30, 2021

Since I am using 9.0, I am actually using jna-platform 5.8.0.

However, the idea of prefixing darwin probably solves the issue of the clashing libraries.

@cbtum
Copy link
Author

cbtum commented Oct 3, 2021

@Mizux , just tried the new com.google.ortools:ortools-java:9.1.9490. Seems the problem with the clashing library is solved by prefixing ortools. However, I still experience different behavior in two different projects. Again, Platform.RESOURCE_PREFIX differs in both projects. The working project now uses ortools-darwin-x86-64, the broken project uses ortools-darwin as ressource path. So I guess the difference is not so much in the complete path, but rather in the Platform.RESOURCE_PREFIX.

It might be relevant to mention, that the working project is meant to be a library for the broken project. When I override the Platform.RESOURCE_PREFIX in my working project, I can use it as a library for the other project without any problems. Any ideas why Platform.RESOURCE_PREFIX might be different on the same computer?

PS: As described #2802, I also had problems with the linux dependency and solved it by saving com.google.ortools:ortools-linux-x86-64:9.1.9490 on maven local.

@Mizux
Copy link
Collaborator

Mizux commented Oct 4, 2021

@cbtum Platform.RESOURCE_PREFIX is computed by g:net.java.dev.jna a:jna-platform which has changed its behavior between 5.5.0 and 5.8.0 so you should try to check which version you are using in both projects ?

see: #2519 (comment) for details and jna PR link.

note: it seems we are using 5.8.0 since v9.0 d6b3090 (see the tag list)

@cbtum
Copy link
Author

cbtum commented Oct 11, 2021

@Mizux , thanks for your help. Apparently there was a conflict with another library. Although gradle marked this conflict as resolved (in the https://docs.gradle.org/current/userguide/viewing_debugging_dependencies.html), the problem described above was fixed after removing the other library.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Help Needed Modeling/Usage problem Lang: Java Java wrapper issue OS: Mac MacOS
Projects
ToDo
  
Done
Development

No branches or pull requests

2 participants