Problem running on Websphere server on Unix platform
Problem running on Websphere server on Unix platform
I downloaded the jfreechart-1.0.9.jar and included in my project. It works fine on my PC's test server, also works fine on the websphere server on a windows server. When I deployed the same application to websphere on an AIX/UNIX server, I got error when running a web report calling Jfreechart class.
[Servlet Error]-[org/jfree/chart/axis/CategoryAxis]: java.lang.NoClassDefFoundError: org/jfree/chart/axis/CategoryAxis
at org.jfree.chart.ChartFactory.createBarChart(ChartFactory.java:794)
A call from ChartFactory.createBarChart function to CategoryAxis class fails with NoClassDefFoundError. I checked and the class is out there in place. What can I do to make it work. It is clueless as everything looks in place. Download page states that both version of jar files are platform independent. Why is it working on windows server not Unix? Thank.
[Servlet Error]-[org/jfree/chart/axis/CategoryAxis]: java.lang.NoClassDefFoundError: org/jfree/chart/axis/CategoryAxis
at org.jfree.chart.ChartFactory.createBarChart(ChartFactory.java:794)
A call from ChartFactory.createBarChart function to CategoryAxis class fails with NoClassDefFoundError. I checked and the class is out there in place. What can I do to make it work. It is clueless as everything looks in place. Download page states that both version of jar files are platform independent. Why is it working on windows server not Unix? Thank.
-
- Posts: 844
- Joined: Fri Oct 13, 2006 9:29 pm
- Location: Sunnyvale, CA
No. The jar is not in the path. The problem is the call fails when one Jfreechart class calls another class within the jar. If the path is missing it should not enter the caller at first. The jar file is included in the lib directory within the web app deployed. All other jar files included in this lib path are called with no problem. They are not included in classpath either. Thanks for replying. Can you explain why this particular one needs to be there and why the first call to ChartFactory.createBarChart from my code didn't fail?
-
- Posts: 844
- Joined: Fri Oct 13, 2006 9:29 pm
- Location: Sunnyvale, CA
The typical reason why people would get NoClassDefFoundError exceptions is that they forget to put the JFreeChart jar on their environment's CLASSPATH variable. It appears that your web app deployment's lib directory must handle the classpath automagically. I have no clue why you would only see the error on the second call to ChartFactory.createBarChart unless there is some weird server side behavior that I am unawear of. I do not do any web development with Java, so I have reached the limits of my knowledge in this area.monaweb wrote:Can you explain why this particular one needs to be there and why the first call to ChartFactory.createBarChart from my code didn't fail?
Richard West
Design Engineer II
Advanced Micro Devices
Sunnyvale, CA
Design Engineer II
Advanced Micro Devices
Sunnyvale, CA
If you are in a web-application and all the jars are in the WEB-INF/lib directory, then they are added on the classpath automatically.
However, your error might result from a simple Headless-Exception or a related problem.
You are running your application on a server that has no X11 installed and no X11-Server running. The server runs fine until you try to access the charting (which uses the AWT which is not available as you have no X11 server and probably did not activate the Headless mode).
Enable the headless mode (if you are running JDK 1.4 or later, else you have troubles now) and your no-classdef-found-error should go away.
(The NoClassDefFoundError is thrown when a dependency for a class cannot be loaded. The dependency can be another class or can be a native library. Therefore this error does not necessarily indicate a ClassPath problem. Thanks Sun for messing up a otherwise clear exception )
However, your error might result from a simple Headless-Exception or a related problem.
You are running your application on a server that has no X11 installed and no X11-Server running. The server runs fine until you try to access the charting (which uses the AWT which is not available as you have no X11 server and probably did not activate the Headless mode).
Enable the headless mode (if you are running JDK 1.4 or later, else you have troubles now) and your no-classdef-found-error should go away.
(The NoClassDefFoundError is thrown when a dependency for a class cannot be loaded. The dependency can be another class or can be a native library. Therefore this error does not necessarily indicate a ClassPath problem. Thanks Sun for messing up a otherwise clear exception )
-
- JFreeChart Project Leader
- Posts: 11734
- Joined: Fri Mar 14, 2003 10:29 am
- antibot: No, of course not.
- Contact:
Maybe we should try to submit a patch (to OpenJDK) that makes the exception more clear? I'm short on time at the moment, though, unfortunately.Taqua wrote:(The NoClassDefFoundError is thrown when a dependency for a class cannot be loaded. The dependency can be another class or can be a native library. Therefore this error does not necessarily indicate a ClassPath problem. Thanks Sun for messing up a otherwise clear exception )
David Gilbert
JFreeChart Project Leader
Read my blog
Support JFree via the Github sponsorship program
JFreeChart Project Leader
Read my blog
Support JFree via the Github sponsorship program
-
- JFreeChart Project Leader
- Posts: 11734
- Joined: Fri Mar 14, 2003 10:29 am
- antibot: No, of course not.
- Contact:
See item 10 in the FAQ:monaweb wrote:How do I enable headless mode? Thanks.
http://www.jfree.org/jfreechart/faq.html#FAQ10
David Gilbert
JFreeChart Project Leader
Read my blog
Support JFree via the Github sponsorship program
JFreeChart Project Leader
Read my blog
Support JFree via the Github sponsorship program
I read the discussions and added
System.setProperty("java.awt.headless", "true");
at the first line of doGet() function of the servlet. Compiled with J2RE1.4.2_01 and ran on WebSphere5 on AIX5.2. The error message changed to
[Servlet Error]-[Can't connect to X11 window server using '155.179.85.43:0.0' as the value of the DISPLAY variable.]: java.lang.InternalError: Can't connect to X11 window server using '155.179.85.43:0.0' as the value of the DISPLAY variable.
at sun.awt.X11GraphicsEnvironment.initDisplay(Native Method)
at sun.awt.X11GraphicsEnvironment.<clinit>(X11GraphicsEnvironment.java:175)
at java.lang.Class.forName1(Native Method)
at java.lang.Class.forName(Class.java(Compiled Code))
at java.awt.GraphicsEnvironment.getLocalGraphicsEnvironment(GraphicsEnvironment.java:91)
at java.awt.Font.initializeFont(Font.java:333)
at java.awt.Font.<init>(Font.java:368)
at org.jfree.chart.axis.Axis.<clinit>(Axis.java:130)
at org.jfree.chart.ChartFactory.createBarChart(ChartFactory.java:794)
instead of NoClassFound error.
Do I have to get the system admin involved to force xvfb?
System.setProperty("java.awt.headless", "true");
at the first line of doGet() function of the servlet. Compiled with J2RE1.4.2_01 and ran on WebSphere5 on AIX5.2. The error message changed to
[Servlet Error]-[Can't connect to X11 window server using '155.179.85.43:0.0' as the value of the DISPLAY variable.]: java.lang.InternalError: Can't connect to X11 window server using '155.179.85.43:0.0' as the value of the DISPLAY variable.
at sun.awt.X11GraphicsEnvironment.initDisplay(Native Method)
at sun.awt.X11GraphicsEnvironment.<clinit>(X11GraphicsEnvironment.java:175)
at java.lang.Class.forName1(Native Method)
at java.lang.Class.forName(Class.java(Compiled Code))
at java.awt.GraphicsEnvironment.getLocalGraphicsEnvironment(GraphicsEnvironment.java:91)
at java.awt.Font.initializeFont(Font.java:333)
at java.awt.Font.<init>(Font.java:368)
at org.jfree.chart.axis.Axis.<clinit>(Axis.java:130)
at org.jfree.chart.ChartFactory.createBarChart(ChartFactory.java:794)
instead of NoClassFound error.
Do I have to get the system admin involved to force xvfb?
No, but the headless mode must be activated before any of the AWT classes are loaded. When you try to set the property in the same servlet that also uses JFreeChart, then the classes are already loaded (as on loading the servlet, all dependent classes are loaded as well. Servlet references JFreeChart and JFreeChart references AWT).
The only safe way to do this, is to set the system property during the server startup (means: Add a "-Djava.awt.headless=true" to your java commandline arguments or the server's global configuraiton).
The only safe way to do this, is to set the system property during the server startup (means: Add a "-Djava.awt.headless=true" to your java commandline arguments or the server's global configuraiton).
-
- Posts: 1
- Joined: Wed Oct 22, 2008 7:27 pm