google / or-tools

Google's Operations Research tools:
https://developers.google.com/optimization/
Apache License 2.0
11.2k stars 2.12k forks source link

same code works perfect on mac but not linux #3740

Closed ben-xj closed 1 year ago

ben-xj commented 1 year ago

What version of OR-Tools and what language are you using? Version: 9.5 Language: Java/maven

Which solver are you using (e.g. CP-SAT, Routing Solver, GLOP, BOP, Gurobi) SCIP

What operating system (Linux, Windows, ...) and version? Macos intel monterey . Centos 7.8

What did you do? Steps to reproduce the behavior:

  1. import or-tools in pom as follows, pull the jar from maven central repo
    <dependency>
    <groupId>com.google.ortools</groupId>
    <artifactId>ortools-java</artifactId>
    <version>9.5.2237</version>
    <type>jar</type>
    <scope>compile</scope>
    </dependency
  2. works perfect on my mac
  3. i packaged my project as a jar, and deployed it on centos

What did you expect to see same output as on my mac

What did you see instead?

java.lang.RuntimeException: java.nio.file.NoSuchFileException: /BOOT-INF/lib/ortools-linux-x86-64-9.5.2237.jar!/ortools-linux-x86-64/
        at com.google.ortools.Loader.loadNativeLibraries(Loader.java:115)
        at com.aliyun.publictransport.schedule.core.model.ShortTerm.schedulingMipModel(ShortTerm.java:76)
        at com.aliyun.publictransport.schedule.core.model.ShortTerm.run(ShortTerm.java:61)
        at com.aliyun.publictransport.schedule.service.OverhaulService.originOverhaul(OverhaulService.java:103)
        at com.aliyun.publictransport.schedule.service.OverhaulService$$FastClassBySpringCGLIB$$5a9c825c.invoke(<generated>)
        at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:218)
        at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.invokeJoinpoint(CglibAopProxy.java:769)
        at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:163)
        at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:747)
        at org.springframework.aop.interceptor.AsyncExecutionInterceptor.lambda$invoke$0(AsyncExecutionInterceptor.java:115)
        at java.util.concurrent.FutureTask.run(FutureTask.java:266)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
        at java.lang.Thread.run(Thread.java:750)
Caused by: java.nio.file.NoSuchFileException: /BOOT-INF/lib/ortools-linux-x86-64-9.5.2237.jar!/ortools-linux-x86-64/
        at com.sun.nio.zipfs.ZipPath.getAttributes(ZipPath.java:725)
        at com.sun.nio.zipfs.ZipFileSystemProvider.readAttributes(ZipFileSystemProvider.java:294)
        at java.nio.file.Files.readAttributes(Files.java:1737)
        at java.nio.file.FileTreeWalker.getAttributes(FileTreeWalker.java:219)
        at java.nio.file.FileTreeWalker.visit(FileTreeWalker.java:276)
        at java.nio.file.FileTreeWalker.walk(FileTreeWalker.java:322)
        at java.nio.file.Files.walkFileTree(Files.java:2662)
        at java.nio.file.Files.walkFileTree(Files.java:2742)
        at com.google.ortools.Loader.lambda$unpackNativeResources$0(Loader.java:68)
        at com.google.ortools.Loader.unpackNativeResources(Loader.java:97)
        at com.google.ortools.Loader.loadNativeLibraries(Loader.java:108)
        ... 13 more

why is there a "!" after the path? java.nio.file.NoSuchFileException: /BOOT-INF/lib/ortools-linux-x86-64-9.5.2237.jar ! /ortools-linux-x86-64/

Make sure you include information that can help us debug (full error message, model Proto).

Anything else we should know about your project / environment

Mizux commented 1 year ago

Could be related to:

ben-xj commented 1 year ago

Could be related to:

doesn't seem to be the same issue as #3577, plus i tried to compile from source and modified my Loader.java like in #3728, but here the problem is i can only generate or-tools java and native lib for mac, but not for linux expect a jar containing:

image

however, i get:

image

is there a way to build a complete jar pack on my mac ?

