AEM6 starting from console with -debug -nofork options - debugging

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.

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.

How to debug start of eclipse plugin?

I try to migrate an eclipse plugin from Java8 to Java9. If I start a debug session (Run as Eclipse Application...) all works fine.
However, after installing my plugin I am not able to use it. If I use ss in the OSGI console I get following status for my plugin:
1102 STARTING org.treez.core_1.0.0.201712191435
and if I manually try to start it I get
osgi> start 1102
gogo: BundleException: Error loading bundle activator.
I tried to start a remote debug session, as suggested here:
Debugging Eclipse plug-ins
I set a break point in the constructor of my Activator but that break point is never reached.
=> How can I get additional information about why the loading of the bundle activator fails? Is there some log file? Can I somewhere set a logging level to TRACE?
I assume that the issue might be that a resource can be found while debugging the Eclipse Application but not when using the bundled jar. More info, e.g. the name of the resource that could not be found, would be very helpful.
Related questions:
Debugging Eclipse plug-ins
CQ5 OSGi bundle does not start:- Activator cannot be found
When plugins fail to start there is normally a message in the .log file in the workspace .metadata directory.
On Linux, Unix and macOS this file and directory are hidden so you may need to do something special to see them.

How can I debug with the Cloud-SDK-based Maven App Engine plugin?

I'd like to debug with the Cloud-SDK Based Maven plugin (com.google.cloud.tools::appengine-maven-plugin v. 1.3.0).
I run the goal appengine:run in Eclipse in Debug, but this does not put me into Debug mode, e.g. stopping on breakpoints.
I can use remote-debugger, but it is a hassle to run two processes every time I need to start my application. Is there a way of running a Debug session with one command?
I believe the only way to do this with Maven is by setting up a remote debug configuration in Eclipse as described in the App Engine documentation.
<configuration>
<jvmFlags>
<jvmFlag>-Xdebug</jvmFlag>
<jvmFlag>-Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=5005</jvmFlag>
</jvmFlag>
</configuration>
Your eclipse remote debug configuration needs to use the port specified in the jvmFlag arguments.
Another more practical way to run the debugger is to use Google Cloud Tools for Eclipse.

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.

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

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

Resources