Decision Optimization

Decision Optimization

Delivers prescriptive analytics capabilities and decision intelligence to improve decision-making.


#Analytics
#DecisionOptimization
#DecisionOptimization
 View Only
  • 1.  CPLEX Studio 12.8.0 with Java: UnsatisfiedLink ilog.concert.cppimpl

    Posted 06/11/18 11:17 AM

    Originally posted by: testuser11222


    hi Guys, 

     

    I am trying to execute few jobs on CPLE using java however facing issue while running the code. 

    Following is the details. 

    Code

    import ilog.concert.IloException;
    import ilog.opl.IloCplex;
    import org.junit.Test;
    
    public class TestCplex {
    
        @Test
        public void testCPLX(){
            try {
                IloCplex cplex = new IloCplex();
            } catch (IloException e) {
                e.printStackTrace();
            }
        }
    }
    

    POM.xml

    <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-surefire-plugin</artifactId>
            <version>2.21.0</version>
            <dependencies>
                    <dependency>
                            <groupId>org.apache.maven.surefire</groupId>
                            <artifactId>surefire-junit4</artifactId>
                            <version>2.21.0</version>
                    </dependency>
            </dependencies>
            <configuration>
                    <forkMode>once</forkMode>
                    <argLine>-Djava.library.path=/Applications/CPLEX_Studio_Community128/opl/bin/x86-64_osx/:/Applications/CPLEX_Studio_Community128/opl/oplide/:/Applications/CPLEX_Studio_Community128/cplex/bin/x86-64_osx/:/Applications/CPLEX_Studio_Community128/opl/lib/oplall.jar</argLine>
            </configuration>
    </plugin>
    

    Error:

    [ERROR] Tests run: 1, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 0.163 s <<< FAILURE! - in test.java.cplexTests.TestCplex
    [ERROR] testCPLX(test.java.cplexTests.TestCplex)  Time elapsed: 0.092 s  <<< ERROR!
    java.lang.UnsatisfiedLinkError: ilog.concert.cppimpl.concert_wrapJNI.swig_module_init()V
    at test.java.cplexTests.TestCplex.testCPLX(TestCplex.java:13) 
    [INFO]
    [INFO] Results:
    [INFO]
    [ERROR] Errors:
    [ERROR]   TestCplex.testCPLX:13 » UnsatisfiedLink ilog.concert.cppimpl.concert_wrapJNI.s...
    

    Following is the environment variable value. 

    Both LD_LIBRARY_PATH and LYLD_LIBRARY_PATH contains following value

    /Applications/CPLEX_Studio_Community128/cplex/bin/x86-64_osx/:/Applications/CPLEX_Studio_Community128/opl/bin/x86-64_osx/
    

     


    #CPLEXOptimizers
    #DecisionOptimization


  • 2.  Re: CPLEX Studio 12.8.0 with Java: UnsatisfiedLink ilog.concert.cppimpl

    Posted 06/11/18 11:43 AM

    Can you print the java.library.path property and the DYLD_LIBRARY_PATH from function testCPLX() to make sure they look as expected?

    Also, can you show the contents of directory /Applications/CPLEX_Studio_Community128/opl/bin/x86-64_osx?

    Finally, you should have only one of opl or cplex on your paths (in your case opl since you are using oplall.jar).


    #CPLEXOptimizers
    #DecisionOptimization


  • 3.  Re: CPLEX Studio 12.8.0 with Java: UnsatisfiedLink ilog.concert.cppimpl

    Posted 06/11/18 02:17 PM

    Originally posted by: testuser11222


    I have make following modification as per you suggestion. 

    • in both DYLD_LIBRARY_PATH and LD_LIBRARY_PATH path i kept only /Applications/CPLEX_Studio_Community128/opl/bin/x86-64_osx
    • And put the following line in my test case 
    System.out.println(System.getenv("LD_LIBRARY_PATH"));
    System.out.println(System.getenv("DYLD_LIBRARY_PATH"));
    

    however the problem is, both prints null. 

    from console if i echo them, I could see the vaule


    #CPLEXOptimizers
    #DecisionOptimization


  • 4.  Re: CPLEX Studio 12.8.0 with Java: UnsatisfiedLink ilog.concert.cppimpl

    Posted 06/11/18 03:19 PM

    How exactly do you set these environment variable? And how exactly do you invoke your Java program? It seems those variables are not propagated to the JVM.

    What is the output of

    System.out.println(System.getProperty("java.library.path"));

    ?


    #CPLEXOptimizers
    #DecisionOptimization


  • 5.  Re: CPLEX Studio 12.8.0 with Java: UnsatisfiedLink ilog.concert.cppimpl

    Posted 06/11/18 04:25 PM

    Originally posted by: testuser11222


    I am setting environment variable as mentioned below 

    export DYLD_LIBRARY_PATH=/Applications/CPLEX_Studio_Community128/cplex/bin/x86-64_osx/:
    export LD_LIBRARY_PATH=/Applications/CPLEX_Studio_Community128/cplex/bin/x86-64_osx/:
    

    and following the output of, 

    System.out.println(System.getProperty("java.library.path"));
    

    /Applications/CPLEX_Studio_Community128/opl/bin/x86-64_osx/

     

    I am setting java.libaray.path using maven as mentioned in the question.

     

    And following is the content of the directory 

     

    ls /Applications/CPLEX_Studio_Community128/opl/bin/x86-64_osx
    libcplex1280.jnilib                     libcplex1280remotejni.jnilib            libicui18n.dylib                        libiculx.dylib                          liboplb.dylib
    libcplex1280mpitransport.dylib          libcplex1280tcpiptransport.dylib        libicuio.55.dylib                       libicutu.55.dylib                       liboplnl1.12.dylib
    libcplex1280mpiworker.dylib             libcplex1280tcpipworker.dylib           libicuio.dylib                          libicutu.dylib                          liboplnl1.dylib
    libcplex1280processtransport.dylib      libicudata.55.dylib                     libicule.55.dylib                       libicuuc.55.dylib                       oplrun
    libcplex1280processworker.dylib         libicudata.dylib                        libicule.dylib                          libicuuc.dylib                          oplrunjava
    libcplex1280remote.dylib                libicui18n.55.dylib                     libiculx.55.dylib                       libopl1280.dylib
    

    #CPLEXOptimizers
    #DecisionOptimization


  • 6.  Re: CPLEX Studio 12.8.0 with Java: UnsatisfiedLink ilog.concert.cppimpl

    Posted 06/12/18 02:40 AM

    You environment variables now use 'cplex' instead of 'opl'. I guess this is just a copy-paste error?

    Do you invoke the Java program in the same shell (or a sub-shell) in which you set the environment variables?

    Do things work correctly if you directly invoke the program from the shell without using maven?

    From what you report it seems the environment variables are not properly set/propagated to the JVM that executes your program. That would not be a problem with CPLEX but with your runtime setup.

    I don't know maven well but could you try to set these environment variables in the pom.xml?


    #CPLEXOptimizers
    #DecisionOptimization


  • 7.  Re: CPLEX Studio 12.8.0 with Java: UnsatisfiedLink ilog.concert.cppimpl

    Posted 06/12/18 10:32 AM

    Originally posted by: testuser11222


    yes, that was a typo error. 

    I modified my pom.xml to set the environment variable. 

     

    <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-surefire-plugin</artifactId>
            <version>2.21.0</version>
            <dependencies>
                    <dependency>
                            <groupId>org.apache.maven.surefire</groupId>
                            <artifactId>surefire-junit4</artifactId>
                            <version>2.21.0</version>
                    </dependency>
            </dependencies>
            <configuration>
                    <forkMode>once</forkMode>
                    <argLine>-Djava.library.path=/Applications/CPLEX_Studio_Community128/opl/bin/x86-64_osx/ -DLD_LIBRARY_PATH=/Applications/CPLEX_Studio_Community128/opl/bin/x86-64_osx/</argLine>
                    <environmentVariables>
                            <LD_LIBRARY_PATH>/Applications/CPLEX_Studio_Community128/opl/bin/x86-64_osx/</LD_LIBRARY_PATH>
                            <DYLD_LIBRARY_PATH>/Applications/CPLEX_Studio_Community128/opl/bin/x86-64_osx/</DYLD_LIBRARY_PATH>
                    </environmentVariables>
            </configuration>
    
    </plugin>
    

     

     

    However it's the same error, also the output of printing environment variable is also same. 

     

            System.out.println("LD_LIBRARY_PATH env: "+System.getenv("LD_LIBRARY_PATH"));
            System.out.println("DYLD_LIBRARY_PATH env: " +System.getenv("DYLD_LIBRARY_PATH"));
            System.out.println("LD_LIBRARY_PATH prop: "+System.getProperty("LD_LIBRARY_PATH"));
            System.out.println("DYLD_LIBRARY_PATH prop: "+ System.getProperty("DYLD_LIBRARY_PATH"));
    

     

    Outout

    LD_LIBRARY_PATH env: null
    DYLD_LIBRARY_PATH env: null
    LD_LIBRARY_PATH prop: /Applications/CPLEX_Studio_Community128/opl/bin/x86-64_osx/
    DYLD_LIBRARY_PATH prop: null
    

     


    #CPLEXOptimizers
    #DecisionOptimization


  • 8.  Re: CPLEX Studio 12.8.0 with Java: UnsatisfiedLink ilog.concert.cppimpl

    Posted 06/13/18 09:18 AM

    What happens if you run your application directly in the command line without using maven?

    The following works without a problem for me (on Linux though, but also using bash):

    javac -classpath $COSDIR/opl/lib/oplall.jar:/usr/share/java/junit4.jar TestCplex.java

    LD_LIBRARY_PATH=$COSDIR/opl/bin/x86-64_linux java -Djava.library.path=$COSDIR/opl/bin/x86-64_linux -classpath $COSDIR/opl/lib/oplall.jar:/usr/share/java/junit4.jar:. org.junit.runner.JUnitCore TestCplex

    COSDIR is set to the absolute of the path in which CPLEX Optimization Studio is installed.


    #CPLEXOptimizers
    #DecisionOptimization