Author Topic: Access EA from Outside: SSJavaCOM  (Read 3930 times)

Viking

  • EA User
  • **
  • Posts: 247
  • Karma: +1/-2
    • View Profile
Access EA from Outside: SSJavaCOM
« on: July 20, 2017, 11:01:08 pm »
Hi,
I want to access EA from Eclipse using java. I turned into 32 bit.

I am using following code:

package com.sparxea.explore;
import org.sparx.Repository;
public class Explore {
   public static void main(String[] args) {
      String db = "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!");
      System.loadLibrary("SSJavaCOM");
      Repository rep = new Repository();
      rep.OpenFile(db);
   }
}

I am not allowed to put the SSJavaCOM.dll into the system-folder. So I used an Environment variable: %ProgramFiles(x86)%\Sparx Systems\EA\Java API

I get following Exception from "new Repository()", because the dll cannot be found:

java.lang.Exception: Failed to construct object. Error code: 0x80040154
   at org.sparx.Repository.comConstructor(Native Method)
   at org.sparx.Repository.<init>(Repository.java:190)

Any ideas? Is the reason the environment variable? Is there an alternative?

Many thanks in advance, V.
« Last Edit: July 20, 2017, 11:04:05 pm by Viking »

OpenIT Solutions

  • EA User
  • **
  • Posts: 464
  • Karma: +4/-0
    • View Profile
Re: Access EA from Outside: SSJavaCOM
« Reply #1 on: July 20, 2017, 11:38:40 pm »
Hi,

The dll needs to be on your PATH AND the eaapi.jar needs to be on your Java classpath. It looks like a config issue so check both are OK.

Regards,

Jon.

Helmut Ortmann

  • EA User
  • **
  • Posts: 915
  • Karma: +39/-1
    • View Profile
Re: Access EA from Outside: SSJavaCOM
« Reply #2 on: July 25, 2017, 03:48:28 pm »
Hi,

