Hi,
I am trying get the jfreechart 1.0.9 working on Tomcat 5.0.27 with JDK 1.5 both on my development and remote shared hosting environment.
For some reason I get error whenever I try to run the following statement on the hosting environment:
ChartUtilities.writeChartAsPNG(response.getOutputStream(), chart, 800, 600);
It is working just fine in my development environment.
My development environment is identical to the hosting environment, I have placed all the jfreechart .jar files under WEB-INF/lib folder. Again, on my home development PC I get no errors, in the shared hosting environment I am getting errors. I wonder if this is a security issue of some kind. Please help.
The error trace is:
HTTP Status 500 -
type Exception report
message
description The server encountered an internal error () that prevented it from fulfilling this request.
exception
javax.servlet.ServletException
org.apache.jasper.runtime.PageContextImpl.doHandlePageException(PageContextImpl.java:825)
org.apache.jasper.runtime.PageContextImpl.access$1100(PageContextImpl.java:64)
org.apache.jasper.runtime.PageContextImpl$12.run(PageContextImpl.java:745)
java.security.AccessController.doPrivileged(Native Method)
org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:743)
org.apache.jsp.test_jsp._jspService(test_jsp.java:100)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:94)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:324)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:292)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:236)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
sun.reflect.GeneratedMethodAccessor228.invoke(Unknown Source)
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
java.lang.reflect.Method.invoke(Method.java:585)
org.apache.catalina.security.SecurityUtil$1.run(SecurityUtil.java:239)
java.security.AccessController.doPrivileged(Native Method)
javax.security.auth.Subject.doAsPrivileged(Subject.java:517)
org.apache.catalina.security.SecurityUtil.execute(SecurityUtil.java:266)
org.apache.catalina.security.SecurityUtil.doAsPrivilege(SecurityUtil.java:157)
root cause
java.lang.NoClassDefFoundError
org.jfree.chart.title.TextTitle.arrangeRR(TextTitle.java:588)
org.jfree.chart.title.TextTitle.arrange(TextTitle.java:459)
org.jfree.chart.JFreeChart.drawTitle(JFreeChart.java:1308)
org.jfree.chart.JFreeChart.draw(JFreeChart.java:1198)
org.jfree.chart.JFreeChart.createBufferedImage(JFreeChart.java:1396)
org.jfree.chart.JFreeChart.createBufferedImage(JFreeChart.java:1376)
org.jfree.chart.ChartUtilities.writeChartAsPNG(ChartUtilities.java:168)
org.jfree.chart.ChartUtilities.writeChartAsPNG(ChartUtilities.java:121)
org.apache.jsp.test_jsp._jspService(test_jsp.java:86)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:94)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:324)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:292)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:236)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
sun.reflect.GeneratedMethodAccessor228.invoke(Unknown Source)
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
java.lang.reflect.Method.invoke(Method.java:585)
org.apache.catalina.security.SecurityUtil$1.run(SecurityUtil.java:239)
java.security.AccessController.doPrivileged(Native Method)
javax.security.auth.Subject.doAsPrivileged(Subject.java:517)
org.apache.catalina.security.SecurityUtil.execute(SecurityUtil.java:266)
org.apache.catalina.security.SecurityUtil.doAsPrivilege(SecurityUtil.java:157)
note The full stack trace of the root cause is available in the Apache Tomcat/5.0.27 logs.
NoClassDefFoundError only in shared hosting environment
-
- JFreeChart Project Leader
- Posts: 11734
- Joined: Fri Mar 14, 2003 10:29 am
- antibot: No, of course not.
- Contact:
Most likely your shared host is running a headless server. See item 10 in the Frequently Asked Questions:
http://www.jfree.org/jfreechart/faq.html#FAQ10
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


Thanks Dave. I think you are right. I did some research and I see many people have the same issue when they deploy to Linux.
Hosting company will not do install anything or change any configuration just for me. Is there anything you think I can do in my jsp to overcome this issue?
I tried to put System.setProperty("java.awt.headless", "true"); in jspinit, but it did not help.
Do you have any other suggestions?
Hosting company will not do install anything or change any configuration just for me. Is there anything you think I can do in my jsp to overcome this issue?
I tried to put System.setProperty("java.awt.headless", "true"); in jspinit, but it did not help.
Do you have any other suggestions?
Nope, you cant do anything. Sadly.
Once the AWT was initialized, redefining the headless property makes no sense anymore. What you *can* try is to set the system property in your web-inf.xml file so that it get set before any AWT related classloading (and thus AWT initialization) happens. However, chances that this works are still extremely minimal.
Well, setting up a server on linux and not putting it in headless mode is a bug on your hosting services side. But if they are stubborn (as administrators tend to be), you are lost.
Once the AWT was initialized, redefining the headless property makes no sense anymore. What you *can* try is to set the system property in your web-inf.xml file so that it get set before any AWT related classloading (and thus AWT initialization) happens. However, chances that this works are still extremely minimal.
Well, setting up a server on linux and not putting it in headless mode is a bug on your hosting services side. But if they are stubborn (as administrators tend to be), you are lost.