I currently develop an application in JBoss 7.2 using NetBeans. In one of my EJB components, I need to use the JFreeChart library to produce some charts that I need. So what I did is, first, to add the external jars needed (in this case jcommon-1.0.22.jar and jfreechart-1.0.18.jar).
My code looks like this:
The EJB:
@Stateless
public class GraphGeneratorBean implements GraphGenerator {
@Override
public void createGraph() {
PieChart demo = new PieChart("Comparison", "Which operating system are you using?");
}
}
The graph class:
public class PieChart {
public PieChart(String applicationTitle, String chartTitle) throws IOException {
super(applicationTitle);
PieDataset dataset = createDataset();
JFreeChart chart = createChart(dataset, chartTitle);
...
}
It compiles fine, but when I run the application, I get the runtime error:
JBAS014134: EJB Invocation failed on component GraphGeneratorBean for method public abstract void com.test.reportmanager.GraphGenerator.createGraph(): javax.ejb.EJBTransactionRolledbackException: Unexpected Error
...
Caused by: java.lang.NoClassDefFoundError: org/jfree/data/general/PieDataset
...
Caused by: java.lang.ClassNotFoundException: org.jfree.data.general.PieDataset from [Module "deployment.Component1-EJB.jar:main" from Service Module Loader]
which means that the PieDataset.class could not be loaded by the ClassLoader, although I see that the specific file is in place (org/jfree/data/general/). I have read some possible solutions and I tried adding the jars with the Class-Path
line in the Manifest.MF
but had no luck. I am working with Windows.
Can anyone give me a good step-to-step solution? Thanks in advance!
EDIT:
My file layout is:
.\build
|- ...
.\dist
|- ...
.\src
|- conf
|- java
.\lib
|- jfreechart-1.0.18.jar
|- jcommon-1.0.22.jar
And my manifest (of the component that uses this librady) is:
Manifest-Version: 1.0
Dependencies: deployment.Component1-EJB.jar, deployment.Component2-EJB.jar
Class-Path: lib\jfreechart-1.0.18.jar; lib\jcommon-1.0.22.jar