Utgard Tutorial

1,323 views
Skip to first unread message

YT Chen

unread,
Feb 12, 2014, 4:47:46 AM2/12/14
to open...@googlegroups.com
Hello, 

I'm having a problem when using Utgard to try to connect to our OPC Server.


And I'm using the following code:

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

I got the following error:

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

How did I solve the Access denied problem?

Jens Reimann

unread,
Feb 12, 2014, 12:21:24 PM2/12/14
to open...@googlegroups.com

Hi,

This has nothing to do with utgard sorry.

You need to configure your Windows machine for remote dcom access.

Jens

--
You received this message because you are subscribed to the Google Groups "openSCADA" group.
To unsubscribe from this group and stop receiving emails from it, send an email to openscada+...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Justin Smith

unread,
Feb 12, 2014, 3:00:02 PM2/12/14
to open...@googlegroups.com
Check the FAQ for JInterop (Utgard uses it under the hood to do DCOM stuff): http://j-interop.org/faq.html

The JInterop quickstart is a good way to actually see if you have DCOM working correct or not: http://j-interop.org/quickstart.html

Also, J-Integra has a good write-up on actually getting DCOM configured properly: http://j-integra.intrinsyc.com/support/com/doc/remoteaccess.html

In my experience, 99% of the issues you will see with using OPC (I have 0 problems with utgard) com from the fact that it sits on top of DCOM, so it is essential to get that working correctly.

--
Justin Smith
Summit Management Systems, Inc
(615) 281-9454
Skype: jwsmith22

People demand freedom of speech as a compensation for the freedom of thought which they seldom use.  ~ Soren Kierkegaard

YT Chen

unread,
Feb 12, 2014, 11:01:13 PM2/12/14
to open...@googlegroups.com
Hi, 

I have set the DCOM before run the Utgard tutorial.

I searched this problem earlier.

But I can't solve this problem.

Have any other advice for it? 

Jens Reimann

unread,
Feb 13, 2014, 1:43:46 AM2/13/14
to open...@googlegroups.com

Which version and edition of Windows are you running?

--

YT Chen

unread,
Feb 13, 2014, 10:38:11 PM2/13/14
to open...@googlegroups.com
I'm running Windows XP Professional Service Pack 3 Edition on my virtual machine.

I'm also tried to run Windows 7 Professional 64-bit Edition.

Both of them have the same problem.

YT Chen

unread,
Feb 14, 2014, 3:57:14 AM2/14/14
to open...@googlegroups.com
I just tried to read the "SWToolbox.TOPServer.V5" item from TOPServer for local access.

The firewall and the anti-virus are disabled.

The DCOM has configured about ANONYMOUS, EVERYONE, SYSTEM, INTERACTIVE, NETWORK...

The
 TOPServer has configured, too.

Some problems about the
ci.setUser and ci.setPassword.

I set them to "", does it has any influence?

Jens Reimann

unread,
Feb 14, 2014, 11:39:19 AM2/14/14
to open...@googlegroups.com

Hi,
yes that is the problem.  You must authenticate with a username and password.

--

Justin Smith

unread,
Feb 14, 2014, 4:07:44 PM2/14/14
to open...@googlegroups.com
Dont forget domain as well, "localhost" if there is none.  This, at least, works for me.

YT Chen

unread,
Feb 17, 2014, 1:34:57 AM2/17/14
to open...@googlegroups.com
Hi,

I can run the UtgardTutorial1 and connect to the OPC server successfully.


I tried to set password for my windows account and use it in UtgardTutorial1.

It seems to work normally.

In UtgardTutorial1, it retrieved the value from "_System._Time_Second".

But the results like this, 

Value: [[org.jinterop.dcom.core.JIUnsignedInteger@912767]].

How to interpret it to seconds?

Sincerely,

thank you for all your assistance.

Jens Reimann

unread,
Feb 17, 2014, 2:05:19 AM2/17/14
to open...@googlegroups.com

Well this is some specific information from your opc server.  You have to look it up in their documentation.

Reply all
Reply to author
Forward
0 new messages