views:

200

answers:

0

I m using -javagent agent.jar to instrument java classes in tomcat.While using -javaagent:,in manifest file of the jar we will mention the premain class which gets called first and from there we can start instrumenting Byte code . From my Premain class(which get first called ) I add shutdownhook class to JVM. Runtime.getRuntime().addShutdownHook(ws). ws is object of my Webserver class that extends Thread.In start() method of ws class i create a server socket new ServerSocket(port).While the JVM shutdown run() method of Ws (Shutdownhook )is called and i close the serversocket ss.close().In 64 bit linux machines the port remains unclosed.In 32 bit machines with tomcat 5 the method is properly called and closed.But in 64 bit linux OS machine shutdownHook never gets called and port which i opened for serversocket remains occupied when the Tomcat shutdown