Link to home
Start Free TrialLog in
Avatar of Nyamathkhan
Nyamathkhan

asked on

Problem with Pie chart in Jsp

Hi,

im trying to implement the pie chart in jsp page. and for that im using jfreechart's but im unable to under why im getting this problem below

problem :

The type org.jfree.util.PublicCloneable cannot be resolved. It is indirectly referenced from
 required .class files

at line :

JFreeChart chart = ChartFactory.createPieChart("Pie Chart ", data, true, true, false);


code :

<html>
<body>
String view = (String)request.getAttribute("option");
      if (view.equalsIgnoreCase("chart")) {

            int startIndex = 0;
            Vector vector = (Vector)session.getAttribute("defects");
            Iterator itr = vector.listIterator();
            int count = vector.size();
            int cd = 0;
            int od = 0;
            int fd = 0;
            int sd = 0;
            int ke = 0;
            DefectDetails dd = null;
            while (itr.hasNext()) {
                  dd = (DefectDetails)itr.next();
                  String status = (String)dd.getTechMStatus();
                  if(status.equalsIgnoreCase("closed")) {
                        cd = cd++;
                  }
                  if(status.equalsIgnoreCase("open")) {
                        od = od++;
                  }
                  if(status.equalsIgnoreCase("fixed")) {
                        fd = fd++;
                  }
                  if(status.equalsIgnoreCase("known error")) {
                        ke = ke++;
                  }
                  if(status.equalsIgnoreCase("solving")) {
                        sd = sd++;
                  }
            }
            final DefaultPieDataset data = new DefaultPieDataset();
        data.setValue("Closed", new Double(cd));
        data.setValue("Open", new Double(od));
        data.setValue("Fixed", new Double(fd));
        data.setValue("Known Errors", new Double(ke));
        data.setValue("Solving", new Double(sd));

        JFreeChart chart = ChartFactory.createPieChart
        ("Pie Chart ", data, true, true, false);

        try {
            final ChartRenderingInfo info = new
          ChartRenderingInfo(new StandardEntityCollection());
            File file1 = new File("C:\\Program Files\\Apache Software Foundation\\Tomcat 5.5\\webapps\\piechart.png");
            ChartUtilities.saveChartAsPNG(file1, chart, 600, 400, info);
        } catch (Exception e) {
            out.println(e);
        }
%>

    <IMG SRC="C:\\Program Files\\Apache Software Foundation\\Tomcat 5.5\\webapps\\piechart.png" WIDTH="600" HEIGHT="400" BORDER="0" USEMAP="#chart">
<% } %>
</body>
</html>

can body help me out for the solution please.

Regards,
nyamath.
ASKER CERTIFIED SOLUTION
Avatar of mrcoffee365
mrcoffee365
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
check whether jcomm.jar is available in your classpath. if so then there is no duplication
Avatar of Nyamathkhan
Nyamathkhan

ASKER

Hi,

you are right the jcommon.jar file was not there in the class path and now i have added it to the class path but still im getting the exception.

error :

SEVERE: Servlet.service() for servlet jsp threw exception
java.lang.NoSuchMethodError: org.jfree.ui.RectangleInsets.<init>(DDDD)V
      at org.jfree.chart.axis.Axis.<clinit>(Axis.java:146)
      at org.jfree.chart.StandardChartTheme.<init>(StandardChartTheme.java:227)
      at org.jfree.chart.ChartFactory.<clinit>(ChartFactory.java:229)
      at org.apache.jsp.Defect_005fDetails_jsp._jspService(Defect_005fDetails_jsp.java:194)
      at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:98)
      at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
      at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:331)
      at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:329)
      at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:265)
      at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
      at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:269)
      at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:188)
      at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:691)
      at org.apache.catalina.core.ApplicationDispatcher.processRequest(ApplicationDispatcher.java:469)
      at org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:403)
      at org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:301)
      at com.dash.DashBoardServlet.doPost(DashBoardServlet.java:191)
      at com.dash.DashBoardServlet.doGet(DashBoardServlet.java:35)
      at javax.servlet.http.HttpServlet.service(HttpServlet.java:690)
      at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
      at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:269)
      at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:188)
      at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
      at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:174)
      at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
      at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:117)
      at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:108)
      at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:151)
      at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:874)
      at org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:665)
      at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:528)
      at org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:81)
      at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:689)
      at java.lang.Thread.run(Thread.java:595)
--------------org.apache.jasper.JasperException: Exception in JSP: /Defect_Details.jsp:141

