JFreeChart PieChart EJB

Hi, I just downloaded JFreeChart and tried out some sample applications on my desktop and everything is working great. I need a graphing utility on the server side and I thought I would convert the chart to an image and serialize it, but the call to ChartFactory.createPieChart(..., ...) is not returning in my session bean call. Not sure what I might be doing wrong. Here is my test code:

publicvoid createPieChart(java.util.Hashtable values,int width,int height){

// create a dataset...

System.out.println("In createpiechart..");

DefaultPieDataset dataset =new DefaultPieDataset();

dataset.setValue("Category 1", 43.2);

dataset.setValue("Category 2", 27.9);

dataset.setValue("Category 3", 79.5);

System.out.println("creating piechart..");

// create a chart...

JFreeChart chart = ChartFactory.createPieChart(

"Sample Pie Chart",

dataset,

true,// legend?

true,// tooltips?

false// URLs?

);

System.out.println("created piechart..");//does not reach here

}

Any clues?

[1706 byte] By [shruti_giri] at [2007-9-30 21:09:44]
# 1
The only way it wouldn't reach there is if:1) There is an exception being thrown. Could you copy the text from System.out.print(...) exactly from the console?2) You are running it in a Thread and for some reason the thread is killed.
rkippen at 2007-7-7 2:42:50 > top of Java-index,Security,Cryptography...
# 2

Thanks a heap for replying. Well maybe the prolem is something else. The client is quitting with this error:

java.rmi.ServerException: RemoteException occurred in server thread; nested exception is:

java.rmi.RemoteException

at com.sun.corba.se.internal.iiop.ShutdownUtilDelegate.mapSystemException(ShutdownUtilDelegate.java:61)

at javax.rmi.CORBA.Util.mapSystemException(Util.java:65)

at grapher._Grapher_Stub.createPieChart(Unknown Source)

at grapher.Frame2.jButton1_actionPerformed(Frame2.java:82)

at grapher.Frame2_jButton1_actionAdapter.actionPerformed(Frame2.java:105)

at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:1764)

at javax.swing.AbstractButton$ForwardActionEvents.actionPerformed(AbstractButton.java:1817)

at javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:419)

at javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:257)

at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(BasicButtonListener.java:245)

at java.awt.Component.processMouseEvent(Component.java:5134)

at java.awt.Component.processEvent(Component.java:4931)

at java.awt.Container.processEvent(Container.java:1566)

at java.awt.Component.dispatchEventImpl(Component.java:3639)

at java.awt.Container.dispatchEventImpl(Container.java:1623)

at java.awt.Component.dispatchEvent(Component.java:3480)

at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:3450)

at java.awt.LightweightDispatcher.processMouseEvent(Container.java:3165)

at java.awt.LightweightDispatcher.dispatchEvent(Container.java:3095)

at java.awt.Container.dispatchEventImpl(Container.java:1609)

at java.awt.Window.dispatchEventImpl(Window.java:1590)

at java.awt.Component.dispatchEvent(Component.java:3480)

at java.awt.EventQueue.dispatchEvent(EventQueue.java:450)

at java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchThread.java:197)

at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:150)

at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:144)

at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:136)

at java.awt.EventDispatchThread.run(EventDispatchThread.java:99)

Caused by: java.rmi.RemoteException

at com.sun.enterprise.iiop.POAProtocolMgr.mapException(POAProtocolMgr.java:494)

at com.sun.ejb.containers.BaseContainer.postInvoke(BaseContainer.java:564)

at grapher.GrapherBean_EJBObjectImpl.createPieChart(GrapherBean_EJBObjectImpl.java:32)

at grapher._GrapherBean_EJBObjectImpl_Tie._invoke(Unknown Source)

at com.sun.corba.ee.internal.POA.GenericPOAServerSC.dispatchToServant(GenericPOAServerSC.java:569)

at com.sun.corba.ee.internal.POA.GenericPOAServerSC.internalDispatch(GenericPOAServerSC.java:211)

at com.sun.corba.ee.internal.POA.GenericPOAServerSC.dispatch(GenericPOAServerSC.java:113)

at com.sun.corba.ee.internal.iiop.ORB.process(ORB.java:275)

at com.sun.corba.ee.internal.iiop.RequestProcessor.process(RequestProcessor.java:83)

at com.iplanet.ias.corba.ee.internal.iiop.ServicableWrapper.service(ServicableWrapper.java:25)

at com.iplanet.ias.util.threadpool.FastThreadPool$ThreadPoolThread.run(FastThreadPool.java:283)

at java.lang.Thread.run(Thread.java:536)

On the server side there are no exceptions being thrown. Here's the output:

[01/Nov/2004:11:42:40] INFO ( 492): LDR5010: All ejb(s) of [GrapherApp] loaded successfully!

[01/Nov/2004:11:42:41] INFO ( 492): CORE3276: Installing a new configuration

[01/Nov/2004:11:42:43] INFO ( 492): CORE3280: A new configuration was successfully installed

[01/Nov/2004:11:42:43] INFO ( 492): WEB4004: Closing web application environment for virtual server [server1]

