keanhoo168 Posted August 30, 2010 Share Posted August 30, 2010 I getting exception message "javax.servlet.ServletException: Invoker service() exception" message and root cause message "java.lang.NoClassDefFoundError: org/apache/commons/digester/Rule" appear when i try to run my report in java program.When i previes it in iReport, the report can come out without any problem.Can someone help me please? Code:package func;import net.sf.jasperreports.engine.*;import net.sf.jasperreports.engine.export.*;import java.sql.Connection;import java.sql.DriverManager;import java.sql.SQLException;import java.util.*;import javax.servlet.http.HttpServlet;import javax.servlet.http.HttpServletRequest;import javax.servlet.http.HttpServletResponse; public class jasperTest extends HttpServlet { public void doPost(HttpServletRequest request, HttpServletResponse response){ Connection connection = null; String fileName = "C:\\report1.jasper"; String outFileName = "C:\\test.pdf"; HashMap hm = new HashMap(); //Get database connection. try { Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver"); //jdbc:sqlserver://[serverName[\instanceName][:portNumber]][;property=value[;property=value]] connection = DriverManager.getConnection("jdbc:sqlserver://191.120.40.101:1433;databaseName=dbo;userName=sa;password=solution"); } catch (ClassNotFoundException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (SQLException e) { // TODO Auto-generated catch block e.printStackTrace(); } try { // Fill the report using an empty data source JasperPrint print = JasperFillManager.fillReport(fileName, hm, connection); // Create a PDF exporter JRExporter exporter = new JRPdfExporter(); // Configure the exporter (set output file name and print object) exporter.setParameter(JRExporterParameter.OUTPUT_FILE_NAME, outFileName); exporter.setParameter(JRExporterParameter.JASPER_PRINT, print); // Export the PDF file exporter.exportReport(); } catch (JRException e) { e.printStackTrace(); System.exit(1); } catch (Exception e) { e.printStackTrace(); System.exit(1); } } public void doGet(HttpServletRequest request, HttpServletResponse response){ doPost(request, response); }} Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now