Bug 189905 - java/icedtea-web cannot launch system settings
Summary: java/icedtea-web cannot launch system settings
Status: Closed FIXED
Alias: None
Product: Ports & Packages
Classification: Unclassified
Component: Individual Port(s) (show other bugs)
Version: Latest
Hardware: Any Any
: Normal Affects Only Me
Assignee: freebsd-java (Nobody)
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2014-05-18 04:00 UTC by Kevin Zheng
Modified: 2014-05-21 21:18 UTC (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Kevin Zheng 2014-05-18 04:00:00 UTC
IcedTea installs a setting and policy editor. These can be run through the installed desktop icon or from the command line by invoking 'itweb-settings' and 'itweb-policyeditor'. Unfortunately, neither work:

[kevinz@epsilon ~]$ itweb-settings 
Your custom JRE /usr/local/openjdk7 read from deployment.properties under key deployment.jre.dir as /usr/local/openjdk7 is not valid. Using default (/usr/local/openjdk7/jre/bin/java, /usr/local/openjdk7/jre/lib/rt.jar) in attempt to start. Please fix this.
Error: could not find libjava.so
Error: Could not find Java SE Runtime Environment.

[kevinz@epsilon ~]$ itweb-policyeditor 
Your custom JRE /usr/local/openjdk7 read from deployment.properties under key deployment.jre.dir as /usr/local/openjdk7 is not valid. Using default (/usr/local/openjdk7/jre/bin/java, /usr/local/openjdk7/jre/lib/rt.jar) in attempt to start. Please fix this.
Error: could not find libjava.so
Error: Could not find Java SE Runtime Environment.

Java runs fine, and so does the policy editor when invoked through a browser. I suspect something is wrong with the script that launches the application.

The settings editor worked in previous versions of the FreeBSD port of IcedTea. I cannot recall which version, though.

How-To-Repeat: Run 'itweb-settings' and 'itweb-policyeditor' from the command line, or through the provided desktop icons.
Comment 1 Jung-uk Kim freebsd_committer freebsd_triage 2014-05-19 21:06:10 UTC
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Actually, it is a well-known problem.  The culprit is in
java/openjdk7, not in java/icedtea-web.  Please drop the following
file under java/openjdk7/files directory, rebuild the port, and try again.

https://svn.redports.org/jkim/java/openjdk7/files/patch-src-solaris-bin-java_md_solinux.c

BTW, you have an incorrect configuration, i.e., deployment.jre.dir in
deployment.properties should have a JRE path, not JDK path.  In other
words, it had to be set to /usr/local/openjdk7/jre.

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

iQEcBAEBAgAGBQJTemQyAAoJEHyflib82/FGDaEH+QGhR/INp+ALgqUgXcEHgfwL
orm546rvXo/jNICVhW0VzcoLTeiZfIrOyciYCKgXxYoAddrp42JvybzdX6a47CdX
rUeDMAYBq/BIsYUTcaOm1OZNhr67K0j+wH/BC+IX38+t1lEsmindRMIyaHZFSAUK
NgYRgpUj7lg8gYYoomGJUSeUhD6TyCgMWJkbNNw6dM6OgC2+sXuxZXRyefi3UZgc
7fI0RY8F2aFJCnfmeCiVp/7jx4CIUUutwl7EquhPcybq5mFI+FeW2YtY0wDbwl50
SkYWykDNDIW4ikbct7BIB+bXTFW2brc9oc8Juuyt2gjlvVYj0sXLGzVsU2Ziy2Q=
=Bsr/
-----END PGP SIGNATURE-----
Comment 2 dfilter service freebsd_committer freebsd_triage 2014-05-21 21:03:19 UTC
Author: jkim
Date: Wed May 21 20:03:14 2014
New Revision: 354761
URL: http://svnweb.freebsd.org/changeset/ports/354761
QAT: https://qat.redports.org/buildarchive/r354761/

Log:
  - Fix printing services.  When CUPS is used, ${LOCALBASE}/bin/lpr must be
  used to print a generated PostScript file.  When lpd(8) is used, lpr(1) from
  base must be used.  Also, status command for lpc(8) requires a printer name.
  If no argument is specified, i.e., "/usr/sbin/lpc status", then it displays
  the command usage, i.e., "usage: status  {all | printer ...}".
  Unfortunately, "usage" is interpreted as a printer name because ":" is
  included.  Add "all" and adjust an expression for grep(1). [1]
  - Use /proc/curproc/file to find its executable path if available.  It fixes
  java/icedtea-web, for example. [2]
  
  PR:		ports/178856 [1]
  PR:		java/189905 [2]

Added:
  head/java/openjdk7/files/patch-src-share-classes-sun-print-PSPrinterJob.java   (contents, props changed)
  head/java/openjdk7/files/patch-src-solaris-bin-java_md_solinux.c   (contents, props changed)
  head/java/openjdk7/files/patch-src-solaris-classes-sun-print-UnixPrintServiceLookup.java   (contents, props changed)
Modified:
  head/java/openjdk7/Makefile

Modified: head/java/openjdk7/Makefile
==============================================================================
--- head/java/openjdk7/Makefile	Wed May 21 19:58:46 2014	(r354760)
+++ head/java/openjdk7/Makefile	Wed May 21 20:03:14 2014	(r354761)
@@ -3,7 +3,7 @@
 
 PORTNAME=	openjdk
 PORTVERSION=	${JDK_MAJOR_VERSION}.${PORT_MINOR_VERSION}.${PORT_BUILD_NUMBER}
-PORTREVISION=	4
+PORTREVISION=	5
 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}/ \
@@ -130,7 +130,8 @@ MAKE_ENV+=	EXTRA_CFLAGS=-DLIBICONV_PLUG
 
 post-patch:
 	@${REINPLACE_CMD} "s|%%LOCALBASE%%|${LOCALBASE}|" \
