JFree Chart 1.0.13 shows trouble in Linux server

A discussion forum for JFreeChart (a 2D chart library for the Java platform).
Locked
sathi
Posts: 1
Joined: Mon Jun 13, 2011 11:18 am
antibot: No, of course not.

JFree Chart 1.0.13 shows trouble in Linux server

Post by sathi » Mon Jun 13, 2011 12:26 pm

Hi,I have gone thru the forum which has already discussed about this issue.But still i cant find a solution out of it.Thats why am posting a question related to it.

Am using Netbeans ide 4.1 to work with the chart.My chart application worked well on the windows environment...I generated a .WAR file and deployed it in the LINUX server...I retrieved the chart from a client machine. At the first time the chart worked perfectly in the explorer and after a while it showed the following error

It displays the following error
HTTP Status 500 -

type Exception report

message

description The server encountered an internal error () that prevented it from fulfilling this request.

exception

javax.servlet.ServletException: Servlet execution threw an exception

root cause

java.lang.NoClassDefFoundError
GenChart.processRequest(GenChart.java:105)
GenChart.doPost(GenChart.java:182)
javax.servlet.http.HttpServlet.service(HttpServlet.java:709)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)

note The full stack trace of the root cause is available in the Apache Tomcat/5.0.28 logs.
Apache Tomcat/5.0.28[/color]
Below i have given my servlet code to Write the chart as an image.

Code: Select all

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */


import java.io.IOException;
import java.io.PrintWriter;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.jfree.chart.ChartFrame;
import org.jfree.chart.plot.CategoryPlot;
import java.awt.Color;
import java.sql.*;
import java.io.*;
import java.util.Locale;
import javax.servlet.RequestDispatcher;
import javax.servlet.ServletOutputStream;
import org.jfree.chart.ChartFactory;
import org.jfree.chart.ChartRenderingInfo;
import org.jfree.chart.ChartUtilities;
import org.jfree.chart.JFreeChart;
import org.jfree.chart.encoders.EncoderUtil;
import org.jfree.chart.entity.StandardEntityCollection;
import org.jfree.chart.imagemap.ToolTipTagFragmentGenerator;
import org.jfree.chart.plot.PlotOrientation;
import org.jfree.data.*;
import org.jfree.data.category.CategoryDataset;
import org.jfree.data.jdbc.JDBCCategoryDataset;
import org.jfree.data.jdbc.JDBCPieDataset;
import javax.servlet.*;
import javax.servlet.http.*;
import mis.form1.* ;
import mis.Conn01;



public class GenChart extends HttpServlet {
    private String name;



    protected void processRequest(HttpServletRequest request,HttpServletResponse response)
    throws ServletException, IOException {

        String month1 = request.getParameter("month");
        String year1 = request.getParameter("year");
         ServletOutputStream out = response.getOutputStream();
         ChartRenderingInfo info = new ChartRenderingInfo(new StandardEntityCollection());
          Conn01 conObj = null; 
        Connection connection = null;
        HttpSession session = request.getSession(true);    
        String name  = (String) session.getAttribute( "theName" ); 
      String name1 = (String) session.getAttribute( "theName1" ); 
      String grandtotal=null;
     
try {
          conObj = new Conn01();
          connection = conObj.conn01(name, name1 );
    
              String sql = "SELECT SUM(netloan) as total FROM graphbus WHERE month='"+month1+"' AND year='"+year1+"'  group by month";
                  Statement s = connection.createStatement();
            s.executeQuery(sql);
            ResultSet rs = s.getResultSet();
            while (rs.next()) {
                grandtotal = rs.getString("total");
              
            }
                  connection.close();
        }
catch (Exception e) {
            System.out.println("Exception is ;" + e);
        }

        try {
             conObj = new Conn01();
            String sql="SELECT CONCAT(state,'- ',sum(netloan)),sum(netloan) as total FROM graphbus WHERE month='"+month1+"' AND year='"+year1+"'  group by state";

            JDBCPieDataset dataset=new JDBCPieDataset(conObj.conn01(name, name1 ));

            dataset.executeQuery( sql);

            JFreeChart chart = ChartFactory.createPieChart3D(
                "BUSINESS FOR THE MONTH- " + month1+ " YEAR- " + year1 + " TOTAL- " + grandtotal,
                dataset,
                true,
                true,
                true   );

            /* TODO output your page here
            out.println("<html>");
            out.println("<head>");
            out.println("<title>Servlet GenChart</title>");
            out.println("</head>");
            out.println("<body>");
            out.println("<h1>Servlet GenChart at " + request.getContextPath () + "</h1>");
            out.println("</body>");
            out.println("</html>");
            */
        {
ChartUtilities.writeChartAsPNG(out, chart, 800, 500);

 }
                                      
        }
        catch (Exception e) {
            System.out.println("Exception is ;" + e);
        }

             }

    // <editor-fold defaultstate="collapsed" desc="HttpServlet methods. Click on the + sign on the left to edit the code.">
    /**
     * Handles the HTTP <code>GET</code> method.
     * @param request servlet request
     * @param response servlet response
     * @throws ServletException if a servlet-specific error occurs
     * @throws IOException if an I/O error occurs
     */
    
    protected void doGet(HttpServletRequest request, HttpServletResponse response)
    throws ServletException, IOException {
        processRequest(request, response);
    }

    /**
     * Handles the HTTP <code>POST</code> method.
     * @param request servlet request
     * @param response servlet response
     * @throws ServletException if a servlet-specific error occurs
     * @throws IOException if an I/O error occurs
     */
  
    protected void doPost(HttpServletRequest request, HttpServletResponse response)
    throws ServletException, IOException {
        processRequest(request, response);
    }

    /**
     * Returns a short description of the servlet.
     * @return a String containing servlet description
     */
   
    public String getServletInfo() {
        return "Short description";
    }// </editor-fold>

 

}

It genereates a beautiful Piechart in Windows server...But when WAR file is deployed in LINUX SERVER it shows the error i ve mentioned at the top.

Am using total 4 jar files

my-sql-connector-java-3.1.11.jar
servlet-api.jar

and

jcommon-1.0.16
jfreechart-1.0.13

i ve them in my lib folder in my windows server.
What should i do further to make thee chart work in the Linux environment.(Red Hat Linux).

Most important is the chart worked in my client system first time when i retrieved it from the server and after a while it dint work...I dont know what went wrong.It would be a great help if u assist me with this.Thanx in advance.

Locked