I wanna use an embedded Tomcat V6. The code works perfectly, but only as long as the programm is running. So if there is no Thread.Sleep it will exit immediately, otherwiese keep on running till the time is up.
How can I keep the emmbedded Tomcat alive. setAwait(true) should deal with this, shouldn't it? But i does not work. Tried to figure out more about this, but there is nothing in the description. Any other ideas?
If you want your embedded Tomcat to run indefinitively you will need some code to handle outside administrative requests (like restart, shutdown, stuff like that). That will go in your main thread, incidentially keeping the Tomcat instance alive.
This class should do what you are looking for.
Related
In our confluence server (tomcat 9 based), we added interruptThreshold to 30mins to kill long running threads (usually these are stuck threads).
However, interrupts for certain threads are not succesful (and it is okay, as it's mentioned in documentation that it doesn't work in all cases), but these specific threads gets killed after 8 hours.
These specific threads are related to a custom plugin and our developers say they don't have such 8 hours setting anywhere and I couldn't find anything in tomcat or in confluence.
We will be able to replicate the stuck threads, but how to findout what's killing them after 8 hours?
Such actions on Tomcat should be logged in the {CONFLUENCE_HOME}/{DATA_FOLDER}/logs folder, please find these logs files and look for this operation/timestamp.
If for some reason, logs are not fully reflected, you can set it as described in
https://confluence.atlassian.com/doc/configuring-logging-181535215.html.
Also, you can control loggng in -X... Java / Tomcat statements when running start.bin/start.sh.
We use Wildfly 10.1.0.Final here and over the last few days some curious behavior has manifested. First it was one user, but now over the course of the last few days, it's up to four users.
In house, we typically run Wildfly through standalone.bat on Windows (although I use mine as a service, and on Ubuntu).
The behavior is that after about an hour, a second instance of Wildfly attempts to start. These users do not have it installed as a service; it's run purely through the script. Sometimes it takes about two hours, but it's typically one. What we'll see in the log is that the Configured system properties: line prints in the log, followed by the usual startup information. There is no previous shutdown, no restart; the existing Java process controlling Wildfly is still running. A second whole Java process is being started. It gets about 1 second into the startup process, at which point Undertow sees the 8080 port is already in use, and then stops. What happens though, is that the two instances seem to start stepping all over each other and the end result is that both Java processes are still running, and our application is undeployed, with accompanying .undeployed file.
I have searched around but have turned up nothing. Are there any facilities in Wildfly to try and troubleshoot this? Is there a way to determine why Wildfly was started (to try and see why the second instance is popping up)? I think it's unlikely to be anything in our code that makes a whole new second Java process pop up, because we don't have any such thing coded in, but I'm open to possibilities.
EDIT: To add a detail, I just noticed that when this happens, while the original process was started by the logged in user (as shown in Windows Task Manager), the second process was started by the SYSTEM user. Keep in mind that Wildfly was not installed as a service (i.e. it's not erroneous service startup).
SEVERE: The web application [/webapps/bb-nautilus-BBLEARN] appears to have started a thread named [MessageQueueHandler-bb-nautilus-content-blitz-0] but has failed to stop it. This is very likely to create a memory leak.
If an application starts all kinds of stuff (registering jdbc drivers, starting threads, ...) when it is fired up, it is the responsibility of that application to also clean up after itself when it is stopped.
Are you the author of this application ? Correct your code. Not the author of this application ? Submit a bug report.
In the latter case, until the bug is addressed it might be possible to add a ServletContextListener of your own making to the deployment. But clearing up leftover Threads from "foreign" code is at any rate going to require you to figure out how to find those Thread objects and then subsequently stop() them, which is a deprecated method.
MessageQueue may be busy doing something strange. It refuses to exit. So, reboot the server and try starting Bb Learn after that. Post the new error after you know that no part of Bb Learn was running after a failed app restart.
It is really frustrating especially when I am working with sockets. Anyone know how to fix this? I constantly go into the task manager...
I think the most likely reason for this is a thread which does not terminate. This might be caused by the thread waiting for a time out, but a number of other reasons might prevent the thread from exiting as well.
I suggest you connect jvisualvm (part of the jdk, located in the bin folder) to your application and investigate what part of your application stays alive.
Edit: If your application runs in your systems default vm, you should see it in jvisualvm out of the box. But if you are using different vms, you have to start the application with appropriate parameters in order to connect jvisualvm to it.
This short guide explains the settings pretty well.
I have the task to port a standalone java deamon program to J2EE on weblogic.
Old: The java program starts two threads which loop endlessly based on an interval that can be configured via a properties file.
New: The program should run on weblogic 10.1.x and start when the managed server it will deployed to is started or the servlet is initialized and it shouldn't have to be invoked by a client.
I know already that creating your own threads is highly discouraged for weblogic so I'll search for another way to make this happen. I already tried via startup class, but that means the server remains in the state STARTING forever because naturally the programm is designed to run forever, I didn't know the server is actually waiting for the Startup Class to end. Next best thing I know of would be the usual servlet by calling its URL once and implement starting the programm in it. Even then, how would you prevent the browser from getting hung up on the servlet call (because it does run forever) without making the program logic asynchronous by creating a thread? Also I read something about Listeners, would that be the thing I should be looking for?
One last thing, I definitly need to run it on weblogic, so suggestions for other solutions wouldn't help me.
This is a confusing question because it's so basic... You just need to create a web service with your endless loops in it. You don't need to hit a URL to start it. Just deploy a .war or .ear file with your code and you're done.
http://docs.oracle.com/cd/E13222_01/wls/docs81/webserv/example.html