Reputation: 59
I am trying to get a Dynmic Report to work with the following code:
import java.sql.Connection;
import net.sf.dynamicreports.jasper.builder.JasperReportBuilder;
import net.sf.dynamicreports.report.builder.DynamicReports;
import net.sf.dynamicreports.report.builder.column.Columns;
import net.sf.dynamicreports.report.builder.component.Components;
import net.sf.dynamicreports.report.builder.datatype.DataTypes;
import net.sf.dynamicreports.report.constant.HorizontalAlignment;
import net.sf.dynamicreports.report.exception.DRException;
/**
*
* @author Nigel Backhurst
*/
public class UnsoldLots
{
private Connection con;
private Seller seller;
private int auctionID;
public UnsoldLots(Connection c, Seller s, int a)
{
con = c;
seller = s;
auctionID = a;
String sellerName = seller.FirstName + " " + seller.Surname;
String sellerID = seller.idSeller;
String auction = Integer.toString(a);
String sql = "SELECT LotNumber, Description FROM lots WHERE "
+ "AuctionID = \'" + auction + "\' AND idSellers = \'"
+ sellerID + "\' AND LotSold = \'F\'";
String rTitle = "Unsold Lots for " + sellerName;
JasperReportBuilder report = DynamicReports.report();
//create a new report
report
.columns(
Columns.column("Lot", "LotNumber", DataTypes.integerType()),
Columns.column("Description", "Description", DataTypes.stringType())
)
.title(
//title of the report
Components.text(rTitle )
.setHorizontalAlignment(HorizontalAlignment.CENTER))
.pageFooter(Components.pageXofY())
.setDataSource( sql , con);
try
{
//show the report
report.show();
} catch (DRException e)
{
e.printStackTrace();
}
}
}
However, I get the following exception when I run the code and cannot work out why:
Exception in thread "AWT-EventQueue-0" java.lang.NoClassDefFoundError: org/apache/commons/lang3/Validate
at net.sf.dynamicreports.report.base.component.DRList.setType(DRList.java:80)
at net.sf.dynamicreports.report.base.component.DRList.<init>(DRList.java:52)
at net.sf.dynamicreports.report.base.DRBand.<init>(DRBand.java:44)
at net.sf.dynamicreports.report.base.DRReport.init(DRReport.java:144)
at net.sf.dynamicreports.report.base.DRReport.<init>(DRReport.java:126)
at net.sf.dynamicreports.report.builder.ReportBuilder.<init>(ReportBuilder.java:75)
at net.sf.dynamicreports.jasper.builder.JasperReportBuilder.<init>(JasperReportBuilder.java:117)
at net.sf.dynamicreports.report.builder.DynamicReports.report(DynamicReports.java:120)
at iea.auction.manager.UnsoldLots.<init>(UnsoldLots.java:45)
I suspect I might be missing an include but cannot work out which.
Upvotes: 0
Views: 1921
Reputation: 69450
You miss the commons-lang3.jar
in your classpath. Download and add it to your classpath.
Upvotes: 1