Linux No Exception Problem
Linux No Exception Problem
Hi,
I am running into a problem getting charts to render from a servlet under Linux. The servlet generates a chart and writes the chart out as a PNG to the response stream. The servlet works fine under Windows. However in Linux, the chart does not display (a placeholder for the image is displayed), and there is no error that is being returned.
I am running:
- Linux Red Hat 7.2
- JFreeChart 0.9.4a
- JDK 1.4.1_01
I have tried setting java.awt.headless=true, but without success.
Does anyone have any experience with this problem? Is there a way to generate at least an error message to get a clue as to what is going wrong?
Your help is greatly appreciated.
Regards,
Ricky Eng
ricky@island.com
I am running into a problem getting charts to render from a servlet under Linux. The servlet generates a chart and writes the chart out as a PNG to the response stream. The servlet works fine under Windows. However in Linux, the chart does not display (a placeholder for the image is displayed), and there is no error that is being returned.
I am running:
- Linux Red Hat 7.2
- JFreeChart 0.9.4a
- JDK 1.4.1_01
I have tried setting java.awt.headless=true, but without success.
Does anyone have any experience with this problem? Is there a way to generate at least an error message to get a clue as to what is going wrong?
Your help is greatly appreciated.
Regards,
Ricky Eng
ricky@island.com
Re: Linux No Exception Problem
Hi again,
After some digging, I found that there was an Exception begin generated:
java.lang.UnsatisfiedLinkError: /usr/java/j2sdk1.4.1_01/jre/lib/i386/libawt.so: libXp.so.6: cannot open shared object file: No such file or directory
at java.lang.ClassLoader$NativeLibrary.load(Native Method)
at java.lang.ClassLoader.loadLibrary0(ClassLoader.java:1473)
at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1389)
at java.lang.Runtime.loadLibrary0(Runtime.java:788)
at java.lang.System.loadLibrary(System.java:832)
at sun.security.action.LoadLibraryAction.run(LoadLibraryAction.java:50)
at java.security.AccessController.doPrivileged(Native Method)
at java.awt.Toolkit.loadLibraries(Toolkit.java:1401)
at java.awt.Toolkit.<clinit>(Toolkit.java:1422)
at java.awt.Color.<clinit>(Color.java:250)
at com.jrefinery.chart.ValueAxis.<clinit>(Unknown Source)
at com.jrefinery.chart.ChartFactory.createTimeSeriesChart(Unknown Source)
at com.island.web.charts.subscriber.reports.stats.JFreeChartsStatsViewer.generateFirmVolumeChart(JFreeChartsStatsViewer.java:131)
at com.island.web.forms.subscriber.reports.stats.StatsChartsFormHandler.doFirmVolume(StatsChartsFormHandler.java:123)
at com.island.web.forms.subscriber.reports.stats.StatsChartsFormHandler.processAction(StatsChartsFormHandler.java:76)
at com.island.web.forms.subscriber.SecureFormHandler.service(SecureFormHandler.java:255)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:103)
at com.caucho.server.http.FilterChainServlet.doFilter(FilterChainServlet.java:96)
at com.caucho.server.http.Invocation.service(Invocation.java:312)
at com.caucho.server.http.CacheInvocation.service(CacheInvocation.java:135)
at com.caucho.server.http.RunnerRequest.handleRequest(RunnerRequest.java:342)
at com.caucho.server.http.RunnerRequest.handleConnection(RunnerRequest.java:272)
at com.caucho.server.TcpConnection.run(TcpConnection.java:137)
at java.lang.Thread.run(Thread.java:536)
According to John Matthews in [http://www.object-refinery.com/phorum-3 ... 252&t=2987], if I am running JRE 1.4.x and have set java.awt.headless=true, I should not have this problem???
What gives?
Regards,
Ricky Eng
ricky@island.com
After some digging, I found that there was an Exception begin generated:
java.lang.UnsatisfiedLinkError: /usr/java/j2sdk1.4.1_01/jre/lib/i386/libawt.so: libXp.so.6: cannot open shared object file: No such file or directory
at java.lang.ClassLoader$NativeLibrary.load(Native Method)
at java.lang.ClassLoader.loadLibrary0(ClassLoader.java:1473)
at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1389)
at java.lang.Runtime.loadLibrary0(Runtime.java:788)
at java.lang.System.loadLibrary(System.java:832)
at sun.security.action.LoadLibraryAction.run(LoadLibraryAction.java:50)
at java.security.AccessController.doPrivileged(Native Method)
at java.awt.Toolkit.loadLibraries(Toolkit.java:1401)
at java.awt.Toolkit.<clinit>(Toolkit.java:1422)
at java.awt.Color.<clinit>(Color.java:250)
at com.jrefinery.chart.ValueAxis.<clinit>(Unknown Source)
at com.jrefinery.chart.ChartFactory.createTimeSeriesChart(Unknown Source)
at com.island.web.charts.subscriber.reports.stats.JFreeChartsStatsViewer.generateFirmVolumeChart(JFreeChartsStatsViewer.java:131)
at com.island.web.forms.subscriber.reports.stats.StatsChartsFormHandler.doFirmVolume(StatsChartsFormHandler.java:123)
at com.island.web.forms.subscriber.reports.stats.StatsChartsFormHandler.processAction(StatsChartsFormHandler.java:76)
at com.island.web.forms.subscriber.SecureFormHandler.service(SecureFormHandler.java:255)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:103)
at com.caucho.server.http.FilterChainServlet.doFilter(FilterChainServlet.java:96)
at com.caucho.server.http.Invocation.service(Invocation.java:312)
at com.caucho.server.http.CacheInvocation.service(CacheInvocation.java:135)
at com.caucho.server.http.RunnerRequest.handleRequest(RunnerRequest.java:342)
at com.caucho.server.http.RunnerRequest.handleConnection(RunnerRequest.java:272)
at com.caucho.server.TcpConnection.run(TcpConnection.java:137)
at java.lang.Thread.run(Thread.java:536)
According to John Matthews in [http://www.object-refinery.com/phorum-3 ... 252&t=2987], if I am running JRE 1.4.x and have set java.awt.headless=true, I should not have this problem???
What gives?
Regards,
Ricky Eng
ricky@island.com
Re: Linux No Exception Problem
I am having percisely the same problem: "The servlet works fine under Windows. However in Linux, the chart does not display (a placeholder for the image is displayed), and there is no error that is being returned."
How did you find the error? and have you been able to figure it out yet?
Thanks, gerry
How did you find the error? and have you been able to figure it out yet?
Thanks, gerry
Re: Linux No Exception Problem
The exception you've posted doesn't look like the one that it usually reported when X11 is not running on Linux. I wonder if there is a problem with your JDK install, are you able to try it on another server?
Regards,
Dave Gilbert
Regards,
Dave Gilbert
Re: Linux No Exception Problem
In my case, I'm attempting to use this on a Linux Server that has Websphere installed. Apparently it uses JDK 1.3.1 and there is not an option to upgrade the JDK, w/out upgrading Websphere. So I'm stuck ...
I do know that this line never comes back:
JFreeChart chart = ChartFactory.createLineChart(.....
Initially, we had the X11 issue, but the system admin fixed that w/ X Virtual Frame Buffer (Xvfb).
Thanks, Gerry
I do know that this line never comes back:
JFreeChart chart = ChartFactory.createLineChart(.....
Initially, we had the X11 issue, but the system admin fixed that w/ X Virtual Frame Buffer (Xvfb).
Thanks, Gerry
Re: Linux No Exception Problem
There was a problem a while back that sounded like a font issue:
http://www.object-refinery.com/phorum-3 ... 748&t=4748
Aside from that, I'm not sure what the cause might be...
Regards,
Dave Gilbert
http://www.object-refinery.com/phorum-3 ... 748&t=4748
Aside from that, I'm not sure what the cause might be...
Regards,
Dave Gilbert
Re: Linux No Exception Problem
Thanks Dave, this thread refers to a Font issue. However, i don't have an option to set the label, tick label or legend fonts before this line:
JFreeChart chart = ChartFactory.createLineChart(.....
and this is the line that is not returning. Is there a way to set the font's prior to this line?
thanks, gerry
JFreeChart chart = ChartFactory.createLineChart(.....
and this is the line that is not returning. Is there a way to set the font's prior to this line?
thanks, gerry
Re: Linux No Exception Problem
Hi Gerry,
I wasn't thinking...you haven't tried to draw the chart yet, just create one. There's not much that should go wrong in the creation. I have only two ideas:
(1) You are missing the jcommon-0.7.1.jar file on your classpath. Seems unlikely though.
(2) There is some problem loading the gorilla.jpg image in the JFreeChartInfo class. This was reported with version 0.9.2 but I don't think it has been a problem since then.
I think your best bet for tracking down the problem is to find a log somewhere that reports some kind of error message...it seems unusual that nothing gets reported at all.
Regards,
Dave Gilbert
I wasn't thinking...you haven't tried to draw the chart yet, just create one. There's not much that should go wrong in the creation. I have only two ideas:
(1) You are missing the jcommon-0.7.1.jar file on your classpath. Seems unlikely though.
(2) There is some problem loading the gorilla.jpg image in the JFreeChartInfo class. This was reported with version 0.9.2 but I don't think it has been a problem since then.
I think your best bet for tracking down the problem is to find a log somewhere that reports some kind of error message...it seems unusual that nothing gets reported at all.
Regards,
Dave Gilbert
Re: Linux No Exception Problem
Hello:
I work with Gerry, and he wanted me to post the solution we used to fix the problem. Initially I set the Virtual Frame Buffer to run on display #69 (so that I'd wouldn't interfere with our other X sessions and VNC sessions and such). This caused Gerry to experience the hang problem. When I switched it to run on display #2, Gerry's problem went away. Here's the command I ran to successfully start the Virtual Frame Buffer:
/usr/X11R6/bin/Xvfb :2 -screen 0 1024x768x32 &
Ricky, I think you have a separate problem. Your JDK is looking for libXp.so.6, which it probobly isn't finding. On our Redhat 7.3 system there was a libXp.so.6.2, but not a libxp.so.6. So running the following two commands as the root user should solve your problem:
ln -s /usr/X11R6/lib/libXp.so.6.2 /usr/X11R6/lib/libXp.so.6
ln -s /usr/X11R6/lib/libXp.so.6.2 /usr/lib/libXp.so.6
I work with Gerry, and he wanted me to post the solution we used to fix the problem. Initially I set the Virtual Frame Buffer to run on display #69 (so that I'd wouldn't interfere with our other X sessions and VNC sessions and such). This caused Gerry to experience the hang problem. When I switched it to run on display #2, Gerry's problem went away. Here's the command I ran to successfully start the Virtual Frame Buffer:
/usr/X11R6/bin/Xvfb :2 -screen 0 1024x768x32 &
Ricky, I think you have a separate problem. Your JDK is looking for libXp.so.6, which it probobly isn't finding. On our Redhat 7.3 system there was a libXp.so.6.2, but not a libxp.so.6. So running the following two commands as the root user should solve your problem:
ln -s /usr/X11R6/lib/libXp.so.6.2 /usr/X11R6/lib/libXp.so.6
ln -s /usr/X11R6/lib/libXp.so.6.2 /usr/lib/libXp.so.6
Re: Linux No Exception Problem
I finally had a chance to try this code on another server with the same JDK and configuration. I got the same error.
After some advice from a Sun forum:
<http://forum.java.sun.com/thread.jsp?fo ... ead=344897>
we installed XFree86-libs-4.1.0-3 and freetype-2.0.3-7.
That fixed the problem.
Apparently, you still need the X libraries installed on Linux to create buffered images, even if you are using JDK 1.4.x and have set headless=true.
Incidentally, my chart has text in it. It appears as if JFreeCharts makes calls to the awt.Font class which makes calls to a native fonts package under Linux.
The error we got was:
java.lang.UnsatisfiedLinkError: /usr/java/j2sdk1.4.1_01/jre/lib/i386/libfontmanager.so: libstdc+
not open shared object file: No such file or directory
at java.lang.ClassLoader$NativeLibrary.load(Native Method)
at java.lang.ClassLoader.loadLibrary0(ClassLoader.java:1473)
at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1389)
at java.lang.Runtime.loadLibrary0(Runtime.java:788)
at java.lang.System.loadLibrary(System.java:832)
at sun.security.action.LoadLibraryAction.run(LoadLibraryAction.java:50)
at java.security.AccessController.doPrivileged(Native Method)
at sun.awt.font.NativeFontWrapper.<clinit>(NativeFontWrapper.java:42)
at sun.java2d.SunGraphicsEnvironment$1.run(SunGraphicsEnvironment.java:108)
at java.security.AccessController.doPrivileged(Native Method)
at sun.java2d.SunGraphicsEnvironment.<init>(SunGraphicsEnvironment.java:78)
at sun.awt.X11GraphicsEnvironment.<init>(X11GraphicsEnvironment.java:150)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.j
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccess
at java.lang.reflect.Constructor.newInstance(Constructor.java:274)
at java.lang.Class.newInstance0(Class.java:306)
at java.lang.Class.newInstance(Class.java:259)
at java.awt.GraphicsEnvironment.getLocalGraphicsEnvironment(GraphicsEnvironment.java:62)
at java.awt.Font.initializeFont(Font.java:303)
at java.awt.Font.<init>(Font.java:339)
at com.jrefinery.chart.AxisConstants.<clinit>(Unknown Source)
at com.jrefinery.chart.HorizontalDateAxis.<init>(Unknown Source)
at com.jrefinery.chart.ChartFactory.createTimeSeriesChart(Unknown Source)
at com.island.web.charts.subscriber.reports.stats.JFreeChartsStatsViewer.generateFirmVol
tatsViewer.java:131)
at com.island.web.forms.subscriber.reports.stats.StatsChartsFormHandler.doFirmVolume(Sta
ava:123)
at com.island.web.forms.subscriber.reports.stats.StatsChartsFormHandler.processAction(St
java:76)
at com.island.web.forms.subscriber.SecureFormHandler.service(SecureFormHandler.java:255)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:103)
at com.caucho.server.http.FilterChainServlet.doFilter(FilterChainServlet.java:96)
at com.caucho.server.http.Invocation.service(Invocation.java:312)
at com.caucho.server.http.CacheInvocation.service(CacheInvocation.java:135)
at com.caucho.server.http.RunnerRequest.handleRequest(RunnerRequest.java:342)
at com.caucho.server.http.RunnerRequest.handleConnection(RunnerRequest.java:272)
at com.caucho.server.TcpConnection.run(TcpConnection.java:137)
at java.lang.Thread.run(Thread.java:536)
Installing: compat-libstdc++-6.2-2.9.0.16.i386.rpm fixed this problem.
I can now create buffered PNGs using JFreeCharts under Linux.
Ricky
After some advice from a Sun forum:
<http://forum.java.sun.com/thread.jsp?fo ... ead=344897>
we installed XFree86-libs-4.1.0-3 and freetype-2.0.3-7.
That fixed the problem.
Apparently, you still need the X libraries installed on Linux to create buffered images, even if you are using JDK 1.4.x and have set headless=true.
Incidentally, my chart has text in it. It appears as if JFreeCharts makes calls to the awt.Font class which makes calls to a native fonts package under Linux.
The error we got was:
java.lang.UnsatisfiedLinkError: /usr/java/j2sdk1.4.1_01/jre/lib/i386/libfontmanager.so: libstdc+
not open shared object file: No such file or directory
at java.lang.ClassLoader$NativeLibrary.load(Native Method)
at java.lang.ClassLoader.loadLibrary0(ClassLoader.java:1473)
at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1389)
at java.lang.Runtime.loadLibrary0(Runtime.java:788)
at java.lang.System.loadLibrary(System.java:832)
at sun.security.action.LoadLibraryAction.run(LoadLibraryAction.java:50)
at java.security.AccessController.doPrivileged(Native Method)
at sun.awt.font.NativeFontWrapper.<clinit>(NativeFontWrapper.java:42)
at sun.java2d.SunGraphicsEnvironment$1.run(SunGraphicsEnvironment.java:108)
at java.security.AccessController.doPrivileged(Native Method)
at sun.java2d.SunGraphicsEnvironment.<init>(SunGraphicsEnvironment.java:78)
at sun.awt.X11GraphicsEnvironment.<init>(X11GraphicsEnvironment.java:150)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.j
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccess
at java.lang.reflect.Constructor.newInstance(Constructor.java:274)
at java.lang.Class.newInstance0(Class.java:306)
at java.lang.Class.newInstance(Class.java:259)
at java.awt.GraphicsEnvironment.getLocalGraphicsEnvironment(GraphicsEnvironment.java:62)
at java.awt.Font.initializeFont(Font.java:303)
at java.awt.Font.<init>(Font.java:339)
at com.jrefinery.chart.AxisConstants.<clinit>(Unknown Source)
at com.jrefinery.chart.HorizontalDateAxis.<init>(Unknown Source)
at com.jrefinery.chart.ChartFactory.createTimeSeriesChart(Unknown Source)
at com.island.web.charts.subscriber.reports.stats.JFreeChartsStatsViewer.generateFirmVol
tatsViewer.java:131)
at com.island.web.forms.subscriber.reports.stats.StatsChartsFormHandler.doFirmVolume(Sta
ava:123)
at com.island.web.forms.subscriber.reports.stats.StatsChartsFormHandler.processAction(St
java:76)
at com.island.web.forms.subscriber.SecureFormHandler.service(SecureFormHandler.java:255)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:103)
at com.caucho.server.http.FilterChainServlet.doFilter(FilterChainServlet.java:96)
at com.caucho.server.http.Invocation.service(Invocation.java:312)
at com.caucho.server.http.CacheInvocation.service(CacheInvocation.java:135)
at com.caucho.server.http.RunnerRequest.handleRequest(RunnerRequest.java:342)
at com.caucho.server.http.RunnerRequest.handleConnection(RunnerRequest.java:272)
at com.caucho.server.TcpConnection.run(TcpConnection.java:137)
at java.lang.Thread.run(Thread.java:536)
Installing: compat-libstdc++-6.2-2.9.0.16.i386.rpm fixed this problem.
I can now create buffered PNGs using JFreeCharts under Linux.
Ricky
Re: Linux No Exception Problem
Thanks Ricky and Mark for posting these solutions...it is a great help to those that will be searching for answers in the future.
Regards,
Dave Gilbert
Regards,
Dave Gilbert