How to debug Spring if project deployed from console to Tomcat server? - eclipse

I have issue to deploy Spring project directly from Eclipse. It doesn't work if I try run to server option from Eclipse. But same project works fine if I deploy from console to local Tomcat. I would like to debug it by setting break point and also want to see debug output to console as I used many log as logger.info("Listing Walks"); Where is this log if I deploy from console?

on the console in your tomcat folder do
set JPDA_ADDRESS=8000
set JPDA_TRANSPORT=dt_socket
bin/catalina.bat jpda start
This starts tomcat in debug mode
Then in in eclipse you can create a remote debug profile to attach to the tomcat process on port 8000

Related

Debug Tomcat Web Application in Eclipse

I have a Advanced Java Application(Spring+Hibernate) with Maven. Project runs without any error.
I follow below process to test the application.
Build War using below command.
C:\Dev\ProjectApp> mvn clean package -Dmaven.test.skip=true
This builds war file inside target folder(C:\Dev\ProjectApp\target).
Place Application.war inside webapps folder(C:\Apps\Apache\Jakarta\Tomcat6\webapps)
run startup.bat from Tomcat6\bin folder.
hit the application in web Browser (http://localhost:8080/).
I want to debug this application from eclipse IDE itself. While application runs in webbrowser. I want to debug using breakpoints.
What are the steps to run this application in eclipse? What are constraints involved in this?
Thanks in Advance !
To simply debug the flow of the application, you can use the eclipse as the basis.
Goto the server view and create a new tomcat server (or any server that you use for dev). Next right-click on your project --> run as --> run on server and select the server that you just created. Keep in mind that the server should have all the configurations that you need to have to run the application. If your project requires some custom settings in the application server, then tell eclipse to take control of the server installation by selecting "Use Tomcat installation". (double click on the server to configure it)
Next add debuggers and start the server from within eclipse.
Happy debugging !
Set the environment variables first
set JPDA_ADDRESS=8000
set JPDA_TRANSPORT=dt_socket
You can edit the startup.bat to have
call "%EXECUTABLE%" jpda start %CMD_LINE_ARGS%
and start in the same way as above.
After this you can have your eclipse open a remote debugging session that connects to localhost:8000.
However, I would strongly recommend to use the WTP plugin in eclipse to build and start/stop the tomcat from within eclipse itself.

Deploy and debug application on OC4J in eclipse

I have a tomcat webapp project checked out in eclipse (call it 'xyz'). I use eclipse tomcat plugin with Devloader. Everything runs fine. etc, etc, happy.
Now I want to run the same project on OC4J app server and debug in eclipse. For that, I have downloaded and installed standalone OC4J server. I created a OC4J server instance in eclipse. Question is how do I deploy the earlier checked out project 'xyz' to run on OC4J server in eclipse.
Additionally, is there any plugin for OC4J similar to tomcat in eclipse, that makes life easier.
Thanks in advance for your replies.
Package your application in an EAR file and deploy it to OC4J
Start OC4J with VM arguments that enable remote debugging (See http://docs.oracle.com/javase/1.4.2/docs/tooldocs/solaris/jdb.html)
Create a Debug Configuration of type Remote Java Application in Eclipse, and use that to connect to the running VM

eclipse and tomcat- couldn't load tomcat server configuration at

I try run spring MVC application via tomcat. I attached to preferences_> server tomcat. But when i start Run On Server next i press finish button. And i see couldn't load tomcat server configuration at /Servers/Tomcat v6.0 server at localhost-config. The configuration may by corrupt or incomplete. Project have to good because it is sample project generated via Spring Tools from template. How fix it?

Starting tomcat in eclipse vs command line

I am using tomcat 6 and when I start it from the command line the application it's running works fine, but when I start tomcat from eclipse (I added it as a server in eclipse) I get a 404 error when I try to run the application in my browser. Any ideas why this is?
By default, when you reference an existing Tomcat instance in Eclipse, only its engine is been used. All already-deployed webapps in Tomcat's /webapps folder are ignored. You seem to expect that they are also accessible when you start Tomcat from inside Eclipse.
You need to configure the Tomcat server reference in Eclipse to set Server Locations to Use Tomcat installation instead of (default) Use workspace metadata. Double click the Tomcat server entry in Servers view to edit it.
This way, everything which is deployed to Tomcat, outside control of Eclipse, will also be available when you start Tomcat from inside Eclipse.

Can I debug an application which is running on other eclipse instance?

I have two eclipse instances running.
And in one I have the code base.
And in other eclipse i am running the application.
So can I debug this application in the eclipse where I have code base?
I imagine your build produces a JAR file? if so, then you can run the JAR from the console and then plug the eclipse debugger.
Check this tutorial, that is clear and with screenshots
You should be able to launch a remote debug session
1/ Specify the following option when launching the app from the first eclipse
-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=8000
2/ Launch a Remote Java App (Run > Debug> Debug Configurations... > Remote Java Application.)
-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=8000
(if port 8000 is free) in order to debug the app from the "code base" eclipse.
See Remote Debugging with Eclipse.
You can specify the sources in the Remote Java App configuration by referencing your own code base.
Yes, you can attach the debugger to a remote JVM. See How to attach debugger to running process?