icmp4j icon indicating copy to clipboard operation
icmp4j copied to clipboard

java.lang.NumberFormatException

Open joearkay opened this issue 7 years ago • 13 comments

java.lang.RuntimeException: java.lang.NumberFormatException: null
	at org.icmp4j.platform.unix.LinuxProcessNativeBridge.executePingRequest(LinuxProcessNativeBridge.java:94)
	at org.icmp4j.platform.unix.UnixNativeBridge.executePingRequest(UnixNativeBridge.java:128)
	at org.icmp4j.IcmpPingUtil.executePingRequest(IcmpPingUtil.java:117)

This occurs when calling IcmpPingUtil.executePingRequest(request)

joearkay avatar May 24 '17 15:05 joearkay

@laurentbh Could we look at this? I'd be happy to go through my implementation with you.

joearkay avatar May 26 '17 13:05 joearkay

Hey Joe,

1- Which flavor of *nix are your running ? 2- On that system what is the result of a ping command (where you specify packet size and timeout) ? 3- did you try using the icmp4j with JNI or JNA library ?

L.

laurentbh avatar May 26 '17 22:05 laurentbh

Hi @laurentbh

1- Which flavor of *nix are your running ? PRETTY_NAME="Raspbian GNU/Linux 8 (jessie)" NAME="Raspbian GNU/Linux" VERSION_ID="8" VERSION="8 (jessie)" ID=raspbian ID_LIKE=debian

2- On that system what is the result of a ping command (where you specify packet size and timeout ? I'm not sure, as the NPE occured before my Logging reported it. 3- did you try using the icmp4j with JNI or JNA library ? I'm using JNA:

<jna-platform-version>3.5.1</jna-platform-version>
       <jna-version>3.5.1</jna-version>

It's really odd, because I can't replicate the error on my local machine - it's only happening on a client's machine that I don't have direct access to.

joearkay avatar May 30 '17 14:05 joearkay

Joe,

The stack trace shows that the library is not using JNA, but execution a ping command. Are you sure libicmp4jJNA.so is in your class path ?

L.

laurentbh avatar May 30 '17 17:05 laurentbh

Hi @laurentbh - Yes, it is. What's odd is that this error hadn't occurred for the 2 months or so that I've been testing on this unit, then showed up for a couple of days, and then disappeared. When the error showed up, it only happened on some IP addresses, and not others, also.

There were no hardware/software changes during this period.

joearkay avatar May 31 '17 08:05 joearkay

Hi @laurentbh - Just as an FYI, I'd also raised an issue on the Sourceforge for this project: https://sourceforge.net/p/icmp4j/discussion/general/thread/eb5bde09/?limit=25#2581

Doing some further digging, I read that ICMP4J only uses JNA on Windows, but invokes the terminal ping command on Unix, so why would JNA on *nix matter?

I'd love to get to the bottom of this, with you.

joearkay avatar Jun 13 '17 07:06 joearkay

I ran a similar command that would be invoked by ICMP4J, and can't see why it wouldn't behave:

ping -c 1 -s 32 -w 5 www.google.com
PING www.google.com (216.58.206.36) 32(60) bytes of data.
40 bytes from 216.58.206.36: icmp_seq=1 ttl=53 time=34.9 ms

--- www.google.com ping statistics ---
1 packets transmitted, 1 received, 0% packet loss, time 0ms
rtt min/avg/max/mdev = 34.966/34.966/34.966/0.000 ms

joearkay avatar Jun 13 '17 10:06 joearkay

Wonder where you saw that:

Doing some further digging, I read that ICMP4J only uses JNA on Windows, but invokes the terminal ping command on Unix, so why would JNA on *nix matter?

ICMP4J will use JNA or JNI if it is properly configured. In your case, it looks like sometimes the output of ping can't be parsed.

laurentbh avatar Jun 13 '17 17:06 laurentbh

Hi @laurentbh - I read this on the front of your website http://www.icmp4j.org/d/index.html

Written in Java, uses JNA to perform native calls in Windows, spawns the ping executable in Linux/Solaris

Ok, thanks.

So if there's a JNA present on linux, this will be used? If not, the terminal ping command will be invoked?

joearkay avatar Jun 13 '17 17:06 joearkay

ok, we have to update the doc then! If your class path is correct and ICMP4J doesn't uses JNA, it's possible that the provided library is incompatible with your system, and need to be recompiled. What is the output of
file libicmp4jJNA.so

laurentbh avatar Jun 13 '17 17:06 laurentbh

Hi @laurentbh I've done some additional debugging. It turns out that, despite including the JNA with maven, when I build, this library isn't picking it up, as it's looking in the wrong location (resource /libicmp4jJNA_32bit.so not found)

Therefore, it's invoking the command line on Raspbian. This is fine for a successful ping, but for an unsuccessful ping, the parsing code doesn't seem to work, and hence throws the NumberFormatException when trying to parseInt(ttlAsString)

joearkay avatar Jun 22 '17 14:06 joearkay

Joe, Refer to Maven's doc to use a native library at runtime. Anyways, please use SourceForge for questions as it's the official site for Icmp4j. The parsing issue will be fixed from there

https://sourceforge.net/projects/icmp4j/

laurentbh avatar Jun 22 '17 18:06 laurentbh

Thanks @laurentbh - I appreciate your help

joearkay avatar Jun 23 '17 06:06 joearkay