since release 13 EA supports so called Hypbrid Scripting (see: http://www.sparxsystems.com/resources/user-guides/automation/hybrid-scripting.pdf).

The benefit is: You can generate, build, deploy and run by EA your little Java Program which can access a Repository. Maybe it's of use.

Regards,

Helmut
Coaching, Training, Workshop (Addins: hoTools, Search&Replace, LineStyle)

Viking

  • EA User
  • **
  • Posts: 247
  • Karma: +1/-2
    • View Profile
Re: Access EA from Outside: SSJavaCOM
« Reply #3 on: July 25, 2017, 04:04:27 pm »
Hi,
The dll needs to be on your PATH AND the eaapi.jar needs to be on your Java classpath. It looks like a config issue so check both are OK.
Regards,
Jon.
I imported the eaapi.jar into eclipse. I think it is the link to the dll. Path in windows or in eclipse? I have to check this.
« Last Edit: July 25, 2017, 04:16:36 pm by Viking »

Viking

  • EA User
  • **
  • Posts: 247
  • Karma: +1/-2
    • View Profile
Re: Access EA from Outside: SSJavaCOM
« Reply #4 on: July 25, 2017, 04:07:16 pm »
Hi,
since release 13 EA supports so called Hypbrid Scripting (see: http://www.sparxsystems.com/resources/user-guides/automation/hybrid-scripting.pdf).
The benefit is: You can generate, build, deploy and run by EA your little Java Program which can access a Repository. Maybe it's of use.
Regards, Helmut
Thank you very much for the hint. I did not know.

Viking

  • EA User
  • **
  • Posts: 247
  • Karma: +1/-2
    • View Profile
Re: Access EA from Outside: SSJavaCOM
« Reply #5 on: August 02, 2017, 03:46:21 am »
Hi,
The dll needs to be on your PATH AND the eaapi.jar needs to be on your Java classpath. It looks like a config issue so check both are OK.
Regards,
Jon.
The dll is linked via the PATH and the eeapi.jar is imported and linked in Eclipse. Did yoo get the examples to run?

Viking

  • EA User
  • **
  • Posts: 247
  • Karma: +1/-2
    • View Profile
Re: Access EA from Outside: SSJavaCOM
« Reply #6 on: August 15, 2017, 03:15:26 am »
I am still getting the 0x80040154 exception.

The environment is a follows:
- The code gets started inside Eclipse
- Eclipse is run with Java 64 bit.
- Eclipse runs Java code with 32 bit (it says "<terminated> Explore [Java Application] c:\Program Files (x86)\Java\jdk1.8.0_112\bin.javaw.exe).
- I set the classpath via project > Properties > libaries > Add External JARs
- I set the dll path via adding it to "Native Library Location" of the classpath-enty.
- I left eaapi.jar and SSJavaCOM.dll in the sparx JAVA API directory.

The exceptions comes as soon as I call "new Repository".

Is the reason because the libraries are not located in windows\system32 ?

Many thanks in advance, V.


Viking

  • EA User
  • **
  • Posts: 247
  • Karma: +1/-2
    • View Profile
Re: Access EA from Outside: SSJavaCOM
« Reply #7 on: August 15, 2017, 07:39:08 pm »
If I understand 0x80040154 correctly SSJavaCOM.dll cannot link other required dlls. Which are these libraries and where are they? As a precaution I set the PATH to C:\Windows\System32 (because this path was mentioned in the readme), but it did not help.

Viking

  • EA User
  • **
  • Posts: 247
  • Karma: +1/-2
    • View Profile
Re: Access EA from Outside: SSJavaCOM
« Reply #8 on: August 16, 2017, 01:49:55 am »
I think we checked all alternatives now. We also checked it from DOS-box with JDK 32-bit. We always get the same error message.

It would have been nice to get feedback from Sparx in this forum. The forum is hosted by Sparx and it should be in the interest of this company to support its customers. Otherwise the EAAPI-"offer" should be shaped to what it is able to do. O.K., maybe the reason is that the library must be located in C:\Windows\System32. But that would contradict the readme.
« Last Edit: August 16, 2017, 01:54:50 am by Viking »

KP

  • EA Administrator
  • EA Expert
  • *****
  • Posts: 2495
  • Karma: +32/-2
    • View Profile
Re: Access EA from Outside: SSJavaCOM
« Reply #9 on: August 16, 2017, 09:20:42 am »
It would have been nice to get feedback from Sparx in this forum.

If you aren't getting the answers you need from this user forum, you can contact Sparx Support. Use the "Report a Bug" link at the bottom of this page.
The Sparx Team
support@sparxsystems.com

Aaron B

  • EA Administrator
  • EA User
  • *****
  • Posts: 892
  • Karma: +13/-0
    • View Profile
Re: Access EA from Outside: SSJavaCOM
« Reply #10 on: August 18, 2017, 11:41:37 am »
Under 64-bit operating systems, the SSJavaCOM.dll file will need to be copied into C:\Windows\SysWOW64.

In a bit of confusing Microsoft logic under 64-bit versions of Windows, the "System32" directory is for 64-bit applications, and "SysWOW64" is for 32-bit applications.

Viking

  • EA User
  • **
  • Posts: 247
  • Karma: +1/-2
    • View Profile
Re: Access EA from Outside: SSJavaCOM
« Reply #11 on: August 22, 2017, 12:47:32 am »
Under 64-bit operating systems, the SSJavaCOM.dll file will need to be copied into C:\Windows\SysWOW64.

In a bit of confusing Microsoft logic under 64-bit versions of Windows, the "System32" directory is for 64-bit applications, and "SysWOW64" is for 32-bit applications.

Thank you, Aaron. I think this is the answer. To set a PATH was the wrong way. Because I am running a 64-bit OS, the dll would be exceuted as 64 bit. That's why it HAS TO be put in SysWOW64 to be executed as 32-bit.

Carl P.

  • EA Novice
  • *
  • Posts: 6
  • Karma: +0/-0
    • View Profile
Re: Access EA from Outside: SSJavaCOM
« Reply #12 on: June 14, 2018, 05:57:51 am »
Under 64-bit operating systems, the SSJavaCOM.dll file will need to be copied into C:\Windows\SysWOW64.

In a bit of confusing Microsoft logic under 64-bit versions of Windows, the "System32" directory is for 64-bit applications, and "SysWOW64" is for 32-bit applications.

Thank you, Aaron. I think this is the answer. To set a PATH was the wrong way. Because I am running a 64-bit OS, the dll would be exceuted as 64 bit. That's why it HAS TO be put in SysWOW64 to be executed as 32-bit.

Thanks Aaron. I was trying to run the Java_Sample and I had the same problem. Please let the documentation team update it to indicate the difference between 32-bit and 64-bit Windows (http://www.sparxsystems.com/enterprise_architect_user_guide/14.0/automation/automation_connect_setup.html). I lost a few hours looking for the solution before I found your answer :). Thanks again.
Carl,