3

I have 2 custom classes I want to use in my Jasper report. I have followed this suggestion: Custom Class for JasperReports field How ever I can't get IReport to compile the report.

Compile result:

net.sf.jasperreports.engine.design.JRValidationException: Report design not valid :
1. java.lang.ClassNotFoundException: Will not load classes from default package (Client)      
2. java.lang.ClassNotFoundException: Will not load classes from default package (User)     
at net.sf.jasperreports.engine.design.JRAbstractCompiler.verifyDesign(JRAbstractCompiler.java:271) 
at net.sf.jasperreports.engine.design.JRAbstractCompiler.compileReport(JRAbstractCompiler.java:153)     
at com.jaspersoft.ireport.designer.compiler.IReportCompiler.run(IReportCompiler.java:512)     
at org.openide.util.RequestProcessor$Task.run(RequestProcessor.java:572)     
at org.openide.util.RequestProcessor$Processor.run(RequestProcessor.java:997)

The jrxml file: https://gist.github.com/4285142

I am parsing another class, which holds an object of theese 2 classes:

User class:

public class User
{
    int _userId;
    UserPermission _userPermission;
    String _firstName;
    String _lastName;
    String _userName;
    String _userPassword;
    String _saltValue;
    Date _creationDate;
    Date _editedDate;

    //get&setters
}

Client class:

public class Client 
{
     int _clientId;
     String _name;
     String _address;
     City _city;
     long _phoneNo;
     String _eMail;
     Date _creationDate;
     Date _editedDate;

     //get&setters
}
Community
  • 1
  • 1
KLIM8D
  • 582
  • 1
  • 8
  • 25
  • Have you tried moving these classes to a proper package? The error seems to suggest that it can't use classes from the default package (i.e. no package) – Guillaume Dec 14 '12 at 13:06
  • @Guillaume I might need to import the classes somehow. I just don't know how to do it. – KLIM8D Dec 14 '12 at 13:21
  • You can define imports in the .jrxml file, actually looking at your design you're already importing models.Client and models.User, maybe you could try importing models.* instead? – Guillaume Dec 14 '12 at 13:25
  • @Guillaume Just trying changing the import to "models.*", still the same compile error. My folder structure is /appName/src/, where the report is located in src and the package/folder models aswell (/appName/src/models/) – KLIM8D Dec 14 '12 at 13:38
  • Are you trying to compile from iReport? If so you might need to add your compiled classes folder to iReport's classpath. Go to Tools -> Options -> iReport -> Classpath – Guillaume Dec 14 '12 at 13:54
  • @Guillaume I didn't work either :( Custom classes seems to complicated. I wrote a java wrapper class which I parse to the JRBeanCollectionDatasource instead. It works now, and I'm able to generate the pdf :) – KLIM8D Dec 14 '12 at 16:37

0 Answers0