EJB中使用JFreeChart遇到的问题

09-10-16 Drizzt

今天写了的ejb如下

package cn.edu.hhu.ejb.entity.facade;

import java.awt.Font;

import java.awt.Insets;

import javax.ejb.Stateless;

import javax.servlet.http.HttpServletRequest;

import javax.servlet.http.HttpServletResponse;

import javax.servlet.http.HttpSession;

import org.jfree.chart.ChartFactory;

import org.jfree.chart.JFreeChart;

import org.jfree.chart.plot.PiePlot;

import org.jfree.chart.servlet.ServletUtilities;

import org.jfree.chart.title.TextTitle;

import org.jfree.data.general.DefaultPieDataset;

import org.jfree.data.time.Month;

import org.jfree.data.time.TimeSeries;

import org.jfree.data.time.TimeSeriesCollection;

@Stateless

public class ImageShow implements ImageShowRemote{

private static String unitName;

private static String year;

private static String url;

public String getimageurl(HttpServletRequest request, HttpServletResponse response) {

String titleStr = year + unitName + "降水量统计";

String filename = null;

Font font;

try {

//访问量统计时间线

TimeSeries timeSeries = new TimeSeries("统计", Month.class);

//时间曲线数据集合

TimeSeriesCollection lineDataset = new TimeSeriesCollection();

//构造数据集合

timeSeries.add(new Month(1, 2007), 11200);

timeSeries.add(new Month(2, 2007), 9000);

timeSeries.add(new Month(3, 2007), 6200);

timeSeries.add(new Month(4, 2007), 8200);

timeSeries.add(new Month(5, 2007), 8200);

timeSeries.add(new Month(6, 2007), 12200);

timeSeries.add(new Month(7, 2007), 13200);

timeSeries.add(new Month(8, 2007), 8300);

timeSeries.add(new Month(9, 2007), 12400);

timeSeries.add(new Month(10, 2007), 12500);

timeSeries.add(new Month(11, 2007), 13600);

timeSeries.add(new Month(12, 2007), 12500);

lineDataset.addSeries(timeSeries);

JFreeChart chart = ChartFactory.createTimeSeriesChart("统计时间线", "月份", "访问量", lineDataset, true, true, true);

TextTitle title = new TextTitle(titleStr);

chart.setTitle(title); //设置标题

font = new Font("黑体", Font.CENTER_BASELINE, 20); //设置标题的字体和大小

title.setFont(font);

chart.setBackgroundPaint(java.awt.Color.white); //设置图片的底色

HttpSession session = request.getSession();

filename = ServletUtilities.saveChartAsPNG(chart, 500, 300, session);

ServletUtilities.sendTempFile(filename, response);

url = request.getContextPath() + "/DisplayChart?filename=" + filename;

}

catch (Exception ex) {

System.out.print(ex.fillInStackTrace());

}

return url;

}

}

其中JFreeChart部分没有问题,但是放入ejb中打包在jboss中报错

--- MBeans waiting for other MBeans ---

ObjectName: jboss.j2ee:service=EJB3,module=ImageShow.jar

State: FAILED

Reason: java.lang.NoClassDefFoundError: org/jfree/data/general/PieDataset

--- MBEANS THAT ARE THE ROOT CAUSE OF THE PROBLEM ---

ObjectName: jboss.j2ee:service=EJB3,module=ImageShow.jar

State: FAILED

Reason: java.lang.NoClassDefFoundError: org/jfree/data/general/PieDataset

跪求解决,谢谢