I needed to break down and debug a processor I'm working on. I found a
JIRA issue a year old that's probably not been taken care of. I'd like
to help.
https://issues.apache.org/jira/browse/NIFI-513
I wrote this quickie on how to set up IntelliJ or Eclipse to accomplish
that. I'm using IntelliJ, but I'm a very old Eclipse guy and still
active in the Eclipse forums. It's actually easier than I make it look
here because I'm covering Eclipse as well as IntelliJ and I'm trying not
to assume the person who follows will know too much about doing this or
might never have done remote debugging before.
Hope this helps someone. Maybe someone in charge of the NiFi user doc
could use this to resolve the JIRA issue.
------------------------------------------------------------------------
Steps to debugging a NiFi processor you've written. See this article
<http://blog.trifork.com/2014/07/14/how-to-remotely-debug-application-running-on-tomcat-from-within-intellij-idea/>*
to learn how remote debugging works in IntelliJ. The example uses
IntelliJ to debug an application running in Tomcat, but it's a similar
thing no matter if you're using Eclipse (or IntelliJ) to debug NiFi.
1. Edit /conf/bootstrap.conf/ and simply uncomment the line that starts
out with java.arg.debug.
2. Create a Debug configuration.
In IntelliJ IDEA, ...
1. Do Run → Edit Configurations
2. Click the green +.
3. Choose Remote (because it's a remote debugging session you want
to create.
4. Give a Name:, something like "Local NiFi".
5. Change the port to 8000 (this value must match the one in
/conf/bootstrap.conf/).
6. If you're only debugging a processor in a project with multiple
modules, set the drop-down Search sources using module's
classpath: to the module in which it lives.
In Eclipse, do
1. Do Run → Debug Configurations....
2. Choose Remote Java Application.
3. Click on the New Launch Configuration icon (a tiny sheet of
paper with a yellow plus sign in upper left of dialog).
4. Give it a name like "Local NiFi".
5. In Project:, type the name (or browse for it) of the project
containing your processor code.
6. Set the Port: to 8000 or whatever you established in
/conf/bootstrap.conf/.
7. Click Apply or, if you're ready, Debug.
3. Launch NiFi (or bounce it).
4. Set one or more breakpoints in your processor code.
5. Launch the debugger.
In IntelliJ IDEA, do Run → Debug and choose "Local NiFi" (or
whatever you called it) from the list presented. This brings up the
debugger and displays, "Connected to the target VM, address
'localhost:8000', transport: 'socket'
In Eclipse, do Run → Debug Configurations..., scroll down and choose
"Local NiFi" or whatever you called it. What you see should give you
warm fuzzies, something akin to what I'm reporting seeing in
IntelliJ IDEA.
6. Prepare data flows into your processor.
7. Start your processor; the IDE debugger should pop up stopped at the
first breakpoint.
8. Debug away.
*
http://blog.trifork.com/2014/07/14/how-to-remotely-debug-application-running-on-tomcat-from-within-intellij-idea/