hashmapinc / nifi-opcua-bundle

Apache License 2.0
31 stars 11 forks source link

Failed to invoke @OnEnabled method due to java.lang.ArrayIndexOutOfBoundsException: 0: {} #61

Open huwdjones opened 6 years ago

huwdjones commented 6 years ago

Hi there,

I followed the set up in the README however the StandardOPCUAService Service Controller seems to be stuck in a constant state of Enabling.

2018-09-28 15:19:03,020 ERROR [Timer-Driven Process Thread-5] o.a.n.c.s.StandardControllerServiceNode StandardOPCUAService[id=20a35742-0166-1000-7d4a-d276e0e14317] Failed to invoke @OnEnabled method due to java.lang.ArrayIndexOutOfBoundsException: 0: {}
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.invokeMethodsWithAnnotations(ReflectionUtils.java:142)
    at org.apache.nifi.util.ReflectionUtils.invokeMethodsWithAnnotations(ReflectionUtils.java:130)
    at org.apache.nifi.util.ReflectionUtils.invokeMethodsWithAnnotations(ReflectionUtils.java:75)
    at org.apache.nifi.util.ReflectionUtils.invokeMethodsWithAnnotation(ReflectionUtils.java:52)
    at org.apache.nifi.controller.service.StandardControllerServiceNode$2.run(StandardControllerServiceNode.java:433)
    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
    at java.util.concurrent.FutureTask.run(FutureTask.java:266)
    at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$201(ScheduledThreadPoolExecutor.java:180)
    at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:293)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
    at java.lang.Thread.run(Thread.java:748)

I don't know whether or not this is related but the GetOPCNodeList property "Starting Nodes" mentioned in the documentation appears to have been replaced with the property "Node Filter". I placed the same string I would have used in the "Starting Nodes" field in the "Node Filter" property. I'm not sure whether or not this is correct - the documentation does not mention this field.

I've also tried various combinations of versions of OPC Foundation project and this bundle but had issues with dependencies.

Any ideas?

Many thanks.

cherrera2001 commented 6 years ago

Hi @huwdjones I am going to have a look at this now....

huwdjones commented 6 years ago

Hi @cherrera2001 thank you. Please let me know if there is anything further I can provide or help in testing.

Chouvic commented 5 years ago

Hey everyone, just to mention that I also tried this set up and hit upon the same problem yesterday. Any ideas what the issue is and if there is a fix for it? Thanks.

randypitcherii commented 5 years ago

Hey, team. I'm trying to reproduce the issue locally and I'm having trouble even building.

Are you able to build the UA-Java dependency locally? https://github.com/OPCFoundation/UA-Java

I'm getting local errors on multiple versions of Java 6 and Java 8 (using both openJDK and oracle) when building on the 549bb94 commit.

If you're able to build, can you please confirm what commit you're working from on the UA-Java repo and which version of java you're using?

randypitcherii commented 5 years ago
[ERROR] /projects/UA-Java/src/main/java/org/opcfoundation/ua/utils/SunJceUtils.java:[39,16] cannot find symbol
[ERROR]   symbol:   class BASE64Decoder
[ERROR]   location: package sun.misc

I'm getting many errors similar to the one above. Maybe there's something I can add to the pom.xml to address this?

This may be related to the issues you're having.

huwdjones commented 5 years ago

Hi @randypitcherii I managed to build from the 549bb94 commit. I started with Ubuntu 16.04.5 LTS and installed the default mvn package from aptitude. Inspecting the java version shows:

$ java -version
java version "1.8.0_181"
Java(TM) SE Runtime Environment (build 1.8.0_181-b13)
Java HotSpot(TM) 64-Bit Server VM (build 25.181-b13, mixed mode)

The only changes I had to account for were to have enough memory for compilation and also the 549bb94 commit for UA-Java now builds opc-ua-stack-1.3.343.jar rather than the SNAPSHOT jar suggested by the README instructions.

vantaka2 commented 5 years ago

@huwdjones ; I'm not a Java developer, might be a simple question.

