java.lang.ClassNotFoundException:org/jfree/data/general/Seri

A discussion forum for JFreeChart (a 2D chart library for the Java platform).
Locked
qiyanlike
Posts: 2
Joined: Mon Feb 25, 2008 2:57 am

java.lang.ClassNotFoundException:org/jfree/data/general/Seri

Post by qiyanlike » Mon Feb 25, 2008 3:10 am

hi all !
I have a problem let me headaches a week ago.
Chart shows the applet, BarChart and PieChart is good. XYBarChart But there will be problems.
I first serializable of JFreeChart object, and then in the anti-serializable , the result of this exception has emerged.
java.lang.ClassNotFoundException:org/jfree/data/general/SeriesChangeListener
anyone help me,thank you very much!

jfreechart1.0.0.jar and jcommon1.0.0.jar

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 » Thu Feb 28, 2008 4:59 am

I'd check your classpath to make sure you don't have any older version of the JFreeChart jar on your classpath.
David Gilbert
JFreeChart Project Leader

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

qiyanlike
Posts: 2
Joined: Mon Feb 25, 2008 2:57 am

Post by qiyanlike » Thu Feb 28, 2008 6:08 am

first , thank you for replay. I am sorry, I do not think I said that very clearly. I have my code stickers out, you can copy down try. Really is a very strange question.

ChartApplet .java

Code: Select all

import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.io.PrintWriter;
import java.io.StringWriter;
import java.net.URL;

import java.awt.Color;
import java.awt.GradientPaint;

import javax.swing.JApplet;
import javax.swing.JOptionPane;

import org.jfree.chart.ChartPanel;
import org.jfree.chart.JFreeChart;
import org.jfree.chart.axis.NumberAxis;
import org.jfree.chart.plot.PlotOrientation;
import org.jfree.chart.plot.XYPlot;
import org.jfree.data.xy.IntervalXYDataset;
import org.jfree.data.xy.XYBarDataset;
import org.jfree.data.xy.XYSeries;
import org.jfree.data.xy.XYSeriesCollection;

public class ChartApplet extends JApplet {

public void viewChart( boolean b) {
        try {
        	buildChart(b);
        } catch (Exception e) {
            StringWriter swriter = new StringWriter();
            PrintWriter pwriter = new PrintWriter(swriter);
            e.printStackTrace(pwriter);
            JOptionPane.showMessageDialog(this, swriter.toString());
        }
	}


    private void buildChart(boolean b) throws Exception{
		//if(url != null) {
		   if(chart == null || b) {
			   
			   chart = (JFreeChart) this.loadObject(url);
		   }
		   if (chart == null) {
			   System.out.println(" chart == null");
		   }
		   if(chart != null) {
			    
				ChartPanel chartPanel = new ChartPanel(chart);
								getContentPane().setBackground(Color.WHITE);
				
				getContentPane().removeAll();
				
				getContentPane().add(chartPanel);
				
				getContentPane().validate();
		    } else {
		        JOptionPane.showMessageDialog(this, "Empty chart.");
		    }
		//} else {
		//   JOptionPane.showMessageDialog(this, "Source URL not specified");
		//}
    }



private Object loadObject(URL url) throws IOException {
    	
         JFreeChart chart = null;
        // serialize and deserialize the chart....
         try {
             ByteArrayOutputStream buffer = new ByteArrayOutputStream();
             ObjectOutputStream out = new ObjectOutputStream(buffer);
             out.writeObject(buildXYBarChart());
             out.close();
 
             ObjectInputStream in = new ObjectInputStream(
                 new ByteArrayInputStream(buffer.toByteArray())
             );
             chart = (JFreeChart) in.readObject(); //[b] ---->There is an exception[/b]
             in.close();
         }
         catch (Exception e) {
            e.printStackTrace();
         }
    	
         return chart;
}
    private JFreeChart buildXYBarChart(){		
        IntervalXYDataset dataset = createDataset();		
		JFreeChart chart = org.jfree.chart.ChartFactory.createXYBarChart(
				"XYBarChart", 
				"X",
				false, 
				"Y", 
				dataset, 
				PlotOrientation.VERTICAL, 
				true, 
				false, 
				false);
        // then customise it a little...
        chart.setBackgroundPaint(new GradientPaint(0, 0, Color.white, 1000, 0, Color.blue));
        XYPlot plot = (XYPlot) chart.getPlot();
        NumberAxis domainAxis = (NumberAxis) plot.getDomainAxis();
        domainAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
      plot.setNoDataMessage("No data available");
          
		return chart;
	}

    private IntervalXYDataset createDataset() {
        XYSeries series = new XYSeries("Series 1");
        series.add(1.0, 5.0);
        series.add(2.0, 7.8);
        series.add(3.0, 9.3);
        XYSeriesCollection collection = new XYSeriesCollection();
        collection.addSeries(series);
        return new XYBarDataset(collection, 0.3);
    }
}
testApplet.html

Code: Select all

<html>
<body>
	<table width="98%" id="table1" border="0" align="center" cellpadding="1" cellspacing="1" bgcolor="#C1D9FC" class="ac-hui">
		<tr>
			<td  id="contentTD" align="center" class="ac-bai">
			<script src="<%=basePath%>/inc/testApplet.js"></script>
			</td>
		</tr>
    </table>
    <table>
<button name="test" onclick="viewChart();" value="Test Applet Button">
    </table>
</body>
<script>

	function viewChart(){
		document.getElementById("chartTest").viewChart(true);
	}

</script>
</html>
testApplet.js

Code: Select all

  var tdObj = document.getElementById("contentTD");
  var _app = navigator.appName;

  if (_app == 'Mozilla') {
    tdObj.document.write('<embed code="ChartApplet.class"'
    			 + 'name="chartTest"'
                 + 'width="100%"'
                 + 'height="360"'
                 + 'type="application/x-java-applet;version=1.1.2"'
                 + 'CODE = "ChartApplet.class"'
                 + 'CODEBASE = "applets"'
                 + 'ARCHIVE = "jfreechart-1.0.0.jar,jcommon-1.0.0.jar"'
                 + 'pluginspage="...java.sun.com/products/plugin/1.1.2/plugin-install.html"'
                 + 'scriptable="false"'
                   );
    }
  else if (_app == 'Microsoft Internet Explorer') {
    tdObj.document.write('<OBJECT '
    			   + 'name="chartTest"'
                   + 'classid="clsid:8AD9C840-044E-11D1-B3E9-00805F499D93"'
                   + 'codebase="<%=request.getContextPath()%>/download/jinstall-112-win32.cab#Version=1,1,2,0"'
                   + 'width="100%"'
                   + 'height="360">'
                   + '<PARAM name="code" value="ChartApplet.class">'
				   + '<PARAM name="codebase" value="applets" >'
				   + '<PARAM name="archive" value="jfreechart-1.0.9.jar,jcommon-1.0.12.jar" >'
				   + '<PARAM NAME="MAYSCRIPT" VALUE="true">'
				   + '<param name="DebugOutput" value="TRUE">'
    			      			   + '<PARAM name="scriptable" value="true">'
    			                     
                   + '</OBJECT>');
    }
  else {
    tdObj.document.write('<p>Sorry, unsupported browser.</p>');
    }

nubiste
Posts: 13
Joined: Mon Aug 04, 2008 9:53 am

Post by nubiste » Mon Aug 18, 2008 9:44 am

How did you manage to resolve this?

Locked