5

I have been unable to find a solution that fixes my issue, so I am opening a new topic.

Utgard (http://openscada.org/projects/utgard) seems like a very useful tool to me. In this phase I just want to be able to access the TOP OPC Server locally on a Windows 8 OS via Eclipse. However, when trying to run their tutorial I end up with an "Access is denied". I do not think that I have made any mistakes with username, password and so on.

The Exele OPC DA Test Client does not return any errors. I can connect, retrieve and rewrite values.

Please note that I am a newbie when it comes to OPC and OpenSCADA. Any help will be greatly appreciated.

package org.openscada.opc.tutorial;
import java.util.concurrent.Executors;
import org.jinterop.dcom.common.JIException;
import org.openscada.opc.lib.common.ConnectionInformation;
import org.openscada.opc.lib.da.AccessBase;
import org.openscada.opc.lib.da.DataCallback;
import org.openscada.opc.lib.da.Item;
import org.openscada.opc.lib.da.ItemState;
import org.openscada.opc.lib.da.Server;
import org.openscada.opc.lib.da.SyncAccess;

 public class UtgardTutorial1 {


public static void main(String[] args) throws Exception {
    // create connection information
    final ConnectionInformation ci = new ConnectionInformation();
    //final ConnectionInformation connectionInformation = new ConnectionInformation();
    ci.setHost("127.0.0.1");
    //ci.setDomain("");
    ci.setUser("Me");
    ci.setPassword("Password");
    ci.setProgId("SWToolbox.TOPServer.V5");
    //ci.setClsid("680DFBF7-C92D-484D-84BE-06DC3DECCD68"); // if ProgId is not working, try it using the Clsid instead
    // create an id for the tag you want to retrieve
    final String itemId = "_System._Time_Second";
    // create a new server
    final Server server = new Server(ci, Executors.newSingleThreadScheduledExecutor());
    //final Server serverServer = new Server(connectionInformation, Executor.newSingleThreadSchedulesExecutor);

    try {
        // connect to server
        server.connect();
        // add sync access, poll every 500 ms
        final AccessBase access = new SyncAccess(server, 500);
        access.addItem(itemId, new DataCallback() {
            @Override
            public void changed(Item item, ItemState state) {
                System.out.println(state);
            }
        });
        // start reading
        access.bind();
        // wait a little bit
        Thread.sleep(10 * 1000);
        // stop reading
        access.unbind();
    } catch (final JIException e) {
        System.out.println(String.format("%08X: %s", e.getErrorCode(), server.getErrorMessage(e.getErrorCode())));
    }
}

}

Error stack trace:

INFO  org.openscada.opc.lib.da.Server - Failed to connect to server
org.jinterop.dcom.common.JIException: Access is denied, please check whether the [domain-username-password] are correct. Also, if not already done please check the GETTING STARTED and FAQ sections in readme.htm. They provide information on how to correctly configure the Windows machine for DCOM access, so as to avoid such exceptions.  [0x00000005]
    at org.jinterop.winreg.smb.JIWinRegStub.winreg_OpenKey(Unknown Source) ~[org.openscada.jinterop.core_2.0.8.201303051454.jar:na]
    at org.jinterop.dcom.core.JIProgId.getIdFromWinReg(Unknown Source) ~[org.openscada.jinterop.core_2.0.8.201303051454.jar:na]
    at org.jinterop.dcom.core.JIProgId.getCorrespondingCLSID(Unknown Source) ~[org.openscada.jinterop.core_2.0.8.201303051454.jar:na]
    at org.jinterop.dcom.core.JIComServer.<init>(Unknown Source) ~[org.openscada.jinterop.core_2.0.8.201303051454.jar:na]
    at org.openscada.opc.lib.da.Server.connect(Server.java:123) ~[org.openscada.opc.lib_1.0.0.201303051455.jar:na]
    at org.openscada.opc.tutorial.UtgardTutorial1.main(UtgardTutorial1.java:32) [bin/:na]
Caused by: org.jinterop.dcom.common.JIRuntimeException: Access is denied, please check whether the [domain-username-password] are correct. Also, if not already done please check the GETTING STARTED and FAQ sections in readme.htm. They provide information on how to correctly configure the Windows machine for DCOM access, so as to avoid such exceptions.  [0x00000005]
    at org.jinterop.winreg.IJIWinReg$openKey.read(Unknown Source) ~[org.openscada.jinterop.core_2.0.8.201303051454.jar:na]
    at ndr.NdrObject.decode(Unknown Source) ~[org.openscada.jinterop.deps_1.0.0.201303051454.jar:na]
    at rpc.ConnectionOrientedEndpoint.call(Unknown Source) ~[org.openscada.jinterop.deps_1.0.0.201303051454.jar:na]
    at rpc.Stub.call(Unknown Source) ~[org.openscada.jinterop.deps_1.0.0.201303051454.jar:na]
Cœur
  • 37,241
  • 25
  • 195
  • 267
user2656046
  • 53
  • 1
  • 5
  • have you checked DCOM settings of the OPC Server? – AndersK Aug 06 '13 at 18:50
  • Hi claptrap, thanks for your reply! Yes, I checked DCOM settings more than once guided by a lot of different articles on the Internet. I guess they're not the problem. It's only in my IDE that I get these errors. – user2656046 Aug 07 '13 at 09:57
  • ah ok, good luck finding the problem. – AndersK Aug 07 '13 at 10:20
  • Hi claptrap, It turned out you were right after all. (I posted the DCOM-setting I altered as a comment to Jouni Aro.) Thanks again! – user2656046 Aug 08 '13 at 14:58
  • hey i am also a newbie using utgard. I have a python utility(openOPC) which connects without username and password. but i want to replicate the same in java and i am using utgard, What username and password should i use. I tried using my machine login username and password but i am getting bad username or authentication error – nandini Sep 11 '16 at 14:20

2 Answers2

4

You don't have access to the local Windows Registry, so the client fails to convert the server's ProgID to CLSID. Make sure you run the application with enough privileges in there, i.e. that you are an Administrator user.

Alternatively, you can just configure the connection using the server's CLSID, so you will not need the registry.

An OPC client should actually use the OpcEnum service running on the server computer to do the ProgID to CLSID conversion. Perhaps the service is not available or Utgard only tries the registry (I do not know Utgard myself). If you don't have the server installed on the client machine, the registry-based ProgID to CLSID conversion will fail anyway, since that information is not available in the local Windows Registry. The worst case is that Utgard will try to open the remote Windows Registry, which only rarely succeeds (or you need to ensure that it's enabled separately).

