This discussion is archived
3 Replies Latest reply: Jul 9, 2007 10:10 AM by FrançoisDegrelle RSS

My java bean makes my Forms application crashing. Any idea?

odaboval Newbie
Currently Being Moderated

As I said earlier, please excuse my poor skills in java !!

Here is the problem:
Using different sources (tutorials, code exemples, OTN forum), I think I managed to build a java bean application.

Under jDeveloper, it works fine.. I can display a nice graph.
But when I add the class name in the Oracle Forms bean item, Forms crashes...

(BTW, I made a test with a very basic Java Bean, and I was able to successfully display the results in Forms)
We use Forms 10g.
So, there is something bad in my code ...
Do you have any suggestion ?

Here is the code and the java console display :
1) the java code :
package oracle.forms.RadarGraph;

import oracle.forms.handler.IHandler;
import oracle.forms.ui.CustomEvent;
import oracle.forms.ui.VBean;
import oracle.forms.engine.Main;

import java.awt.Color;
import java.awt.Dimension;
import org.jfree.chart.ChartFactory;
import org.jfree.chart.ChartPanel;
import org.jfree.chart.JFreeChart;
import org.jfree.chart.axis.NumberAxis;
import org.jfree.chart.plot.PolarPlot;
import javax.swing.*;
import org.jfree.ui.ApplicationFrame;
import org.jfree.ui.RefineryUtilities;
import java.lang.String;

public class PolarChart extends VBean
JFrame mainFrame;

static oracle.forms.handler.IHandler mHandler;
// properties you can set
protected static final ID SETHIDDEN = ID.registerProperty("SETHIDDEN");
protected static final ID GETBGCOLOR = ID.registerProperty("GETBGCOLOR");

public PolarChart(String s)
mainFrame = new JFrame();
JPanel jpanel = createPanel();
jpanel.setPreferredSize(new Dimension(600, 500));

public void init(oracle.forms.handler.IHandler handler)
mHandler = handler;
// put your initialisation instructions here

// Set the properties to the bean
public boolean setProperty( property, Object value)
if(property == SETHIDDEN)
//System.err.printlnln("Set property 01=" + (String)value) ;
// get the paremeter string:
String sParam = (String)value;
if ( sParam.equals("true") )

return true;
else // default behaviour
return super.setProperty(property, value);

// Get the properties of the bean
public Object getProperty( property)
if (property == GETBGCOLOR)
// return the color of the parent container:
String sColor = "";
Color color = this.getParent().getBackground();
sColor = "r" + color.getRed() + "g" + color.getGreen() + "b" + color.getBlue();
return sColor ;
else // default behaviour
return super.getProperty(property);

// Send a message to the Forms module
public void dispatch_event( ID id )
CustomEvent ce = new CustomEvent(mHandler, id);

private static XYDataset createDataset()
XYSeriesCollection xyseriescollection = new XYSeriesCollection();
XYSeries xyseries = new XYSeries("Series 1");
xyseries.add(0.0D, 2D);
xyseries.add(90D, 13D);
xyseries.add(180D, 9D);
xyseries.add(270D, 8D);
XYSeries xyseries1 = new XYSeries("Series 2");
xyseries1.add(90D, -11.199999999999999D);
xyseries1.add(180D, 21.399999999999999D);
xyseries1.add(250D, 17.300000000000001D);
xyseries1.add(355D, 10.9D);
return xyseriescollection;

private static JFreeChart createChart(XYDataset xydataset)
JFreeChart jfreechart = ChartFactory.createPolarChart("Polar Chart", xydataset, true, false, false);
PolarPlot polarplot = (PolarPlot)jfreechart.getPlot();
polarplot.addCornerTextItem("Mesure 1");
polarplot.addCornerTextItem("Mesure 2");
NumberAxis numberaxis = (NumberAxis)polarplot.getAxis();
return jfreechart;

public static JPanel createPanel()
JFreeChart jfreechart = createChart(createDataset());
ChartPanel chartpanel = new ChartPanel(jfreechart);
return chartpanel;

public void run()

public static void main(String args[])
PolarChart polarchart = new PolarChart("Polar Chart");
// polarchart.setVisible(true);

2) the java console error :
connectMode=HTTP, native.
Forms Applet version is :
java.lang.InstantiationException: oracle.forms.RadarGraph.PolarChart
     at java.lang.Class.newInstance0(Native Method)
     at java.lang.Class.newInstance(Unknown Source)
     at oracle.forms.handler.UICommon.instantiate(Unknown Source)
     at oracle.forms.handler.UICommon.onCreate(Unknown Source)
     at oracle.forms.handler.JavaContainer.onCreate(Unknown Source)
     at oracle.forms.engine.Runform.onCreateHandler(Unknown Source)
     at oracle.forms.engine.Runform.processMessage(Unknown Source)
     at oracle.forms.engine.Runform.processSet(Unknown Source)
     at oracle.forms.engine.Runform.onMessageReal(Unknown Source)
     at oracle.forms.engine.Runform.onMessage(Unknown Source)
     at oracle.forms.engine.Runform.sendInitialMessage(Unknown Source)
     at oracle.forms.engine.Runform.startRunform(Unknown Source)
     at oracle.forms.engine.Main.createRunform(Unknown Source)
     at oracle.forms.engine.Main.start(Unknown Source)
     at Source)
     at Source)

In advance, thanks a lot for your help.