Bug 186636 - java/openjdk7 Throws "sun.net.PortConfig: unknown OS" Exception when Creating a JMX Connector
Summary: java/openjdk7 Throws "sun.net.PortConfig: unknown OS" Exception when Creating...
Status: Closed FIXED
Alias: None
Product: Base System
Classification: Unclassified
Component: java (show other bugs)
Version: 9.1-RELEASE
Hardware: Any Any
: Normal Affects Only Me
Assignee: Greg Lewis
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2014-02-10 20:10 UTC by Ryan Frederick
Modified: 2014-02-15 23:40 UTC (History)
0 users

See Also:


Attachments
patch-src-solaris-classes-sun-net-PortConfig.java (553 bytes, text/x-java)
2014-02-11 20:32 UTC, Jung-uk Kim
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Ryan Frederick 2014-02-10 20:10:00 UTC
When attempting to start a Java application using java/openjdk7 7.51.13,1 the following exception is thrown when the application attempts to create a JMX connector:

Exception in thread "main" java.lang.InternalError: sun.net.PortConfig: unknown OS
        at sun.net.PortConfig$1.run(PortConfig.java:59)
        at sun.net.PortConfig$1.run(PortConfig.java:45)
        at java.security.AccessController.doPrivileged(Native Method)
        at sun.net.PortConfig.<clinit>(PortConfig.java:44)
        at java.net.SocketPermission$1.run(SocketPermission.java:1217)
        at java.net.SocketPermission$1.run(SocketPermission.java:1209)
        at java.security.AccessController.doPrivileged(Native Method)
        at java.net.SocketPermission.initEphemeralPorts(SocketPermission.java:1208)
        at java.net.SocketPermission.<clinit>(SocketPermission.java:235)
        at sun.security.util.SecurityConstants.<clinit>(SecurityConstants.java:259)
        at java.lang.Class.getProtectionDomain(Class.java:2181)
        at javax.management.remote.rmi.RMIConnector$1.run(RMIConnector.java:2108)
        at javax.management.remote.rmi.RMIConnector$1.run(RMIConnector.java:2104)
        at java.security.AccessController.doPrivileged(Native Method)
        at javax.management.remote.rmi.RMIConnector.<clinit>(RMIConnector.java:2138)
        at com.sun.jmx.remote.protocol.rmi.ClientProvider.newJMXConnector(ClientProvider.java:46)
        at javax.management.remote.JMXConnectorFactory.newJMXConnector(JMXConnectorFactory.java:369)
        at javax.management.remote.JMXConnectorFactory.connect(JMXConnectorFactory.java:267)
        at javax.management.remote.JMXConnectorFactory.connect(JMXConnectorFactory.java:227)
        at org.nagios.JMXQuery.connect(JMXQuery.java:53)
        at org.nagios.JMXQuery.main(JMXQuery.java:75)
Comment 1 johnweldon4 2014-02-11 18:00:03 UTC
The patch suggested by lwhsu worked for me:
http://people.freebsd.org/~lwhsu/patch/openjdk7-PortConfig.diff
--
John Weldon
Comment 2 Jung-uk Kim freebsd_committer freebsd_triage 2014-02-11 20:21:58 UTC
Responsible Changed
From-To: freebsd-java->glewis

Over to the maintainer.
Comment 3 Jung-uk Kim freebsd_committer freebsd_triage 2014-02-11 20:32:01 UTC
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

For the upstream, I prefer the attached patch to support all BSDs.

Jung-uk Kim
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.22 (FreeBSD)

