Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feature Request]: Apache Nifi 2 support ( Java 21 version ) #1984

Open
1 of 16 tasks
ismaHenzel opened this issue Jan 22, 2025 · 8 comments
Open
1 of 16 tasks

[Feature Request]: Apache Nifi 2 support ( Java 21 version ) #1984

ismaHenzel opened this issue Jan 22, 2025 · 8 comments
Labels
integration-nifi https://plc4x.apache.org/users/integrations/apache-nifi.html java Pull requests that update Java code

Comments

@ismaHenzel
Copy link

What would you like to happen?

Plc4x runs with Java 11, and Apache NiFi versions 1.x also use Java 11. However, after I updated Apache NiFi to the latest version (Version 2), Plc4x stopped working.

The error message is as follows:

GhostProcessor[id=018f1016-372a-13ca-dfb0-0a1b9d02d9d0] Encountering difficulty starting. (Validation State is INVALID: ['Missing Processor' validated against 'Any Property' is invalid because Processor is of type org.apache.plc4x.nifi.Plc4xSourceRecordProcessor, but this is not a valid Processor type]). Will continue trying to start.

Programming Languages

  • plc4j
  • plc4go
  • plc4c
  • plc4net

Protocols

  • AB-Ethernet
  • ADS /AMS
  • BACnet/IP
  • CANopen
  • DeltaV
  • DF1
  • EtherNet/IP
  • Firmata
  • KNXnet/IP
  • Modbus
  • OPC-UA
  • S7
@chrisdutz
Copy link
Contributor

Could it be that the Nifi API changed? The major version change usually indicates that. I would assume you need to update the code of the adapter to the new version and API.

@ismaHenzel
Copy link
Author

ismaHenzel commented Jan 23, 2025

Could it be that the Nifi API changed? The major version change usually indicates that. I would assume you need to update the code of the adapter to the new version and API.

I'm sorry if I gave the impression that I was using PLC4X with custom development. I'm actually using the .nar from https://mvnrepository.com/artifact/org.apache.plc4x/plc4j-nifi-plc4x-nar/0.12.0. I also tested building the .nar 0.13 from the plc4x-extras repository, but the same error occurred.

I ran a clean version of Apache NiFi in Docker with versions 1.28.0, 2.0.0, and 2.1.0 using the following Dockerfile:
`version: "3.8"

services:
nifi:
image: apache/nifi:1.28.0
deploy:
replicas: 1
container_name: nifi
restart: always
ports:
- 8443:8443
environment:
- NIFI_WEB_HTTPS_PORT=8443
- SINGLE_USER_CREDENTIALS_USERNAME=admin
- SINGLE_USER_CREDENTIALS_PASSWORD=adminadminadmin
volumes:
- ./lib:/opt/nifi/nifi-current/extensions
- ./lib_2:/opt/nifi/nifi-current/nar_extensions
`
When running version 1.x, everything works fine, but in version 2.x, the error mentioned below appears.

I checked the logs, and when I click on the processors in the NiFi UI, this error occurs. Additionally, PLC4X is not found among the available processors.

2025-01-22 23:57:43,138 INFO [main] org.apache.nifi.runtime.Application Started Application in 20.611 seconds (20611807389 ns)
nifi  | 2025-01-22 23:57:55,506 WARN [NiFi Web Server-133] org.apache.nifi.web.api.dto.DtoFactory Unable to get extension class for [org.apache.plc4x.
nifi.Plc4xSourceRecordProcessor]
nifi  | java.lang.NoSuchFieldError: Class org.apache.nifi.expression.ExpressionLanguageScope does not have member field 'org.apache.nifi.expression.Ex
pressionLanguageScope VARIABLE_REGISTRY'
nifi  |         at org.apache.plc4x.nifi.BasePlc4xProcessor.(BasePlc4xProcessor.java:105)
nifi  |         at java.base/java.lang.Class.forName0(Native Method)
nifi  |         at java.base/java.lang.Class.forName(Class.java:534)
nifi  |         at java.base/java.lang.Class.forName(Class.java:513)
nifi  |         at org.apache.nifi.nar.StandardExtensionDiscoveringManager.getClass(StandardExtensionDiscoveringManager.java:497)
nifi  |         at org.apache.nifi.web.api.dto.DtoFactory.fromDocumentedTypes(DtoFactory.java:3296)
nifi  |         at org.apache.nifi.web.controller.ControllerFacade.getFlowFileProcessorTypes(ControllerFacade.java:486)
nifi  |         at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:103)
nifi  |         at java.base/java.lang.reflect.Method.invoke(Method.java:580)

Running these tests with a minimal setup, I realized that my first error, "validated against 'Any Property' is invalid because Processor is of type," occurred because the processor was not installed because the error above, and I have many processgroups using PLC4X processors.

@ottlukas ottlukas added java Pull requests that update Java code integration-nifi https://plc4x.apache.org/users/integrations/apache-nifi.html labels Jan 23, 2025
@sruehl
Copy link
Contributor

sruehl commented Jan 23, 2025

there is a related PR to that, might be related apache/plc4x-extras#52

@ismaHenzel
Copy link
Author

there is a related PR to that, might be related apache/plc4x-extras#52

Yes, this is likely the problem. I will keep the production Apache NiFi at version 1.28.1 and hope that version 0.13, when officially released, will support nifi 2.x versions.

I tried to build this PR locally for testing, but I'm encountering compilation errors. As my knowledge of Java is minimal, I can't provide much assistance, but I'm available to help test the new release before its official launch.

Thanks for the responses, everyone !

@chrisdutz
Copy link
Contributor

To me it looks as if one module can only support NiFi 1 or NiFi 2, but not both ... I hope the PR is adding a second module for 2.0 but even if not, it should not be hard to update it to do so.

However I am not sure there's currently anyone working on the PR ... also do I not know if it's finished for testing ...

@ismaHenzel
Copy link
Author

Certainly, I believe it's not that difficult to compile for version 2. I ran a mvn clean package inside the NiFi folder from the branch with the possible fix, but errors occurred during the build. Maybe later I'll try to build it again and take a closer look at what was going wrong. For now, NiFi 1.28.1 is working very well, and the update would be more about exploring the new features and keeping it on the latest version. I'll see if I can generate a .nar for Java 21 that runs on NiFi 2 in the coming days.

@ismaHenzel ismaHenzel reopened this Jan 23, 2025
@chrisdutz
Copy link
Contributor

I did notice a day ago that I needed to build the plc4x-maven-plugin in order to build PLC4X and that I needed to downgrade to Java 21 from 23 to have the build running ... perhals this is also what you need to do?

@ismaHenzel
Copy link
Author

Hello!

I used Java 21 to build the project, but I’m unsure whether I correctly built the plc4x-maven-plugin. I will attempt the build again tomorrow and update this issue with the results.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
integration-nifi https://plc4x.apache.org/users/integrations/apache-nifi.html java Pull requests that update Java code
Projects
None yet
Development

No branches or pull requests

4 participants