I am trying to debug my code, the eclipse doesn't stating in debug mode, however it is working fine in normal start.
Below is the exception I got in eclipse popup :
Server Tomcat v7.0 Server at localhost was unable to start within 90
seconds. If the server requires more time, try increasing the timeout
in the server editor.
When I look in to the console everything looks fine, please have a look....
INFO: Loading XML bean definitions from ServletContext resource [/WEB-INF/security/oauth/details.xml]
Mar 11, 2015 11:48:38 AM org.springframework.core.io.support.PropertiesLoaderSupport loadProperties
INFO: Loading properties file from class path resource [dev/com.myPack.plat.data.mongo.config.props/mongo-config.properties]
Please help me on this.
Removing all breakpoints fixed my case
As per the solution, your main problem is that you have included breakpoint in your program. If you don't remember your breakpoint, you can skip those breakpoints during execution of your program. Follow these steps.
Only applicable for Eclipse.
Menu---> Run---> Skip all Breakpoints
Now you can start your tomcat server easily.
Happy learning, happy coding
http://www.oliverspost.com/ for more information
There are multiple reason for not starting tomcat in debug mode in eclipse. Below checkpoint could help you to resolve the issue.
If you are using Window operation system then first check your window firewall specially inbound rule. If it contains javaTM in list then enable rule if it is disable and select enable connection and click on apply and ok.
Check your eclipse preference jre and tomcat runtime configuration. JDK path is more preferable.
Increase timeout if require
Before you start the server, check process in task manager or for mac user check activity monitor. java process need to be kill if it is running.
Restart eclipse and clean build and debug. If issue still persist then take new instance of eclipse. some time eclipse internal setting also restrict tomcat debug mode.
Also there is one other possible solution, Just check out the breakpoints whether they are on line or parameters. i think to remove all those break points is best way to start server in debug mode.
normally this happens when we do pull frequently from git.
Removing breakpoints also worked for me, in fact my problems started when I set a breakpoint in this sentence:
private void process(HttpServletRequest req, HttpServletResponse resp)
throws ServletException, IOException
I don't know if the type of the parameters matter, but it was the first time this happens to me.
Restarting the tomcat couple times fixed it for me.
Related
I have a Java project which is deployed on remote JBoss server that I'm trying to debug using JPDA in IDEA.
The following was added to JBoss config to turn this feature on:
"JAVA_OPTS=$JAVA_OPTS -agentlib:jdwp=transport=dt_socket,address=8787,server=y,suspend=n"
I created a new debug configuration in IDEA for the server and it seems that the port is opened and I'm able to connect:
Connected to the target VM, address: 'here's goes the IP:8787', transport: 'socket'
However, when I add breakpoints in the app it doesn't seem to stop executing the code.
There's a REST controller which is I'm absolutely sure should trigger the breakpoint when request is sent to the server. But for some reason that's not the case.
Here's what I've tried so far:
Invalidate Caches/Reset IDEA
Make request to server via Postman instead of browser
But with no luck.
The code on the server should match with my local project.
I'm pretty convinced that the problem has to be on my side.
I've only debugged applications deployed with Tomcat, maybe there's something specific about JBoss?
Might be related to IntelliJ IDEA: Breakpoint not being hit, and is shown without the tick, just a red dot since there's no ticks and also gradle is used.
In addition, I remember when I debugged a tomcat + maven project with JPDA and added breakpoint, IDEA would evaluate and calculate something for a considerable amount of time but in the current project there's no sign of it.
When I start Server Liferay for the first time everything goes well. But when I stop the server and then I try to start it again, I get the following error:
[ServiceProxyFactory:265] Service
"com.liferay.portal.kernel.cache.SingleVMPool" is unavaiable in 60000
milliseconds while setting field "_singleVMPool" for class
"com.liferay.portal.kernel.cache.SingleVMPoolUtil", will retry...
I have a workaround: delete the %LIFERAY_HOME%\osgi\state folder content and start the server.
How may I solve this issue? Could it be a configuration issue?
When you are using a java agent with Liferay but haven't configured it completely, you can end up with ClassNotFoundExceptions and, in some cases, failures starting the SingleVMPools.
The fix is pretty easy, though, and is covered here: https://community.liferay.com/blogs/-/blogs/liferay-ce-7-x-liferay-dxp-7-x-java-agents
I wrote a Java servlet filter on my local machine and deployed it a remote (machine) web server. Unfortunately, it's been very difficult and time-consuming trying to trace errors reported by Apache Tomcat 5.5, my JSP/servlet engine. I can't keep writing System.out.println(...), saving, deploying, testing JSP pages, and so on. It's taking too long. There has to be a better, faster way.
Is it possible to remotely debug servlet filters? I don't have a web server on my local machine, which is why I'm asking about remote debugging. Specifically, I'm looking for a way to debug, line-by-line, the servlet filter, on-the-fly, as it's happening on the remote web server. Does such a method exist?
Or, is there a better method than writing to standard output. It's taking too long and I feel that must be a more efficient means of debugging Java servlet filters.
Note: I'm using Eclipse for development.
Thank you very much for any help.
Update
Thank you all for your help. I really appreciate it.
I added the JVM argument to Tomcat, restarted Tomcat. Then, on the machine with Eclipse, I entered in the appropriate info in the Debug config, put the breakpoint in, and tested. Unfortunately, it did not work. In the config, I left it as Socket Attach, clicked apply, and that was it. I pressed the debug button and it said the connection was refused. I tried ports 8000 and 8001 and both did not work.
Let me explain what I'm trying to do, that might be better.
I have a login page called login.jsp. On that page, is a form whose action attribute is servlet/LoginServlet. When the user submits the form, it calls servlet/LoginServlet, which is mapped to a class in the web.xml file. Let's call this class com.mysite.mypkg.classA. In class A, it calls a method from another class called com.custom.mypkg.classB. I want to put a breakpoint in classB.
So, using the url with login.jsp page in the Eclipse debugger won't call it. I tried using servlet/LoginServlet and that also did not work.
What should I put in for the URL? Or, do I debug this type of setup?
Thank you.
Update 2
I found this site here, which is pretty comprehensive. I ran netstat -a and noticed that the debug port is not listed. Windows Firewall is turned off, but there could be another thing blocking the port, who knows. Anyway, I placed the VM argument here and it's not working.
Thank you.
For remote debugging you need to start the server in debug mode. There are couple of ways doing that.
1 > start the server using
catinlina.bat jpda start
2 > Add an jvm argument to the tomcat java process
-Xdebug -Xrunjdwp:transport=dt_socket,address=8000,server=y,suspend=n
Once the server is started in debug mode , you need to change the perspective of the project in eclipse to debug.
Then go to Run - > Debug configuration.
Double click remote java application and enter the details such as
Remote IP address
Debug port . Default tomcat debug port is 8000. If you use jvm argument, use the port mentioned in the jvm argument.
Click Apply
Go to the java file you want to debug.
Put a break point in the source code and run the scenario you want to test (Eg Web application using browser)
Also , ensure that the code in the java file is in sync with code deployed on remote server.
Happy Debugging!!!
Peace.
Sanket Raut
You can attach a debugger to a running Tomcat instance, provided that you gave it the right command line options when you launched it.
The Tomcat Development Wiki explains how to do this, and as a bonus gives you instructions on how to set up to debug from the Eclipse or NetBeans IDEs.
Of course, attaching a debugger to a running Tomcat has both security and performance implications*.
* And OH&S issues - you might get badly scratched if you tried this on the wrong kind of tomcat ...
You should run your remote tomcat with the following starup parameter:
bin/catalina.bat jpda start
Then in Eclipse on your local machine go to Run -> Debug Configurations -> Remote Java Application, create new configuration here, use IP of the remote machine as a host and 8000 as a port there
Run this configuration and use the breakpoints in Eclipse for debugging
It might sound a bit too naive, but I always had a tough time to debug a java class during server startup. Here is the scenario:
The java application is hosted on a tomcat server.
Suppose there is a class which is invoked while the tomcat server starts up.
As soon as I stop the tomcat instance for a restart, the eclipse debug stops and I can start the debug only once the application is up and running.
Now how do I debug this class on eclipse?
Thanks for you help in advance.
You need to pass the "wait for debugger to connect" flag to tomcat. So the startup will wait until you have connected and thus you won't miss the breakpoint.
Take for example those java options to make tomcat listen for a debugger:
-Xdebug -Xnoagent -Djava.compiler=NONE -Xrunjdwp:transport=dt_socket,address=8797,server=y,suspend=y
The wait for a debugger connection flag is the suspend=y entry in the above line.
Debugging of classes during startup should work without problems. For example, suppose you implement a ServletContextListener class. The belonging contextInitialized method is called during Tomcat startup (or to be more precise: while your app gets deployed).
You can set breakpoints in this class. At that point, Tomcat is already started completely and there shouldn't be any problems with debugging.
I'm using Apache and Tomcat on a Windows server and since this morning, Tomcat stops working without any logs. It doesn't hang, it just shut down.
There's no log in Tomcat, the CPU/Memory are fines, there are no System.Exit in my code.
Anybody ever had this problem?
It happens at random, after 5-10 minutes. The application responds normally and sometime, boom.. stops working.
UPDATE : Still no clue. The Admin team will install the webapp on another box...
My script to start tomcat had last line tail -f catalina.out.
Sometime I did not kill this script, the shell then timed out and killed the script with all child processes, including tomcat.
This sounds like the JVM is crashing. Have you looked for a JVM crash log? It typically has a name like hs_err_pid*.log and is created in the JVM's working directory.
If you find a file like this and upload it, then we can probably help more.
Some questions:
Have you recently changed the version of Java you are using?
What is the exact version of Tomcat you are using?
Are you using Tomcat Native (the Apache Portable Runtime)?
Faced this issue recently.
Scenario : Tomcat started successfully but automatically gets shut down after 1 hour and sometimes this happened after 1 day and nothing is there in tomcat logs.
Issue : Actual issue was high memory usage and no free SWAP memory.
How I found the solution
If tomcat don't show any logs, then there must be something in system logs so, I checked /var/log/messages but since permission denied for me I tried /var/log/dmesg and got this
"Out of memory: Kill process 14606 (java) score 106 or sacrifice child".
In the output I noticed Swap Memory free 0 K. Ran top command to confirm the same. So, somehow there was a high memory usage which caused the OS to kill my tomcat process.
After spending hours finally got the reason.
ps -ef | grep tomcat showed that there were several tomcat processes running for the same application. It seems that, earlier tomcat shutdowns might not have taken successfully and the processes were not killed even after the shutdown due to some reason, which was causing the high memory usage.
So, killed all running tomcat processes using kill. SWAP memory got freed.
Started tomcat again, worked fine. :)
Recently I had this problem, If somebody faces the same issue in future I hope this will help.
Scenario: Tomcat shuts down without any logs or errors
Root Cause for my problem: synchronized method accessed from a task using TimerTask
I had a singleton class with a synchronized method accessed from various threads based on timer or user action
some times this method will take up to few minutes to complete. When TimerTask is waiting on this method for sometime (I guess timer is timed out /thread is killed or something is happening in the background) and the moment the lock on the method is released the tomcat is getting killed.
So I removed synchronized keyword and removed singleton and made some code changes for thread safety. Then the problem is gone.
How I found out: I had a log statement in the first line of synchronized method and everytime the tomcat shutdowns i found this message in the last few lines.
Regards,
Phanindra Kasturi
things to look for in debugging an issue like this:
Look at the logs directory ($TOMCAT_ROOT/logs) to make sure none of the log files have any stack traces
Look at the tomcat startup script to make check the location of the log files to see if the logs are not being written to another directory.
Another reason could be some other user/process could be issuing a kill -9 that could kill tomcat without giving it any chance to log errors.
another possibility is that some process was started this morning on the box that is binding to a port that your server requires.
Are your servlets or one of it's dependencies allowed to call System.exit()? (Not sure how locked down Tomcat VMs are in that sense)
I've had developers thinking it's ok to use exit(666); on detecting a non-invertable matrix (which isn't good, but sure as heck not fatal). Arrgh. Perhaps you have some similar culprit in your system?
I noticed CATALINA_OPTS in my path and that was set for a lower JVM size. Hence, the crash and no log trace of tomcat was found. The server automatically shutdown in less than 2 hrs.
check, CATALINA_OPTS or JAVA_OPTS -- these might have jvm settings. either increase them or comment them out and increase the swap memory.
“The Service on local computer started and then stopped ,Some services stop automatically if there are not in use by other services or programs.”
I gone through the problem i have tried so many ways to get out of the problem finally i got the solution as follows.
1) Click Run Command from start button.
2) Enter Services.msc then click OK,you will get all the services in your computer.
3) Select your service and right click on the service and select Properties
4) Goto Logon Properties and select Local System Account then click OK.
This will work.
Sometime it happens if some other program is running on the same port. For example Skype. Shut down that program before you start Tomcat.
try to clean your elipse projects because you could have tried to add another server which used port 8080 then when you try to execute the tomcat server externally that defaulty uses port 8080 the tomcat server automatically shutdowns after cleaning the project copy the new war file and paste it in bin it works fine
conclusion: when the server tries to use the port which has already been acquired you will see such type of issues.