I am doing load test for my project, when i tried to use jconsole to monitor when the server is restarted connection is getting lost is there any solution for this?
Thanks
jconsole connects to a process, when the server is restarted it gets a new process id, and jconsole did not know of the new process that is created. There is no other but you have to connect it yourself.
Jconsole is connected to a process (jvm). When your server is stop, the process doesn't exist anymore and so the jconsole connection is lost. And so you have to connect jconsole to the new process created when you server is starting.
is there any solution for this?
One way to ease the pain is to use a JMX URL instead of a process ID. The JMX URL never changes on restart so while you have to reconnect anyway, at least the process is less painful.
URLs are of the format service:jmx:rmi:///jndi/rmi://hostName:portNum/jmxrmi. Not sure what your server is, but here's how to enable it on tomcat.
Related
I am really stuck with why my GlassFish connection pool does not ping successfully. When I try a long-running process alert comes up which I have to remove in order to access options again in the admin console.
Things to note:
I can ping the connection with the same settings locally using the same driver (I am trying to connect on a Dev machine).
I have another SQL Server database which is pingable from the development Glassfish installation I am trying to create the new connection on (the database is a SQL Server database).
I cannot see any log output of any worth, the only thing it seems to print out is "Interrupting idle Thread" messages.
Any suggestions on what to try next? Does anyone know if I could increase the logging detail would this likely give me more information?
Thanks,
Matt.
Copy connection jar files to 'domains\domain1\lib\ext' folder. Then restart your glassfish.
Is it possible to make my local computer function as a gateway in Java? I need the other local machines to connect directly to my computer to see if they are alive or not.
You could run a Java server program on your desired PC and let it listen on a port. Then you could use other programs (browser, other Java programs etc.) to connect to this port, and send commands to be executed by the Java server program.
If you just want to see if the PC is turned on or not, I'd just use the ping command though. Or see this answer: How to do a true Java ping from Windows?
Surely it's the other way round? Surely you want to connect to the other machines to see if they're alive? In which case see InetAddress.isReachable().
Try this.
Create a Java Server Socket, which keeps listening to the client at some port.
Write a client in Java which connects to the Server, wrap the connection logic in try-catch block....
If your host is alive the try code is executed which contains the code to connect to the
Server, if this connection process fails you will get UnknownHostException, here you can instead type a message that the connection failed.
You could more easily manage and control this by polling for other devices from a central server. If possible, avoid unnecessary client/agent apps that might tax your development and support resources as well as taking up RAM on the client workstations.
There are many monitoring tools that already do what you want. I'd have a look at Nagios, for example.
If you want to develop your own app, do your own quick troubleshooting, or just get a feel for network discovery tools, then take a look at NMAP. You could, for example, search a subnet for anything that responds to TCP:445 and see what Windows machines are alive.
If you do go the Nmap route, please have a look at Nmap4j on Sourceforge. It's a Java wrapper API that simplifies the work needed to integrate Java and Nmap.
Cheers!
I have an application runs in jboss 4.2.2 server with jdk 1.6. The program has bug in it that it doesn't set http connection timeout when it opens its the connection. So when the third party side has issues the connection is hanged forever which makes the thread hangs as well. And soon we are running out of thread. However, due to the release cycle we can't put a fix in immediately. I was wondering there is a way to terminate a network connection from outside the jvm? So the thread can be release back to the thread pool? I potentially has a lot of connection open to the same third party site so it is nice to figure out the problem connection and just kill that one.
Thanks,
While searching for a question of my own, I came across what seems to be a great tutorial on how to externally kill a thread.
http://www.rhcedan.com/2010/06/22/killing-a-java-thread/
You can grep the output of netstat and kill the connection using tcpkill, and run this using cron.
However this cannot be more than a very temporary solution.
This ServerFault Q & A may be relevant. It explains that tcpkill will only work if there is active traffic on the connection.
(This is because ... apparently ... tcpkill works by sending a TCP RESET packet. In order for this to work it needs to know the correct sequence number, and it can only figure this out by examining other packets for the session.)
Some background information.
- Running a java server on localhost
- Running a webserver on localhost
I would like a webpage to have a 'server status' feature which lets me know whether the server is running or not. My question, what is the best way to do this?
When I launch the java server, I write a flag in the database to signify that it is running.
Javascript/PHP sockets to try and bind on the same port. (Not sure if possible yet)
Shell script to locate the program in the task list.
Thanks!
When I launch the java server, I write
a flag in the database to signify that
it is running.
would not be of much help if the server should segfault.
Maybe have a look at http://mmonit.com/monit/
what is pretty much what you are looking for
I suspect the simplest method is simply for your web service (backend) to try and connect to the port that your server is running on, and provide an automatically refreshing page that reports this status. If your server goes down then you'll get an faster notification than if you're polling (say) the process table.
Of course the fact that you can connect to the port doesn't really give you an indication of whether it's working other than it's opened a port (e.g. it may have no resources etc. to service requests) but it's a start.
when i try to start my java based server there is a message that says the port is already in use...
And all my java web servers are stopped... So if anyone can help me i will appreciate it...
If there is really still a process that has the port open, you can easily check for that (and close the process) via TCPView. It might be that the port is just lingering (for example due to not being shutdown properly), in which case you'd have to wait for the socket to close and check that the code is clear with regard to that.
I was trying to establish socket communication between PC(JAVA Server)<-->Android(Client)
on Debugging, popped the problem : Address already in use
instant/feasible resolution i found out was to:
run cmd as adminstrator
netstat -abn
find the process listening to the port of intrest
terminate the process from task manager
PS : Unlike from an external application mentioned in previous answers, steps in this answer allows you to find out the used ports with the resources already present.
A few options... us TCPView to find the program that has the port open and kill it... reboot... just reset the network connection. Try those.