Bug 240016

Summary: net-mgmt/unifi5: Allow newer versions of Java
Product: Ports & Packages Reporter: Greg Lewis <glewis>
Component: Individual Port(s)Assignee: Mark Felder <feld>
Status: Closed FIXED    
Severity: Affects Only Me Flags: bugzilla: maintainer-feedback? (feld)
Priority: ---    
Version: Latest   
Hardware: Any   
OS: Any   
Attachments:
Description Flags
Patch for newer Java support
none
Udpated patch none

Description Greg Lewis freebsd_committer freebsd_triage 2019-08-21 16:17:23 UTC
Created attachment 206754 [details]
Patch for newer Java support

Based on https://community.ui.com/questions/Running-Unifi-Controller-on-Java-9-10-and-11/f1ac1330-40b8-4af6-83b6-8d55e48e4a32 I have a patch for the unifi5 port that will allow it to run with newer versions of Java.

Note that testing has been light.  I've only started it and navigated to the set up page, I haven't tried to do anything beyond that.  I've tested with both openjdk8 and openjdk11 so far.

Feel free to use this or not.
Comment 1 Greg Lewis freebsd_committer freebsd_triage 2019-09-18 03:05:02 UTC
Created attachment 207594 [details]
Udpated patch

I've updated the patch based on the update of the port to 5.11.39
Comment 2 Greg Lewis freebsd_committer freebsd_triage 2019-09-18 03:05:19 UTC
Mark, any comments on this?
Comment 3 Mark Felder freebsd_committer freebsd_triage 2019-09-18 15:26:25 UTC
(In reply to Greg Lewis from comment #2)

Haven't had time to test it myself, but if it works I'll take it. :-)

Thanks for being persistent.
Comment 4 Mark Felder freebsd_committer freebsd_triage 2019-09-18 15:34:47 UTC
The only change I see worth making is to avoid using that echo and shell expansion trick. I don't want us to run into shell expansion limits (or bugs) in the future, so we can just hack it with find, and replace sed with tr which is faster


basically:


find /usr/local/share/java/unifi/lib/ -maxdepth 1 -type f -name '*.jar' | tr '\n' ':'
Comment 5 Mark Felder freebsd_committer freebsd_triage 2019-09-18 17:35:27 UTC
(In reply to Mark Felder from comment #4)

ok that didn't work so well because of trailing : character with this method. My research shows your approach isn't uncommon. My main concern is now the process list output is blown up by this HUGE monster classpath definition. I've worked around it by setting the env CLASSPATH instead.

I'm not entirely sure why we're moving from the java -jar ace.jar method to this classpath definition and telling java to run "com.ubnt.ace.Launcher start" instead, but I trust you know far more about Java than I do.
Comment 6 commit-hook freebsd_committer freebsd_triage 2019-09-18 17:38:07 UTC
A commit references this bug:

Author: feld
Date: Wed Sep 18 17:38:00 UTC 2019
New revision: 512281
URL: https://svnweb.freebsd.org/changeset/ports/512281

Log:
  net-mgmt/unifi5: Update to 5.11.46

  Also pull in port improvements from glewis@ to enable customizing which Java
  that Unifi runs with

  PR:		240016

Changes:
  head/net-mgmt/unifi5/Makefile
  head/net-mgmt/unifi5/distinfo
  head/net-mgmt/unifi5/files/unifi.in
Comment 7 Greg Lewis freebsd_committer freebsd_triage 2019-09-18 18:07:46 UTC
Thanks Mark!

There is an explanation of why it switches from a direct java -jar invocation to using the class path and naming the main class at

https://community.ui.com/questions/Running-Unifi-Controller-on-Java-9-10-and-11/f1ac1330-40b8-4af6-83b6-8d55e48e4a32

The tl;dr version is that JDK9+ needs activation.jar on the class path and this is the simplest way to get it there.
Comment 8 Greg Lewis freebsd_committer freebsd_triage 2019-09-18 18:09:47 UTC
Note that I assume unifi will eventually support Java 11 out of the box, so we can likely revert to a straight java -jar invocation at that point.
Comment 9 Mark Felder freebsd_committer freebsd_triage 2019-09-18 18:43:12 UTC
Thanks, and please let me know if you encounter any issues with the changes I've committed.