NoClassDefFoundError only in shared hosting environment

A discussion forum for JFreeChart (a 2D chart library for the Java platform).
Locked
eric74b
Posts: 5
Joined: Mon Apr 07, 2008 6:09 pm
Location: US

NoClassDefFoundError only in shared hosting environment

Post by eric74b » Mon Apr 07, 2008 6:20 pm

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.

david.gilbert
JFreeChart Project Leader
Posts: 11734
Joined: Fri Mar 14, 2003 10:29 am
antibot: No, of course not.
Contact:

Post by david.gilbert » Mon Apr 07, 2008 7:32 pm

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
David Gilbert
JFreeChart Project Leader

:idea: Read my blog
:idea: Support JFree via the Github sponsorship program

eric74b
Posts: 5
Joined: Mon Apr 07, 2008 6:09 pm
Location: US

Post by eric74b » Mon Apr 07, 2008 9:00 pm

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?

Taqua
JFreeReport Project Leader
Posts: 698
Joined: Fri Mar 14, 2003 3:34 pm
Contact:

Post by Taqua » Tue Apr 08, 2008 12:12 am

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.

eric74b
Posts: 5
Joined: Mon Apr 07, 2008 6:09 pm
Location: US

Post by eric74b » Tue Apr 08, 2008 2:41 am

Thank you, Taqua.

Actually, I found out from the hosting company that I could modify the php.ini file, that might help. I will try that.

Will defining the environment variable as follows be sufficient? :

java.awt.headless=true

[/code]

oldboys
Posts: 4
Joined: Tue Apr 08, 2008 10:03 am

Post by oldboys » Tue Apr 08, 2008 11:04 am

u have to change this in your tomcat env, so maybe look on the tomcat support/forum/ ... or use google.

and yes only setting java.awt.headless=true should be sufficient.

Locked