Jump to content
Changes to the Jaspersoft community edition download ×

OneThousandAndOne!! bug found - JRDataProvider


Recommended Posts

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.




[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

  • Replies 3
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

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 simply

change the attributes of the same object:




// You should put here a:
// jrField = new new JRDesignField();



Problem 2:

there is a classCastException on line 143:


map= (Map)map.get("Tasks"«»);


this returns a List of Map objects, not a single Map.


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:


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);


Don't ask me why iReport thinks that your class is not an instance of JRDataSourceProvider on your machine...




Link to comment
Share on other sites

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,


Link to comment
Share on other sites

  • 4 months later...
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

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 account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Create New...