Re:
Exception in thread "main" java.lang.InternalError: Can't connect to window server - not enough permissions.
Unless there is someone out there who has found a work-around, I am going to have to switch to a new graphics application and re-write a lot of code.
I've spend several days trying to find a work-around to this problem, and am convinced at this point there is no resolution.
I am afraid this is the end of Jfreechart running as an application (i.e., cron or launchd process, no GUI invloved) under Mac OS X 10.6+. Apple has cranked up the security of their OS significantly, which breaks Jfreechart as an application because it cannot securely connect to the Window Server.
For several years, I have had a collection of Java (v1.6) applications running on our Mac Xserver (v10.4), producing data figures of real-time satellite data. Recently we added a new Xserve running Mac OS X 10.6, and I ported one of the applications over. Running via Apple Remote Desktop (the GUI I/F), everything worked fine. But when I tried running via SSH (either normal user or root), I got the stacktrace pasted below. When operationally run from a cron or launchd process, the same stacktrace results.
I've searched all the forums/posts I could find and tried various work-arounds: -Djava.awt.headless=true does not work - the most frequent suggested work-around. As mentioned running as root does not work.
An very detailed description of the problems of using the Window Server from a Daemon/Agent can be found at:
http://developer.apple.com/mac/library/ ... n2083.html
---------------------------------------------------------------------------------------------------
Fri Dec 18 18:11:30 xxx.yyy.zzz java[75172] <Warning>: 3891612: (connectAndCheck) Untrusted apps are not allowed to connect to or launch Window Server before login.
Fri Dec 18 18:11:30 xxx.yyy.zzz java[75172] <Error>: kCGErrorFailure: Set a breakpoint @ CGErrorBreakpoint() to catch errors as they are logged.
Exception in thread "main" java.lang.InternalError: Can't connect to window server - not enough permissions.
at java.lang.ClassLoader$NativeLibrary.load(Native Method)
at java.lang.ClassLoader.loadLibrary0(ClassLoader.java:1861)
at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1762)
at java.lang.Runtime.loadLibrary0(Runtime.java:823)
at java.lang.System.loadLibrary(System.java:1045)
at sun.security.action.LoadLibraryAction.run(LoadLibraryAction.java:50)
at java.security.AccessController.doPrivileged(Native Method)
at sun.awt.NativeLibLoader.loadLibraries(NativeLibLoader.java:38)
at sun.awt.DebugHelper.<clinit>(DebugHelper.java:29)
at java.awt.Component.<clinit>(Component.java:560)
----------------------------------------------------------------------------------------------
JfreeChart Apps under Mac OSX 10.6? Can't connect to window
JfreeChart Apps under Mac OSX 10.6? Can't connect to window
Last edited by daveb48 on Tue Dec 29, 2009 9:49 pm, edited 1 time in total.
Re: The end of JfreeChart Apps under Mac OSX 10.6? Server Err
The headless mode works perfectly, if you stick to the sane limitations that come with it. Do not (I repeat: DO NOT) create heavyweight AWT components and you should be totally fine. If your code makes use of a ChartPanel, a ApplicationFrame or other similar classes, you are doing it wrong. Stick with Graphics2D, AWT-images and stay away from every class that extends java.awt.Component. A Component will try to generate a heavyweight peer and that of course requires a valid GUI system.
Re: The end of JfreeChart Apps under Mac OSX 10.6? Server Err
Bingo. Thanks so much for your help - I just took out the "extends ApplicationFrame" from the class definition, and it works fine now from launchd daemon (which now replaces cron) on Mac OS X Snow Leopard. I should have seen that.