Note that as I do not know Utgard, I am just guessing which strategies it is attempting. Nevertheless, using CLSID only will bypass the whole conversion part, which is your problem.

E: Considering that your other client can connect without a problem, I suspect that Utgard does not try to use OpcEnum at all.

Jouni Aro
  • 2,099
  • 14
  • 30
  • Hi Jouni Aro, thank you for your clear explanation. I will set your answer as accepted answer because I heard this is a common problem indeed and it will help a lot of people. However, I solved the issue by altering once more the DCOM settings as claptrap suggested. This time I set "location" to "Run application from the following computer 'myComputerName'" instead of "Run application from this computer". Not sure why, but it works fine now. – user2656046 Aug 08 '13 at 14:55
  • I'm also using the CLSID as you said! But that in itself didn't make the exception go away. I also had to change the DCOM as explained in my previous comment. – user2656046 Aug 08 '13 at 15:01
  • 1
    Hello, could you please summerize the DCOM configuration you used. – Kumait Dec 18 '14 at 08:21
  • Hey user2656046 can you tell me how you changed the dcom config and where is it and how to use clsid instead – nandini Sep 11 '16 at 14:26
1

I got the same error, and solve the problem by applying the following patch to the registry:

  • HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System
  • create or modify 32-bit DWORD: LocalAccountTokenFilterPolicy
  • set the value to: 1
Xin Wan
  • 21
  • 3