javaintersystems-cacheglobalintersystems

Java connection via Globals API causes a StackOverflowError


I am trying to connect a Java application to an InterSystems Caché database via Globals API.

import com.intersys.globals.*;

public class Assignment {

    public static void main(String[] args) {
        final String user = "Andrew";
        final String password = "Tobilko";

        Connection connection = ConnectionContext.getConnection();
        connection.connect("USER", user, password);
    }

}

The stacktrace:

Exception in thread "main" java.lang.StackOverflowError
    at com.intersys.globals.internal.GlobalsConnectionJNI.connectImpl(Native Method)
    at com.intersys.globals.internal.GlobalsConnectionJNI.connect(GlobalsConnectionJNI.java:107)
    at com.tobilko.a3.Assignment.main(Assignment.java:12)
  1. The credentials and the namespace are correct.
  2. The Cache instance has been initialised correctly and by instruction.
  3. All the global environment variables including GLOBALS_HOME and DYLD_LIBRARY_PATH have been set.
  4. The following libraries have been soft-linked:

    ln -s $GLOBALS_HOME/bin/libisccache.dylib /usr/local/lib
    ln -s $GLOBALS_HOME/bin/liblcbjni.dylib /usr/local/lib
    ln -s $GLOBALS_HOME/bin/liblcbindnt.dylib /usr/local/lib
    ln -s $GLOBALS_HOME/bin/liblcbclientnt.dylib /usr/local/lib
    ln -s $GLOBALS_HOME/bin/libmdsjni.dylib /usr/local/lib
    
  5. -Djava.library.path=/usr/local/lib has been specified.

  6. The jars have been included.

enter image description here

These steps led me to a StackOverflowError exception. I have no idea where I could have made a mistake.

Any help would be appreciated.


Solution

  • I skipped the Window configuration part because it isn't my OS.

    Apparently, the next configuration is required for all systems:

    Configuration for Windows

    The default stack size of the Java Virtual Machine on Windows is too small for running eXTreme applications (running them with the default stack size causes Java to report EXCEPTION_STACK_OVERFLOW). To optimize performance, heap size should also be increased.

    To temporarily modify the stack size and heap size when running an eXTreme application, add the following command line arguments:

    -Xss1024k -Xms2500m -Xmx2500m
    

    Increasing the stack size has resolved the issue.