ben-xj commented 1 year ago

What version of OR-Tools and what language are you using? Version: 9.5 Language: Java/maven

Which solver are you using (e.g. CP-SAT, Routing Solver, GLOP, BOP, Gurobi) SCIP

What operating system (Linux, Windows, ...) and version? Macos intel monterey . Centos 7.8

What did you do? Steps to reproduce the behavior:

  1. import or-tools in pom as follows, pull the jar from maven central repo
<dependency>
            <groupId>com.google.ortools</groupId>
            <artifactId>ortools-java</artifactId>
            <version>9.5.2237</version>
            <type>jar</type>
            <scope>compile</scope>
        </dependency
  1. works perfect on my mac
  2. i packaged my project as a jar, and deployed it on centos

What did you expect to see same output as on my mac

What did you see instead?

java.lang.RuntimeException: java.nio.file.NoSuchFileException: /BOOT-INF/lib/ortools-linux-x86-64-9.5.2237.jar!/ortools-linux-x86-64/
        at com.google.ortools.Loader.loadNativeLibraries(Loader.java:115)
        at com.aliyun.publictransport.schedule.core.model.ShortTerm.schedulingMipModel(ShortTerm.java:76)
        at com.aliyun.publictransport.schedule.core.model.ShortTerm.run(ShortTerm.java:61)
        at com.aliyun.publictransport.schedule.service.OverhaulService.originOverhaul(OverhaulService.java:103)
        at com.aliyun.publictransport.schedule.service.OverhaulService$$FastClassBySpringCGLIB$$5a9c825c.invoke(<generated>)
        at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:218)
        at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.invokeJoinpoint(CglibAopProxy.java:769)
        at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:163)
        at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:747)
        at org.springframework.aop.interceptor.AsyncExecutionInterceptor.lambda$invoke$0(AsyncExecutionInterceptor.java:115)
        at java.util.concurrent.FutureTask.run(FutureTask.java:266)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
        at java.lang.Thread.run(Thread.java:750)
Caused by: java.nio.file.NoSuchFileException: /BOOT-INF/lib/ortools-linux-x86-64-9.5.2237.jar!/ortools-linux-x86-64/
        at com.sun.nio.zipfs.ZipPath.getAttributes(ZipPath.java:725)
        at com.sun.nio.zipfs.ZipFileSystemProvider.readAttributes(ZipFileSystemProvider.java:294)
        at java.nio.file.Files.readAttributes(Files.java:1737)
        at java.nio.file.FileTreeWalker.getAttributes(FileTreeWalker.java:219)
        at java.nio.file.FileTreeWalker.visit(FileTreeWalker.java:276)
        at java.nio.file.FileTreeWalker.walk(FileTreeWalker.java:322)
        at java.nio.file.Files.walkFileTree(Files.java:2662)
        at java.nio.file.Files.walkFileTree(Files.java:2742)
        at com.google.ortools.Loader.lambda$unpackNativeResources$0(Loader.java:68)
        at com.google.ortools.Loader.unpackNativeResources(Loader.java:97)
        at com.google.ortools.Loader.loadNativeLibraries(Loader.java:108)
        ... 13 more

why is there a "!" after the path? java.nio.file.NoSuchFileException: /BOOT-INF/lib/ortools-linux-x86-64-9.5.2237.jar ! /ortools-linux-x86-64/

Make sure you include information that can help us debug (full error message, model Proto).

Anything else we should know about your project / environment

i simply don't understand why the target path is /BOOT-INF/lib/ortools-linux-x86-64-9.5.2237.jar ! /ortools-linux-x86-64/, cause i checked there exists path /BOOT-INF/lib/ortools-linux-x86-64-9.5.2237.jar/ortools-linux-x86-64/...

Mizux commented 1 year ago

seems you use SpringBoot which seems to mess up the java path

ben-xj commented 1 year ago

seems you use SpringBoot which seems to mess up the java path

by following the instruction in Java springboot packaging error #3553, now the packaging problem seems to be solved, hooray!