Tomcat within Eclipse - starting with JPDA enabled - eclipse

I'm trying to get a webapp up and running - for debugging - within a Tomcat instance configured in Eclipse (to keep my work flow as automatic as possible). I'm trying to get remote debugging enabled within the Tomcat JVM, and I've read about two sets of VM arguments:
-agentlib:jdwp=transport=dt_socket,address=8000,server=y,suspend=n
or..
-Xdebug
-Xrunjdwp:transport=dt_socket,address=8000,server=y,suspend=n
But whenever I attempt to use either of these, I get an error message in my console:
Error occurred during initialization of VM
agent library failed to init: jdwp
ERROR: Cannot load this JVM TI agent twice, check your java command line for duplicate jdwp options.
I don't know where I should be looking for these other - supposedly duplicate - jdwp options. Where are these configured? How can I get this working?

If you've correctly setup Tomcat to be started and stopped inside an Eclipse instance, then you should not have to manually setup the debug options for the server to debug your application from inside of Eclipse. When you start Tomcat in debug mode from within Eclipse, the debug options are automatically added to the startup process. By manually configuring them in the launch configuration you are causing a duplication of the settings, thus the error response.
To verify that you have setup the server correctly, here are some steps to setup Tomcat in the Helios release:
If your Servers view is not open, go to Window->Show View->Servers
Right-click the servers window and select New->Server
In the 'Select the server type' window select the Tomcat version you are setting up
Select next (if already configured the server runtime environment, then 'Finish' button will be available)
Enter server name and installation directory for your environment
select 'Finish'
At this point, you should be able to see your newly setup Tomcat instance in your Servers window. At this point you can deploy your application to the newly setup server. To start the server in debug mode, you can select the debug botton available from the Servers window. Once the server starts the IDE will be automatically connected to allow for debugging your deployed application.

Related

how to setup a debugger for AEM or CQ?

how to setup a debugger for AEM or CQ? I'm using Eclipse IDE and Maven 3.2.5 for build and AEM version 6.0. I'm new to AEM and Java.
This Adobe article walks you through it: https://helpx.adobe.com/experience-manager/kb/CQ5HowToSetupRemoteDebuggingWithEclipse.html
Step 1: Add the Remote Debugging JVM Parameter
To use remote debugging, you must start CQ5 with this JVM parameter:
-agentlib:jdwp=transport=dt_socket,address=8000,server=y,suspend=n
You can add the parameter by doing the following;
Start your server like this: crx-quickstart/bin/start -d --debug-port 8000. The -d parameter adds the jvm parameter to the CQ5 java process.
Add it to your crx-quickstart/bin/start script CQ_JVM_OPTS environment variable (so your server always starts in debug mode).
Include it as a parameter when starting CQ5 with java -jar directly. For example, java -Xmx512m
-agentlib:jdwp=transport=dt_socket,address=8000,server=y,suspend=n -jar cq-author-4502.jar
Notes
If necessary, you can change the port defined under "...,address=8000,..." from 8000 to something that works better in
your environment.
Starting CQ 5.5, using the last solution, when Quickstart forks a new process it does not start the JVM with the debug options. You can
prevent forking by specifying the -nofork command line option.
Te start script is located under crx-quickstart/server for CQ versions < 5.5
Step 2: Start a remote debugging session
To start a remote debugging session from Eclipse, do the following:
Open Eclipse.
Choose Run > Debug Configurations.
Right-click Remote Java Applications and select New.
Select your CQ5 project under Project.
Type in the port from the "address" configuration of the jvm parameter defined above. In the example, it is port 8000 (and the host
name of the machine you are connecting to, most likely localhost)
To start a debugging session, double-click your new configuration in the Debug Configurations screen after saving it.
Applies to: CQ 5.x and Adobe Experience Manager 6.x
If you're on windows follow these steps.
Open AEM crx-quickstart, move onto bin, open start.bat(Right click and edit), find default JVM options, add the line
-Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=3000 next to headless=true in the start.bat file, save it. Open cmd in the bin folder. Type start.bat and hit enter which will open the instance with debugging port 3000.
Open Eclipse. Add breakpoints to the java file. Run > Debug Configurations > Remote Java Application, right click and select New Configuration, provide a name, select project(the one with .core), change port to 3000, apply and debug. Change the perspective to Debug, Window > Perspective > Open Perspective > Other > Debug.
Open AEM Page containing the component which uses the java class for which the breakpoints have added. If you’ve added breakpoints for the HelloWorldModel.java, open the page with helloworld component or refresh if already opened. And that’s it, eclipse will notify and the program will be paused at the breakpoint.
Possible Errors you might encounter with:
Failed to connect to remote VM. Connection refused. Connection
refused: connect
The debugger has already started when you hit apply and debug and trying to run the debugger again will get you this error.
Debugger not pausing at breakpoints and no notification in eclipse.
If the instance was already running and you hit start.bat in cmd, you’ll find this unusuality. Close the instance, and enter start.bat(in the bin folder). You’ll find the message below when the instance is ready. It might or might won’t open the browser by its own. So just open the browser and enter http://localhost:[portnumber]/.
SUCCESSFULLY LOADED validation.properties via the CLASSPATH from ‘/ (root)’ using class loader for DefaultSecurityConfiguration class!
RAWProcessor succesfully installed
17.10.2019 12:59:41.437 *INFO * [main] Startup completed
Step1: Start AEM service in debug mode with -debug parameter and a port number.
Step2: Setup debug configuration in IDE with the above port.
References:
How to start AEM in debug mode?
CQ5How To Setup Remote Debugging With Eclipse

