1

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
BrainArchitect
  • 558
  • 8
  • 16
  • When you rightclick project-> properties-> libraries you see jfreechart.jar inthe list?If not you have to add it.As you sayd only problem have to be its not loaded by classLoader. – Tomas Bisciak Jul 17 '14 at 10:44
  • Yes, both jcommon-1.0.22.jar and jfreechart-1.0.18.jar are on the list. Otherwise it couldn't be able to compile in the first place.. – BrainArchitect Jul 17 '14 at 10:48
  • Maybe this can help you http://stackoverflow.com/questions/16624671/how-do-i-get-started-with-jfreechart .Otherwise update question with manifest file as well ,so others can have idea whats wrong. – Tomas Bisciak Jul 17 '14 at 10:58
  • I followed the instructions on the link you gave me but nothing. I added in the question the file structure and MANNIFEST.MF content. Maybe something wrong with the paths used in Class-Path? – BrainArchitect Jul 17 '14 at 11:33
  • Class path looks good.Seems to me that you have it set up properly.Try to remove libs from classpath,clean and build project ,add them again ,reopen netbeans and run it again.I had this problem with jnativehook library,even tho i had jar in class path netbeans were throwing error that it doesnt see it,I did mentioned and error went away.Im getting curious of what its causing your error now.Hopefully someone will give another insight. – Tomas Bisciak Jul 17 '14 at 11:56
  • Thanks for the advice. Unfortunately it didn't work, so I suppose I have to wait for more answers... – BrainArchitect Jul 17 '14 at 12:31
  • "extends JFrame" looks wrong for server side code. ;) – David Gilbert Jul 17 '14 at 12:42
  • Of course! Copy-paste mistake.. But still doesn't affect the reason I get this error – BrainArchitect Jul 17 '14 at 12:49

0 Answers0