Book a Demo

Author Topic: EA API - Does neither work in EA nor in Eclipse  (Read 4822 times)

Viking

  • EA User
  • **
  • Posts: 478
  • Karma: +2/-2
    • View Profile
EA API - Does neither work in EA nor in Eclipse
« on: August 01, 2017, 04:26:57 am »
Hello, I am curious if anybody got the example of EA to work. I often read the same problems as I have, but no solution. I am not allowed to put the SSJavaCOM.dll into a system folder. That's why I am using System.load("C:/Program Files (x86)/Sparx Systems/EA/Java API/SSJavaCOM.dll") instead. I tried this in EA and Eclipse. In EA I got a java.lang.NullPointerException. In Eclipse the system throws "Exception in thread "main" java.lang.Exception: Failed to construct object. Error code: 0x80040154". I tried several alternatives (e.g. setting pathes in environment variables). But nothing works in both environments. I cannot image that the restriction with the directory is the reason. Help and ideas are very welcome. V.
« Last Edit: August 01, 2017, 09:02:38 pm by Viking »

Viking

  • EA User
  • **
  • Posts: 478
  • Karma: +2/-2
    • View Profile
Re: EA API - Does neither work in EA nor in Eclipse
« Reply #1 on: August 01, 2017, 09:09:29 pm »
Does the code only work if the SSJavaCOM.dll file has been copied to C:\Windows\SysWOW64?

I used this:
Code: [Select]
package com.dbis.sparxea.explore;
import org.sparx.*;
import java.util.*;
public class Explore {
    public static void main(String[] args) {
tring connectionString = "EntArchDB_PROD --- DBType=1;Connect=Provider=SQLOLEDB;Integrated Security=SSPI;Persist Security Info=False;Initial Catalog=EntArchDB;Data Source=ldbisprd1,4042;LazyLoad=1;";
System.out.println("Start Connection!");
try {
[i][b]System.load("C:/Program Files (x86)/Sparx Systems/EA/Java API/SSJavaCOM.dll");[/b][/i]
        java.lang.reflect.Field LIBRARIES;
            LIBRARIES = ClassLoader.class.getDeclaredField("loadedLibraryNames");
            LIBRARIES.setAccessible(true);
            System.out.println("Libraries: " + LIBRARIES.get(ClassLoader.getSystemClassLoader()));
    }
    catch (UnsatisfiedLinkError e) {
      System.err.println("Native code library failed to load.\n" + e);
      System.exit(1);
    }
        catch (NoSuchFieldException nsf) {
        System.err.println("Native code library failed to load.\n" + nsf);
        System.exit(1);
            }
        catch (IllegalAccessException iae) {
          System.err.println("Native code library failed to load.\n" + iae);
          System.exit(1);
          }
    Repository rep = new org.sparx.Repository();
System.out.println("Repository" + rep);
rep.OpenFile(connectionString);
// rep.ActivateDiagram(0);
}
}

Any suggestions? V.