My current development process is to change Java code, mvn package, ant update, restart my tomcat server. I would really like to be able to add breakpoints, and debug my DSpace instance live. I recently ran across an issue with the oceanlink code, and wanted to debug, but had to resort to println / log info to see variables.
I'm familiar with the wiki page: https://wiki.duraspace.org/display/DSPACE/IDE+Integration+-+DSpace+and+IDEA
I was just wondering if there was more condensed, recent guidance on the subject.
I created a video walkthrough describing our Developer setup in IDEA: https://www.youtube.com/watch?v=mrLl1qPsy6I
Near the end of the video it shows which modules to deploy and how you can arrange the context paths.
Less than two years after the previous video, here's finally the debugging video: https://www.youtube.com/watch?v=V5Zi71zYmf8
One super powerful feature not covered in the video is "evaluate expression". When the program is paused in a breakpoint, you can use "evaluate expression" to execute any arbitrary method calls on the current state of the program.
Bram has provided an excellent tutorial on this topic, the one other strategy I can recommend that can sometimes be faster to setup is Remote Debugging.
The goal is to get into a "remote debug mode" on your existing deployed DSpace webapp in tomcat or in the DSpace CLI. Then you can attach to it directly without configuring embedded tomcat in Intellij. This is great because it can be completed locally using localhost or remotely over the network against an existing development server hostname/IP.
Copy first text boxes settings into env settings to your tomcat or CLI instance.
-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=5005
4.a. For DSpace CLI in [DSACE_HOME]/bin/dspace add the following line just prior to the java command (note we set suspend to y to assure that we have an opportunity to connect to the debugging port before the application executes.
export JAVA_OPTS="$JAVA_OPTS -agentlib:jdwp=transport=dt_socket,server=y,suspend=y,address=5005"
4.b For Tomcat Configuration export env settings already provided in tomcat catalina.sh script to start tomcat in debug mode. (note we set suspend to n to allow tomcat to start properly.
export JPDA_OPTS=-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=5005
%TOMCAT_HOME%/bin/catalina.sh jpda start
Once you have started the CLI app or Tomcat, then you can connect your configured debug settings. First select your Debug config from the Run/Debug dropdown on the toolbar and start in debug mode using the "Debug" icon.
This will connect to the debug port (if you have problems check for firewall restrictions). You should now be able to set breakpoints and step through your code in Intellij while it is executing on the server.
Caveats are that you will need to complete the entire mvn build/ant deploy to get any of your changes into the running tomcat/cli application. For faster developer turnaround, it is best to run the war/cli directly in intellij and using Bram's tutorial is excellent for that purpose. However, when this is not possible, this is a great alternative to be able to debug on existing live test sites.
Cheers, Mark
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With