LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Java 8 (https://www.linuxquestions.org/questions/linux-newbie-8/java-8-a-4175515932/)

EODSteven 08-22-2014 08:17 AM

Java 8
 
Does anyone have any idea what could cause ports not to bind when switching from Java 8 back to Java 7...I'm stumped.

MensaWater 08-22-2014 08:28 AM

What exactly do you mean by "switching back"?

If you were running Java 8 and started your process that relied on a given port then tried to restart that process using Java 7 it may simply be you forgot to stop the original process (or it didn't stop when you thought it did) so the port is still in use.

Run "lsof -i :<port>" for the port you're talking about to see if it is already in use. If lsof sees it then it will give you the PID of the process that is using it.

EODSteven 08-22-2014 08:38 AM

Quote:

Originally Posted by MensaWater (Post 5225367)
What exactly do you mean by "switching back"?

If you were running Java 8 and started your process that relied on a given port then tried to restart that process using Java 7 it may simply be you forgot to stop the original process (or it didn't stop when you thought it did) so the port is still in use.

Run "lsof -i :<port>" for the port you're talking about to see if it is already in use. If lsof sees it then it will give you the PID of the process that is using it.

I wish is was that easy...when I do a netstat the ports I'm trying to bind are not used but nonetheless they will not bind...Thx. BTW switching back is made via command line with Java 8 but I did do a complete shutdown and reboot...I had the same idea that the port was in use.

EODSteven 08-22-2014 08:41 AM

Quote:

Originally Posted by EODSteven (Post 5225378)
I wish is was that easy...when I do a netstat the ports I'm trying to bind are not used but nonetheless they will not bind...Thx.

Could it be some kind of dependency with ssh and Java 7...I've tried all the usual things and its a bare bones Ubuntu 14.04 and Java server install ...I finally broke down and installed Gnome shell so I could navigate easiar but I didn't want to. Does IPTables have anything to do with Ports?...and yes, I did all the IPTables -F -X -N for both IP4 and IP6.

MensaWater 08-22-2014 09:18 AM

Certainly iptables deals with ports. In fact I'd say that mostly is its purpose though of course it can do NATting and other things.

However, iptables if tied to ports should either allow or forbid them regardless of which application is attempting to use them. You should be able to determine if iptables is your issue simply by stopping it and testing. If it works when iptables is stopped then it means you need to add a rule allowing the port.

I'd still suggest looking with lsof -i since you can specify the port easily instead of having to look for it. Linux netstat has some capabilities along those lines but IMHO it is still inferior to what you can glean with lsof.

EODSteven 08-22-2014 02:56 PM

Quote:

Originally Posted by MensaWater (Post 5225399)
Certainly iptables deals with ports. In fact I'd say that mostly is its purpose though of course it can do NATting and other things.

However, iptables if tied to ports should either allow or forbid them regardless of which application is attempting to use them. You should be able to determine if iptables is your issue simply by stopping it and testing. If it works when iptables is stopped then it means you need to add a rule allowing the port.

I'd still suggest looking with lsof -i since you can specify the port easily instead of having to look for it. Linux netstat has some capabilities along those lines but IMHO it is still inferior to what you can glean with lsof.

Ok I just switched to Java 7 and did losf -i...hold on switch computers for copy and paste...

EODSteven 08-22-2014 02:57 PM

Quote:

Originally Posted by EODSteven (Post 5225569)
Ok I just switched to Java 7 and did losf -i...hold on switch computers for copy and paste...

Code:

Java 8 running all servers running

java    5253 steve  40u  IPv6 113558      0t0  TCP localhost:46088->localhost:mysql (ESTABLISHED)
java    5253 steve  44u  IPv6 114808      0t0  TCP *:25565 (LISTEN)
java    6238 steve  28u  IPv6 139795      0t0  TCP *:25568 (LISTEN)
java    6238 steve  79u  IPv6 145592      0t0  TCP localhost:8193 (LISTEN)
java    6238 steve  89u  IPv6 163542      0t0  UDP *:25569
java    6238 steve  90u  IPv6 352727      0t0  TCP eodsteven.org:42175->192.230.66.3.ip.incapdns.net:https (ESTABLISHED)
java    6238 steve  91u  IPv6 163351      0t0  TCP *:19002 (LISTEN)
java    6238 steve  108u  IPv6 163551      0t0  TCP localhost:46210->localhost:mysql (ESTABLISHED)
java    6367 steve  28u  IPv6 140975      0t0  TCP *:25572 (LISTEN)
java    6367 steve  45u  IPv6 146849      0t0  TCP localhost:46180->localhost:mysql (ESTABLISHED)
java    6367 steve  46u  IPv6 146850      0t0  TCP localhost:46181->localhost:mysql (ESTABLISHED)
java    6367 steve  55u  IPv6 160083      0t0  TCP *:19003 (LISTEN)
java    6367 steve  56u  IPv6 160252      0t0  UDP *:25573
java    6487 steve  28u  IPv6 150747      0t0  TCP *:25570 (LISTEN)
java    6487 steve  81u  IPv6 157847      0t0  TCP *:8192 (LISTEN)
java    6487 steve  90u  IPv6 159438      0t0  TCP localhost:46186->localhost:mysql (ESTABLISHED)
java    6487 steve  95u  IPv6 161785      0t0  UDP *:25571
java    6487 steve  99u  IPv6 160528      0t0  TCP *:19001 (LISTEN)
java    6487 steve  113u  IPv6 160674      0t0  TCP localhost:46195->localhost:mysql (ESTABLISHED)

I switch over to Java 7
I shut down the server using port 25570...

steve@eodsteven:~$ lsof -i
COMMAND  PID  USER  FD  TYPE DEVICE SIZE/OFF NODE NAME
java    5253 steve  40u  IPv6 113558      0t0  TCP localhost:46088->localhost:mysql (ESTABLISHED)
java    5253 steve  44u  IPv6 114808      0t0  TCP *:25565 (LISTEN)
java    6238 steve  28u  IPv6 139795      0t0  TCP *:25568 (LISTEN)
java    6238 steve  79u  IPv6 145592      0t0  TCP localhost:8193 (LISTEN)
java    6238 steve  89u  IPv6 163542      0t0  UDP *:25569
java    6238 steve  91u  IPv6 163351      0t0  TCP *:19002 (LISTEN)
java    6238 steve  108u  IPv6 163551      0t0  TCP localhost:46210->localhost:mysql (ESTABLISHED)
java    6367 steve  28u  IPv6 140975      0t0  TCP *:25572 (LISTEN)
java    6367 steve  45u  IPv6 146849      0t0  TCP localhost:46180->localhost:mysql (ESTABLISHED)
java    6367 steve  46u  IPv6 146850      0t0  TCP localhost:46181->localhost:mysql (ESTABLISHED)
java    6367 steve  55u  IPv6 160083      0t0  TCP *:19003 (LISTEN)
java    6367 steve  56u  IPv6 160252      0t0  UDP *:25573

and when I restart the server....

[14:43:00 INFO]: Starting minecraft server version 1.7.10
[14:43:00 INFO]: Loading properties
[14:43:01 INFO]: Default game type: SURVIVAL
[14:43:01 INFO]: This server is running CraftBukkit version git-Spigot-1610 (MC: 1.7.10) (Implementing API version 1.7.10-R0.1-SNAPSHOT)
[14:43:02 INFO]: Debug logging is disabled
[14:43:02 INFO]: Server Ping Player Sample Count: 12
[14:43:02 INFO]: Using 4 threads for Netty based IO
[14:43:02 INFO]: Generating keypair
[14:43:03 INFO]: Starting Minecraft server on *:25570
[14:43:04 WARN]: **** FAILED TO BIND TO PORT!
[14:43:05 INFO]: Stopping server

and finally...

steve@eodsteven:~$ lsof -i:25570
steve@eodsteven:~$

switch back to Java8...

steve@eodsteven:~$ sudo update-java-alternatives -s java-8-oracle
[sudo] password for steve:
steve@eodsteven:~$
COMMAND  PID  USER  FD  TYPE DEVICE SIZE/OFF NODE NAME
java    5253 steve  40u  IPv6 113558      0t0  TCP localhost:46088->localhost:mysql (ESTABLISHED)
java    5253 steve  44u  IPv6 114808      0t0  TCP *:25565 (LISTEN)
java    6238 steve  28u  IPv6 139795      0t0  TCP *:25568 (LISTEN)
java    6238 steve  79u  IPv6 145592      0t0  TCP localhost:8193 (LISTEN)
java    6238 steve  89u  IPv6 163542      0t0  UDP *:25569
java    6238 steve  91u  IPv6 163351      0t0  TCP *:19002 (LISTEN)
java    6238 steve  108u  IPv6 163551      0t0  TCP localhost:46210->localhost:mysql (ESTABLISHED)
java    6367 steve  28u  IPv6 140975      0t0  TCP *:25572 (LISTEN)
java    6367 steve  45u  IPv6 146849      0t0  TCP localhost:46180->localhost:mysql (ESTABLISHED)
java    6367 steve  46u  IPv6 146850      0t0  TCP localhost:46181->localhost:mysql (ESTABLISHED)
java    6367 steve  55u  IPv6 160083      0t0  TCP *:19003 (LISTEN)
java    6367 steve  56u  IPv6 160252      0t0  UDP *:25573

[14:50:29] [Server thread/INFO]: Starting minecraft server version 1.7.10
[14:50:29] [Server thread/INFO]: Loading properties
[14:50:29] [Server thread/INFO]: Default game type: SURVIVAL
[14:50:30] [Server thread/INFO]: This server is running CraftBukkit version git-Spigot-1610 (MC: 1.7.10) (Implementing API version 1.7.10-R0.1-SNAPSHOT)
[14:50:30] [Server thread/INFO]: Server Ping Player Sample Count: 12
[14:50:30] [Server thread/INFO]: Using 4 threads for Netty based IO
[14:50:30] [Server thread/INFO]: Debug logging is disabled
[14:50:31] [Server thread/INFO]: Generating keypair
[14:50:31] [Server thread/INFO]: Starting Minecraft server on *:25570
[14:50:32] [Server thread/INFO]: Set PluginClassLoader as parallel capable
[14:50:34] [Server thread/INFO]: [WorldEdit] Loading WorldEdit v5.6.3
[14:50:34] [Server thread/INFO]: [OpenInv] Loading OpenInv v2.2.2
[14:50:34] [Server thread/INFO]: [LimitCreative] Loading LimitCreative v1.7.2
[14:50:34] [Server thread/INFO]: [Essentials] Loading Essentials vDev2.14.95
[14:50:34] [Server thread/INFO]: [Prison] Loading Prison v2.0.4

Server starts up just fine.....see what I mean? Very weird!


EODSteven 08-23-2014 12:37 PM

Well as much as I like to brag, I don't like saying I have stumped the panel....I have 4 diffrent forums trying to brain storm with me to figure this out. I have even tried setting it up to run as a java 7 server inside a java 8 environment and same thing...failed to bind port. I also forced it to use IPv4 instead of 6, no change, and I have disabled Netty...nothing seems to work. It woud be a lot easiar for the developer to program his plugin to work with java 8 but thats not gonna happen....I wish I new how to code!

MensaWater 08-25-2014 09:05 AM

Most Java applications expect a certain version of Java and won't run on anything else. (Sometimes they want a very old version which is insecure). It may simply be Minecraft only runs on the one version. The failed to bind port may be a red herring for port 25570 - it may be trying to do something else (e.g. open another port as well) that it isn't telling you about but that is already in use. I notice on your second lsof -i output although 25570 has gone away other ports in the same range are still active.

To verify you can actually LISTEN on port 25570 after stopping the Java application run:
nc -l 25570
That should start a local LISTENer on the specified port. If it works you can stop it and you'll know the port itself isn't your issue.

You can run strace on your application and see what it is actually doing at the point it gives the failed to bind message.

EODSteven 08-27-2014 04:16 AM

Quote:

Originally Posted by MensaWater (Post 5226855)
Most Java applications expect a certain version of Java and won't run on anything else. (Sometimes they want a very old version which is insecure). It may simply be Minecraft only runs on the one version. The failed to bind port may be a red herring for port 25570 - it may be trying to do something else (e.g. open another port as well) that it isn't telling you about but that is already in use. I notice on your second lsof -i output although 25570 has gone away other ports in the same range are still active.

To verify you can actually LISTEN on port 25570 after stopping the Java application run:
nc -l 25570
That should start a local LISTENer on the specified port. If it works you can stop it and you'll know the port itself isn't your issue.

You can run strace on your application and see what it is actually doing at the point it gives the failed to bind message.

I have tried several other different Ports but thank you very much for those useful tools...I'm gonna give up on that one particular plugin and find one that works with Java 8. I hate to think of going backwards due to one particular lazy coder...Thank you. I always wondered how to do a Stack Trace and I assume strace is just that.


All times are GMT -5. The time now is 07:46 AM.