hashmapinc / nifi-opcua-bundle

Apache License 2.0
31 stars 11 forks source link

Compilation Failure: byte[] cannot be converted to ByteString #46

Closed LibertyWalk closed 4 years ago

LibertyWalk commented 6 years ago

I tried to "mvn clean install" this project to get the necessary files for integration in NIFI. However, I'm getting the following error message: C:\Users\libertywalk\Downloads\nifi-opcua-bundle_hasmap\nifi-opcua-bundle\nifi-opcua-service\src\main\java\com\hashmapinc\tempus\processors\StandardOPCUAService.java:[320,73] error: incompatible types: byte[] cannot be converted to ByteString

I'm not quite sure why this occurs. Here's my environment;

mvn -version output: Maven home: C:\Users\krennd\apache-maven-3.5.2-bin\apache-maven-3.5.2\bin.. Java version: 1.8.0_162, vendor: Oracle Corporation Java home: C:\Program Files (x86)\Java\jdk1.8.0_162\jre Default locale: de_DE, platform encoding: Cp1252 OS name: "windows 10", version: "10.0", arch: "x86", family: "windows" OPC Foundation Stack Version: 1.03.342.1-SNAPSHOT nifi-opcua-bundle branch: master

AndrewMcCutcheon commented 6 years ago

Hello

I have had the issue also, and do want a correct fix, but I have found a temporary workaround.

On checking the code, Line 320 is only used, if providing a certificate for the system (not generating one).

If you insert a comment "//"to line 320, the project will build and you can at least start to check your workflows.

// endpointDescription.setServerCertificate(myOwnCert.getEncoded());

I hope this helps

cherrera2001 commented 6 years ago

Hey Andrew, You are correct. We will be submitting a fix for this ASAP.

AndrewMcCutcheon commented 6 years ago

Hi Guys

I have added the service, but when I enable it, I get the following message:

StandardOPCUAService[id=e2d91445-0161-1000-0000-00001711dd07] Failed to invoke @OnEnabled method due to java.lang.ArrayIndexOutOfBoundsException: 0: 0

Any ideas?

cherrera2001 commented 6 years ago

@AndrewMcCutcheon I will pull and build now...I will let you know.

cherrera2001 commented 6 years ago

@AndrewMcCutcheon I found the issue and submitted a fix, would you mind pulling the branch noted in opcnifi-46 - Update code for latest UA Stack #47. Don't forget to build 1.03.342.1 of the UA stack and copy the jar into the deploy-local module.

If it works I will merge to master.

@LibertyWalk this should work for you as well.

Thanks!!

AndrewMcCutcheon commented 6 years ago

Hi Chris

Thanks for the quick response, but not good news I am afraid...

I have pulled the branch, and added the jar file, then when building the package using mvn clean install, I get the following error in compilation:

