Bram has provided an excellent tutorial on this topic, another strategy that I can recommend, which can sometimes be faster to set up, is remote debugging.
The goal is to enter "remote debugging mode" on an existing deployed DSpace web server in tomcat or in CLS DSpace. Then you can connect directly to it without setting up the built-in tomcat in Intellij. This is great because it can be executed locally using localhost or remotely over the network against the existing host name / IP address of the development server.
- Choose Run> Modify Configurations.
- Select the Add (+)> Remote option.
- Configure remote settings, configure the appropriate host / port configuration for your tomcat or cli host site and provide the appropriate name (DSpace Remote)
Copy the first settings of the text fields into the env settings on your tomcat or CLI instance.
-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=5005
4.a. For the DSpace CLI in [DSACE_HOME] / bin / dspace, add the following line immediately before the java command (note that we set suspend to y to ensure that we can connect to the debug port before the application executes.
export JAVA_OPTS="$JAVA_OPTS -agentlib:jdwp=transport=dt_socket,server=y,suspend=y,address=5005"
4.b For configuration, Tomcat Configurations are already provided in the tomcat catalina.sh script to run tomcat in debug mode. (note that we set suspend to n to allow tomcat to start correctly.
export JPDA_OPTS=-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=5005 %TOMCAT_HOME%/bin/catalina.sh jpda start
Once you have launched the CLI or Tomcat application, you can enable the customized debugging settings. First, select the Debug configuration from the Run / Debug drop-down list on the toolbar and start in debug mode using the Debug icon.
This will result in a connection to the debug port (if you have problems checking the limits of the firewall). Now you can set breakpoints and execute your code in Intellij while it is running on the server.
The caveats are that you will need to complete the deployment of mvn build / ant in order to get any changes in the current tomcat / cli application. To speed up development, it is best to run war / cli directly in intellij, and using a Bram tutorial is great for this purpose. However, when this is not possible, this is a great alternative to debug existing test sites.
Cheers, Mark
source share