I have seen many online tutorial explaining how to use eclipse to do remote debug of WAR file.
But what I want to know is how to do the debug inside eclipse just as debugging a JAVA application? I have Tomcat 7 configured in my eclipse as a server. And I have tested it with a sample servlet program successfully meaning I can set breakpoint in the source code and run into it.
My WAR application is built by gradle. I have imported the gradle project into my eclipse and build it ok inside eclipse by running gradle task inside "gradle tasks view". I added the project into the server. However, when I try to use "Debug as > Debug on Server", it fails and the breakpoint is not get hit. Anyone could share the experience to debug WAR inside eclipse?
I am a IntelliJ Idea user but I have a generic advice here. What you can do is that you can run your application (war/jar etc) with debug port on and then from eclipse use remote debug (or attached to a process sort of option).
Make sure you have exact copy of the code from which you have created war/jar otherwise lines might mismatch while debugging and will be hard to make sense.
On the "Servers" view, select the right tomcat server overview, then go on the "Modules" tab.
There, you can add the war by clicking on "Add External Web Module...".
Set the war path in the "Document base", and what ever you want on the "Path" field.
Example:
Document base: "C:\eclipse-workspace\MyProject\war\myWarToDebug.war"
Path: "/myapp"
Start the server in debug mode. Access your app using the url
<yourServerHost>:<serverPort>/<pathSetInModuleTab>.
Note that when reaching the breakpoint, Eclipse may say there is no sources found. Simply go on the server debug configuration and add the project sources in the "Source" tab.
Before debug you must decompile using jd gui for open class file inside war file and save as java project.
Related
I have a Java application that must be launched from a shell script. This application uses a jar library that I want to modify and debug from eclipse. I have tried it and I failed.
What I have tried
I have compile my library to generate the jar. In the folder where the application looks for the mentioned jar, I have renamed the original one and created a symbolik link to mine.
Then, from eclipse, I have done the following:
Right click on my jar's project > debug as > debug configurations.
Select Remote java Application and Connection Type = Standard (Socket listen)
At this point, I can see a label at the bottom right telling: "Waiting to vm to connect".
Next I have gone to the application's main folder and executed the launcher script.
I am sure that the application is using the modified library because I have added a System.out.printlin("...") and I can see it in the console. Despite of this, the debug mode is not activated in eclipse, and the application is not paused.
Note: I have compiled the proyect with make.
For remote debugging, the JVM that is being used to run the application must be configured to run in debug mode. So you'll need to include those options in the script that's launching your application.
Having said that, what is so special about the shell script that it can't be converted into a run configuration to launch directly from Eclipse?
I'm developing a datastore plugin to Geoserver, to develop it faster I am trying to remote debug it. Geoserver uses Tomcat behind the curtains. I prepared everything to remote debug via Eclipse and accomplished it. Now I can remote debug my plugin. However, when I modify my code (I tried to add a harmless line like: int noHarm = 5;) and then export it as jar and copy that jar to webapps\lib\ under Geoserver installation directory, I fail to remote debug the plugin. After that I changed that modification back to when it was worked(deleted int noHarm = 5;) and created the jar again, then copied it under webapps\lib\ , now I am able to remote debug again.
When I open stores page in Geoserver, it stops at breakpoints in the canProcess() method with the jar exported from not modified code or when I try to add new Store it stops at breakpoints in the createDataStore() method with the jar exported from not modified code. But if I change even a tiny line or add it won't stop at breakpoints even though it connects to virtual host succesfully(I use vmware workstation with windows 7-32 bit on it if it helps).
What could be the problem?
Thanks very much in advance.
I found the solution, it was about eclipse. My source files was not in the workspace so, in the project build path --> under the source tab I was using Link Source button. That button allows you to link java files (which are not under your workspace) to your project and let those files act as source. What I did to solve this problem:
I then moved those files under project's real source folder
With that I created jar.
I stopped Geoserver(Tomcat) and copied my jar under webapps\lib\
I started Geoserver(Tomcat) and connected to server via eclipse remote debug.
After these steps I was able to remote debug with every jar I deployed.
my application is running in eclipse but i want to run it on tomcat .i want to run my spring application in tomcat server and don't want to use eclipse or any other tool, so how can i do that and where do i put my various files basically the directory of it, and the complete procedure to do that.
main problem is in the directory structure and the path to be put in the tomcat server to run that application. i tried but it gives the 404 error file not found ,as i am new to the spring framework explain in detail
You are asking a very broad question. But, in an attempt to point you in the right direction please see this article. The link given provides insight into the directory structure of your application.
Now as far as running "outside of eclipse" you should be able to export your project from the "File" menu as a "Web Application Archive" or "WAR" file. This file can then be placed under ${CATALINA_BASE}/webapps and be launched when you start your container.
If you are using a stock configuration and you have an archive named "myapp.war", you can access it on
http://localhost:8080/myapp
I hope this information helps you get to where you need to go.
First export the war file using eclipse as you are using eclipse.
Then follow the procedure
How to deploy a war file in Tomcat 7
I use ant script to create a war file of my application. Is there a way to debug my application in eclipse?
If you are using tomcat server. Install Mongrel plug-in to your eclipse. After building ant script, just add break points to code and click on tomcat start button provided by Mongrel plug-in. Your app will be automatically running in debug mode. And Mongrel(Tomcat) automatically deploys your war file.
I am currently using the same for my projects.
If you have all the source code in Eclipse and merely use the ant script for building, you should be able to do debugging by just putting the generated war in the deploy folder of your server (or doing whatever else your server requires to deploy a war), and then simply start up your server via Eclipse.
Eclipse wouldn't 'know' that anything has been deployed to the server it has just started, but the connection between WTP's deployer and JDT's debugger is pretty weak anyway. It will simply try to match classes in the JVM to Java files in your workspace. If you have the actual source there this will of course match and you can debug.
I am trying to use tomcat with eclipse. I have installed it all and got the tomcat plugin installed. I have put a .war file in the webapps folder of tomcat and have made sure autodeploy is set to true. The problem I am having is that I can't get tomcat to run this .war file. The tomcat server is started and running as it tells me under the servers tab at the bottom of eclipse. It also shows the name of my .war file under it and says synchronized meaning it at least knows its there. But I can't get it to work at all. Even when I go to the local host page it shows the title of apache tomcat but does not show the file. I want it to show me the .war file. It has the correct xml files and everything in it. Any help is much appreciated.
You may try to check whether the application is deployed or not. You can directly go to the Tomcat directory to see this.
Another possible thing could be, you might be typing the incorrect url.
http://localhost:8080/[your_application]
where 8080 is the port you have specified for tomcat.
You need to let Eclipse publish your web project for you when using the Eclipse Tomcat plugin instead of trying to manually deploy it youself.
The Tomcat plugin for Eclipe supports hot deployment whereby you can change jsp's etc without having to manually redeploy your web application.
If you have a valid web project in eclipse then you can check that it is being deployed by looking at the Server View.
Window, Show View, Other, Server
This window should contain details of your Apache server. (If no server is listed then you'll need to right click on the list and set one up.)
To check that your application is being deployed right click on your server and select Add/Remove projects. Check that your web project is listed. If it is not listed under Configured Project then add it.
If your project does not appear in the list then it probably wasn't setup as a Dynamic Web Project. You can fix this by by right clicking on the project to bring up project properties and then clicking on facets and then enabling Dynamic Web Project.
It is also worth having the Console view visible when starting/stopping Tomcat so that you can see the server output.
Start tomcat from the command line (not eclipse) and see if your webapp shows up. It should if you have indeed created a valid war file. If it doesn't work, check the logs.
You shouldn't be manually deploying the war file if you are using eclipse to launch tomcat. Running tomcat from eclipse does not necessarily use the same default workspace as the standalone tomcat. Check the configurations for the 'server': it may be that the eclipse launched server's webapp folder is empty.
If for some reason your webapp failed to initialize properly (error in the descriptor, an uncaught exception in a context listener, ...) tomcat will unload it and you won't see anything at http://localhost:8080/yourwebapp.
Is it there in the list of applications in tomcat manager?
if you havent done this...then follow the steps...
Go to http://localhost:8080/
Go to Tomcat manager and check if your application is there in the list of deployed applications. Try redeploying or starting the application if running=false. It usually tells you what is wrong when you do that.