JFreeChart问题:JFreeChart不能在JBoss下使用?

weizhihui1213 2006-03-23 03:08:42
我用JFreeChart制作统计图,在Tomcat下测试通过,一样的代码,放到JBoss下就出错,难道JBoss不支持JFreeChart?环境:win2k + jdk1.5 + jbuilder2006 + jboss4.0,提示错误:

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/jfree/chart/ChartUtilities
org.apache.jasper.runtime.PageContextImpl.doHandlePageException(PageContextImpl.java:825)
org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:758)
org.apache.jsp.testChart_jsp._jspService(testChart_jsp.java:69)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:94)
javax.servlet.http.HttpServlet.service(HttpServlet.java:810)
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:810)
org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:75)

root cause

java.lang.NoClassDefFoundError: org/jfree/chart/ChartUtilities
org.jfree.chart.servlet.ServletUtilities.saveChartAsPNG(ServletUtilities.java:187)
cn.com.iaspec.sz119.stat.chart.ChartPie3D.draw(ChartPie3D.java:52)
org.apache.jsp.testChart_jsp._jspService(testChart_jsp.java:52)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:94)
javax.servlet.http.HttpServlet.service(HttpServlet.java:810)
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:810)
org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:75)

note The full stack trace of the root cause is available in the Apache Tomcat/5.0.28 logs.
...全文
208 点赞 收藏 10
写回复
10 条回复
切换为时间正序
当前发帖距今超过3年,不再开放新的回复
发表回复
weizhihui1213 2006-03-23
哈哈,OK了,突然的灵机一动,就解决了。在JBoss下不是放到web-inf下的lib中,而是要放到Jboss 的lib中。谢谢大家的帮忙,结帖了
回复
jfy3d 2006-03-23
放到 WEB-INF /lib里么
回复
weizhihui1213 2006-03-23
没有人知道是什么原因吗?大家帮帮忙呀
回复
weizhihui1213 2006-03-23
这个测试代码是JFreeChart中demo经过一点改动得到的
回复
weizhihui1213 2006-03-23
不知道重新启动了多少次了,看看我的测试代码:
类:
package test;
import.....(类编译没有问题)
public class testChart extends ApplicationFrame {
public testChart(String title) {
super(title);
}

private static PieDataset createDataset() {
DefaultPieDataset dataset = new DefaultPieDataset();
dataset.setValue("One", new Double(43.2));
dataset.setValue("Two", new Double(10.0));
dataset.setValue("Three", new Double(27.5));
dataset.setValue("Four", new Double(17.5));
dataset.setValue("Five", new Double(11.0));
dataset.setValue("Six", new Double(19.4));
return dataset;
}

private static JFreeChart createChart(PieDataset dataset) {

JFreeChart chart = ChartFactory.createPieChart3D("Test",dataset,true,true,false);

PiePlot3D plot3=(PiePlot3D) chart.getPlot();
plot3.setDepthFactor(0.1);
plot3.setLabelGap(0.02);
plot3.setLabelFont(new Font("SansSerif",Font.PLAIN,11));
plot3.setNoDataMessage("No Data available");

return chart;
}

public String draw(){
JFreeChart chart = createChart(createDataset());
HttpSession session = null;
chart.setBackgroundPaint(new GradientPaint(0, 0, Color.white, 0, 1000,
Color.white));
String fileName = "";
try {
fileName = ServletUtilities.saveChartAsPNG(chart, 600, 350, null,
session);
} catch (Exception e) {
e.printStackTrace();
}
return fileName;
}
}

jsp页面:
<%@page contentType="text/html; charset=GBK"%>
<%@page import="test.testChart"%>
<html>
<head>
<title>testChart</title>
</head>
<body bgcolor="#ffffff">
<%
testChart tct = new testChart("Test");
String filename = tct.draw();
String graphURL = request.getContextPath() + "/servlet/DisplayChart?filename=" + filename;
%>
<img src="<%= graphURL %>" border=0>
</body>
</html>

web.xml:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN" "http://java.sun.com/dtd/web-app_2_3.dtd">
<web-app>
<display-name>web</display-name>
<servlet>
<servlet-name>DisplayChart</servlet-name>
<servlet-class>org.jfree.chart.servlet.DisplayChart</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>DisplayChart</servlet-name>
<url-pattern>/servlet/DisplayChart</url-pattern>
</servlet-mapping>
</web-app>

回复
Timsole 2006-03-23
那就应该没问题吧 仔细看看 配置完了重器 呵呵
回复
weizhihui1213 2006-03-23
jar文件都放进去了,jfreechart-1.0.1.jar、jcommon-1.0.0.jar、gnujaxp.jar、junit.jar、servlet.jar
回复
GumPGZ 2006-03-23
不是提示你:
java.lang.NoClassDefFoundError: org/jfree/chart/ChartUtilities

看你的jar都放进去了么
回复
weizhihui1213 2006-03-23
大家帮帮忙呀,这个问题搞了2天了,太郁闷了,实在不行,就只好暂时放弃了
回复
weizhihui1213 2006-03-23
web.xml如下:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN" "http://java.sun.com/dtd/web-app_2_3.dtd">

<web-app>
<display-name>test</display-name>
<description>test</description>

<listener>
<listener-class>cn.com.iaspec.waf.controller.web.DefaultComponentManager</listener-class>
</listener>

<servlet>
<servlet-name>MainServlet</servlet-name>
<servlet-class>cn.com.iaspec.waf.controller.web.MainServlet</servlet-class>
<init-param>
<param-name>default_locale</param-name>
<param-value>en_US</param-value>
</init-param>
</servlet>

<servlet>
<servlet-name>DisplayChart</servlet-name>
<servlet-class>org.jfree.chart.servlet.DisplayChart</servlet-class>
</servlet>

<servlet-mapping>
<servlet-name>MainServlet</servlet-name>
<url-pattern>*.do</url-pattern>
</servlet-mapping>

<servlet-mapping>
<servlet-name>DisplayChart</servlet-name>
<url-pattern>/servlet/DisplayChart</url-pattern>
</servlet-mapping>

<env-entry>
<description>Define the implementation class of the Component Manager</description>
<env-entry-name>param/ComponentManager</env-entry-name>
<env-entry-value>cn.com.iaspec.waf.controller.web.ComponentManager</env-entry-value>
<env-entry-type>java.lang.String</env-entry-type>
</env-entry>
<env-entry>
<description>Define the implementation class of the Web Crontroller</description>
<env-entry-name>param/WebController</env-entry-name>
<env-entry-value>cn.com.iaspec.waf.controller.web.DefaultWebController</env-entry-value>
<env-entry-type>java.lang.String</env-entry-type>
</env-entry>

</web-app>

回复
相关推荐
发帖
Web 开发
创建于2007-09-28

8.0w+

社区成员

Java Web 开发
申请成为版主
帖子事件
创建了帖子
2006-03-23 03:08
社区公告
暂无公告