How can I debug scala source code in IDEA with SBT Jetty-run? - debugging

I found related answer in Debugging Scala code with simple-build-tool (sbt) and IntelliJ . But I still don't get it. Does it mean I need to first config the following in sbt.bat
set SCRIPT_DIR=%~dp0
java -Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=5005 -Xmx512M -jar "%SCRIPT_DIR%sbt-launch-0.7.5.RC0.jar" %*
And then launch the "Remote" in Run/Debug configurations in IDEA all with default?
After those two steps, the program can stop in the breakpoint when I refresh my web application page?

See my answer in the related question:
Debugging Scala code with simple-build-tool (sbt) and IntelliJ

Related

Gradle / IntelliJ miscommunication causing "Unable to start daemon process"

My IntelliJ Idea projects have been working fine until I cloned a new project from our repo and installed Gradle.
This new project runs, but running the debugger causes the following error:
I've completed the steps recommended in this similar SO question. I have also read the Gradle Daemon guide.
Some helpful information:
-Gradle does respond to command line prompts, including --profile and --status:
-The project builds and executes; the problem is only the debugger. Is this a mapping issue between IntelliJ and Gradle?
-In the Settings menu, Gradle JVM: is set to "Use Project JDK (Java version "1.8.0_211") and this program is written in Java 8. Delegate settings set to: Build and run using intelliJ IDEA. Run tests using IntelliJ IDEA. Should these change to Gradle?
-I took the advice of one of the respondents and had one of our IT guys check out my ports and firewall settings. He was unable to solve the problem and said the issue is with Gradle.
So far, nothing has worked. What should I do?
I solved this problem after some tinkering:
In (IntelliJ) File > Settings > Build, Execution, Deployment > Gradle, I changed "Use gradle 'wrapper' task configuration" to "Use local gradle distribution."
Also, notice in this screenshot that "Gradle VM options" has a custom value; this was suggested as a solution in another post. This relates to memory management, as some people speculated that the daemon was crashing because of a RAM issue. My solution appears to work regardless of whether I alter that value.

Spring boot runtime error details

I'm a beginner to spring and spring boot.I'm using command line runner to execute my application.I was facing issue that my application services stops immediately without any error when I run the application. After reviewing all files i came to know that one of autowired variable was not having #component notation in its class.After fixing it started working fine.
My question here is, is there a run time debugger in spring boot to trace these types of errors ?
inside src/main/resources/application.properties or src/main/resources/application.yml add
debug: true
run with debug using spring-boot property
java -jar /path/to/file.jar --debug
run with debug using jvm args
java -Ddebug -jar /path/to/file.jar
also you can ise IDE such Itellij IDEA (in Run Configurations) for your main class
ps: I believe, other IDEs, such as eclipse / STS or NetBeans also should have similar property
set env variable DEBUG=true and run app
5.1. unix bash: DEBUG=true java -jar /path/to/file.jar
5.2. windows cmd:
set DEBUG=true
java -jar path\to\file.jar

Can the IntelliJ IDEA run tab have color?

I am running a spring boot application inside IntelliJ IDEA and noticed a difference if I run it via the run tab (run menu) and via manual command from the terminal tab.
If I run it through a maven run target (play button), I do not see any colors inside the 'run' tab. If I run it via 'mvn spring-boot:run from the 'terminal' tab I see the pretty color highlights. The maven run configuration also runs the same command, spring-boot:run.
Application started from the play button/run configuration (run tab):
Application started from the terminal tab via mvn spring-boot:run (terminal tab):
Inside build.gradle, add the following block to get colorized log output when running your Spring Boot app inside IntelliJ IDEA via gradle bootRun.
bootRun {
jvmArgs = ["-Dspring.output.ansi.enabled=ALWAYS"]
}
It's supported for the Spring Boot Run/Debug configuration type. It explicitly passes
-Dspring.output.ansi.enabled=always
JVM option enabling the color output.
As far as I know, ANSI colors support is not available when you run it in IntelliJ IDEA using Maven or Gradle configurations in the built-in console. Feature request is welcome.
In IDEA 2017.1 EAP I'm getting colours even if I'm just running the application with the standard run command
Edit:
Might be that Community edition doesn't support Spring Boot at all (https://www.jetbrains.com/idea/features/editions_comparison_matrix.html)
You can obtain the very same output also in the Community Edition with the previously mentioned option:
-Dspring.output.ansi.enabled=always
Simply go to "Run" -> "Edit Configurations..." and add the option in the "VM options:" field for your main class.

AEM6 starting from console with -debug -nofork options

As I know when AEM is started in debug mode from the console using the -debug option, the JVM will be forced to fork, but what will be the result if the AEM is started with the -debug -nofork options? e.g:
java -jar aem6-author-p4502.jar -debug 8000 -nofork
Fork or nofork does not matter. aem6 will decide based on the available memory. if you want to debug, using following command
java.exe -Xdebug -Xrunjdwp:transport=dt_socket,server=y,address=9669,suspend=n -XX:+PrintGC -XX:+UseG1GC -XX:MaxGCPauseMillis=200 -jar aem-quickstart-6.2.1.jar
then in intellj or eclipse connect it with remote debug. you can only debug the code in osgi bundles. you can't debug the jsp code.
What works for me is to double-click the server instance in Eclipse. It opens up the details. Near the right bottom corner, there is an option for "Debug". Expand it and uncheck the "Resolve sources when connecting".
This stops Eclipse from comparing your Eclipse code with the code running inside the server. This isn't an ideal answer. Ideally, we want to sync the Eclipse code with the server code, otherwise debugging has no meaning -- assume you're off by even one line of code when debugging.
I'm answering your specific question. For a broader answer on this, please see:
Eclipse java debugging: source not found
Sometimes our system OS generates multiple java forks in that case -nofork added at the end of the command will resolve the issue.

How to debug OFBiz in IntelliJ IDEA

I have try to debug OFBiz in IntelliJ IDEA. But I couldn't find any particular document for that. So first I try to configure debugging OFBiz in Eclipse and then try to debug OFBiz in IntelliJ with same configuration. It's working with Eclipse but it did not work with IntelliJ.
What I have Done:
Run > Edit Configuration
Then select Application
Configuration option:
Main class: org.ofbiz.base.start.Start
VM option: -Xms128M -Xmx512M
Working directory: (path of the OFBiz project)
Use classpath of module: Project directory (i.e ofbiz)
What should be the right configuration for debugging OFBiz in IntelliJ. If anyone can provide a link(where this is documented) then it also will be helpful.
Run/Debug Configurations -> Add New Configuration -> Jar Application -> Then you should set Path to ofbiz.jar and working directory
For me it works good

Resources