How to launch and debug spring application on linux server? - java

I have a spring application on my local PC. And a VPS, run centos OS and has installed tomcat. My application could run well in localhost, but after I put it on the server(/tomcat/webapps) through ftp. It doesn't work any more and the tomcat will stop service when start that application. So what's the right steps to run application on tomcat on a linux server, and how can I check what's wrong with the application(like the debug log on local Eclipse)? Thx!

Can you check Tomcat's server logs, (located in <~tomcat-installation-directory>/logs? You may find the possible cause for your server's crash. If you server and application is up and running, then you may do remote debugging using Eclipse.

Related

Timeout when starting Tomcat from Eclipse

My server.xml is configured to use Apache in connection to Tomcat. If I start Tomcat with startup.sh, it works fine because I can access a simple html-file located in webapps/ROOT at port 80 and 443.
Netstat -tulpn shows that a java process occupies the 8005 and 8009 ports.
Then I run shutdown.sh, and the netstat shows the ports are no longer occupied.
I try to start Tomcat from Eclipse. The console says it is started within 10000ms. The ports 8005 and 8009 are occupied by a javaprocess, but in Eclipse I get timeout, and the state of the server is 'Starting'.
I try to start a html-script that calls the restful web service, but I get 503 Service unavailable. I've stuggled with this the whole day. I do not understand what to do with this. Please help !
I have just solved this problem. It was due to my java version 8 was not supported by Tomcat version 8.5. I had to install tomcat version 9. Then I got another problem when I added tomcat to Eclipse. That was Unknown version of Tomcat. I eventually solved that problem too by setting my user as the owner of the apache-tomcat-directory.

Accessibility of Tomcat during debug

I am trying to debug Web Service running on Tomcat 7.0 via Axis2 in Eclipse Mars2.
I have started Tomcat inside Eclipse with this arguments:
-Xdebug
-Xnoagent
-Xrunjdwp:transport=dt_socket,address=8000,server=y,suspend=n
I have created the remote debug configuration for my project and started it. Everything seems fine: there's tomcat running and in debug perspective I see my Remote Java Application with some Daemon threads.
But how do I test it? When I try to access tomcat via browser typing "http://localhost:8080/axis2/services/REButils/" it returns 404, Soap UI returns the same?
How do I invoke my service if it's unaccessible?
I've managed to start Tomcat separately in jpda mode and it worked fine with eclipse remote debugging.
No idea why 404 happenned while starting apache from Eclipse though.

Application running on wrong apache Tomcat server

I created an application on Eclipse, locally on my PC. Once it was working I created a war file and deployed it to my Linux server. Now the problem is that the application is still running on my local Tomcat. I am not sure why this is happening.
Is there any place I can look to find the cause of this issue?
I created this application in JSP/servlet.
Your query looks invalid , application can keep on running on your local PC and server both , its about which one you access i.e. which url you use in browser.
To stop the application from running on your pc there are a lot of thing you can do to stop it.
If you are running windows and tomcat is installed as a service then you can stop the Apache Tomcat service by opening services.msc
You can also uninstall tomcat using $CATALINA_HOME/uninstall.exe
You can also access the tomcat's manager application and un-deploy your application. To do this go to http://localhost:port/manager/html. Enter the credentials you used during installation to log in. Find the application from the list there and stop it.
You might check the running java vm by jvisualvm on your OS(with GUI). Or check the current running processes both in PC and linux server.
If you have not stopped the application running locally it will continue to run till you stop the tomcat server. Application can be packaged into a war file while tomcat is running.
If you have started the tomcat with in eclipse, use "Server" view in eclipse to stop the tomcat. If you have started tomcat via command line, you can use shutdown.sh or shutdown.cmd to stop the tomcat.

eclipse - Java Remote debugging does not hit the breakpoint

I am using Jetty 8 and trying to connect from Eclipse(Remote Debugging). I am using Java 1.6. I have the latest code in eclipse. The port is not blocked in firewall.
Jetty is running on port 8080. I opened the debug port on 5999 using the below command
java -Xdebug -agentlib:jdwp=transport=dt_socket,address=5999,server=y,suspend=n -jar start.jar.
I opened the application in browser(https://[servername]:8080) and logged in to the application.
Later I connected in eclipse(Run-->Debug configurations and gave hostname and port(5999)), breakpoint is not hit when I browse through the application in browser. But I could able to see the Threads in the eclipse, only the code is not hit in eclipse

Failed to Start Apache tomcat from eclipse juno in linux at port 80

At the window platform I have run tomcat from eclipse juno. But at linux I face this problem
When I run web project from eclipse I got this error message, while from command line I can able to run tomcat.
Error Message is - Port 80 required by Tomcat v7.0 Server at localhost
is 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).
I already check my port using nmap and other command
The main point is that when I run tomcat from command line then it start, but when I start this from eclipse I got this error
First, check again whether the port is indeed in use. I believe that you have apache web server (httpd) that is taking the port.
Second, on linux only processes running under root user can use lower ports (under 100). Probably when you run tomcat from command line you run it as root (e.g. using sudo), however when you are running it from eclipse it is running under your user.
The solution is:
for development use other port. E.g 8080.
For production:
use special user account (not root) to run tomcat. E.g. user named tomcat. Configure it to listen to port 8080. Run apache web server (httpd) under root user configured to listen to port 8080 and configured to be connected to tomcat using mod_jk. This is most secure and reliable commonly used configuration.
After starting Tomcat from the command line you also stopped it? Because if Tomcat is still running from the command line you get this error while trying to start it again out of eclipse.
Is it right that you run your Tomcat on Port 80? This wont work in an Linux environment, because Linux comes up with an Apache Webserver listening on Port 80.
I believe linux comes with a apache server, which may be running on port 80. So when you try to run the tomcat on the same port, it is complaining port already in use. To find out if apache is installed you can use the rpm command. I believe it is rpm -qa will tell you all packages installed. Now as far as the directory for apache files it is normally
/var/www/htdocs.

Categories