Problem with servlet utilities

A free public discussion forum for the JFreeChart class library.

Problem with servlet utilities

Postby eels06 » Fri Dec 22, 2006 4:24 pm

hello everybody,

i'm a new jfreechart user, i'm tring to save charts using ServletUtilities class.

Here is my code :



Code: Select all
       
try {
   result = ServletUtilities.saveChartAsJPEG(chart, WIDTH, HEIGHT, session);
   result = "./DisplayChart?filename=" + result ;
   LOG.debug("chart sauvé à l'adresse : "+result) ;
} catch (IOException e) {...}


and i have this stack trace :

Code: Select all
16:16:11,657 - ERROR org.apache.catalina.core.ContainerBase.[jonas].[localhost].[/Pangoo-Web].[action] [http-9000-Processor25] - Servlet.service() for servlet action threw exception
java.lang.IllegalArgumentException: setAttribute: Non-serializable attribute
   at org.apache.catalina.session.StandardSession.setAttribute(StandardSession.java:1251)
   at org.apache.catalina.session.StandardSessionFacade.setAttribute(StandardSessionFacade.java:129)
   at org.jfree.chart.servlet.ServletUtilities.registerChartForDeletion(ServletUtilities.java:310)
   at org.jfree.chart.servlet.ServletUtilities.saveChartAsJPEG(ServletUtilities.java:264)
   at com.orange.pangoo.chart.ChartBuilder.buildLastMeasureChart(ChartBuilder.java:136)
   at com.orange.pangoo.chart.ChartBuilder.buildLastMeasureChart(ChartBuilder.java:89)
   at com.orange.pangoo.action.chart.LastGraphAction.execute(LastGraphAction.java:85)
   at org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:413)
   at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:225)
   at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1858)
   at org.apache.struts.action.ActionServlet.doGet(ActionServlet.java:446)
   at javax.servlet.http.HttpServlet.service(HttpServlet.java:743)
   at javax.servlet.http.HttpServlet.service(HttpServlet.java:856)
   at sun.reflect.GeneratedMethodAccessor205.invoke(Unknown Source)
   at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
   at java.lang.reflect.Method.invoke(Method.java:585)
   at org.apache.catalina.security.SecurityUtil$1.run(SecurityUtil.java:243)
   at java.security.AccessController.doPrivileged(Native Method)
   at javax.security.auth.Subject.doAsPrivileged(Subject.java:517)
   at org.apache.catalina.security.SecurityUtil.execute(SecurityUtil.java:275)
   at org.apache.catalina.security.SecurityUtil.doAsPrivilege(SecurityUtil.java:161)
   at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:245)
   at org.apache.catalina.core.ApplicationFilterChain.access$000(ApplicationFilterChain.java:50)
   at org.apache.catalina.core.ApplicationFilterChain$1.run(ApplicationFilterChain.java:156)
   at java.security.AccessController.doPrivileged(Native Method)
   at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:152)
   at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
   at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)
   at org.objectweb.jonas.web.catalina55.ResetAuthenticationValve.invoke(ResetAuthenticationValve.java:62)
   at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)
   at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
   at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)
   at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
   at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:869)
   at org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:664)
   at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527)
   at org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:80)
   at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:684)
   at java.lang.Thread.run(Thread.java:595)


This line throws the exception :
Code: Select all
result = ServletUtilities.saveChartAsJPEG(chart, WIDTH, HEIGHT, session);


When i don't use the session parameter it works (but the chart is marked as "one-time" and deleted by the DisplayChart servlet right after it is streamed to the client)

I can't find where is the problem... can somebody help me ?

thank you
eels06
 
Posts: 4
Joined: Fri Dec 22, 2006 4:13 pm

Postby demonhead » Sun Dec 24, 2006 8:31 pm

Code: Select all
org.jfree.chart.servlet.ServletUtilities.registerChartForDeletion(ServletUtilities.java:310)

Thats where the problem lies,have alook at the source code you shoudl be able to debug the problem
demonhead
 
Posts: 24
Joined: Thu May 25, 2006 5:44 am

Postby eels06 » Tue Dec 26, 2006 10:27 am

yes, you're right.

Here is the code of ServletUtilities.registerChartForDeletion(...)
Code: Select all
310 ChartDeleter chartDeleter = (ChartDeleter) Session.getAttribute("JFreeChart_Deleter");
311 if (chartDeleter == null) {
312    chartDeleter = new ChartDeleter();
313    session.setAttribute("JFreeChart_Deleter", chartDeleter);
314 }


It seems that i can't put a chartDeleter in my session... i gonna try to find out why

:D
eels06
 
Posts: 4
Joined: Fri Dec 22, 2006 4:13 pm

Postby eels06 » Wed Dec 27, 2006 4:09 pm

:roll: i can't manage to find why this code doesn't work...

i don't know why ServletUtilities is not able to put (or get) a chart deleter in (from) my Session ????
eels06
 
Posts: 4
Joined: Fri Dec 22, 2006 4:13 pm

Postby Taqua » Wed Dec 27, 2006 11:08 pm

The ChartDeleter class does not implement the Serializable interface. Fix that and you can add it to the session. (The servlet standard says, any object you add to the session must be serializable, so that it can be used in clustered environments.)

Regards,
Thomas
Taqua
JFreeReport Project Leader
 
Posts: 698
Joined: Fri Mar 14, 2003 3:34 pm

Postby eels06 » Thu Dec 28, 2006 3:59 pm

thanks for your answers.
eels06
 
Posts: 4
Joined: Fri Dec 22, 2006 4:13 pm

Re: Problem with servlet utilities

Postby banman101 » Mon Jun 07, 2010 8:06 pm

I ran into this same problem. For me, it is caused by my having <distributable /> tag defined in my web.xml.

I passed in a null session to avoid the error as was described above.
banman101
 
Posts: 1
Joined: Mon Jun 07, 2010 8:01 pm

Re: Problem with servlet utilities

Postby samsudeen » Sat Feb 19, 2011 6:36 pm

Sir, I am having a problem with the ServletUtilities.java.
It being a java.lang.Class type I do not know how to
initialize this class with the web.xml file of a servlet
class, for exaple HelloServlet3.java. I am just one
among the beginners of the java programing language.
Kindly look forward for your reply. Appreciate
samsudeen
samsudeen
 
Posts: 1
Joined: Sat Feb 19, 2011 5:54 pm


Return to JFreeChart - General

Who is online

Users browsing this forum: Bing [Bot], Google [Bot], Yahoo [Bot] and 12 guests