Book a Demo

Author Topic: COM automation "the action cannot be completed"  (Read 6278 times)

Hans Olthof

  • EA User
  • **
  • Posts: 24
  • Karma: +0/-0
    • View Profile
COM automation "the action cannot be completed"
« on: September 14, 2014, 10:22:54 am »
Hi,
I'm getting an error connecting to a local database (.eap) file.
I'm coding on Windows7-32Bit. Most recent version of sparx corporate edition.
Whenever my code attempts to do "OpenFile(<file absolute path>)", I get the following modal box: "The action cannot be completed because the other program is busy"  Choose 'switch to' to activate the busy program and correct the problem" - with switch-to and retry options. Neither option corrects the problem. A background copy of EA has been started, , which I cannot switch to.
I've tried this in Java (and I've confirmed that the DLL and jar files are accessible) and C# - with the same outcome.
Here is my java code:

Code: [Select]
     org.sparx.Repository r = new org.sparx.Repository();      
        boolean result = r.OpenFile(f.getAbsolutePath());
      if (result) {
             ...

I've confirmed that the new repository is acquiring a com connection.
The OpenFile fails, prompting the message.

I'm probably missing something really basic here.
However, I've had java/EA automation working fine on Windows XP.
I've also uninstalled, cleaned the registry and re-installed EA to see if there was a com registration issue.

Any help would be most appreciated.

Hans

EXploringEA

  • EA User
  • **
  • Posts: 172
  • Karma: +8/-0
    • View Profile
Re: COM automation "the action cannot be comp
« Reply #1 on: September 15, 2014, 04:38:02 am »
Hi Hans,

From your comments I understand that your code has started EA in the background OK - but the open file doesn't work; personally I haven't seen this behaviour with EA but would suggest you hardcode the filename to remove any dependencies on any other functions and see if that works.

I have seen this message with other applications, and it has usually been due to:

1. The application presenting a dialog (usually hidden behind another window and hence not visible - but may be accessible by tabbing through the windows) - e.g. asking for a filename as it didn't find the filename I provided or a password - does your eap file have security enabled, if so it will need username/password and this will result in a dialog box if not provided in the call.

2. The application really being tied up with another caller

Also I always find it useful to try one of the examples provided by Sparx (under C:\Program Files (x86)\Sparx Systems\EA\Code Samples\Java_Sample) as these are usually known to work OK.  I did a post on the Java example some time ago which you can find at http://exploringea.com/2013/12/11/ea-automation-with-java/ and may be of help.

Adrian
« Last Edit: September 15, 2014, 06:14:41 am by MrWappy »
EXploringEA - information, utilities and addins

Hans Olthof

  • EA User
  • **
  • Posts: 24
  • Karma: +0/-0
    • View Profile
Re: COM automation "the action cannot be completed
« Reply #2 on: September 15, 2014, 01:05:32 pm »
Hi Adrian,
Thanks for your response. I had actually come across your web post whilst researching this problem.

I've run the sparx example code, with the same result.
I'm now sure (famous last words!) that the code is ok (especially, since I've tried java and C#) and that I have some configuration problem on my machine.

regards,
Hans

qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +396/-301
  • I'm no guru at all
    • View Profile
Re: COM automation "the action cannot be completed
« Reply #3 on: September 15, 2014, 03:36:49 pm »
Out of curiosity I tried to run Sparx' provided Java code but got
Quote
Error: Could not find or load main class org.sparx.javaexample.Main
What voodoo is missing here?

q.

EXploringEA

  • EA User
  • **
  • Posts: 172
  • Karma: +8/-0
    • View Profile
Re: COM automation "the action cannot be comp
« Reply #4 on: September 15, 2014, 05:21:38 pm »
@hans

Seems strange - my next suggestion would be to remove as much as possible from your coding environment, so use some simple VBA in Excel, such as the function below (could be a sub) but just getting some information back from the model is always confidence building, to just open the file and close EA.

When you add a cell with  =openEA("Filename") it will call the function and return a value (after a time lag with EA doing its startup work).  You can track progress in the VBA debugger.


Code: [Select]
Function openEA(Filename As String)
  Set m_Repository = CreateObject("EA.Repository")
   m_Repository.OpenFile (Filename)
   openEA = m_Repository.Models.Count
  m_Repository.Exit
End Function

If that does the same email to Sparx support.

Sorry not more helpful.

@qwerty

Sorry if I gave the wrong impression and set the wrong expectations about Sparx's code.

Although the java code works fine, the batch files provided didn't work out of the box.   I think I mentioned in the post I had some minor environmental issues, and from memory it was associated with paths that need sorting - not uncommon with Java I've found.






« Last Edit: September 15, 2014, 05:23:18 pm by MrWappy »
EXploringEA - information, utilities and addins

Hans Olthof

  • EA User
  • **
  • Posts: 24
  • Karma: +0/-0
    • View Profile
Re: COM automation "the action cannot be completed
« Reply #5 on: September 15, 2014, 05:29:21 pm »
Hi,
I've gotten the C# code working. I went through and made sure that I had no interop.EA files lying around and selected the Interop.EA via C# project browser to the sparx installation directory - as opposed to the COM Type Libraries. (Enterprise Architect library).

I tried the same approach with the java code - to no avail.
I did have Oracle Single-Sign-On (SSO) on the machine and in desperation killed that - still no change. I even went back to some old copies of sparx and got that DLL.

I'm interested to know if *anyone* has the java automation going.

Right now, I'm going ahead with C# - if I squint it looks the same as java anyway.

regards, and thanks for the help so far.
Hans

EXploringEA

  • EA User
  • **
  • Posts: 172
  • Karma: +8/-0
    • View Profile
Re: COM automation "the action cannot be completed
« Reply #6 on: September 15, 2014, 06:11:46 pm »
Hi Hans

Yes I got it working - but a bit frustrating but then I hadn't been coding Java for over a decade so a bit rusty.

The issues I had with Java related to paths and having files in the correct place.  You may have already checked but just in case the Sparx readme.txt file in "C:\Program Files (x86)\Sparx Systems\EA\Java API" specifies 2 files that need to be placed.

Adrian
EXploringEA - information, utilities and addins

Hans Olthof

  • EA User
  • **
  • Posts: 24
  • Karma: +0/-0
    • View Profile
Re: COM automation "the action cannot be completed
« Reply #7 on: September 15, 2014, 06:18:15 pm »
Hi Adrian,
Thanks for that. Yes, I've just checked the access path of the two files (DLL and jar) they are accessible to the code.
*Something* is working, since in the eclipse debugger, I do see a COM object on the stack (or is it heap?), and an ea is fired up.
It it just at that point of opening the file that it does the finger-in-ear-routine.

In the meantime, I'm porting my reams of XML processing to C# (sigh!).

Hans