How to see tomcat console when tomcat started from services - java

This might be silly question but I really don't know it.
I have performed some changes in my web application in java/jsp.
Tested it in localhost in eclipse where I can see logs in console.
After that I have deployed the changes to beta server and its not
reflecting as in localhost hence want to see running logs through
tomcat console but Tomcat is already running and was started with
services utility of windows.
Is there any way to open console of running tomcat.
I do know that we can see tomcat logs as well, but running console
will be preferred for me as there are multiple projects are running on
same server.

You can check log file(s) in the tomcat-home/logs folder.

You can attach Eclipse to a running process if you have started the server with the right settings: see Attach debugger to application using Eclipse On windows, you can either delete and reinstall the services as in https://tomcat.apache.org/tomcat-7.0-doc/windows-service-howto.html or, you can add these parameters in the Windows registry for the Tomcat you are running: see http://www.tomcatexpert.com/knowledge-base/allocating-more-ram-tomcat-windows . I would be very careful with the registry hack unless you've hacked the registry before and are comfortable doing it.

Related

Debug code on one machine, run JBoss on another

Is it possible to setup JBoss server on one machine (PC) and then connect to it from another machine (laptop) ? I want to be able to run/deploy my application on the server on the PC and through Intellij on the laptop debug my code using that JBoss instance on the PC. I'm running a domain version of JBoss. Right now I have both the server and client running on the same machine. I'm not sure how to get around doing it, thanks for any help.
Yes it is possible to remote debug your application.
If you look at the first lines in the startup script standalone.[sh|bat], you'll see that debug agent can be enabled with the --debug command switch.
Switching this debug option will enable the JPDA and will listen on port 8787 by default.
This can also be achieved using JAVA_OPTS (look at the end of standalone.conf[.bat])
Once you started WildFly, you'll need to add a remote debug configuration in IntelliJ using the IP and port of your server. Here is the official documentation.
For remote deployment, you should have a look at the jboss-cli.
In Eclipse you can connect as follows, I'm sure Intellij must have something similar as well:
Run-> Debug Configuration->Remote Java Application. Here you can define the Host and Port of the application server, irrespective of it's location, be it local or any remote location.

How to Debug Java EE Web application When it's Live

I want to debug a java EE web application that run on Apache Tomcat. Is there any way to debug the application without stoping the server.
You can use remote debugging, but you'll need your server (once) to be started with the correct arguments for that. For instance, since you are using Tomcat, you can add these arguments in catalina.sh:
-Xdebug -Xrunjdwp:transport=dt_socket,address=8000,server=y,suspend=n
Then you can attach your debugger to REMOTE_IP:8000 and start debugging.
Always take into account that you are working in a production environment, so be careful with this.
The trick here is to start Tomcat with remote debugging enabled.
The easy way to do this is to use the options jpda start if you start tomcat using the catalina.sh or catalina.bat shell script.
If you are starting Tomcat using your IDE or something, then you must add the following options to the JVM that runs Tomcat:
-Xdebug -Xrunjdwp:transport=dt_socket,address=8000,server=y,suspend=n
After you do that, then you need to configure your IDE to connect to the remote debugging port.
Check this Tomcat FAQ for more information.
you can't. The server have to be started in debug mode.
I invite you to read the wiki: http://wiki.apache.org/tomcat/FAQ/Developing
If you don't want to restart your live tomcat.
Create a new server (configured in debug mode), then copy you application on it.
Debug on this server.

tomcat server instance debugging in the eclipse

I have the following configuration in the eclipse
Created a tomcat 7.0 server instance from the servers view.
Created a sample web application and deployed in the server through maven-tomcat-plugin and tested it in the browser ( started the server by right
clicking the server from the server view and selected start )
Tried to configure the remote debugging settings in the created server instance using JPDA options,i added the env variables in the server setting.
i could not connect the debugger to the server when i start the server from the eclipse as like previously.
But it connected seamlessly when i start the directly from the installation directory using the command prompt as like
catlina.bat jpda start
After that i tried this I started the server instance by ( started the server by right clicking the server from the server view and selected DEBUG mode)
I got the Break points in the code and even Hot Code replacement
working!!!
Can anyone explain the following?
What goes wrong when i tried jpda options for the remote debugging with the created server instance in the eclipse?
How the debug option and Hot Code replacement works with the server instance?Is this remote debugging or something else?Can you explain on this one?
the eclipse tomcat plugin spawns a separate JVM while running, you can confirm that in the windows task list, using ps in unix like systems or using visualVM.
That VM is launched in debug mode with the JPDA parameters set by the plugin itself, and that is how the debugging mechanism works, it's based on the JVM functionality. You can confirm which jpda parameters are used by using visual VM, that comes with the JDK.
I don't think you can override the JPDA parameters that the eclipse plugin setted for you, that's why in point 1) it did not work. For 2) it works via remote debugging made transparent by automatic setting the parameters and connecting the remote debugger once the server starts.

Tomcat returns 404 status

I was trying to change the user who runs the tomcat process.
In process of changing I have added new user and made tomcat run under him.
how now if i ping the tomcat, I get 404 error.
I am not sure how to proceed.
Can I check if tomcat has loaded all the classes ?
Can I check anything else to make sure tomcat loaded the servlets.
Is there anything else I can check to resolve this 404 error.
Thanks a lot
You didn't say what operating system you are using. Look in your tomcat logs directory and verify that tomcat actually started up. A lot of times the log will be called catalina.out. It should say "server starting up in X ms". Also, look at the running processes on your system. There should be a Java process running for Tomcat. You can also use netstat or dig on Linux to see if there is a process listening on a particular port. You can check what port Tomcat should be listening on by looking in the conf directory and looking at the Tomcat server configuration in the server.xml file.

problem with tomcat 6

I just started the tomcat and opened my browser and gave http://localhost:8080. But i found 404 error.
I tried running the same in eclipse i got the following error message.
Several ports (8005, 8080, 8009)
required by Tomcat v6.0 Server at
localhost are already in use. The
server may already be running in
another process, or a system process
may be using the port. To start this
server you will need to stop the other
process or change the port number(s).
What could be the problem?
I just started the tomcat and opened my browser and gave http://localhost:8080. But i found 404 error.
Tomcat runs fine, but there was nothing to serve on the given URL. There's no ROOT webapp anywhere or there's no welcome file. You need to either deploy a webapp or let the URL point to a valid resource.
I tried running the same in eclipse i got the following error message.
Several ports (8005, 8080, 8009) required by Tomcat v6.0 Server at localhost are already in use. The server may already be running in another process, or a system process may be using the port. To start this server you will need to stop the other process or change the port number(s).
A port can be used only once by only one application at time. This indicates that you haven't shutdown the first instance of Tomcat before you run the one in Eclipse which is apparently been configured to listen on same ports.
If you are using windows, probably tomcat is running as a service.
Control Panel -> Administrative Tools -> Services -> Find Apache Tomcat 6
Right Click and choose properties
Startup Type : change it to manual, and hit the stop button.
click, ok and close all windows.
You can now run tomcat from eclipse IDE without changing the ports.
Just go and kill the javaw process.

Categories

Resources