138:         data.setValue("Known Errors", new Double(ke));
139:         data.setValue("Solving", new Double(sd));
140:
141:         JFreeChart chart = ChartFactory.createPieChart("Pie Chart ", data, true, true, false);
142:
143:         try {
144:                   final ChartRenderingInfo info = new ChartRenderingInfo(new StandardEntityCollection());


Stacktrace:
org.apache.jasper.JasperException: Exception in JSP: /Defect_Details.jsp:141

138:         data.setValue("Known Errors", new Double(ke));
139:         data.setValue("Solving", new Double(sd));
140:
141:         JFreeChart chart = ChartFactory.createPieChart("Pie Chart ", data, true, true, false);
142:
143:         try {
144:                   final ChartRenderingInfo info = new ChartRenderingInfo(new StandardEntityCollection());


Stacktrace:
      at org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:451)
      at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:355)
      at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:329)
      at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:265)
      at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
      at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:269)
      at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:188)
      at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:691)
      at org.apache.catalina.core.ApplicationDispatcher.processRequest(ApplicationDispatcher.java:469)
      at org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:403)
      at org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:301)
      at com.dash.DashBoardServlet.doPost(DashBoardServlet.java:191)
      at com.dash.DashBoardServlet.doGet(DashBoardServlet.java:35)
      at javax.servlet.http.HttpServlet.service(HttpServlet.java:690)
      at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
      at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:269)
      at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:188)
      at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
      at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:174)
      at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
      at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:117)
      at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:108)
      at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:151)
      at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:874)
      at org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:665)
      at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:528)
      at org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:81)
      at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:689)
      at java.lang.Thread.run(Thread.java:595)

Regards,
nyamath.
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Hi,

Im unable to under stand that which method it is trying to find in jar. and i have attached the screen shot of the class and its method available in the jar.

if it is not the correct version of jar then can u please suggest the right version ?

thanks,
nyamath.
method.JPG
melchkishore is right, it's likely that now you have 2 jcommon.jar files in your path, and one of them is not the version that goes with your chart code.  Or that the jcommon.jar that you put in your classpath does not go with the version of jfreechart you are trying to run.

You can also see that the signature of the method that gives the exception is different from the one listed in your IDE, so that's the clue that there's a version problem.  You didn't write the call to RectangleInsets, it is within the Jfreechart classes somewhere, and it's calling a different method signature.
Hi,

earlier i was using jcommon.jar and according to ur comments i have tried with jcommon-1.0.16.jar but still im getting the same problem ?  for reference u can see the attachment below.

can u please suggest me what i need to do ?

Regards,
nyamath.

problem.JPG
Can you check the server classpath whether it is still using jcommon.jar ?
Hi,

i have check the jcommon.jar in server it was not replaced by the newer version of jar. i have replaced it and its working fine thanks for your help man. now its working fine.

Regards,
nyamath.
Great -- glad to help.
thanks for ur reply !

i got a new problem with the pie chart code. as u can see im trying to create the pie chart image with .png extension and saving at a perticular location on the tomcat installed server machine. but when im trying to access the image from the client machine its unable to display the image at the client browser
code :
 JFreeChart chart = ChartFactory.createPieChart("Pie Chart ", data, true, true, false);
        try {
                  ChartRenderingInfo info = new ChartRenderingInfo(new StandardEntityCollection());
                  final File file = new File("C:\\Program Files\\Apache Software Foundation\\Tomcat 5.5\\webapps\\piechart.png");
                  ChartUtilities.saveChartAsPNG(file, chart, 600, 400, info);
        } catch (Exception e) {
            e.printStackTrace();
        }

%>
            <center>
                  <img src="C:\\Program Files\\Apache Software Foundation\\Tomcat 5.5\\webapps\\piechart.png" width = "600" height = "400" alt=" Chart View ">
            </center><br>


its displaying the image as below :


prob.JPG
You don't put server file paths into html.  You put the url for the image, which in this case would be "/piechart.png".

The way EE works, you award points for the help you got, and if you have a new question, you open a new question.
ok
Is your problem solved?
no, im still facing the problem

the code is working fine with a small problem. that is the code is working on the server end. but not at the client side. means the jsp is not getting the updated image from the server every time when the request maid for the jsp. but when the new browser is opened and make a request to the jsp then the updated image is relecting.

im unable to understand what might be the problem in this ?
can you plz provide the solution for this one.

Regards,
nyamath.
Yes, the problem you posted is solved.  You need to award points to the experts here who helped you, then post a new question about the wrong image path that experts can work with you on.
ok
I've requested that this question be deleted for the following reason:

No comment has been added to this question in more than 21 days, so it is now classified as abandoned.

I have recommended this question be closed as follows:

Not enough information to confirm an answer.

If you feel this question should be closed differently, post an objection and a moderator will read all objections and then close it as they feel fit. If no one objects, this question will be closed automatically the way described above.

Experts-Exchange Auto Deleter
This question has excellent answers and jfreechart is still in use.  Award points to
mrcoffee365 Comment 2010-05-12 at 11:41:51ID: 32697800
krishna kishore mellacheruvu venkata  Comment 2010-05-14 at 05:53:03ID: 32711819

Split the points evenly.