Hello Peter, > -----Ursprüngliche Nachricht----- > Von: l...@kreuser.name <l...@kreuser.name> > Gesendet: Donnerstag, 11. Mai 2023 16:16 > An: Tomcat Users List <users@tomcat.apache.org> > Betreff: Re: Java Agent and Tomcat shutdown > > Hi Thomas > > > Am 11.05.2023 um 16:05 schrieb Thomas Hoffmann (Speed4Trade GmbH) > <thomas.hoffm...@speed4trade.com.INVALID>: > > > > Hello, > > > > we are using a java agent to start a listening process (JMX proxy). > > > > The systemd file for tomcat looks like (snippet): > > JAVA_OPTS=... -javaagent:/opt/runtime/jmxagent/jmxagent.jar > > -Dorg.goktay.rmiregistry.port=15000 -Dorg.goktay.rmiserver.port=15001 > > > I do think that setting JAVA_OPTS is triggering this behavior: EVERY java > process contains this rmi server with this conflicting port. > > The way to go is using CATALINA_OPTS. The options go only into the start- > process... You are completely right. Everything makes sense now 😊 Thanks for the quick help! Much appreciated!
> HTH > > Peter > > > ExecStart=/opt/apache-tomcat/bin/catalina.sh run > > ExecStop=/opt/apache-tomcat/bin/catalina.sh stop 60 > > > > When starting the service, everything works fine and the java agent is > accessible via the opened port 15000. > > > > However, when stopping tomcat, it seems that a java process is started and > tries to open the same port again: > > 2670]: Exception in thread "main" > > java.lang.reflect.InvocationTargetException > > at > java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native > Method) > > at > java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethod > AccessorImpl.java:77) > > at > java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(Delegatin > gMethodAccessorImpl.java:43) > > at java.base/java.lang.reflect.Method.invoke(Method.java:568) > > at > java.instrument/sun.instrument.InstrumentationImpl.loadClassAndStartAgent(In > strumentationImpl.java:493) > > at > > java.instrument/sun.instrument.InstrumentationImpl.loadClassAndCallPre > > main(InstrumentationImpl.java:503) > > Caused by: java.rmi.server.ExportException: Port already in use: 15000; > nested exception is: > > java.net.BindException: Address already in use > > at > java.rmi/sun.rmi.transport.tcp.TCPTransport.listen(TCPTransport.java:346) > > at > java.rmi/sun.rmi.transport.tcp.TCPTransport.exportObject(TCPTransport.java:2 > 43) > > at > java.rmi/sun.rmi.transport.tcp.TCPEndpoint.exportObject(TCPEndpoint.java:415 > ) > > at java.rmi/sun.rmi.transport.LiveRef.exportObject(LiveRef.java:147) > > at > java.rmi/sun.rmi.server.UnicastServerRef.exportObject(UnicastServerRef.java:2 > 35) > > at > > java.rmi/sun.rmi.registry.RegistryImpl.setup(RegistryImpl.java:223) > > at > > java.rmi/sun.rmi.registry.RegistryImpl.<init>(RegistryImpl.java:208) > > at > java.rmi/java.rmi.registry.LocateRegistry.createRegistry(LocateRegistry.java:20 > 3) > > at org.goktay.jmx.JMXAgent.premain(JMXAgent.java:33) > > ... 6 more > > Caused by: java.net.BindException: Address already in use > > at java.base/sun.nio.ch.Net.bind0(Native Method) > > at java.base/sun.nio.ch.Net.bind(Net.java:555) > > at java.base/sun.nio.ch.Net.bind(Net.java:544) > > at java.base/sun.nio.ch.NioSocketImpl.bind(NioSocketImpl.java:643) > > at java.base/java.net.ServerSocket.bind(ServerSocket.java:388) > > at java.base/java.net.ServerSocket.<init>(ServerSocket.java:274) > > at java.base/java.net.ServerSocket.<init>(ServerSocket.java:167) > > at > java.rmi/sun.rmi.transport.tcp.TCPDirectSocketFactory.createServerSocket(TCP > DirectSocketFactory.java:45) > > at > java.rmi/sun.rmi.transport.tcp.TCPEndpoint.newServerSocket(TCPEndpoint.java > :673) > > at > java.rmi/sun.rmi.transport.tcp.TCPTransport.listen(TCPTransport.java:335) > > ... 14 more > > *** java.lang.instrument ASSERTION FAILED ***: "result" with message > > agent load/premain call failed at > > src/java.instrument/share/native/libinstrument/JPLISAgent.c line: 422 > > > > The premain method is entered again and of course the port is already used. > > Is there a way to stop tomcat without re-entering the java agent? > > Using shutdown.sh shows the same problem. > > > > Thanks in advance! > > Thomas > > > > --------------------------------------------------------------------- > > To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org > > For additional commands, e-mail: users-h...@tomcat.apache.org > > > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org > For additional commands, e-mail: users-h...@tomcat.apache.org