【问题标题】:Utgard - Access denied乌特加德 - 访问被拒绝
【发布时间】:2013-08-07 06:25:20
【问题描述】:

我一直无法找到解决我的问题的解决方案,所以我要打开一个新主题。

Utgard (http://openscada.org/projects/utgard) 对我来说似乎是一个非常有用的工具。在这个阶段,我只想能够通过 Eclipse 在 Windows 8 操作系统上本地访问 TOP OPC 服务器。但是,当尝试运行他们的教程时,我最终会遇到“访问被拒绝”。我不认为我在用户名、密码等方面有任何错误。

Exele OPC DA 测试客户端不返回任何错误。我可以连接、检索和重写值。

请注意,我是 OPC 和 OpenSCADA 的新手。任何帮助将不胜感激。

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())));
    }
}

}

错误堆栈跟踪:

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]

【问题讨论】:

  • 你检查过 OPC Server 的 DCOM 设置了吗?
  • 嗨拍手,感谢您的回复!是的,我根据 Internet 上许多不同的文章多次检查了 DCOM 设置。我想他们不是问题。只有在我的 IDE 中才会出现这些错误。
  • 嗯,好的,祝你好运。
  • 嗨,拍手,事实证明你是对的。 (我将我更改的 DCOM 设置发布为对 Jouni Aro 的评论。)再次感谢!
  • 嘿,我也是使用 utgard 的新手。我有一个无需用户名和密码即可连接的 python 实用程序(openOPC)。但我想在java中复制相同的内容,我正在使用utgard,我应该使用什么用户名和密码。我尝试使用我的机器登录用户名和密码,但我收到错误的用户名或身份验证错误

标签: java opc


【解决方案1】:

您无权访问本地 Windows 注册表,因此客户端无法将服务器的 ProgID 转换为 CLSID。确保您在其中以足够的权限运行应用程序,即您是管理员用户。

或者,您可以只使用服务器的 CLSID 配置连接,因此您不需要注册表。

OPC 客户端实际上应该使用服务器计算机上运行的 OpcEnum 服务来执行 ProgID 到 CLSID 的转换。也许该服务不可用或者 Utgard 只尝试注册(我自己不认识 Utgard)。如果您没有在客户端计算机上安装服务器,则基于注册表的 ProgID 到 CLSID 的转换无论如何都会失败,因为本地 Windows 注册表中没有该信息。最坏的情况是 Utgard 会尝试打开远程 Windows 注册表,但很少会成功(或者您需要确保单独启用它)。

请注意,由于我不了解 Utgard,我只是猜测它正在尝试哪些策略。不过,仅使用 CLSID 会绕过整个转换部分,这是您的问题。

E:考虑到您的其他客户端可以毫无问题地连接,我怀疑 Utgard 根本没有尝试使用 OpcEnum。

【讨论】:

  • 您好 Jouni Aro,感谢您的清晰解释。我会将您的答案设置为已接受的答案,因为我听说这确实是一个常见问题,它会帮助很多人。但是,我按照 claptrap 的建议再次更改了 DCOM 设置,从而解决了这个问题。这次我将“位置”设置为“从以下计算机'myComputerName'运行应用程序”而不是“从这台计算机运行应用程序”。不知道为什么,但它现在工作正常。
  • 我也在用你说的CLSID!但这本身并没有使例外消失。我还必须按照我之前评论中的说明更改 DCOM。
  • 您好,请您总结一下您使用的 DCOM 配置。
  • 嘿,user2656046,你能告诉我你是如何更改 dcom 配置的吗?它在哪里以及如何改用 clsid
【解决方案2】:

我遇到了同样的错误,并通过以下方式解决了问题 将以下补丁应用于注册表:

  • HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System
  • 创建或修改 32 位 DWORD:LocalAccountTokenFilterPolicy
  • 将值设置为:1

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2014-08-10
    • 2017-03-17
    • 2021-03-06
    • 2011-05-15
    • 2010-09-06
    • 2014-03-22
    • 2013-08-10
    • 2018-04-20
    相关资源
    最近更新 更多