iQEcBAEBAgAGBQJS+ojBAAoJEHyflib82/FGUcgH/24FQEkwia/Zy2qq84YyBX+p
dY+hcZWTrwTg3F9lqGn+Rr+vew464adwoKNVzFMjISWR8d9DjV/sI75jeUhiyWMq
a7tlCihEdUggr8x+oXtRA+6qYY++DWkkmfc6GVyqgzeYwmNcXbzfP2Yriuwj+48W
882ymMP89+PnHLrSf5yAEjmwHhxSjv6r3urEIc69HGCRB1usKNSw1R0BC1conm7z
uXWyuNaaYOKJZ5HIfAixas+1nvQldnjAL32pAmY7JP3EmAl3LBa9trfh/lxq4rUn
2bfAIWYeWg7zwKccZsY4uR8EfuK3js0R8oCjgeX6haZ8wFoK573EM4I0sDQ28mo=
=bO9v
-----END PGP SIGNATURE-----
Comment 4 Li-Wen Hsu freebsd_committer freebsd_triage 2014-02-12 05:54:20 UTC
On Tue, Feb 11, 2014 at 15:32:01 -0500, Jung-uk Kim wrote:
> 
> For the upstream, I prefer the attached patch to support all BSDs.
> 
> --- jdk/src/solaris/classes/sun/net/PortConfig.java
> +++ jdk/src/solaris/classes/sun/net/PortConfig.java
> @@ -49,7 +49,7 @@
>                      if (os.startsWith("Linux")) {
>                          defaultLower = 32768;
>                          defaultUpper = 61000;
> -                    } else if (os.startsWith("SunOS")) {
> +                    } else if (os.startsWith("SunOS") || os.contains("BSD")) {
>                          defaultLower = 32768;
>                          defaultUpper = 65535;
>                      } else if (os.contains("OS X")) {

I like the idea to suport all BSDs.  Do other BSDs have the same port
ranges with FreeBSD?

Li-Wen

-- 
Li-Wen Hsu <lwhsu@FreeBSD.org>
http://lwhsu.org
Comment 5 c.kworr 2014-02-13 15:38:48 UTC
May I object on this one?

As per /usr/include/netinet/in.h:

/*
  * Default local port range to use by setting IP_PORTRANGE_HIGH
  */
#define IPPORT_HIFIRSTAUTO 49152
#define IPPORT_HILASTAUTO 65535

Why the patch ties us to unofficial ephemeral port range while we can 
join Mac OS X by using official IANA suggested ephemeral port range?

-- 
Sphinx of black quartz, judge my vow.
Comment 6 dfilter service freebsd_committer freebsd_triage 2014-02-15 23:31:50 UTC
Author: glewis
Date: Sat Feb 15 23:31:42 2014
New Revision: 344496
URL: http://svnweb.freebsd.org/changeset/ports/344496
QAT: https://qat.redports.org/buildarchive/r344496/

Log:
  . Add BSD support to PortConfig.  Fixes JMX on FreeBSD.
  
  PR:		186636

Added:
  head/java/openjdk7/files/patch-src-solaris-classes-sun-net-PortConfig.java   (contents, props changed)
Modified:
  head/java/openjdk7/Makefile

Modified: head/java/openjdk7/Makefile
==============================================================================
--- head/java/openjdk7/Makefile	Sat Feb 15 23:04:53 2014	(r344495)
+++ head/java/openjdk7/Makefile	Sat Feb 15 23:31:42 2014	(r344496)
@@ -3,6 +3,7 @@
 
 PORTNAME=	openjdk
 PORTVERSION=	${JDK_MAJOR_VERSION}.${PORT_MINOR_VERSION}.${PORT_BUILD_NUMBER}
+PORTREVISION=	1
 PORTEPOCH=	1
 CATEGORIES=	java devel
 MASTER_SITES=	http://download.java.net/openjdk/jdk${JDK_MAJOR_VERSION}u${JDK_MINOR_VERSION}/promoted/b${JDK_BUILD_NUMBER}/ \

Added: head/java/openjdk7/files/patch-src-solaris-classes-sun-net-PortConfig.java
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ head/java/openjdk7/files/patch-src-solaris-classes-sun-net-PortConfig.java	Sat Feb 15 23:31:42 2014	(r344496)
@@ -0,0 +1,13 @@
+$FreeBSD$
+
+--- jdk/src/solaris/classes/sun/net/PortConfig.java	Sat Jan 18 12:20:24 2014 -0800
++++ jdk/src/solaris/classes/sun/net/PortConfig.java	Sat Feb 15 14:31:26 2014 -0800
+@@ -52,7 +52,7 @@
+                     } else if (os.startsWith("SunOS")) {
+                         defaultLower = 32768;
+                         defaultUpper = 65535;
+-                    } else if (os.contains("OS X")) {
++                    } else if (os.contains("OS X") || os.endsWith("BSD")) {
+                         defaultLower = 49152;
+                         defaultUpper = 65535;
+                     } else {
_______________________________________________
svn-ports-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-ports-all
To unsubscribe, send any mail to "svn-ports-all-unsubscribe@freebsd.org"
Comment 7 Greg Lewis freebsd_committer freebsd_triage 2014-02-15 23:32:04 UTC
State Changed
From-To: open->closed

I ended p using the same port range as Mac OS X.  Please let me know if there 
are still problems with the JMX Connector after updating openjdk7.