0

So I'm trying to write a Java program using the SAP BO SDK. When I try to create a session, using a predefined class from the SDK, I get a nullPointerException. I copied my code 1 to 1 from an SDK tutorial. Here is my code:

public class Program {
    public static void main(String[] args) {
        try {
            ISessionMgr sessionMgr = CrystalEnterprise.getSessionMgr();
            ...
        }
    }
}

When I run that code (I commented everything else out for testing), I get the following error:

Exception in thread "main" java.lang.NullPointerException
at com.crystaldecisions.celib.classloader.ClassLoaderHelper$2.getResourceAsStream(ClassLoaderHelper.java:102)
at com.crystaldecisions.celib.classloader.ClassLoaderHelper.getResourceAsStream(ClassLoaderHelper.java:149)
at com.crystaldecisions.sdk.framework.internal.SessionMgr.initializeSystemProperties(SessionMgr.java:258)
at com.crystaldecisions.sdk.framework.internal.SessionMgr.<init>(SessionMgr.java:253)
at com.crystaldecisions.sdk.framework.internal.CEFactory.makeSessionMgr(CEFactory.java:94)
at com.crystaldecisions.sdk.framework.CrystalEnterprise.getSessionMgr_aroundBody0(CrystalEnterprise.java:121)
at com.crystaldecisions.sdk.framework.CrystalEnterprise.getSessionMgr_aroundBody1$advice(CrystalEnterprise.java:512)
at com.crystaldecisions.sdk.framework.CrystalEnterprise.getSessionMgr(CrystalEnterprise.java:1)
at myprogram.main(Program.java:18) <-- Line 4 in my code example above

Does this mean that there is an error in the libraries provided by the SDK? Or that I somehow imported those incorrectly? Is it possible to get any more information from this error code?

Thank you for any help or guidance you can provide.

EDIT: The tutorial used: http://bukhantsov.org/2011/08/getting-started-with-businessobjects-java-sdk/

Nik Weiss
  • 422
  • 7
  • 18
  • Which line is line 18? It looks like it can't find a class or file. – Steve Smith Apr 07 '17 at 11:03
  • ISessionMgr sessionMgr = CrystalEnterprise.getSessionMgr(); – Nik Weiss Apr 07 '17 at 11:03
  • 1
    The documentation of `com.crystaldecisions.sdk.framework.CrystalEnterprise` would be the best place to start. – Andy Turner Apr 07 '17 at 11:06
  • 1
    The `CrystalEnterprise` can not find a resource it's expecting – MadProgrammer Apr 07 '17 at 11:11
  • Use your IDE's debugger to see what is null when the program reaches line 102 of `ClassLoaderHelper` – Ean V Apr 07 '17 at 11:13
  • Are you missing some sort of configuration file that the SDK is expecting somewhere? Or maybe a license-file? – Fildor Apr 07 '17 at 11:14
  • @Fildor as far as I know, I'm not. I followed a tutorial and imported all the external Jar files that are needed (I actually imported all available to be safe). Other programs using the SDK seem to work. – Nik Weiss Apr 07 '17 at 11:15
  • "I followed a tutorial" Please link to the tutorial. – Andy Turner Apr 07 '17 at 11:16
  • @AndyTurner added it in the post as well: http://bukhantsov.org/2011/08/getting-started-with-businessobjects-java-sdk/ – Nik Weiss Apr 07 '17 at 11:17
  • If you have other programs that work with the same SDK, see what they do differently ... do they have resource files that you don't? Try to cut one of them down to what your program looks like at the moment. – Fildor Apr 07 '17 at 11:21
  • @Fildor unfortunately it's not a program I wrote. It's an exe that requires the sdk to run. QueryBuilder4 – Nik Weiss Apr 07 '17 at 11:23
  • @AndyTurner thanks for the tip about the documentation. It was pretty hard to find, and it unfortunately doesn't really say anything. It lists getSessionMgr() as a method, and that it should allow me to create a session to log-in, but it mentions nothing about dependencies, or anything like that. – Nik Weiss Apr 07 '17 at 11:49

1 Answers1

0

The issue was that I was referencing JAR files directly from my Program Files. Copying the files to a local folder in my workspace, and referencing them from there fixed the problem.

Nik Weiss
  • 422
  • 7
  • 18