Utgard OPC connection issues

2,145 views
Skip to first unread message

Christian Babcock

unread,
Jun 19, 2012, 10:21:48 AM6/19/12
to open...@googlegroups.com
I'm having a problem when using Utgard to try to connect to our OPC Server (DriveOPC by ABB).

Using the following code:

package org.openscada.opc.lib;

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.AutoReconnectController;
import org.openscada.opc.lib.da.Server;
import org.openscada.opc.lib.da.SyncAccess;

/**
* Another test showing the "Access" interface with the SyncAccess implementation
* including the AutoReconnectController which should re-establish the connection
* if it breaks.
* @author Jens Reimann
*
*/
public class OPCTest6
{
    public static void main ( final String[] args ) throws Throwable
    {
        // create connection information
        final ConnectionInformation ci = new ConnectionInformation ();
        ci.setHost ( args[0] );
        ci.setDomain ( args[1] );
        ci.setUser ( args[2] );
        ci.setPassword ( args[3] );
        ci.setClsid ( args[4] );

        String itemId = "Saw-toothed Waves.Int2";
        if ( args.length >= 6 )
        {
            itemId = args[5];
        }

        // create a new server
        final Server server = new Server ( ci, Executors.newSingleThreadScheduledExecutor () );
        final AutoReconnectController autoReconnectController = new AutoReconnectController ( server );
        try
        {
            // connect to server
            autoReconnectController.connect ();

            // add sync access

            final AccessBase access = new SyncAccess ( server, 100 );
            access.addItem ( itemId, new DataCallbackDumper () );

            // start reading
            access.bind ();

            // run forever
            final boolean running = true;
            while ( running )
            {
                Thread.sleep ( 10 * 1000 );
            }

            /*
// stop reading
access.unbind ();

// disconnect
autoReconnectController.disconnect ();
*/
        }
        catch ( final JIException e )
        {
            System.out.println ( String.format ( "%08X: %s", e.getErrorCode (), server.getErrorMessage ( e.getErrorCode () ) ) );
        }
    }
}

I have no trouble connecting to the server running on my localhost.

However when I try to run this:

package org.openscada.opc.lib;

import java.net.UnknownHostException;
import java.util.concurrent.Executors;

import org.jinterop.dcom.common.JIException;
import org.openscada.opc.lib.common.ConnectionInformation;
import org.openscada.opc.lib.da.Server;
import org.openscada.opc.lib.da.browser.BaseBrowser;
import org.openscada.opc.lib.da.browser.Branch;
import org.openscada.opc.lib.da.browser.Leaf;
import org.openscada.opc.lib.da.browser.TreeBrowser;

/**
* Another test showing the browser interfaces
* @author Jens Reimann
*
*/
public class OPCTest3
{

    private static void dumpLeaf ( final String prefix, final Leaf leaf )
    {
        System.out.println ( prefix + "Leaf: " + leaf.getName () + " [" + leaf.getItemId () + "]" );
    }

    private static void dumpBranch ( final String prefix, final Branch branch )
    {
        System.out.println ( prefix + "Branch: " + branch.getName () );
    }

    public static void dumpTree ( final Branch branch, final int level )
    {
        final StringBuilder sb = new StringBuilder ();
        for ( int i = 0; i < level; i++ )
        {
            sb.append ( " " );
        }
        final String indent = sb.toString ();

        for ( final Leaf leaf : branch.getLeaves () )
        {
            dumpLeaf ( indent, leaf );
        }
        for ( final Branch subBranch : branch.getBranches () )
        {
            dumpBranch ( indent, subBranch );
            dumpTree ( subBranch, level + 1 );
        }
    }

