在使用utgard通过opcservice读取plc数据时有些opcservice(kingIoservice) 会出现如下错误:
Caused by: org.jinterop.dcom.common.JIRuntimeException: Access is denied. [0x80070005]
at org.jinterop.dcom.core.JICallBuilder.readResult(JICallBuilder.java:1077)
at org.jinterop.dcom.core.JICallBuilder.read(JICallBuilder.java:957)
at ndr.NdrObject.decode(NdrObject.java:19)
at rpc.ConnectionOrientedEndpoint.call(ConnectionOrientedEndpoint.java:138)
at rpc.Stub.call(Stub.java:112)
at org.jinterop.dcom.core.JIComServer.call(JIComServer.java:870)
... 6 common frames omitted
解决办法如下:
修改utgard的源码 server.java
原本的代码如下
if (this.connectionInformation.getClsid() != null) {
this.session = JISession.createSession(this.connectionInformation.getDomain(), this.connectionInformation.getUser(), this.connectionInformation.getPassword());
this.session.setGlobalSocketTimeout(socketTimeout);
this.comServer = new JIComServer(JIClsid.valueOf(this.connectionInformation.getClsid()), this.connectionInformation.getHost(), this.session);
} else {
if (this.connectionInformation.getProgId() == null) {
throw new IllegalArgumentException("Neither clsid nor progid is valid!");
}
this.session = JISession.createSession(this.connectionInformation.getDomain(), this.connectionInformation.getUser(), this.connectionInformation.getPassword());
this.session.setGlobalSocketTimeout(socketTimeout);
this.comServer = new JIComServer(JIProgId.valueOf(this.connectionInformation.getProgId()), this.connectionInformation.getHost(), this.session);
}
修改是只要加上
this.session.useSessionSecurity(true);
修改的代码如下
if ( this.connectionInformation.getClsid () != null )
{
this.session = JISession.createSession ( this.connectionInformation.getDomain (), this.connectionInformation.getUser (), this.connectionInformation.getPassword () );
this.session.setGlobalSocketTimeout ( socketTimeout );
this.session.useSessionSecurity(true);
this.comServer = new JIComServer ( JIClsid.valueOf ( this.connectionInformation.getClsid () ), this.connectionInformation.getHost (), this.session );
}
else if ( this.connectionInformation.getProgId () != null )
{
this.session = JISession.createSession ( this.connectionInformation.getDomain (), this.connectionInformation.getUser (), this.connectionInformation.getPassword () );
this.session.setGlobalSocketTimeout ( socketTimeout );
this.session.useSessionSecurity(true);
this.comServer = new JIComServer ( JIProgId.valueOf ( this.connectionInformation.getProgId () ), this.connectionInformation.getHost (), this.session );
}