Book a Demo

Author Topic: Automation (Java API) - Connecting to EA twice  (Read 4558 times)

romkin

  • EA Novice
  • *
  • Posts: 2
  • Karma: +0/-0
  • I love YaBB 1G - SP1!
    • View Profile
Automation (Java API) - Connecting to EA twice
« on: August 22, 2007, 06:45:06 am »
Hello everybody!

I have this problem...
I'm connecting to EA via Java API.
So I do something like this:

Repository ea = new Repository();
ea.OpenFile("file");
...some processing here...
ea.CloseFile();

It works good.

Then I'm trying to repeat that.
And when I call constructor again I get this exception:

java.lang.Exception: Unknown exception thrown
at org.sparx.Repository.comConstructor(Native Method)
at org.sparx.Repository.<init>(Repository.java:145)
at ...

All manipulations with EA is done in a separate thread.
EA.exe process dies at the end of thread execution.
The second attempt to connect to EA is done in new thread.

What am I doing wrong?
I'm bad at COM and JNI, so I don't fully understand how it all works.

Thanks in advance.

tom_guenter

  • EA Novice
  • *
  • Posts: 11
  • Karma: +0/-0
  • I love YaBB 1G - SP1!
    • View Profile
Re: Automation (Java API) - Connecting to EA twice
« Reply #1 on: June 18, 2008, 06:26:20 pm »
Hi, see the following thread for a possible solution:

http://www.sparxsystems.com/cgi-bin/yabb/YaBB.cgi?num=1206631689/0

Regards,
Tom

Lars H

  • EA User
  • **
  • Posts: 21
  • Karma: +0/-0
    • View Profile
Re: Automation (Java API) - Connecting to EA twice
« Reply #2 on: June 18, 2008, 11:30:19 pm »
Hi,

I had similar problems before, but when I do the following at exit, it works fine:
      repository.CloseFile();
      repository.CloseAddins();
      repository.Exit();

I think the important thing you should add is Exit().

This should be done in a finally block, to make sure it is always done.

If you don't close properly, you will see an EA process left running in the Windows task manager. If you kill that process, you can start a new application.

Hope this helps.
/Lars

Eve

  • EA Administrator
  • EA Guru
  • *****
  • Posts: 8110
  • Karma: +119/-20
    • View Profile
Re: Automation (Java API) - Connecting to EA twice
« Reply #3 on: June 19, 2008, 08:51:30 am »
Another possible solution is that until relatively recently (7.1?) the java API didn't like being called from a different thread within a program that had already used it.

That used to produce a similar error.