CQ5 debug bundles using eclipse won't halt - eclipse

I created a bundle that I already uploaded, but I would like to debug it.
I started the server with debug mode:
java
-agentlib:jdwp=transport=dt_socket,address=8000,server=y,suspend=n -XX:MaxPermSize=256m -Xmx1024M -jar AEM_6.0_Quickstart.jar
Then I set to the project that packaged into the bundle its remote debugging configuration. But when I set the breakpoints in the project, it won't halt where it needs to when the lines are executed.

Below are some steps that can be helpful. Use that command line to start your CQ instance.
java -jar cq5-author-4502.jar -fork -forkargs -- -Xdebug -Xrunjdwp:transport=dt_socket,address=59865,suspend=n,server=y -Xmx1520m -XX:MaxPermSize=512m -XX:-UseSplitVerifier
I have simple title component in which I am calling some service method. And applied some breakpoints in service. I have multi-module eclipse project practice. Setup eclipse debug configurations as shown below :
Inside source add project's module as shown below :
Click on the debug button and refresh the cq page. You will see below image:
Open the Eclipse in debug prospective you can see you variables over there and page still loading as you not complete the method execution.
Hope this will Help!!
Thanks

Replace CQ_JVM_OPTS at cq5/aem directory >> crx/bin/start
CQ_JVM_OPTS='-server -Xmx1024m -XX:MaxPermSize=256M -Djava.awt.headless=true -Xdebug -Xrunjdwp:transport=dt_socket,server=y,address=30303,suspend=n'

Increase the heap size which is allocated to CQ process.
Make XX:MaxPermSize=512m and try.

Related

How to add XX:PermSize to every run config

Recently all my runs of my java code eclipse have been giving me permMem errors.
I can fix this with adding
-XX:PermSize=128M -XX:MaxPermSize=256M
to the dun/debug config, but I don't want to keep doing this. My eclipse config has:
eclipse.vm=C:\Windows\system32\javaw.exe eclipse.vmargs=-Xms384m
-Xmx768m
-XX:MaxPermSize=384m
You can make your VM options to be shared by new run/debug launches by adding you options to Launching Arguments.
It is explained here.
Edit:
My first answer was about plug-in development, sorry about that. You can add shared vm options by:
Window->Preferences->Java->Installed JREs->Select Your JRE->Edit->Add your vm arguments to Default VM Arguments
This adds your VM arguments to your Java application run/debug configurations.

Debug eclipse plugin project -- PermGen space, out of memory error

I have a plugin project. When i debug this as an eclipse application, in the 2nd eclipse that opens, I want to open Project explorer window. As soon as I click on the button to do this, I get java.lang.OutOfMemoryError: PermGen space. I tried changing the PermGen space in the preference, but it did not help. Can any one please suggest a solution.
You should add the -XX:MaxPermSize=256m or 512m to the Window>Preferences>Java>Installed JREs preference page. Edit a JRE and add it to the Default VM arguments tab.
The eclipse native launcher uses the eclipse.ini to add extra permgen arguments to Oracle JVMs, but that information is not used during runtime launching.
What if you try to extend the memory of eclipse when it starts. To do that simply open the .ini file (inside your eclipse folder) and edit the lines that refer to permSize and memory size:
e.g.
-XX:MaxPermSize=500m
-Xms500m
-Xmx2000m
If you don't want to set the permgen size for EVERY launch, you can also add the Parameter to the Debug Configuration.
Run > Debug Configurations
Choose the "Eclpise Application"-Configuration on the right side and choose Arguments in the Tabs.
Add -XX:MaxPermSize=512m to the VM arguments:
-Dosgi.requiredJavaVersion=1.6 -Xms256m -Xmx4g -Dfile.encoding=UTF-8 -XX:MaxPermSize=512m

problem in linking viewer selection with current editor - Eclipse

I often get this error "Operation linking viewer selection with current editor finished with errors" in Eclipse Galileo.
Once this error pops up no UI events is working in the IDE , i cant even able to close it also. Every time i have to go to task manager to stop the process , after this IDE works fine for some 5 min and again it display the same error as mentioned above.
i don't know what is happening , can you guys please help.
Just switch your Project Explorer to the Flat package presentation in Eclipse. It works :)
see details here: https://bugs.eclipse.org/bugs/show_bug.cgi?id=530450#c7
Per the Eclipse manual:
PermGen is the permanent generation of objects in the VM (Class names, internalized strings, objects that will never get garbage-collected). An easy, if somewhat memory-hungry fix is to enlarge the maximum space for these objects by adding
-XX:MaxPermSize=128M
as an argument to the JVM when starting Eclipse. The recommended way to do this is via your eclipse.ini file.
If you are getting OutOfMemoryErrors while running Eclipse, the VM can be told to let the heap grow to a larger amount by passing the -vmargs command to the Eclipse launcher.
-vmargs
-Xms512m
-Xmx1024m
Alternatively, you can invoke the Eclipse executable with command-line arguments directly, as in
eclipse [normal arguments] -vmargs -XX:PermSize=512M -XX:MaxPermSize=1024M -Xmx1024M [more VM args]
Even with recent versions of Eclipse and Flat Package presentation, if you have a lot of large projects loaded this can still be a problem.
I've found however that if you break up your projects into working sets and minimise the amount of projects/tree nodes open by selecting a working set it can really speed up Eclipse and mitigate this problem.
I had this problem (Version: Photon Release (4.8.0)) and I fixed it by removing all breakpoints.

