SHARE
TWEET

Untitled

a guest Apr 27th, 2016 66 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. HTTP Status 500 - Servlet execution threw an exception
  2.  
  3. type Exception report
  4.  
  5. message Servlet execution threw an exception
  6.  
  7. description The server encountered an internal error that prevented it from fulfilling this request.
  8.  
  9. exception
  10.  
  11. javax.servlet.ServletException: Servlet execution threw an exception
  12.     org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
  13. root cause
  14.  
  15. java.lang.NoClassDefFoundError: com/sun/image/codec/jpeg/JPEGCodec
  16.     com.java4less.rchart.gc.awt.ImageEncoder.saveToJPEG(ImageEncoder.java:84)
  17.     com.java4less.rchart.gc.awt.ImageEncoder.encode(ImageEncoder.java:41)
  18.     com.java4less.rchart.gc.awt.ChartAwtImage.saveToStream(ChartAwtImage.java:138)
  19.     com.java4less.rchart.Chart.saveToFile(Chart.java:1494)
  20.     com.java4less.rchart.web.MindChartServlet.doGet(MindChartServlet.java:238)
  21.     com.java4less.rchart.web.MindChartServlet.doPost(MindChartServlet.java:257)
  22.     javax.servlet.http.HttpServlet.service(HttpServlet.java:648)
  23.     javax.servlet.http.HttpServlet.service(HttpServlet.java:729)
  24.     org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
  25. root cause
  26.  
  27. java.lang.ClassNotFoundException: com.sun.image.codec.jpeg.JPEGCodec
  28.     org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1333)
  29.     org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1167)
  30.     com.java4less.rchart.gc.awt.ImageEncoder.saveToJPEG(ImageEncoder.java:84)
  31.     com.java4less.rchart.gc.awt.ImageEncoder.encode(ImageEncoder.java:41)
  32.     com.java4less.rchart.gc.awt.ChartAwtImage.saveToStream(ChartAwtImage.java:138)
  33.     com.java4less.rchart.Chart.saveToFile(Chart.java:1494)
  34.     com.java4less.rchart.web.MindChartServlet.doGet(MindChartServlet.java:238)
  35.     com.java4less.rchart.web.MindChartServlet.doPost(MindChartServlet.java:257)
  36.     javax.servlet.http.HttpServlet.service(HttpServlet.java:648)
  37.     javax.servlet.http.HttpServlet.service(HttpServlet.java:729)
  38.     org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
  39. note The full stack trace of the root cause is available in the Apache Tomcat/8.0.30 logs.
  40.    
  41. private Chart getChart(HttpServletRequest request) {
  42.  
  43.  
  44.         ChartLoader loader = new ChartLoader();
  45.         loader.paintDirect = true;
  46.         String dataFile = null;
  47.         String fileEncoding = "";
  48.         String user = "";
  49.         String psw = "";
  50.         String delim = null;
  51.         if (request != null) {
  52.             boolean isUri = false;
  53.  
  54.             for (Enumeration ps = request.getParameterNames(); ps
  55.                     .hasMoreElements();) {
  56.                 String name = (String) ps.nextElement();
  57.                 if (!isUri) {
  58.                     loader.setParameter(name, request.getParameter(name));
  59.                     if (name.compareTo("DATAFILE") == 0) {
  60.                         dataFile = request.getParameter(name);
  61.                     }
  62.                     if (name.compareTo("PSW") == 0) {
  63.                         psw = request.getParameter(name);
  64.                     }
  65.                     if (name.compareTo("USER") == 0) {
  66.                         user = request.getParameter(name);
  67.                     }
  68.                     if (name.compareTo("FILEENCODING") == 0) {
  69.                         fileEncoding = request.getParameter(name);
  70.                     }
  71.                     if (name.compareTo("ISURI") == 0) {
  72.                         dataFile = request.getParameter(name);
  73.                         isUri = true;
  74.                         delim = "?";
  75.                     }
  76.  
  77.                 } else {
  78.                     dataFile = dataFile + delim + name + "="
  79.                             + request.getParameter(name);
  80.                     delim = "&";
  81.                 }
  82.             }
  83.  
  84.  
  85.         }
  86.         String encodedUserPsw = "";
  87.         if (user.length() > 0) {
  88.             String userPassword = user + ":" + psw;
  89.             encodedUserPsw = (new BASE64Encoder()).encode(userPassword
  90.                     .getBytes());
  91.  
  92.         }
  93.         File f = new File("a.txt");
  94.  
  95.         if (dataFile != null) {
  96.             loader.fileEncoding = fileEncoding;
  97.             loader.loadFromFile(dataFile, false, encodedUserPsw);
  98.         } else {
  99.  
  100.             String[] chartparamname = new String[new Integer(
  101.                     request.getParameter("LENGTH")).intValue()];
  102.             String[] chartparamvalue = new String[new Integer(
  103.                     request.getParameter("LENGTH")).intValue()];
  104.             int i = 0;
  105.  
  106.             for (Enumeration ps = request.getParameterNames(); ps
  107.                     .hasMoreElements();) {
  108.                 String name = (String) ps.nextElement();
  109.                 if ((name.equals("WIDTH")) || (name.equals("HEIGHT"))
  110.                         || (name.equals("LENGTH"))
  111.                         || (name.equals("LEGEND_TITLE"))) {
  112.                 } else {
  113.                     chartparamname[i] = name;
  114.                     chartparamvalue[i] = request.getParameter(name);
  115.                     i++;
  116.  
  117.                 }
  118.             }
  119.             loader.setvalues(chartparamname, chartparamvalue,
  120.                     request.getParameter("LEGEND_TITLE"));
  121.         }
  122.         Chart chart = loader.build(false, false);
  123.         return chart;
  124.     }
  125.  
  126.     public void doGet(HttpServletRequest request, HttpServletResponse response)
  127.             throws ServletException, IOException {
  128.  
  129.         String encode = "jpeg";
  130.  
  131.         response.setContentType("image/" + encode);
  132.         javax.servlet.ServletOutputStream outb = response.getOutputStream();
  133.         response.setDateHeader("Expires", 0L);
  134.         try {
  135.             int w = 300;
  136.             int h = 300;
  137.  
  138.             Chart c = getChart(request);
  139.             c.setSize(w, h);
  140.             c.doubleBuffering = false;
  141.             c.saveToFile(outb, encode);
  142.             outb.close();
  143.         } catch (Exception e) {
  144.             logger.error("doGet(HttpServletRequest, HttpServletResponse)", e);
  145.         }
  146.     }
  147.    
  148. <dependency>
  149.             <groupId>java4less</groupId>
  150.             <artifactId>java4less</artifactId>
  151.             <version>1.0.0</version>
  152.             <optional>false</optional>
  153.         </dependency>
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top