in

Java RMI client waiting forever


Environment: JDK8 update 11, Linux Ubuntu server.

I have a simple RMI client

import java.io.*;
import javax.naming.*;
import java.rmi.registry.*;

public class rmiClient {
    public static void main(String[] args) throws Exception {
        Registry registry = LocateRegistry.getRegistry("127.0.0.1", 1099);
        registry.lookup("rmi://127.0.0.1:1099/a");
    }
}

Then I started the RMIServer

# /home/jdk/8u11/bin/java -cp marshalsec.jar marshalsec.jndi.RMIRefServer 'http://127.0.0.1/#TEST' 1099
* Opening JRMP listener on 1099
Have connection from /127.0.0.1:59806
Reading message...
Is RMI.lookup call for rmi://127.0.0.1:1099/a 2
Sending remote classloading stub targeting http://127.0.0.1/TEST.class
Closing connection

And the RMI client never exit:

# /home/jdk/8u11/bin/jstack 2885
2022-01-02 12:54:16
Full thread dump Java HotSpot(TM) 64-Bit Server VM (25.11-b03 mixed mode):

"Attach Listener" #15 daemon prio=9 os_prio=0 tid=0x00007f7ef8001000 nid=0xb79 waiting on condition [0x0000000000000000]
   java.lang.Thread.State: RUNNABLE

"DestroyJavaVM" #14 prio=5 os_prio=0 tid=0x00007f7f34009800 nid=0xb46 waiting on condition [0x0000000000000000]
   java.lang.Thread.State: RUNNABLE

"RMI Scheduler(0)" #13 daemon prio=5 os_prio=0 tid=0x00007f7f34160000 nid=0xb57 waiting on condition [0x00007f7f0d888000]
   java.lang.Thread.State: WAITING (parking)
    at sun.misc.Unsafe.park(Native Method)
    - parking to wait for  <0x0000000083801b68> (a java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject)
    at java.util.concurrent.locks.LockSupport.park(LockSupport.java:175)
    at java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.await(AbstractQueuedSynchronizer.java:2039)
    at java.util.concurrent.ScheduledThreadPoolExecutor$DelayedWorkQueue.take(ScheduledThreadPoolExecutor.java:1081)
    at java.util.concurrent.ScheduledThreadPoolExecutor$DelayedWorkQueue.take(ScheduledThreadPoolExecutor.java:809)
    at java.util.concurrent.ThreadPoolExecutor.getTask(ThreadPoolExecutor.java:1067)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1127)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
    at java.lang.Thread.run(Thread.java:745)

"GC Daemon" #12 daemon prio=2 os_prio=0 tid=0x00007f7f3415d000 nid=0xb56 in Object.wait() [0x00007f7f0d989000]
   java.lang.Thread.State: TIMED_WAITING (on object monitor)
    at java.lang.Object.wait(Native Method)
    - waiting on <0x0000000083814050> (a sun.misc.GC$LatencyLock)
    at sun.misc.GC$Daemon.run(GC.java:117)
    - locked <0x0000000083814050> (a sun.misc.GC$LatencyLock)

"RMI Reaper" #11 prio=5 os_prio=0 tid=0x00007f7f34157800 nid=0xb55 in Object.wait() [0x00007f7f0da8a000]
   java.lang.Thread.State: WAITING (on object monitor)
    at java.lang.Object.wait(Native Method)
    - waiting on <0x000000008381bf70> (a java.lang.ref.ReferenceQueue$Lock)
    at java.lang.ref.ReferenceQueue.remove(ReferenceQueue.java:142)
    - locked <0x000000008381bf70> (a java.lang.ref.ReferenceQueue$Lock)
    at java.lang.ref.ReferenceQueue.remove(ReferenceQueue.java:158)
    at sun.rmi.transport.ObjectTable$Reaper.run(ObjectTable.java:351)
    at java.lang.Thread.run(Thread.java:745)