How to make eclipse launch a program in the eclipse workbench from the command line?

How do I make eclipse launch a program in the eclipse workbench from the command line?
Specifically, I would like to run a command from the shell that causes my eclipse instance (which is already open) to run a particular program. If there is no program to do this from the shell, is there some RPC API that eclipse provides to make such a program?
I do not want to make a plugin. It must be a separate process that controls eclipse.
Eclipse Remote Control seems that it might do the trick https://github.com/marook/eclipse-remote-control from the Read me file.
Introduction
Eclipse plug-in project which adds remote control features to eclipse.
Commands can be sent via the eclipse remote control client to a
running eclipse instance.
I have not tried it myslef but I ran into it trying to figure out how to write an ant task that triggers .launch file
First create a batch file and save it in a location.
For example if I want to invoke notepad , I will write in the batch as follows
start notepad
In eclipse, you can configure external tools.
Goto Run -> External Tools -> External Tools Configurations.
You will be presented with a Dialog box.
Now Click on the New Configuration Icon.
In the right pane of Window you can assign a configuration Name.
In the Location Text Box, Click on the "Browse File System" Button, and select the batch file you have created earlier.
In the Common Tab, uncheck "Launch In Background".
You can set this configuration in Favourites menu, by clicking the checkbox "External Tools" under Common Tab.
Click on Apply.
Now you can Run your required application. This is for Windows only. I don't have any idea of this for Linux Machines.
Take a look at Product Configuration
1º Create a new Product Configuration (Ctrl+N), and select "Use a launch configuration" (or another option, if it's more convenient) on the first page of the wizard.
2º In the Exporting section you should be able to export your product using the "Eclipse Product export wizard".
3º To run the product, follow this instructions
Hope it helps.
Not a complete answer, but here are some things I've come across with Eclipse:
In general, you can open Eclipse from the command line with something like:
java -Dosgi.requiredJavaVersion=1.5 -Dhelp.lucene.tokenizer=standard -Xms40m -Xmx512m -XX:MaxPermSize=256m -cp plugins/org.eclipse.equinox.launcher_1.3.0.v20120522-1813.jar org.eclipse.core.launcher.Main
That Main launcher takes an -application flag where you can pass what I think are plugins (not sure). I've typically used this to run Ant within Eclipse:
java -Dosgi.requiredJavaVersion=1.5 -Dhelp.lucene.tokenizer=standard -Xms40m -Xmx512m -XX:MaxPermSize=256m -cp plugins/org.eclipse.equinox.launcher_1.3.0.v20120522-1813.jar org.eclipse.core.launcher.Main -application org.eclipse.ant.core.antRunner -buildfile build.xml
I have no idea how to manipulate a running Eclipse instance, and I don't know if you can achieve your goals through an Ant script, but I thought these might be fruitful avenues.
Addition to ams' answer, marook's plugin just support very few commands.
open_file and execute_command with RUN/DEBUG/PROFILE
And marook also have a blog post about how to implement more command http://pielmeier.blogspot.com/2010/07/implementing-new-eclipse-remote-control.html
But as we all know, Eclipse plugin development is quite heavy weight.
So, I suggest just use execute_command with RUN by marook's plugin. The further function to Eclipse IDE, can be done by Eclipse EASE script engine. Write a light weight script and then RUN by marook's plugin, to avoid Eclipse plugin development.
More information about EASE can be found at:
https://opensource.com/life/16/2/how-use-python-hack-your-ide
There is also javascript script support:
https://git.eclipse.org/c/ease/org.eclipse.ease.scripts.git/tree/JavaScript%20Beginner%20Tutorial/02%20File%20IO/05%20Create%20sample%20project%20(using%20modules).js
Here you have a series of examples: http://www.rgagnon.com/javadetails/java-0014.html
Basically, you use:
Runtime.getRuntime().exec(command);

Memory Setting for OC4J in Eclipse

I've looked on the web for a while and can't seem to find the setting to increase the memory allocated to OC4J when launching from Eclipse. Does anyone know where the setting is?
Thanks.
You can add memory setting in the OC4J_JVM_ARGS environment variable. For example you could have something like:
OC4J_JVM_ARGS=-Xmx512m
You could add others if you want:
OC4J_JVM_ARGS=-XX:PermSize=256m -XX:MaxPermSize=256m -Xms1024m -Xmx2048m
Now, I never have run OC4J from Eclipse (only standalone), but you could do the same by selecting your Server view, then Open launch configuration and in the Arguments tab add the values to the VM arguments section directly like:
-Xmx512m
or
-XX:PermSize=256m -XX:MaxPermSize=256m -Xms1024m -Xmx2048m