[INFO] ------------------------------------------------------------- [ERROR] COMPILATION ERROR : [INFO] ------------------------------------------------------------- [ERROR] /root/opctmp/nifi-opcua-bundle/nifi-opcua-bundle/nifi-opcua-service/src/test/java/com/hashmapinc/tempus/processors/nifi_opcua_services/TestStandardOPCUAService.java:[45,21] error: constructor TestServer in class TestServer cannot be applied to given types; [INFO] 1 error [INFO] ------------------------------------------------------------- [INFO] ------------------------------------------------------------------------ [INFO] Reactor Summary: [INFO] [INFO] nifi-opcua ......................................... SUCCESS [ 6.641 s] [INFO] opc-deploy-local ................................... SUCCESS [ 4.698 s] [INFO] nifi-opcua-bundle .................................. SUCCESS [ 0.147 s] [INFO] nifi-opcua-service-api ............................. SUCCESS [ 3.275 s] [INFO] nifi-opcua-service ................................. FAILURE [ 11.645 s] [INFO] nifi-opcua-bundle-processors ....................... SKIPPED [INFO] nifi-opcua-bundle-nar .............................. SKIPPED [INFO] ------------------------------------------------------------------------ [INFO] BUILD FAILURE [INFO] ------------------------------------------------------------------------ [INFO] Total time: 35.293 s [INFO] Finished at: 2018-03-02T06:53:28Z [INFO] Final Memory: 29M/70M [INFO] ------------------------------------------------------------------------ [ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.2:testCompile (default-testCompile) on project nifi-opcua-service: Compilation failure [ERROR] /root/opctmp/nifi-opcua-bundle/nifi-opcua-bundle/nifi-opcua-service/src/test/java/com/hashmapinc/tempus/processors/nifi_opcua_services/TestStandardOPCUAService.java:[45,21] error: constructor TestServer in class TestServer cannot be applied to given types; [ERROR]

cherrera2001 commented 6 years ago

Thats odd, can you ensure that line 45 on TestStandardOPCUAService.java has the following method signature:

server = new TestServer(45678, "user", "test");

The error that you are seeing is that some how your local repo did not get updated with the new test class...

AndrewMcCutcheon commented 6 years ago

Hi Chris

I have checked the file and it does indeed have that line., here are lines 44,45,46

    try {
        server = new TestServer(45678, "user", "test");
    } catch (Exception e) {

For reference, in order to avoid tainting the build I had already done, I created a new clone direc of nifiopc-46 in to a temporary folder

Regards

Andy

AndrewMcCutcheon commented 6 years ago

Hi Chris

Some breaking news...

I wnet back to the original master branch (where i had modified the pom.xml to the correct version of OPC UA Stack), and modified the StandardOPCUAService.java file changing line 320 from

endpointDescription.setServerCertificate(myOwnCert.getEncoded()); to endpointDescription.setServerCertificate(ByteString.valueOf(myOwnCert.getEncoded()));

I left the TestService unaltered, and did a mvn clean install

The NAR built, and I have imported it to my sanbox, and able to use GetNodeID (restricted to no security and no username /password).

I will do further checking on Monday and feed back the results of accessing this in sandbox, and also in PoC environments

Kind Regards

Karthikeyyan commented 5 years ago

@AndrewMcCutcheon - I am facing a similar error - java.lang.ArrayIndexOutOfBoundsException: 0 Built opc-ua-stack-1.3.343.jar and nifi-opcua-bundle-nar-0.0.1-SNAPSHOT.nar file successfully. But there is some bug I believe, that gives me the error. Is there any temporary workaround?

cherrera2001 commented 5 years ago

Hi All,

Sorry I have been AWOL for some time. Could you please give me an idea of what OPC server you are trying to connect to and I will come out with some workaround. Also, the OPC foundation did deprecate the Java SDK so I will need to plan on porting the controller service over to eclipse milo for future support.

On Apr 1, 2019, at 11:35 AM, Karthikeyyan notifications@github.com wrote:

@AndrewMcCutcheon https://github.com/AndrewMcCutcheon - I am facing a similar error - java.lang.ArrayIndexOutOfBoundsException: 0 Built opc-ua-stack-1.3.343.jar and nifi-opcua-bundle-nar-0.0.1-SNAPSHOT.nar file successfully. But there is some bug I believe, that gives me the error. Is there any temporary workaround?

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/hashmapinc/nifi-opcua-bundle/issues/46#issuecomment-478652234, or mute the thread https://github.com/notifications/unsubscribe-auth/AFphD9_MNZNU78ndzzCPM6HzsEfFmSYlks5vcjU4gaJpZM4SGfrn.

Karthikeyyan commented 5 years ago

@cherrera2001 - Thanks for your response. I am working on a B&R PLC which has its own OPC-UA server with Basic256 security policy, no username and password.

My Environment details - Apache Maven 3.6.0 (97c98ec64a1fdfee7767ce5ffb20918da4f719f3; 2018-10-24T14:41:47-04:00) Maven home: C:\Program Files\Apache Software Foundation\apache-maven-3.6.0\bin.. Java version: 1.8.0_191, vendor: Oracle Corporation, runtime: C:\Program Files\Java\jdk1.8.0_191\jre Default locale: en_US, platform encoding: Cp1252 OS name: "windows 10", version: "10.0", arch: "amd64", family: "windows"

java version "1.8.0_201" Java(TM) SE Runtime Environment (build 1.8.0_201-b09) Java HotSpot(TM) 64-Bit Server VM (build 25.201-b09, mixed mode)

Built Java Stack - opc-ua-stack-1.3.343.jar

Error while running TestStandardOPCUAService.java file-

SLF4J: Class path contains multiple SLF4J bindings. SLF4J: Found binding in [jar:file:/C:/Users/SUBBIK/.m2/repository/org/slf4j/slf4j-simple/1.7.12/slf4j-simple-1.7.12.jar!/org/slf4j/impl/StaticLoggerBinder.class] SLF4J: Found binding in [jar:file:/C:/Users/SUBBIK/.m2/repository/com/hashmapinc/tempus/embedded-opcua-server/0.0.2-SNAPSHOT/embedded-opcua-server-0.0.2-SNAPSHOT.jar!/org/slf4j/impl/StaticLoggerBinder.class] SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an explanation. SLF4J: Actual binding is of type [org.slf4j.impl.SimpleLoggerFactory] [main] INFO com.hashmapinc.tempus.processors.StandardOPCUAService - StandardOPCUAService[id=hi1] Creating variables [main] INFO org.opcfoundation.ua.utils.CryptoUtil - SecurityProvider initialized from org.bouncycastle.jce.provider.BouncyCastleProvider [main] INFO org.opcfoundation.ua.utils.CryptoUtil - Using SecurityProvider BC [main] ERROR com.hashmapinc.tempus.processors.Utils - KeySize must be 1024, 2048, 3072 or 4096 [main] INFO com.hashmapinc.tempus.processors.StandardOPCUAService - StandardOPCUAService[id=hi1] Creating Client [main] INFO com.hashmapinc.tempus.processors.StandardOPCUAService - StandardOPCUAService[id=hi1] Discovering endpoints fromopc.tcp://10.21.143.111:4840 [main] INFO org.opcfoundation.ua.transport.tcp.io.TcpConnection - /10.21.143.111:4840 Connecting [main] INFO org.opcfoundation.ua.transport.tcp.io.TcpConnection - /10.21.143.111:4840 Connected [main] INFO org.opcfoundation.ua.transport.tcp.io.SecureChannelTcp - 1785833406 Closed [main] INFO org.opcfoundation.ua.transport.tcp.io.TcpConnection - /10.21.143.111:4840 Closed [TcpConnection/Read] INFO org.opcfoundation.ua.transport.tcp.io.TcpConnection - /10.21.143.111:4840 Closed (expected) java.lang.ArrayIndexOutOfBoundsException: 0 at com.hashmapinc.tempus.processors.StandardOPCUAService.onEnabled(StandardOPCUAService.java:387) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at org.apache.nifi.util.ReflectionUtils.invokeMethodsWithAnnotation(ReflectionUtils.java:68) at org.apache.nifi.util.StandardProcessorTestRunner.enableControllerService(StandardProcessorTestRunner.java:683) at com.hashmapinc.tempus.processors.nifi_opcua_services.TestStandardOPCUAService.testGetNodeListInsecure(TestStandardOPCUAService.java:65) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50) at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12) at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47) at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17) at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325) at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78) at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57) at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290) at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71) at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288) at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58) at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268) at org.junit.runners.ParentRunner.run(ParentRunner.java:363) at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:89) at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:41) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:541) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:763) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:463) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:209)

Line 387 - endpointDescription = EndpointUtil.selectByUrl(endpointDescriptions, context.getProperty(ENDPOINT).getValue())[0];

Any help would be appreciated!