-		${WRKSRC}/hotspot/src/os/bsd/vm/os_bsd.cpp
+		${WRKSRC}/hotspot/src/os/bsd/vm/os_bsd.cpp \
+		${WRKSRC}/jdk/src/share/classes/sun/print/PSPrinterJob.java
 .if empty(ICONV_LIB)
 	@${REINPLACE_CMD} 's| -liconv||' \
 		${WRKSRC}/Makefile \

Added: head/java/openjdk7/files/patch-src-share-classes-sun-print-PSPrinterJob.java
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ head/java/openjdk7/files/patch-src-share-classes-sun-print-PSPrinterJob.java	Wed May 21 20:03:14 2014	(r354761)
@@ -0,0 +1,36 @@
+--- jdk/src/share/classes/sun/print/PSPrinterJob.java
++++ jdk/src/share/classes/sun/print/PSPrinterJob.java
+@@ -1568,9 +1568,31 @@
+         }
+ 
+        String osname = System.getProperty("os.name");
+-       if (osname.equals("Linux") || osname.equals("FreeBSD") || osname.equals("NetBSD") || osname.equals("OpenBSD") || osname.equals("OS X")) {
++       if (osname.equals("Linux") || osname.endsWith("BSD") || osname.contains("OS X")) {
++            String lprPath = "/usr/bin/lpr";
++            if (osname.endsWith("BSD")) {
++                final PrintService pservice = getPrintService();
++                Boolean isIPPPrinter =
++                    (Boolean)java.security.AccessController.doPrivileged(
++                    new java.security.PrivilegedAction() {
++                        public Object run() {
++                            try {
++                                Class psClass =
++                                    Class.forName("sun.print.IPPPrintService");
++                                if (psClass.isInstance(pservice)) {
++                                    return Boolean.TRUE;
++                                }
++                            } catch (Throwable t) {
++                            }
++                            return Boolean.FALSE;
++                        }
++                    });
++                if (isIPPPrinter) {
++                    lprPath = "%%LOCALBASE%%/bin/lpr";
++                }
++            }
+             execCmd = new String[ncomps];
+-            execCmd[n++] = "/usr/bin/lpr";
++            execCmd[n++] = lprPath;
+             if ((pFlags & PRINTER) != 0) {
+                 execCmd[n++] = "-P" + printer;
+             }

Added: head/java/openjdk7/files/patch-src-solaris-bin-java_md_solinux.c
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ head/java/openjdk7/files/patch-src-solaris-bin-java_md_solinux.c	Wed May 21 20:03:14 2014	(r354761)
@@ -0,0 +1,38 @@
+--- jdk/src/solaris/bin/java_md_solinux.c
++++ jdk/src/solaris/bin/java_md_solinux.c
+@@ -899,8 +899,9 @@
+  * onwards the filename returned in DL_info structure from dladdr is
+  * an absolute pathname so technically realpath isn't required.
+  * On Linux we read the executable name from /proc/self/exe.
+- * As a fallback, and for platforms other than Solaris and Linux,
+- * we use FindExecName to compute the executable name.
++ * On FreeBSD we read the executable name from /proc/curproc/file.
++ * As a fallback, and for platforms other than Solaris, Linux, and
++ * FreeBSD, we use FindExecName to compute the executable name.
+  */
+ const char*
+ SetExecname(char **argv)
+@@ -927,9 +928,13 @@
+             }
+         }
+     }
+-#elif defined(__linux__)
++#elif defined(__linux__) || defined(__FreeBSD__)
+     {
++#if defined(__FreeBSD__)
++        const char* self = "/proc/curproc/file";
++#else
+         const char* self = "/proc/self/exe";
++#endif
+         char buf[PATH_MAX+1];
+         int len = readlink(self, buf, PATH_MAX);
+         if (len >= 0) {
+@@ -937,7 +942,7 @@
+             exec_path = JLI_StringDup(buf);
+         }
+     }
+-#else /* !__solaris__ && !__linux__ */
++#else /* !__solaris__ && !__linux__ && !__FreeBSD__ */
+     {
+         /* Not implemented */
+     }

Added: head/java/openjdk7/files/patch-src-solaris-classes-sun-print-UnixPrintServiceLookup.java
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ head/java/openjdk7/files/patch-src-solaris-classes-sun-print-UnixPrintServiceLookup.java	Wed May 21 20:03:14 2014	(r354761)
@@ -0,0 +1,17 @@
+--- jdk/src/solaris/classes/sun/print/UnixPrintServiceLookup.java
++++ jdk/src/solaris/classes/sun/print/UnixPrintServiceLookup.java
+@@ -140,12 +140,12 @@
+     static int cmdIndex = UNINITIALIZED;
+ 
+     String[] lpcFirstCom = {
+-        "/usr/sbin/lpc status | grep : | sed -ne '1,1 s/://p'",
++        "/usr/sbin/lpc status all | grep ':$' | sed -ne '1,1 s/://p'",
+         "/usr/sbin/lpc status | grep -E '^[ 0-9a-zA-Z_-]*@' | awk -F'@' '{print $1}'"
+     };
+ 
+     String[] lpcAllCom = {
+-        "/usr/sbin/lpc status all | grep : | sed -e 's/://'",
++        "/usr/sbin/lpc status all | grep ':$' | sed -e 's/://'",
+         "/usr/sbin/lpc status all | grep -E '^[ 0-9a-zA-Z_-]*@' | awk -F'@' '{print $1}' | sort"
+     };
+ 
_______________________________________________
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 3 Jung-uk Kim freebsd_committer freebsd_triage 2014-05-21 21:17:38 UTC
State Changed
From-To: open->closed

The patch was committed with r354761.  Thanks!