How to setup remote debugging of an eclipse RCP application

My RCP app is not working properly outside of the development environment so I'm trying to setup a remote debugging session.
I start the app using the following parameters:
-vmargs -Xdebug -Xnoagent -Xrunjdwp:transport=dt_socket,address=8000,server=y,suspend=n
I then created a new debug profile which connects to port 8000. In the debug perspective I can see that the connection was successful and the various threads are listed. I should say that the app has a number of bundles (model, UI, services etc.) so I chose the bundle containing the .product as the project to debug.
But, although there seems to be a connection, I cannot set breakpoints. At least, I can set a breakpoint but it never halts.
Is there something else I need to do?
-vmargs -Xdebug -Xnoagent -Xrunjdwp:transport=dt_socket,address=8000,server=y,suspend=y
Please use above VM arguments. suspend should be y.

Eclipse : Whether to select Local Or Shared File during Remote Debugging

I have made some code changes and deployed the code to Jetty Server which is located Remotely .
Accessed the application through browser and I am trying to debug a Application .
Please tell me whether i need to select the Local File Or Shared File from the Eclipse Debug Configurations .
Please see the screen shot here .
The option shown in your screenshot will not help you automatically get code deployed to your remote Jetty.
The option simply allows you to Share your launch configuration (Remote Java Application - ManageWatchlistCall) in your eclipse workspace. This will allow you to checkin the launch configuration in a versioning control system so your colleagues automatically get the sme Remote Java Application launch configuration.
in order to get new code to your remote server, there are only 2 options :
Redeploy your application on the remote server.
Hotdeploy pieces of code to the remote supported (if the server supports it)
Use Hotswap Bug Fixing (works for small fixes) (*)
(*) If you are running Java Virtual Machine (JVM) V1.4 or higher,
Eclipse supports a feature called Hotswap Bug Fixing (not available in
JVM V1.3 or lower). It allows the changing of source code during a
debugger session, which is better than exiting the application,
changing the code, recompiling, then starting another debugging
session. To use this function, simply change the code in the editor
and resume debugging.

Oracle WebLogic Server is "Stopped" and yet I can't start it in Eclipse

When I open the Servers view in Eclipse (Galileo), I have a localhost instance of WLS with a "[Stopped]" indicator on it. When I attempt to start the supposedly stopped instance, I get these errors:
ERROR: transport error 202: bind failed: Address already in use
ERROR: JDWP Transport dt_socket failed to initialize, TRANSPORT_INIT(510)
JDWP exit error AGENT_ERROR_TRANSPORT_INIT(197): No transports initialized [../../../src/share/back/debugInit.c:690]
The "Address already in use" part clued me in that WLS was already running.
How can I stop/view the output of the currently running instance?
I normally run WLS through the command line (Windows) separately but I'm starting to fiddle around with running WLS right inside of Eclipse.
I've been searching for a good guide on setting Eclipse up to interact with WLS but haven't found one yet. If any of you can recommend one I would appreciate that as well.
the message you see means that java debugger cannot bind to the specified port, and not (yet) that weblogic cannot bind to its listen address.
This, can be due to an existing running weblogic instance (running with debugger enabled and on the same port) as you say, but may also mean that another Java program has been started with JDWP enabled on the same port.
So in the second case, please search if there is such a process (netstat -a will help) or just change debugger port you are trying to start weblogic with
If instead you really have a running weblogic instance, there are three cases:
1) it is a windows service (strange that you run weblogic as a service with JDWP activated), thus you can search and stop it through windows services ui
2) you started it through the command line, but in this case you would easily find the command line window you used to start it.
3) it is started by eclipse and you cannot see it for any reason, which is quite strange since it means that eclipse would have started two weblogic instances and one is failing. You can search in eclipse console view if you find a running instance (many consoles can be used at the same time). IF you don't find it just try to quit eclipse, WLS must die together with eclipse and you will see it in weblogic logs or through WLS process disappearing from task manager.
Are you using Oracle Enterprise Pack for Eclipse for running weblogic there? If yes I think this is a good introduction:
http://www.oracle.com/webfolder/technetwork/tutorials/obe/jdev/obe11jdev/11/oepe11g/introeclipseide.htm

Error starting weblogic in eclipse

When I start a Weblogic Server 11gR1 (10.3.1) in the server tab in Eclipse (3.4.2) I immediately get an error popup: Starting ... has encounterd a problem. Server ... failed to start.
However the starting continues and the server ends up in RUNNING mode after some 8 seconds.
No ears deployed, fresh domain and/or server instance.
It used to work fine and I didn't change any configuration as far as I am aware.
Any ideas?
A new server runtime makes no difference. But when I start the server in debug mode, there is no error popup.
When I start the server normally the error pops up and the server starts in debugging state. Remarkable, because while creating the server runtime I did not check the box "always start Weblogic Server in debug mode".
A new workspace and new server runtime solved the problem.
Maybe your Server Runtime is corrupted. Try to drop it and recreate it.
Also, try adding a -clean option to your eclipse startup.