Debugging Webapps in Eclipse - eclipse

I want to debug a webapp through Eclipse. The webapp will be running on a Tomcat 7 instance that I have configured within Eclipse, and thus everything, including Tomcat's launch will be done from within Eclipse.
Now, my question is what is the best way to debug the webapp in such a situation. Is local debugging possible, or the only solution is remote debugging.
I know how to do remote debugging, but given that everything is done from within Eclipse, I wanted to see if there is a better way of doing it.

Click on Run -> Debug Configurations.... On the left side you should have your tomcat server listed. (if not, you first have to define it in the preferences).
Configure your VM settings and whatever you need, then just click Debugin the lower right corner.
Your server should now start in debug mode, and stop on breakpoints.
From now on the server will be included in popdown menu of the Debug-Button in your toolbar.
Alternatively you can add the Servers View (Window -> Show View -> Servers), select your server and start it in debug by right-clicking

Related

How to enter debug mode in eclipse when launching tomcat from cmd

I am using apache-tomcat-8.5.24 and have the workspace in Eclipse configured and tomcat working properly.
I need though to do some debugging, but I dont know how can I enter debug mode in Eclipse with the tomcat running from cmd? I have done it several times in the past but I was always launching tomcat in debug mode from my IDE.
You would have to enable remote debugging on tomcat for which the following catalina property needs to be added in tomcat startup.sh or tomcat.start.sh or wherever you add tomcat startup properties:
CATALINA_OPTS="$CATALINA_OPTS
-agentlib:jdwp=transport=dt_socket,address=8787,server=y,suspend=n"
Then restart tomcat.
After this is done, you need to open eclipse, and to go "Debug --> Debug Configurations -- type in the search box "remote java application", and create new, then select your module/java project which you want to debug and give the port number same as given in the above command (i.e. 8787 in the example above). Then Apply and launch.
While the other answer may solve someones problem, it didnt solve mine. Though the way i followed and solved my problem is:
First you start tomcat (all services up), and then you start the debug mode in eclipse!!!
For tomcat as i use the catalina.bat jpda run to start my tomcat i just edited it and used it as follows:
catalina.bat jpda run - agentlib:jdwp=transport=dt_socket,address=8000,server=y,suspend=n
For eclipse:
1)In Eclipse’s menu, select Run > Debug Configurations…
2)A new Debug Configurations window will appear
3)In the list on the left, select Remote Java Application. Don’t worry
too much about the word “remote” here. It just means that the JVM
process can either be on the local machine or another machine across
the network.
4)Select New in the context menu (you can either right click to see
the option for it, or select the icon above the list)
5)A new Remote Java Application debug configuration window will appear
6)Change the Name field to say “Tomcat (local)”, or the name of your
web application, your choice. The name you put here can be anything,
but shorter is better because the name will show up in menus.
Eclipse Run Configuration for a separate Tomcat JVM
There are at least three subtabs of configuration: Connect, Source,
and Common. Under the Connect subtab, there is a Project field. Select
the Eclipse project that represents the code you want to debug. For
instance, if you want to debug your webapp, select your webapp’s
Eclipse project here.
All of the other default settings should be fine. You should probably
look through the settings to see if you would like to change any
options, just beware of changing settings if you aren’t sure what the
effect will be. Make sure that the port number you’re setting in the
Connect subtab is the same port number you configured your Tomcat
JVM’s debug server to listen on.
Click Apply, then click Debug. At that point, your Eclipse’s debugger
will connect to your Tomcat JVM’s debug server. Next, switch to the
Eclipse Debug perspective. In Eclipse’s menu, select Window > Open
Perspective > Debug.

Breakpoints not working in eclipse [duplicate]

I want to debug a webapp through Eclipse. The webapp will be running on a Tomcat 7 instance that I have configured within Eclipse, and thus everything, including Tomcat's launch will be done from within Eclipse.
Now, my question is what is the best way to debug the webapp in such a situation. Is local debugging possible, or the only solution is remote debugging.
I know how to do remote debugging, but given that everything is done from within Eclipse, I wanted to see if there is a better way of doing it.
Click on Run -> Debug Configurations.... On the left side you should have your tomcat server listed. (if not, you first have to define it in the preferences).
Configure your VM settings and whatever you need, then just click Debugin the lower right corner.
Your server should now start in debug mode, and stop on breakpoints.
From now on the server will be included in popdown menu of the Debug-Button in your toolbar.
Alternatively you can add the Servers View (Window -> Show View -> Servers), select your server and start it in debug by right-clicking

Debug GWT application on server side

