makimura
unread,Sep 17, 2009, 9:47:35 AM9/17/09Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to excella
はじめまして牧村です。
Httpアクセスをトリガーに帳票を出力したいのですが、Javaサーブレットでexcellaが思うように動作せず困っています。(Javaはほとん
ど初めてです。)
具体的には以下のエラーになります。
java.lang.NoClassDefFoundError: Could not initialize class
org.bbreak.excella.reports.tag.SingleParamParser
org.bbreak.excella.reports.processor.ReportCreateHelper.createDefaultParsers
(ReportCreateHelper.java:77)
org.bbreak.excella.reports.processor.ReportProcessor.<init>
(ReportProcessor.java:91)
jp.tuyano.eclipsebook3.SampleServlet.doGet(SampleServlet.java:173)
javax.servlet.http.HttpServlet.service(HttpServlet.java:617)
javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
______________________________
ReportProcessor reportProcessor = new ReportProcessor();
_______________________________
レポートプロセッサーをインスタンス化しようとすると
org.bbreak.excella.reports.tag.SingleParamParserが見つからなく
エラーになります。
excella-repots.1.0.jarをライブラリに指定してよみこんでいるので
SingleParamParserクラスだけ見つからないというのが理解できなくて困っています。
動作環境は
Tomcat 6.0.20
JDK 6u16
とどちらも最新の環境で試しています。
試したのはサンプルにあるものをそのままサーブレットで動くようにしたプログラムです。
下記のコードになります。
package jp.tuyano.eclipsebook3;
import java.io.*;
import javax.servlet.ServletException;
import javax.servlet.http.*;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.net.URL;
import java.net.URLDecoder;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.List;
import org.bbreak.excella.reports.exporter.ExcelExporter;
import org.bbreak.excella.reports.model.ReportBook;
import org.bbreak.excella.reports.model.ReportSheet;
import org.bbreak.excella.reports.processor.ReportProcessor;
import org.bbreak.excella.reports.tag.ImageParamParser;
import org.bbreak.excella.reports.tag.RowRepeatParamParser;
import org.bbreak.excella.reports.tag.SingleParamParser;
/**
*
*
*/
public class SampleServlet extends HttpServlet {
/**
*
*/
private static final long serialVersionUID = 1L;
// ※新たに追記したメソッド
protected void doGet(HttpServletRequest request,
HttpServletResponse response)
throws ServletException,IOException {
response.setContentType("text/html;charset=Shift_JIS");
PrintWriter out = response.getWriter();
out.println("<html><body>");
out.println("<h3>s3ffsf</h3>");
out.println("</body></html>");
//
// 読み込むテンプレートファイルのパス(拡張子含)
// 出力先のファイルパス(拡張子はExpoterによって自動的に付与されるため、不要。)
// 出力ファイルフォーマット(ConvertConfigurationの配列)
// を指定し、ReportBookインスタンスを生成します。
//
String templateFileName = "請求書テンプレート.xls";
URL templateFileUrl = SampleServlet.class.getResource
( templateFileName);
String templateFilePath = URLDecoder.decode
( templateFileUrl.getPath(), "UTF-8");
// TODO: 出力先のディレクトリ、及びファイル名(拡張子不要)を指定してください。
String outputFileName = "請求書サンプル";
String outputFileDir = "C:/reports_output/";
String outputFilePath = outputFileDir.concat( outputFileName);
ReportBook outputBook = new ReportBook( templateFilePath,
outputFilePath, ExcelExporter.FORMAT_TYPE);
//
// テンプレートファイル内のシート名と出力シート名を指定し、
// ReportSheetインスタンスを生成して、ReportBookに追加します。
//
ReportSheet outputSheet = new ReportSheet( "請求書");
outputBook.addReportSheet( outputSheet);
//
// 置換パラメータをReportSheetオブジェクトに追加します。
// (反復置換のパラメータには配列を渡します。)
//
Calendar calendar = Calendar.getInstance();
outputSheet.addParam( SingleParamParser.DEFAULT_TAG, "請求日付",
calendar.getTime());
outputSheet.addParam( SingleParamParser.DEFAULT_TAG, "顧客名称",
"○○商事 様");
//SampleServletに変更
URL imageFileUrl = SampleServlet.class.getResource( "ロゴ.jpg");
String imageFilePath = URLDecoder.decode( imageFileUrl.getPath
(), "UTF-8");
outputSheet.addParam( ImageParamParser.DEFAULT_TAG, "会社ロゴ",
imageFilePath);
out.println(templateFilePath);
outputSheet.addParam( SingleParamParser.DEFAULT_TAG, "差出人住所1",
"〒100-0000");
outputSheet.addParam( SingleParamParser.DEFAULT_TAG, "差出人住所2",
"東京都○○区○○○○ ×××ー×××");
outputSheet.addParam( SingleParamParser.DEFAULT_TAG, "差出人住所3",
"×××ビル 9F");
List<String> productNameList = new ArrayList<String>();
productNameList.add( "商品A");
productNameList.add( "商品B");
productNameList.add( "商品C");
outputSheet.addParam( RowRepeatParamParser.DEFAULT_TAG, "商品名",
productNameList.toArray());
List<BigDecimal> unitPriceList = new ArrayList<BigDecimal>();
unitPriceList.add( new BigDecimal( 10000));
unitPriceList.add( new BigDecimal( 9000));
unitPriceList.add( new BigDecimal( 7000));
outputSheet.addParam( RowRepeatParamParser.DEFAULT_TAG, "単価",
unitPriceList.toArray());
List<Integer> quantityList = new ArrayList<Integer>();
quantityList.add( new Integer( 4));
quantityList.add( new Integer( 5));
quantityList.add( new Integer( 6));
outputSheet.addParam( RowRepeatParamParser.DEFAULT_TAG, "数量",
quantityList.toArray());
List<BigDecimal> priceList = new ArrayList<BigDecimal>();
priceList.add( new BigDecimal( 40000));
priceList.add( new BigDecimal( 45000));
priceList.add( new BigDecimal( 42000));
outputSheet.addParam( RowRepeatParamParser.DEFAULT_TAG, "金額",
priceList.toArray());
BigDecimal subTotal = BigDecimal.ZERO;
for ( BigDecimal price : priceList) {
subTotal = subTotal.add( price);
}
outputSheet.addParam( SingleParamParser.DEFAULT_TAG, "小計",
subTotal);
BigDecimal discount = new BigDecimal( 10000);
outputSheet.addParam( SingleParamParser.DEFAULT_TAG, "値引",
discount);
BigDecimal taxRate = new BigDecimal( 0.05);
BigDecimal taxCharge = subTotal.multiply( taxRate).setScale
( 0, RoundingMode.DOWN);
outputSheet.addParam( SingleParamParser.DEFAULT_TAG, "税額",
taxCharge);
BigDecimal total = subTotal.add( taxCharge).subtract
( discount);
outputSheet.addParam( SingleParamParser.DEFAULT_TAG, "合計",
total);
//
// ReportProcessorインスタンスを生成し、
// ReportBookを元にレポート処理を実行します。
//
//↓ここから下でエラー
ReportProcessor reportProcessor = new ReportProcessor();
reportProcessor.process( outputBook);
}
}
ReportProcessor reportProcessor = new ReportProcessor();
の前までは動作するのですがReportProcessor()のインスタンスを作成しよう
とするとSingleParamParserが見つからないと怒られてしまいます。
この件について解決方法をご存じの方がいればご教示願います。
よろしくお願いいたします。