    public static void main ( final String[] args ) throws Throwable
    {
        // create connection information
        final ConnectionInformation ci = new ConnectionInformation ();
        ci.setHost ( args[0] );
        ci.setDomain ( args[1] );
        ci.setUser ( args[2] );
        ci.setPassword ( args[3] );
        ci.setClsid ( args[4] );

        // create a new server
        final Server server = new Server ( ci, Executors.newSingleThreadScheduledExecutor () );
        try
        {
            // connect to server
            server.connect ();

            // browse flat
            final BaseBrowser flatBrowser = server.getFlatBrowser ();
            if ( flatBrowser != null )
            {
                for ( final String item : server.getFlatBrowser ().browse ( "" ) )
                {
                    System.out.println ( item );
                }
            }

            // browse tree
            final TreeBrowser treeBrowser = server.getTreeBrowser ();
            if ( treeBrowser != null )
            {
                dumpTree ( treeBrowser.browse (), 0 );
            }

            // browse tree manually
            browseTree ( "", treeBrowser, new Branch () );
        }
        catch ( final JIException e )
        {
            e.printStackTrace ();
            System.out.println ( String.format ( "%08X: %s", e.getErrorCode (), server.getErrorMessage ( e.getErrorCode () ) ) );
        }
    }

    private static void browseTree ( final String prefix, final TreeBrowser treeBrowser, final Branch branch ) throws IllegalArgumentException, UnknownHostException, JIException
    {
        treeBrowser.fillLeaves ( branch );
        treeBrowser.fillBranches ( branch );

        for ( final Leaf leaf : branch.getLeaves () )
        {
            dumpLeaf ( "M - " + prefix + " ", leaf );
        }
        for ( final Branch subBranch : branch.getBranches () )
        {
            dumpBranch ( "M - " + prefix + " ", subBranch );
            browseTree ( prefix + " ", treeBrowser, subBranch );
        }
    }
}

I get the following error:

org.jinterop.dcom.common.JIException: Access is denied.  [0x80070005]
80070005: Unknown error (80070005)
    at org.jinterop.dcom.core.JIComServer.init(JIComServer.java:580)
    at org.jinterop.dcom.core.JIComServer.initialise(JIComServer.java:481)
    at org.jinterop.dcom.core.JIComServer.<init>(JIComServer.java:445)
    at org.openscada.opc.lib.da.Server.connect(Server.java:117)
    at UtgardTest.main(UtgardTest.java:94)
Caused by: org.jinterop.dcom.common.JIRuntimeException: Access is denied.  [0x80070005]
    at org.jinterop.dcom.core.JIRemActivation.read(JIRemActivation.java:192)
    at ndr.NdrObject.decode(NdrObject.java:36)
    at rpc.ConnectionOrientedEndpoint.call(ConnectionOrientedEndpoint.java:137)
    at rpc.Stub.call(Stub.java:113)
    at org.jinterop.dcom.core.JIComServer.init(JIComServer.java:568)
    ... 4 more

It seem that using an AutoReconnectController to connect to the server works. When trying to use a Server object though I get an access denied error. Has anyone had similar issues? I've gone through an enabled access to all my COM objects in windows so I'm really at a loss here. Any help would be appreciated. Thanks.

Jens Reimann

unread,
Jun 19, 2012, 10:59:06 AM6/19/12
to open...@googlegroups.com
Maybe you should have a look here ( https://wiki.jenkins-ci.org/display/JENKINS/Windows+slaves+fail+to+start+via+DCOM ). They describe pretty well what has to be done. Also in the case of "Access denied".

Actually what happens (as seens in your stacktrace) is that your OPC Server side Windows rejects the request to create a new COM object. This can have many reasons. You need permissions to create a remote COM object using DCOM with the user you are using.

I hope this helps a little bit.

Justin Smith

unread,
Jul 7, 2012, 7:17:29 PM7/7/12
to open...@googlegroups.com
I see this every time I work at a new installation with OPC (Utgard isnt the culprit).

Every time I have to overcome this, I try Vikram's getting started guide here: http://j-interop.org/quickstart.html
And sometimes have to use the guide he links to at j-integra: http://j-integra.intrinsyc.com/support/com/doc/remoteaccess.html

Either way, it always fixes the problem, barring any super strict IT policies (which is why I hate OPC to begin with...)
Reply all
Reply to author
Forward
0 new messages