2006 IR Open Dicussion Posted September 5, 2006 Share Posted September 5, 2006 By: Diogo Oliveira - diogosales Null values on the fields 2006-03-29 08:39 Hi I'm trying to establish a connection with a custom data source I called TestSource. Nothing goes wrong in compilation but the fields appear with null values. I've created a report test.jasper with a configured connection that I tested (and returned successful test) with a factory TestDataSourceFactory and createDatasource() as a static method that returns the data source. Then the code goes something like this: public class TestDataSourceFactory { public static TestDataSource createDatasource () { return new TestDataSource(); } } and the corresponding datasource object: import net.sf.jasperreports.engine.*; public class TestDataSource implements JRDataSource { public boolean next() { return true; } public Object getFieldValue (JRField field) { return field.getDescription(); } } those implementations may seem ridiculous and trivial but are for testing purposes only. Now the problem is, when I compile the report and run it / view it (e.g. with JRviewer) using the active connection, both fields return null on the report. But I have reasons to believe the problem comes before the code. When I click the Test button on the connection config dialog, it's ok (and changing the factory class name returns not ok), but compiling / executing using active connection seems to do nothing: i even tried inserting System.err.println("FLAG!"); as the first line of code in the createDatasource() method, but still nothing got printed out in the console (where I started iReport). I double checked the field definitions (I defined a couple of fields with iReport, i think i did it right) and the active connection. its should be ok.. What am I doing wrong guys? BTW, i tried to do things programatically, with a tiny app, with something like this in its main() method: String file = "test.jasper"; Map prms = new HashMap(); JasperReport jr = (JasperReport)JRLoader.loadObject(file); JasperPrint jp = JasperFillManager.fillReport(jr,prms,new TestDataSource()); JasperViewer jv = new JasperViewer (jp); But the penultimate line returns an error I can get out of, something like this: Exception in thread "main" java.lang.ExceptionInInitializerError at net.sf.jasperreports.engine.fill.JRFillObjectFactory.getTextField(JRFillObjectFactory.java:514) at net.sf.jasperreports.engine.base.JRBaseTextField.getCopy(JRBaseTextField.java:256) at (...) net.sf.jasperreports.engine.JasperFillManager.fillReport(JasperFillManager.java:601) at Testes.main(Testes.java:28) Caused by: org.apache.commons.logging.LogConfigurationException: java.lang.NullPointerException at org.apache.commons.logging.LogFactory.newFactory(LogFactory.java:558) at org.apache.commons.logging.LogFactory.getFactory(LogFactory.java:355) at org.apache.commons.logging.LogFactory.getLog(LogFactory.java:390) at net.sf.jasperreports.engine.fill.JRFillTextElement.<clinit>(JRFillTextElement.java:61) ... 13 more Caused by: java.lang.NullPointerException at org.apache.commons.logging.LogFactory.newFactory(LogFactory.java:543) ... 16 more And I believe I added all the jar files to the project (using eclipse IDE). Any help would be so much welcome, I'm really stuck here :/ Thanks in advance guys. 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