kjhuebner Posted August 1, 2006 Share Posted August 1, 2006 In attempting to bind and test connection to a JRDataProvider class within IReport, I get an error message which reads: "TestProvider" is not a subclass of "net.sf.jasperreports.engine.JRDataSourceProvider" First, the JRDataSourceProvider is an interface. You cannot have a subclass of an interface. More importantly, my TestProvide class implements this interface correctly. I compile it and make it available in IReport classpath. Here's a sample snippet: public class TestDataSourceProvider implements JRDataSourceProvider See doc for more details. THanks,Ken [file name=JRDataSourceProvider_error.doc size=64512]http://www.jasperforge.org/components/com_joomlaboard/uploaded/files/JRDataSourceProvider_error.doc[/file] Link to comment Share on other sites More sharing options...
Giulio Toffoli Posted August 1, 2006 Share Posted August 1, 2006 Hi Ken, I don't know why you get this error...I tried your classes and iReport recognizes it as a DataSource provider without problems. I got a couple of problems using your datasource (but I'm sure you have to finish it). I used iReport 1.2.5 and I compiled your files stripping out the package (only to speed up my test). Problem 1:the getFields method in the TestDataSourceFactory return two times the same field (Address), this becuase you do not make a new field, but simplychange the attributes of the same object: Code:jrField.setName("Name"«»); jrField.setValueClass(String.class); list.add(jrField); // You should put here a:// jrField = new new JRDesignField(); jrField.setName("Address"«»); jrField.setValueClass(String.class); list.add(jrField); Problem 2:there is a classCastException on line 143: Code:[code]map= (Map)map.get("Tasks"«»); this returns a List of Map objects, not a single Map. Code:[code]Error filling print... ENTERED TestDataSourceFactory.getTheDatasource() ENTERED TestDataSource() CONSTRUCTOR ENTERED TestDataSource getFieldValue() java.lang.ClassCastException: java.util.ArrayList at TestDataSource.getFieldValue(TestDataSource.java:143) at net.sf.jasperreports.engine.fill.JRFillDataset.setOldValues(JRFillDataset.java:788) at net.sf.jasperreports.engine.fill.JRFillDataset.next(JRFillDataset.java:752) at net.sf.jasperreports.engine.fill.JRBaseFiller.next(JRBaseFiller.java:1019) at net.sf.jasperreports.engine.fill.JRVerticalFiller.fillReport(JRVerticalFiller.java:126) at net.sf.jasperreports.engine.fill.JRBaseFiller.fill(JRBaseFiller.java:758) at net.sf.jasperreports.engine.fill.JRBaseFiller.fill(JRBaseFiller.java:685) at net.sf.jasperreports.engine.fill.JRFiller.fillReport(JRFiller.java:89) at net.sf.jasperreports.engine.JasperFillManager.fillReport(JasperFillManager.java:601) at it.businesslogic.ireport.IReportCompiler.run(IReportCompiler.java:742) at java.lang.Thread.run(Thread.java:595) Print not filled. Try to use an EmptyDataSource...! Finally, the message (wrong, you right) is generated from the following code: Code:[code]Object obj = Class.forName((String)jTextFieldJRDataSourceProvider.getText().trim(), true, MainFrame.getMainInstance().getReportClassLoader()).newInstance();if (!(obj instanceof net.sf.jasperreports.engine.JRDataSourceProvider)){ JOptionPane.showMessageDialog((Component)getParent(),""" + jTextFieldJRDataSourceProvider.getText() + "" is not a subclass ofnnet.sf.jasperreports.engine.JRDataSourceProvider.","Error",JOptionPane.ERROR_MESSAGE); return; } Don't ask me why iReport thinks that your class is not an instance of JRDataSourceProvider on your machine... Giulio Link to comment Share on other sites More sharing options...
kjhuebner Posted August 1, 2006 Author Share Posted August 1, 2006 Hi Giulio,I started up my machine again this morning and tried out my custom JRDataSourceProvider again. It worked this time! No exception appeared when I clicked Test. I've ran across quite a few problems like this before.There must be many refresh-related bugs in IReport. I think my strategy going forward is to shutdown and restart IReport whenever I see weird behaviour. At least until you guys fix the bugs I'm seeing! Thanks again,Ken Link to comment Share on other sites More sharing options...
djsiders Posted December 13, 2006 Share Posted December 13, 2006 Any changes made in your provider class are only loaded into Ireports at startup. Guessing it reads the classpath setting and loads all. I think IReports is expecting a completed and tested data provider, and isn't really meant to be a development tool for that (although it would be nice) 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