How did you account for the fact that its building the opc-ua-stack-1.3.343.jar instead of the snapshot jar?

I was following the readme instructions the 'Execute a maven clean install';

I'm getting the following errors, and it seems like its because it built opc-ua-stack-1.3.343.jar instead of the SNAPSHOT jar.

'Could not resolve dependencies for project com.hashmapinc.tempus.processors:nifi-opcua-bundle:pom:0.0.1-SNAPSHOT: Failure to find org.opcfoundation.ua:opc-ua-stack:jar:1.3.343 in https://oss.sonatype.org/content/repositories/snapshots/ was cached in the local repository, resolution will not be reattempted until the update interval of oss-sonatype has elapsed or updates are forced"

huwdjones commented 5 years ago

@vantaka2 I don't remember exactly now but I think I tried everything from checking out an older version to get the SNAPSHOT, to updating the pom file and editting the name to simply renaming the file to SNAPSHOT. No of these are ideal but it points to potentially further incompatibilities which perhaps is why I cannot get this processor to work...

MLIIOTBuild commented 5 years ago

c.h.t.processors.StandardOPCUAService StandardOPCUAService[id=4c60a102-0168-1000-1089-cb0ca8640416] No security mode specified 2019-01-15 15:02:53,630 ERROR [Timer-Driven Process Thread-1] o.a.n.c.s.StandardControllerServiceNode StandardOPCUAService[id=4c60a102-0168-1000-1089-cb0ca8640416] Failed to invoke @OnEnabled method due to java.lang.ArrayIndexOutOfBoundsException: 0: {} 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.invokeMethodsWithAnnotations(ReflectionUtils.java:142) at org.apache.nifi.util.ReflectionUtils.invokeMethodsWithAnnotations(ReflectionUtils.java:130) at org.apache.nifi.util.ReflectionUtils.invokeMethodsWithAnnotations(ReflectionUtils.java:75) at org.apache.nifi.util.ReflectionUtils.invokeMethodsWithAnnotation(ReflectionUtils.java:52) at org.apache.nifi.controller.service.StandardControllerServiceNode$2.run(StandardControllerServiceNode.java:433) at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) at java.util.concurrent.FutureTask.run(FutureTask.java:266) at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$201(ScheduledThreadPoolExecutor.java:180) at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:293) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) at java.lang.Thread.run(Thread.java:748)

@cherrera2001 I am also facing same issue any solution for this I was trying to connect the remote server, but it works fine if I have OPC server and NiFi in same machine.

huwdjones commented 5 years ago

@MLIIOTBuild interestingly I too was trying to connect NiFi to a remote OPC server.

Karthikeyyan commented 5 years ago

@cherrera2001 - I am facing the very same issue. Any updates on this post?

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) with 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"

Screenshot (25) I have not tried server and NiFi on same machine, I will try that give my feedback. Thanks!

paskl91 commented 4 years ago

Hi, We also encountered the same issue, does anyone have a solution for this? Thx

nlesueur31 commented 4 years ago

Hi, I met the same issue with an OPC-UA server simulator (let's call it A) when there is no issue with another one (let's call it B), both on the same machine as NiFi. After some code analysis here is my understanding:

It appears that:

I hope this helps.

cs111 commented 3 years ago

i am facing same issue. @cherrera2001 please help. image

image image

waiting for your ,, please solve this issue

sounavo commented 2 years ago

Anyone has solved this issue? Encountering the same Failed to invoke @OnEnabled method due to java.lang.ArrayIndexOutOfBoundsException: Index 0 out of bounds for length 0: Index 0 out of bounds for length 0

carlosfrutos commented 9 months ago

I also had this problem, and I found the reason.

I'll try to create a PR with the solution. The problem is that the URL from the OPC server MUST match exactly with the property "endpoint URL". Otherwise, it won't match and return 0 elements, hence the ArrayIndexOutOfBounds. In my case, the server was adding a "/OCT" suffix.

The solution I made tries to match the URL with "startsWith" rather than a exact match.