I think this problem is more JBoss than JFreeChart. I've tried putting my jfreechart and jcommon jars into the appropriate WEB-INF/lib directory but it's having problems compiling the jsp that tries and create the chart. Here is the jsp : <%@page import="java.util.Enumeration"%> <%@page import="org.jfree.data.category.*"%> <%@page import="org.jfree.chart.*"%> <%@page import="org.jfree.chart.plot.*"%> <%@page language="java" contentType="image/png" %>
<%! CategoryDataset getDataset(HttpServletRequest request) { DefaultCategoryDataset dataset = new DefaultCategoryDataset(); Enumeration paramNames = request.getParameterNames(); while (paramNames.hasMoreElements()) { String name = (String) paramNames.nextElement(); if (name.startsWith("series")) { dataset.addValue(Double.parseDouble(request.getParameter(name)), "", name.substring(6)); } } return dataset; }
JFreeChart createChart(HttpServletRequest request) { return ChartFactory.createLineChart( // title - the chart title request.getParameter("title"), // domainAxisLabel - the label for the category axis request.getParameter("domainAxisLabel"), // rangeAxisLabel - the label for the value axis request.getParameter("rangeAxisLabel"), // dataset getDataset(request), // orientation PlotOrientation.VERTICAL, // show legend ("true".equals(request.getParameter("legend"))), // tooltips - generate tool tips? true, // urls false); } %>
Here is the error messages : org.apache.jasper.JasperException: Unable to compile class for JSP
An error occurred at line: 13 in the jsp file: /chart.jsp Generated servlet error: CategoryDataset cannot be resolved to a type
An error occurred at line: 13 in the jsp file: /chart.jsp Generated servlet error: DefaultCategoryDataset cannot be resolved to a type
An error occurred at line: 13 in the jsp file: /chart.jsp Generated servlet error: DefaultCategoryDataset cannot be resolved to a type
An error occurred at line: 13 in the jsp file: /chart.jsp Generated servlet error: JFreeChart cannot be resolved to a type
An error occurred at line: 13 in the jsp file: /chart.jsp Generated servlet error: ChartFactory cannot be resolved
An error occurred at line: 13 in the jsp file: /chart.jsp Generated servlet error: PlotOrientation.VERTICAL cannot be resolved to a type
An error occurred at line: 48 in the jsp file: /chart.jsp Generated servlet error: JFreeChart cannot be resolved to a type
An error occurred at line: 48 in the jsp file: /chart.jsp Generated servlet error: The method createChart(HttpServletRequest) is undefined for the type chart_jsp
An error occurred at line: 48 in the jsp file: /chart.jsp Generated servlet error: ChartUtilities cannot be resolved
org.apache.jasper.JasperException: Unable to compile class for JSP
An error occurred at line: 13 in the jsp file: /chart.jsp Generated servlet error: CategoryDataset cannot be resolved to a type
An error occurred at line: 13 in the jsp file: /chart.jsp Generated servlet error: DefaultCategoryDataset cannot be resolved to a type
An error occurred at line: 13 in the jsp file: /chart.jsp Generated servlet error: DefaultCategoryDataset cannot be resolved to a type
An error occurred at line: 13 in the jsp file: /chart.jsp Generated servlet error: JFreeChart cannot be resolved to a type
An error occurred at line: 13 in the jsp file: /chart.jsp Generated servlet error: ChartFactory cannot be resolved
An error occurred at line: 13 in the jsp file: /chart.jsp Generated servlet error: PlotOrientation.VERTICAL cannot be resolved to a type
An error occurred at line: 48 in the jsp file: /chart.jsp Generated servlet error: JFreeChart cannot be resolved to a type
An error occurred at line: 48 in the jsp file: /chart.jsp Generated servlet error: The method createChart(HttpServletRequest) is undefined for the type chart_jsp
An error occurred at line: 48 in the jsp file: /chart.jsp Generated servlet error: ChartUtilities cannot be resolved
Hi Mark/All, Heres the directory structure I have. deploy/MyGraphs.war/ ....................WEB-INF/ ............................lib/ ................................jcommon-1.0.9.jar ................................jfreechart-1.0.5.jar ............................chart-html.jsp ............................chart.jsp
The guy that gave me this example has the chart-html.jsp as just html and an img tag in there that points to the jsp that creates the image. He said it works fine for him but I can't seem to get it working. Any help greatly appreciated.
This does not appear to be a classloader issue. It's a genuine compilation error. Looks like you are using a older version of JFreechart (in which the CategoryDataset class is under org.jfree.data package and not org.jfree.data.category.) The latest version of JFreechart has its classes refactored. You will have to use JFreeChart 1.0.5 library to get this jsp running.
I tried the jars under WEB-INF/lib and extracted them in classes to give it a try. I tried it underneath JBoss/lib, under the default/lib, and under deploy directly and still didn't work. I'm running the latest jfreechart but I guess the source I got it from may be using an older version. I'll have to check. Will re-post if I find anything. Thanks for the feedback guys.
RH
Rob Hunter
Ranch Hand
Joined: Apr 09, 2002
Posts: 788
posted
0
As I stated in the last posting though, I am using 1.0.5 (it's where I mention where I put the jars). I double checked (after extracting the jar) and the class is where it's being referenced. Any ideas with this in mind? Thanks again for the help.
Create a file named jboss-web.xml having the following contents and place it in the WEB-INF folder of your war file. Then after restarting the server try your jsp.
This will help us figure out if your jsp is picking up a different version of the JFreeChart library from the classpath.
Rob Hunter
Ranch Hand
Joined: Apr 09, 2002
Posts: 788
posted
0
Hi Guys, I thought I would re-post after looking at it again. I had the latest version of JFreeChart but the examples were expecting an older version whereby the hierarchy was restructured. Thanks for the help.
Rob
Rob Hunter
Ranch Hand
Joined: Apr 09, 2002
Posts: 788
posted
0
I had it working but now I get this (from when it was working to now I had made zero changes). We have however added another .war file to the default server and the lib and classes directories underneath the .war directory in question may have gotten overwritten. Help would be very much appreciated.
Rob, could you please post this in a new thread. I got confused when I saw that there was a reply to this thread, and it is a different error, and not really related to what you had before.
Thanks
Mark
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to
run our stuff on 16 servers instead of 3.