"RMI TCP Accept-0" #10 daemon prio=5 os_prio=0 tid=0x00007f7f34156000 nid=0xb54 runnable [0x00007f7f0db8b000]
   java.lang.Thread.State: RUNNABLE
    at java.net.PlainSocketImpl.socketAccept(Native Method)
    at java.net.AbstractPlainSocketImpl.accept(AbstractPlainSocketImpl.java:404)
    at java.net.ServerSocket.implAccept(ServerSocket.java:545)
    at java.net.ServerSocket.accept(ServerSocket.java:513)
    at sun.rmi.transport.tcp.TCPTransport$AcceptLoop.executeAcceptLoop(TCPTransport.java:389)
    at sun.rmi.transport.tcp.TCPTransport$AcceptLoop.run(TCPTransport.java:361)
    at java.lang.Thread.run(Thread.java:745)

"Service Thread" #8 daemon prio=9 os_prio=0 tid=0x00007f7f340ce800 nid=0xb52 runnable [0x0000000000000000]
   java.lang.Thread.State: RUNNABLE

"C1 CompilerThread2" #7 daemon prio=9 os_prio=0 tid=0x00007f7f340b1000 nid=0xb51 waiting on condition [0x0000000000000000]
   java.lang.Thread.State: RUNNABLE

"C2 CompilerThread1" #6 daemon prio=9 os_prio=0 tid=0x00007f7f340af800 nid=0xb50 waiting on condition [0x0000000000000000]
   java.lang.Thread.State: RUNNABLE

"C2 CompilerThread0" #5 daemon prio=9 os_prio=0 tid=0x00007f7f340ac800 nid=0xb4f waiting on condition [0x0000000000000000]
   java.lang.Thread.State: RUNNABLE

"Signal Dispatcher" #4 daemon prio=9 os_prio=0 tid=0x00007f7f340aa800 nid=0xb4e runnable [0x0000000000000000]
   java.lang.Thread.State: RUNNABLE

"Finalizer" #3 daemon prio=8 os_prio=0 tid=0x00007f7f3407b000 nid=0xb4d in Object.wait() [0x00007f7f0ed19000]
   java.lang.Thread.State: WAITING (on object monitor)
    at java.lang.Object.wait(Native Method)
    - waiting on <0x000000008381c888> (a java.lang.ref.ReferenceQueue$Lock)
    at java.lang.ref.ReferenceQueue.remove(ReferenceQueue.java:142)
    - locked <0x000000008381c888> (a java.lang.ref.ReferenceQueue$Lock)
    at java.lang.ref.ReferenceQueue.remove(ReferenceQueue.java:158)
    at java.lang.ref.Finalizer$FinalizerThread.run(Finalizer.java:209)

"Reference Handler" #2 daemon prio=10 os_prio=0 tid=0x00007f7f34077000 nid=0xb4c in Object.wait() [0x00007f7f0ee1a000]
   java.lang.Thread.State: WAITING (on object monitor)
    at java.lang.Object.wait(Native Method)
    - waiting on <0x000000008381ca40> (a java.lang.ref.Reference$Lock)
    at java.lang.Object.wait(Object.java:502)
    at java.lang.ref.Reference$ReferenceHandler.run(Reference.java:157)
    - locked <0x000000008381ca40> (a java.lang.ref.Reference$Lock)

"VM Thread" os_prio=0 tid=0x00007f7f34072000 nid=0xb4b runnable

"GC task thread#0 (ParallelGC)" os_prio=0 tid=0x00007f7f3401e800 nid=0xb47 runnable

"GC task thread#1 (ParallelGC)" os_prio=0 tid=0x00007f7f34020000 nid=0xb48 runnable

"GC task thread#2 (ParallelGC)" os_prio=0 tid=0x00007f7f34022000 nid=0xb49 runnable

"GC task thread#3 (ParallelGC)" os_prio=0 tid=0x00007f7f34023800 nid=0xb4a runnable

"VM Periodic Task Thread" os_prio=0 tid=0x00007f7f340d1000 nid=0xb53 waiting on condition

JNI global references: 20

I’m wondering why the client won’t exit, and no errors is reported either. It doesn’t look like a deadlock to me.



Source: https://stackoverflow.com/questions/70553691/java-rmi-client-waiting-forever

How to Read Contents of an Audio File to a string in C#

Multi-String Pattern Matching Algorithm Using TrieHashNode