Search code examples
javaexceptionprofilingsamplingjvisualvm

UTFDataFormatException when trying to connect jvisualvm to an eclipse local process


I am trying to profile a local java application. It is run through Eclipse. I am using the jvisualvm corrsponding to my jdk installation. It sees the process when it is started, it can sample it without problem but when I try to start the profiler, the eclipse console shows this error :

Profiler Agent: Waiting for connection on port 5140 (Protocol version: 15)
Profiler Agent: Established connection with the tool
Profiler Agent Error: Exception when trying to send response or command to client:
java.io.UTFDataFormatException
java.io.UTFDataFormatException
    at java.io.ObjectOutputStream$BlockDataOutputStream.writeUTF(ObjectOutputStream.java:2164)
    at java.io.ObjectOutputStream$BlockDataOutputStream.writeUTF(ObjectOutputStream.java:2007)
    at java.io.ObjectOutputStream.writeUTF(ObjectOutputStream.java:869)
    at org.netbeans.lib.profiler.wireprotocol.VMPropertiesResponse.writeObject(VMPropertiesResponse.java:156)
    at org.netbeans.lib.profiler.wireprotocol.WireIO.sendComplexResponse(WireIO.java:286)
    at org.netbeans.lib.profiler.server.ProfilerServer.sendComplexResponseToClient(ProfilerServer.java:678)
    at org.netbeans.lib.profiler.server.ProfilerServer.handleClientCommand(ProfilerServer.java:1559)
    at org.netbeans.lib.profiler.server.ProfilerServer.listenToClient(ProfilerServer.java:1698)
    at org.netbeans.lib.profiler.server.ProfilerServer.run(ProfilerServer.java:655)
Profiler Agent: Connection with agent closed
Profiler Agent: Connection with agent closed

When looking at the code, the writeUTF function throws this exception when the response is too long...

 void writeUTF(String s, long utflen) throws IOException {
            if (utflen > 0xFFFFL) {
                throw new UTFDataFormatException();
            }
...
}

Would someone have an idea about what happens here ?

Thanks.


Solution

  • This was likely caused by a VisualVM bug—now fixed—associated with long classpaths.