I want to know how to debug the GWT application on server side. I am using eclipse and GWT default server. I run my application by right click and run as web application. I tried to use System.out.println and it didn't work.
If you use the embedded server of DevMode, then it works just like for client-side: Debug as… ⇒ Web Application then set your breakpoints (either client-side or server-side, they run in the same JVM).
When you change your server-side code, Eclipse will recompile it on-the-fly (unless you disabled it, in which case you'll have to explicitly build your project) into your WEB-INF/classes (this is what the GPE should configure), then hit the "reload" button on the DevMode view in Eclipse (the two yellow arrows). The next call from the client to server will use the new server code (without the need to reload the app in the browser).
If Eclipse proposes to hot-swap the code on change, you can say "no".
Follow the below steps to run in debug mode.
Right click on the project -> Debug As -> Web application
OR you can follow below steps also.
Click on Debug As.. as shown in toolbar of Eclipse -> Debug configuration -> Debug

Running JBoss Server from eclipse [Adempiere project]

For testing the webui of adempiere, I need to build the code and deploy it every time with all change. Its much time consuming. The remote debugging is quite useful. But the build, setup and server running time remains the same.
Can we run the JBoss server through eclipse ? Hence can we write the code and test it on debug mode?
You Can run the jboss server in eclipse and deploy adempiere projects in jboss also
Download the jboss4.2.3 and place into your desire location in your drive.
Extract the jboss zip file (let say /home/Giri/Server/jboss4.2.3GA/....)
Open your eclipse IDE, and open the server pane
Click on the Window And choose Show View
It will open a popup and select the server (By writing the help text you will get)
Right click on the server editor, New---->Server
It will open the a new server pop-up
Select the jboss and select the jboss version as the 4.2
Click on the Next button
Here you need to select the your jboss server path (as previously i mentioned /home/Giri/Server/jboss4.2.3GA/ )
Click on the Next (no need to change the ports)---> Finish
Don't bother about the project Add And Remove Project
Now in server editor you will get a jboss server details in single line
Now double click on the server, or Right click on the jboss server And select the Open
It will open server details page
Now update the following settings
In Publishing :- Select Never select auotmatically
In Time Out :- Set start time as 5000
Save(CTRL+S) the settings and close the settings
Click on the Open launch configuration
It will open the a pop-up
Now Navigate into classpath tab, And select the User Entries and add the following mentioned jars by clicking on the Add Jars button at right side
trunk\tools\lib*.jars (Except cglib.jar, log4j.jar, jnlp.jar, javaee.jar)
trunk\japserreportstool\lib*.jars (Except jfreechart***.jar)
and add the javaw.jar from the jre library (by using Add external jars)
If you want to configure the properties files then add the properties files details into Arguments tab
Save it and close it
Right click on the server and Click on the Add And Remove Select available installers and add to right side tab, and click on Finish.
Run click on jboss and publish after that start it....
Hope your server will start properly .....

Server configuration is missing in Eclipse

Im using Eclipse Galileo, and have configured it for Apache Tomcat . I have added Apache Tomcat 6.0 to Windows->Server->Runtime Environments, with the following settings:
Tomcat Installation Directory - C:\apache-tomcat-6.0.24\apache-tomcat-6.0.24
JRE - Workbench Default JRE (This points to C:\Program Files\Java\jre6)
Now, I create a Dynamic Web Project, and add a JSP file to it. But, when I run the project I get the following error:
The Tomcat server configuration at \Servers\Tomcat v6.0 Server at localhost-config is missing. Check the server for errors.
Any way to fix this?
Probably, you have some problems with your server's configuration.
Follow these steps to remove and create a new one, it might help you.
In Eclipse
1. Window -> Show view -> Servers (If you cannot see it, you might need to choose Others -> Server)
2. From Server view -> Delete the server which has problems.
3. Right click -> New -> Server : to create a new one
In my case, after new server was created, I get rid of this "localhost-config is missing"
I faced the same problem once. THe reason for this is that even though the server is available, the config files are missing. You can see the server at Windows -> Show view -> Servers. Their configuration files can be seen at Project Explorer -> Servers. For some reason this second mentioned config files were missing.
I simply deleted the existing server and created a new one with this the config files were also created and the problem was solved!
Similar solution is given at here by Emertana EM
java.lang.NoClassDefFoundError: org/apache/juli/logging/LogFactory
In Eclipse Neo
1. Window -> Show view -> Servers
2. Right click on server -> choose Properties
3. From General Tab -> Switch Location
As Yoni already mentioned, you probably deleted the project named "Servers" from your Project Explorer. If config files for the server still present on a file system, the quickest way to restore it will be Right Click in Project Explorer->Import->General->Existing Projects into Workspace, then select the root dir where Servers dir located, set checkbox near "Servers" and finally click Finish. If everything works as expected, you should see the 'Servers' project added to the Project Explorer view and your old config files will be there. Finally, save the tomcat configuration which you had open. You can startup your Tomcat server without errors now.
From project explorer ,just make sure that Servers is not closed
You need to define the server instance in the Servers view.
In the box at the right bottom, press the Servers tab and add the server there. You by the way don't necessarily need to add it through global IDE preferences. It will be automagically added when you define it in Servers view. The preference you've modified just defines default locations, not the whole server instance itself. If you for instance upgrade/move the server, you can change the physical location there.
Once defining the server in the Servers view, you need to add the newly created server instance to the project through its Server and Targeted runtime preference.
If you're not too attached to your current workspace you can create a new workspace, follow BalusC's steps for server creation, and recreate your project in the new workspace.
I got the same error after installing Eclipse Java EE IDE for Web Developers(Juno) but using the workspace of a much older Eclipse installation. When I created a new workspace I was able to get my Tomcat server running without this error.
Did you, by any chance, deleted stuff from your workspace, or moved it around?
When you create a server for the first time, either globally or through the project's "run on server" settings, Eclipse creates a project in the Servers view, as BalusC pointed out. Eclipse stores this server inside your workspace, in a project called Servers. The project needs to be open for tomcat to run.
(If you want, you can store the server settings elsewher. You can right click and open the server instance from the Servers view and configure various parameters and locations)
This happens when Eclipse shuts down incorrectly - delete the server and then re-create it again.
Remove the server from IDE and install again to it.
In my case, the server list was empty for Apache in "Run Configurations" when I opened
Run > Run Configurations
I fixed this by creating a server in the Servers Panel as in other answers:
Window -> Show view -> Servers
Right click -> New -> Server : to create a new one
this worked for me
In the Server's tab in Eclipse, Stop the Tomcat server
Right-click the server and select "Clean..."
Right-click the server again and select "Clean Tomcat Work Directory..."
In the Eclipse, select the top-level menu option, Project > Clean ...
Be sure your project is selected and click Ok
Restart Eclipse
4th Step is most important.
Go to Servers remove the existing server by clicking delete.
Click the blue link to launch the server.
Set a new runtime environment.
Close the Eclipse and launch it again.
Boom it works!