VMASTER Posted July 2, 2008 Share Posted July 2, 2008 Hi, when i use this code Code: JasperPrint jasperPrint2 = JasperFillManager.fillReport(jasperReport4, reportParam, jdbcConnection); the result is :Code:[code]Exception in thread "main" java.lang.ExceptionInInitializerError at net.sf.jasperreports.engine.fill.JRBaseFiller.<init>(JRBaseFiller.java:400) at net.sf.jasperreports.engine.fill.JRVerticalFiller.<init>(JRVerticalFiller.java:77) at net.sf.jasperreports.engine.fill.JRVerticalFiller.<init>(JRVerticalFiller.java:59) at net.sf.jasperreports.engine.fill.JRFiller.createFiller(JRFiller.java:147) at net.sf.jasperreports.engine.fill.JRFiller.fillReport(JRFiller.java:57) at net.sf.jasperreports.engine.JasperFillManager.fillReport(JasperFillManager.java:402) at ReportDriver2.runReport(ReportDriver2.java:134) at ReportDriver2.main(ReportDriver2.java:257)Caused by: net.sf.jasperreports.engine.JRRuntimeException: Error loading the propertiesDefault properties file not found trovato Default properties file not found at net.sf.jasperreports.engine.util.JRProperties.initProperties(JRProperties.java:183) at net.sf.jasperreports.engine.util.JRProperties.<clinit>(JRProperties.java:150) ... 8 moreCaused by: net.sf.jasperreports.engine.JRException: Default properties file not found at net.sf.jasperreports.engine.util.JRProperties.getDefaults(JRProperties.java:219) at net.sf.jasperreports.engine.util.JRProperties.initProperties(JRProperties.java:160) ... 9 moreJava Result: 1 I placed the files default.jasperreports.properties in the folder src project but can not find I changed the file JRProperties in this way:Code:[code] String curDir = System.getProperty("user.dir"«»); System.out.println("nIn questo momento ti trovi nella directory:"«»); System.out.println(" - " + curDir); String files=curDir+"/default.jasperreports.properties"; System.out.println(" - " + files); InputStream is = JRProperties.class.getResourceAsStream(files); but not find the file! why? Link to comment Share on other sites More sharing options...
lucianc Posted July 2, 2008 Share Posted July 2, 2008 VMASTER wrote:I changed the file JRProperties in this way:...but not find the file! Why would you change JRProperties? default.jasperreports.properties is placed inside the JasperReports jar, you don't need to change any JR source files for the default properties to be found. Regards,Lucian Link to comment Share on other sites More sharing options...
VMASTER Posted July 2, 2008 Author Share Posted July 2, 2008 lucianc wrote: Why would you change JRProperties? default.jasperreports.properties is placed inside the JasperReports jar, you don't need to change any JR source files for the default properties to be found. Regards,Lucian because I downloaded the sources and I am trying to make it work without the jar :P however, the file .properties does not find :( Link to comment Share on other sites More sharing options...
lucianc Posted July 2, 2008 Share Posted July 2, 2008 VMASTER wrote:because I downloaded the sources and I am trying to make it work without the jar :P You should just place defaults.jasperreports.properties on your application's classpath. however, the file .properties does not find Since you've changed the JRProperties source code, I'm afraid I can't tell you why it doesn't work. Link to comment Share on other sites More sharing options...
VMASTER Posted July 2, 2008 Author Share Posted July 2, 2008 You should just place defaults.jasperreports.properties on your application's classpath. ok! done Since you've changed the JRProperties source code, I'm afraid I can't tell you why it doesn't work. I reloaded the original file but does not work equally:( Link to comment Share on other sites More sharing options...
lucianc Posted July 2, 2008 Share Posted July 2, 2008 VMASTER wrote:I reloaded the original file but does not work equally As I don't know what exactly you are doing, I'm going to need a detailed test case to reproduce your problem. Link to comment Share on other sites More sharing options...
VMASTER Posted July 2, 2008 Author Share Posted July 2, 2008 lucianc wrote:VMASTER wrote:I reloaded the original file but does not work equally As I don't know what exactly you are doing, I'm going to need a detailed test case to reproduce your problem. ok , I executed the following steps :1) download source from sourceforge2) insert all files in a netbeans project3) import all jar that jasper require4) run this code : Code: public void runReport(String databaseName, String userName, String password, String reportFile, String empID) { try { String report = reportFile; HashMap reportParam = new HashMap(); reportParam.put("EMPID", empID); Connection jdbcConnection = connectDB(databaseName, userName, password); File sourceFile = new File(report); JasperReport jasperReport4 = (JasperReport) JRLoader.loadObject(sourceFile); JasperPrint jasperPrint2 = JasperFillManager.fillReport(jasperReport4, reportParam, jdbcConnection); int lar = (int) Toolkit.getDefaultToolkit().getScreenSize().getWidth(); int alt = (int) Toolkit.getDefaultToolkit().getScreenSize().getHeight(); myJRViewer jrv = new myJRViewer(jasperPrint2); jrv.setPreferredSize(new Dimension(lar - 50, alt - 50)); JScrollPane reportScroll = new JScrollPane(jrv); JPanel viewer = new JPanel(); viewer.add(reportScroll); JFrame finestra = new JFrame(); finestra.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); finestra.setTitle("STAMPA - ASTER SOFTWARE"«»); finestra.add(viewer); finestra.pack(); finestra.setVisible(true); finestra.repaint(); System.out.println("5"«»); System.exit(0); } catch (Exception ex) { String connectMsg = "Could not create the report " + ex.getMessage() + "n " + ex.toString() + "n" + ex.getCause() + "n" + ex.fillInStackTrace(); System.out.println(connectMsg); } } 5) this is the resultCode:[code]Exception in thread "main" java.lang.ExceptionInInitializerError at net.sf.jasperreports.engine.fill.JRBaseFiller.<init>(JRBaseFiller.java:400) at net.sf.jasperreports.engine.fill.JRVerticalFiller.<init>(JRVerticalFiller.java:77) at net.sf.jasperreports.engine.fill.JRVerticalFiller.<init>(JRVerticalFiller.java:59) at net.sf.jasperreports.engine.fill.JRFiller.createFiller(JRFiller.java:147) at net.sf.jasperreports.engine.fill.JRFiller.fillReport(JRFiller.java:57) at net.sf.jasperreports.engine.JasperFillManager.fillReport(JasperFillManager.java:402) at ReportDriver2.runReport(ReportDriver2.java:134) at ReportDriver2.main(ReportDriver2.java:257)Caused by: net.sf.jasperreports.engine.JRRuntimeException: Error loading the propertiesDefault properties file not found trovato Default properties file not found at net.sf.jasperreports.engine.util.JRProperties.initProperties(JRProperties.java:183) at net.sf.jasperreports.engine.util.JRProperties.<clinit>(JRProperties.java:150) ... 8 moreCaused by: net.sf.jasperreports.engine.JRException: Default properties file not found at net.sf.jasperreports.engine.util.JRProperties.getDefaults(JRProperties.java:219) at net.sf.jasperreports.engine.util.JRProperties.initProperties(JRProperties.java:160) ... 9 moreJava Result: 1 Link to comment Share on other sites More sharing options...
lucianc Posted July 2, 2008 Share Posted July 2, 2008 You said you put default.jasperreports.properties on the application classpath. How exactly did you do that? Link to comment Share on other sites More sharing options...
VMASTER Posted July 3, 2008 Author Share Posted July 3, 2008 lucianc wrote:You said you put default.jasperreports.properties on the application classpath. How exactly did you do that? I found the file default.jasperreports.properties inside jar (source) and I inserted in application classpath (c:myprojectsrc) with a simple copy and paste Link to comment Share on other sites More sharing options...
lucianc Posted July 4, 2008 Share Posted July 4, 2008 OK, I'll give this a try as soon as I'll find some time to do it. Since I'm not familiar with NetBeans, it might take some time until I manage to test this. Regards,Lucian Link to comment Share on other sites More sharing options...
lucianc Posted July 4, 2008 Share Posted July 4, 2008 I've done what you've described and it worked fine for me. I'm attaching a package containing my NetBeans project (I didn't find any project export feature). EDIT: the file is too big to attach it here, so I've uploaded it here. Regards,LucianPost edited by: lucianc, at: 2008/07/04 14:09 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