I'm having a problem when using Utgard to try to connect to our OPC Server.
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();
ci.setHost("127.0.0.1");
ci.setDomain("");
ci.setUser("");
ci.setPassword("");
ci.setProgId("SWToolbox.TOPServer.V5");
//ci.setClsid("680DFBF7-C92D-484D-84BE-06DC3DECCD68"); // if ProgId is not working, try it using the Clsid instead
final String itemId = "_System._Time_Second";
// create a new server
final Server server = new Server(ci, Executors.newSingleThreadScheduledExecutor());
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())));
}
}
}
17:43:28.281 [main] INFO org.openscada.opc.lib.da.Server - Failed to connect to server
org.jinterop.dcom.common.JIException: Message not found for errorCode: 0xC0000022
at org.jinterop.winreg.smb.JIWinRegStub.winreg_OpenHKLM(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:31) [bin/:na]
Caused by: jcifs.smb.SmbAuthException: Access is denied.
at jcifs.smb.SmbTransport.checkStatus(Unknown Source) ~[org.openscada.external.jcifs_1.2.25.201303051448.jar:na]
at jcifs.smb.SmbTransport.send(Unknown Source) ~[org.openscada.external.jcifs_1.2.25.201303051448.jar:na]
at jcifs.smb.SmbSession.send(Unknown Source) ~[org.openscada.external.jcifs_1.2.25.201303051448.jar:na]
at jcifs.smb.SmbTree.send(Unknown Source) ~[org.openscada.external.jcifs_1.2.25.201303051448.jar:na]
at jcifs.smb.SmbFile.send(Unknown Source) ~[org.openscada.external.jcifs_1.2.25.201303051448.jar:na]
at jcifs.smb.SmbFile.open0(Unknown Source) ~[org.openscada.external.jcifs_1.2.25.201303051448.jar:na]
at jcifs.smb.SmbFile.open(Unknown Source) ~[org.openscada.external.jcifs_1.2.25.201303051448.jar:na]
at jcifs.smb.SmbFileOutputStream.<init>(Unknown Source) ~[org.openscada.external.jcifs_1.2.25.201303051448.jar:na]
at jcifs.smb.TransactNamedPipeOutputStream.<init>(Unknown Source) ~[org.openscada.external.jcifs_1.2.25.201303051448.jar:na]
at jcifs.smb.SmbNamedPipe.getNamedPipeOutputStream(Unknown Source) ~[org.openscada.external.jcifs_1.2.25.201303051448.jar:na]
at rpc.ncacn_np.RpcTransport.attach(Unknown Source) ~[org.openscada.jinterop.deps_1.0.0.201303051454.jar:na]
at rpc.Stub.attach(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]
... 6 common frames omitted
17:43:28.281 [main] INFO org.openscada.opc.lib.da.Server - Destroying DCOM session...
17:43:28.281 [main] INFO org.openscada.opc.lib.da.Server - Destroying DCOM session... forked
C0000022: Unknown error (C0000022)
17:43:28.281 [OPCSessionDestructor] DEBUG org.openscada.opc.lib.da.Server - Starting destruction of DCOM session
17:43:28.281 [OPCSessionDestructor] INFO org.jinterop.dcom.core.JISession - About to destroy 0 sessesion which are linked to this session: 845697168
17:43:28.281 [OPCSessionDestructor] INFO o.j.dcom.core.JIComOxidRuntime - destroySessionOIDs for session: 845697168
17:43:28.281 [OPCSessionDestructor] INFO org.openscada.opc.lib.da.Server - Destructed DCOM session
17:43:28.281 [OPCSessionDestructor] INFO org.openscada.opc.lib.da.Server - Session destruction took 0 ms