Support Questions

Find answers, ask questions, and share your expertise

java.lang.ClassNotFoundException: org.apache.nifi.bootstrap.RunNiFi Error

avatar
Super Guru

Hi,

Anyone Unlucky enough to run into this problem (at least as it happens on version M2.0.0-M2) when you try to run run-nifi.bat file to start nifi to be welcomed with this error:

 

 

 

 Could not find or load main class org.apache.nifi.bootstrap.RunNiFi

 

 

 

At this point the nifi-app.log file has not been created so you are out of luck in determining what caused this error.

Solution:

I'm not saying this is the only reason you could encounter this error. After spending some time researching this error , Idid not find the exact match of this error message but I found something close (Example: https://community.cloudera.com/t5/Support-Questions/Error-Error-Could-not-find-or-load-main-class-or... )

In my case you need to watch for the full error message which is :

 

 

 

'F:\NIFI' is not recognized as an internal or external command,
operable program or batch file.
The JAVA_HOME environment variable is not defined correctly.
Instead the PATH will be used to find the java executable.

Error: Could not find or load main class org.apache.nifi.bootstrap.RunNiFi
Caused by: java.lang.ClassNotFoundException: org.apache.nifi.bootstrap.RunNiFi
Press any key to continue . . .

 

 

 

Noticed the first line where it says 'F:\NIFI' is not recognized as an internal or external command..." . This is my installation path for Nifi and it turns out the full path is "NIFI 2.0.0M2" with white space between NIIF and the version and that is basically the problem. Once I removed the whitespace from the folder name it worked at least to where I can see the log file and continue from there.

Hope that will help someone out there running into the same situation.

Thanks

 

 

2 ACCEPTED SOLUTIONS

avatar
Super Collaborator

@SAMSAL 

Navigate to the location of your NiFi installation.

Rename the folder to remove any spaces.

mv "NIFI 2.0.0M2" NIFI_2.0.0M2

Open your system environment variables settings.

Update the NIFI_HOME environment variable to the new path if it's set.

Ensure that the JAVA_HOME variable is correctly set and points to your Java installation directory.

Open the run-nifi.bat script to ensure it correctly references the new path. Look for any hardcoded paths that may still contain spaces and update them

Execute the run-nifi.bat file again to start NiFi. It should now correctly locate the org.apache.nifi.bootstrap.RunNiFi class and proceed without the previous errors.

Check JAVA_HOME: Make sure that the JAVA_HOME environment variable is correct.Ensure it points to a valid Java installation path

echo %JAVA_HOME%

View solution in original post

avatar
Master Mentor

@SAMSAL 
This is not a new problem, but rather something that has existed with NiFi on Windows fro a very long time.  You'll need to avoid using space in directory names or warp that directory name in quotes to avoid the issue.
NIFI-200Bootstrap loader doesn't handle directories with spaces in it on Windows

 

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

View solution in original post

3 REPLIES 3

avatar
Super Collaborator

@SAMSAL 

Navigate to the location of your NiFi installation.

Rename the folder to remove any spaces.

mv "NIFI 2.0.0M2" NIFI_2.0.0M2

Open your system environment variables settings.

Update the NIFI_HOME environment variable to the new path if it's set.

Ensure that the JAVA_HOME variable is correctly set and points to your Java installation directory.

Open the run-nifi.bat script to ensure it correctly references the new path. Look for any hardcoded paths that may still contain spaces and update them

Execute the run-nifi.bat file again to start NiFi. It should now correctly locate the org.apache.nifi.bootstrap.RunNiFi class and proceed without the previous errors.

Check JAVA_HOME: Make sure that the JAVA_HOME environment variable is correct.Ensure it points to a valid Java installation path

echo %JAVA_HOME%

avatar
Super Guru

Hi @RAGHUY ,

Thanks for your reply but Im not sure you offered anything new besides what I stated in my post.  The run.bat which I dont touch or recommend anyone to touch uses relative paths and checks for system variables like %JAVA_HOME% and will return an error if its not found or set incorrectly (different kind of error). Maybe there is a way to ensure that the run.bat and the referenced file "nifi-env.bat" where the NIFI_ROOT is being set is taking care of whitesapces in the path. I tried different things  like surrounding the "NIFI_ROOT" with double quotes where referenced but it did not help.

 

 

avatar
Master Mentor

@SAMSAL 
This is not a new problem, but rather something that has existed with NiFi on Windows fro a very long time.  You'll need to avoid using space in directory names or warp that directory name in quotes to avoid the issue.
NIFI-200Bootstrap loader doesn't handle directories with spaces in it on Windows

 

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