[01/Nov/2004:11:44:05] INFO ( 492): CORE3282: stdout: In createpiechart..

[01/Nov/2004:11:44:05] INFO ( 492): CORE3282: stdout: creating piechart..

shruti_giri at 2007-7-7 2:42:50 > top of Java-index,Security,Cryptography...
# 3
Just wanted to mention that other methods in the bean that are not related to JFreeChart are working just fine.
shruti_giri at 2007-7-7 2:42:50 > top of Java-index,Security,Cryptography...
# 4

The client seems to be pretty sure that the server is throwing an exception. Can you confirm that you're not catching the exception and hiding it on the server side?

Another thing you might try is on your server, create a simple application that calls:

JFreeChart chart = ChartFactory.createPieChart(

"Sample Pie Chart",

dataset,

true, // legend?

true, // tooltips?

false // URLs?

);

rkippen at 2007-7-7 2:42:50 > top of Java-index,Security,Cryptography...
# 5

hmmm...yes you're right. There are exceptions being thrown and for whatever reason App Server 7 is not logging them. An other machine had version 8 on it and that logged the messages. There's probably a setting that I'm missing. After fixing some errors I reached this point:

avax.ejb.EJBException

at com.sun.ejb.containers.BaseContainer.processSystemException(BaseContainer.java:2697)

at com.sun.ejb.containers.BaseContainer.completeNewTx(BaseContainer.java:2603)

at com.sun.ejb.containers.BaseContainer.postInvokeTx(BaseContainer.java:2411)

at com.sun.ejb.containers.BaseContainer.postInvoke(BaseContainer.java:763)

at com.sun.ejb.containers.EJBObjectInvocationHandler.invoke(EJBObjectInvocationHandler.java:137)

at $Proxy19.createPieChart(Unknown Source)

at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)

at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)

at java.lang.reflect.Method.invoke(Method.java:324)

at com.sun.corba.ee.impl.presentation.rmi.ReflectiveTie._invoke(ReflectiveTie.java:117)

at com.sun.corba.ee.impl.protocol.CorbaServerRequestDispatcherImpl.dispatchToServant(CorbaServerRequestDispatcherImpl.java:651)

at com.sun.corba.ee.impl.protocol.CorbaServerRequestDispatcherImpl.dispatch(CorbaServerRequestDispatcherImpl.java:190)

at com.sun.corba.ee.impl.protocol.CorbaMessageMediatorImpl.handleRequestRequest(CorbaMessageMediatorImpl.java:1653)

at com.sun.corba.ee.impl.protocol.CorbaMessageMediatorImpl.handleRequest(CorbaMessageMediatorImpl.java:1513)

at com.sun.corba.ee.impl.protocol.CorbaMessageMediatorImpl.handleInput(CorbaMessageMediatorImpl.java:895)

at com.sun.corba.ee.impl.protocol.giopmsgheaders.RequestMessage_1_2.callback(RequestMessage_1_2.java:172)

at com.sun.corba.ee.impl.protocol.CorbaMessageMediatorImpl.handleRequest(CorbaMessageMediatorImpl.java:668)

at com.sun.corba.ee.impl.transport.SocketOrChannelConnectionImpl.dispatch(SocketOrChannelConnectionImpl.java:375)

at com.sun.corba.ee.impl.transport.SocketOrChannelConnectionImpl.read(SocketOrChannelConnectionImpl.java:284)

at com.sun.corba.ee.impl.transport.ReaderThreadImpl.doWork(ReaderThreadImpl.java:73)

at com.sun.corba.ee.impl.orbutil.threadpool.ThreadPoolImpl$WorkerThread.run(ThreadPoolImpl.java:382)

Caused by: java.lang.NoClassDefFoundError

at org.jfree.chart.ChartFactory.createPieChart(ChartFactory.java:218)

at grapher.StatefulGrapherBean.createPieChart(StatefulGrapherBean.java:73)

at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)

at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)

at java.lang.reflect.Method.invoke(Method.java:324)

at com.sun.enterprise.security.SecurityUtil$2.run(SecurityUtil.java:146)

at java.security.AccessController.doPrivileged(Native Method)

at com.sun.enterprise.security.application.EJBSecurityManager.doAsPrivileged(EJBSecurityManager.java:930)

at com.sun.enterprise.security.SecurityUtil.invoke(SecurityUtil.java:151)

at com.sun.ejb.containers.EJBObjectInvocationHandler.invoke(EJBObjectInvocationHandler.java:128)

... 17 more

|#]

Now I'm not sure how to get to these '17 more'. The ClassNotFound exception in ChartFactory line 218 was on "new JFreeChart()" which exists on the server side in the class path and it's the same package as ChartFactory, so I'm not sure why the error is being thrown there. My guess is it is probably somewhere inside the JFreeChart constructor and I wish I new how to get to those 17 more error messages. Any pointers here? Thanks for your help so far, I'll post some dukes :)

shruti_giri at 2007-7-7 2:42:50 > top of Java-index,Security,Cryptography...
# 6
Never mind - it was a classpath related problem. Thanks for your help anyway.
shruti_giri at 2007-7-7 2:42:50 > top of Java-index,Security,Cryptography...