Support Questions

Find answers, ask questions, and share your expertise

Getting java warning after staring NiFi

avatar
Explorer

Hello,

Recently I setup NiFi 2.0.
Everytime I start NiFi, I get below warning messages in /var/log/messages.

 

Dec 13 12:07:58 myserver nifi.sh[208489]: WARNING: A restricted method in java.lang.foreign.Linker has been called
Dec 13 12:07:58 myserver nifi.sh[208489]: WARNING: java.lang.foreign.Linker::downcallHandle has been called by org.apache.lucene.store.PosixNativeAccess in an unnamed module
Dec 13 12:07:58 myserver nifi.sh[208489]: WARNING: Use --enable-native-access=ALL-UNNAMED to avoid a warning for callers in this module
Dec 13 12:07:58 myserver nifi.sh[208489]: WARNING: Restricted methods will be blocked in a future release unless native access is enabled

 

Is there any way to supress these messages?

Here are product versions.

Red Hat Enterprise Linux 8.8
NiFi 2.0.0
Java OpenJDK 23.0.1.0.11

Regards,

1 ACCEPTED SOLUTION

avatar
Master Mentor

@tono425 
The error messages you are encountering in NiFi are related to Java's native method access restrictions introduced in newer Java versions (likely Java 17 or higher). These warnings indicate that NiFi (or a dependency like Apache Lucene) is calling restricted native methods that require explicit permission to access low-level operating system functions.
The warning mentions java.lang.foreign.Linker::downcallHandle, which is a native method used for low-level interactions with the operating system.
Here are the 3 options you should try to resolve the issue: 

Option 1: Add the Java Option to Enable Native Access

  • Update the NiFi startup configuration to allow unrestricted native access for unnamed modules.

Edit the NiFi Java options in the bootstrap.conf file:

 
Spoiler
nano /opt/nifi/conf/bootstrap.conf
2. Add the following option to the java.arg properties:
Spoiler
java.arg.X=-enable-native-access=ALL-UNNAMED
3. Restart NiFi:
Spoiler
sudo systemctl restart nifi

Option 2: Use a Lower Java Version (if possible)

  • If NiFi was previously running fine with an earlier Java version (e.g., Java 8 or 11), you can revert to it until you're ready to address the native access changes:
  • Update the JAVA_HOME path in NiFi's bootstrap.conf to point to the older Java version.

Option 3: Verify Dependencies

  • Check if you are using the latest versions of NiFi and Apache Lucene:
  • Some of these warnings may be addressed in recent releases of NiFi or its libraries.
  • Consider upgrading NiFi to the latest stable version to ensure compatibility with newer Java versions.

    Happy hadooping












View solution in original post

6 REPLIES 6

avatar
Community Manager

@MattWho @steven-matison Hi! Do you have some insights here? Thanks!


Regards,

Diana Torres,
Community Moderator


Was your question answered? Make sure to mark the answer as the accepted solution.
If you find a reply useful, say thanks by clicking on the thumbs up button.
Learn more about the Cloudera Community:

avatar
Master Mentor

@tono425 

Apache NiFi 2.0.0 has only been tested and verified against Java 21.   I suggest switching to latest Java 21 JDK update and seeing if same messages persist in your Linux /var/log/messages log.

NiFi 2.0.0 System requirements

Please help our community thrive. If you found any of the suggestions/solutions provided helped you with solving your issue or answering your question, please take a moment to login and click "Accept as Solution" on one or more of them that helped.

Thank you,
Matt

 

avatar
Explorer

@MattWho 
Thank you for your advice.
I installed Java 21 (21.0.5) but similar warnings still persist.

Dec 16 11:09:10 myserver nifi.sh[253936]: WARNING: A restricted method in java.lang.foreign.Linker has been called
Dec 16 11:09:10 myserver nifi.sh[253936]: WARNING: java.lang.foreign.Linker::downcallHandle has been called by the unnamed module
Dec 16 11:09:10 myserver nifi.sh[253936]: WARNING: Use --enable-native-access=ALL-UNNAMED to avoid a warning for this module

 Thank you,

avatar
Master Mentor

@tono425 

It is just a WARNING that can safely be ignored.

I found some threads on this here:

https://bugs.openjdk.org/browse/JDK-8310626

https://apachenifi.slack.com/archives/C0L9VCD47/p1730736181056549?thread_ts=1730294478.475309&cid=C0...


https://www.reddit.com/r/java/comments/17cjajl/why_introduce_a_mandatory_enablenativeaccess/

 

I suppose you could try adding a new java.arg.<some string/num> to the NiFi bootstrap.conf to "--enable-native-access=ALL-UNNAMED" to see if that stops these Warnings on NiFi startup.


Please help our community thrive. If you found any of the suggestions/solutions provided helped you with solving your issue or answering your question, please take a moment to login and click "Accept as Solution" on one or more of them that helped.

Thank you,
Matt

avatar
Master Mentor

@tono425 
The error messages you are encountering in NiFi are related to Java's native method access restrictions introduced in newer Java versions (likely Java 17 or higher). These warnings indicate that NiFi (or a dependency like Apache Lucene) is calling restricted native methods that require explicit permission to access low-level operating system functions.
The warning mentions java.lang.foreign.Linker::downcallHandle, which is a native method used for low-level interactions with the operating system.
Here are the 3 options you should try to resolve the issue: 

Option 1: Add the Java Option to Enable Native Access

  • Update the NiFi startup configuration to allow unrestricted native access for unnamed modules.

Edit the NiFi Java options in the bootstrap.conf file:

 
Spoiler
nano /opt/nifi/conf/bootstrap.conf
2. Add the following option to the java.arg properties:
Spoiler
java.arg.X=-enable-native-access=ALL-UNNAMED
3. Restart NiFi:
Spoiler
sudo systemctl restart nifi

Option 2: Use a Lower Java Version (if possible)

  • If NiFi was previously running fine with an earlier Java version (e.g., Java 8 or 11), you can revert to it until you're ready to address the native access changes:
  • Update the JAVA_HOME path in NiFi's bootstrap.conf to point to the older Java version.

Option 3: Verify Dependencies

  • Check if you are using the latest versions of NiFi and Apache Lucene:
  • Some of these warnings may be addressed in recent releases of NiFi or its libraries.
  • Consider upgrading NiFi to the latest stable version to ensure compatibility with newer Java versions.

    Happy hadooping












avatar
Explorer

@Shelton 
Thank you for your advice.

As I use the latest version of NiFi and it requires Java 21, I added the following line in bootstrap.conf and confirmed the warning messages disappeared.

java.arg.EnableNativeAccess=--enable-native-access=ALL-UNNAMED

 I appreciate your help.

Thank you,