[#3396] - Custom JRDataSource Results in ClassNotFoundException

Category:
Bug report
Priority:
None
Status:
Feedback Requested
Project: Severity:
Text
Resolution:
Fixed
Component: Reproducibility:
Always
Assigned to:
0

I followed the wiki article on creating and using a custom JRDataSource adapter. After trying and retrying I keep getting the same issue no matter how I organize my code, change sources, etc. The wiki article I followed is at http://community.jaspersoft.com/wiki/how-create-and-use-jrdatasource-ada....

When searching for the "Factory Class" portion of the "DataAdapter Wizard" it finds my "CustomDataAdapter.MyImplementation" class using the "..." search. Every time I click the "Test" button I get the following error:

net.sf.jasperreports.engine.JRException: java.lang.ClassNotFoundException: CustomDataAdapter.MyImplementation
at net.sf.jasperreports.data.ds.DataSourceDataAdapterService.contributeParameters(DataSourceDataAdapterService.java:92)
at net.sf.jasperreports.data.AbstractDataAdapterService.test(AbstractDataAdapterService.java:129)
at com.jaspersoft.studio.data.wizard.AbstractDataAdapterWizard$3.run(AbstractDataAdapterWizard.java:163)
at org.eclipse.jface.operation.ModalContext$ModalContextThread.run(ModalContext.java:121)
Caused by: java.lang.ClassNotFoundException: CustomDataAdapter.MyImplementation
at org.eclipse.osgi.internal.loader.BundleLoader.findClassInternal(BundleLoader.java:501)
at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:421)
at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:412)
at org.eclipse.osgi.internal.baseadaptor.DefaultClassLoader.loadClass(DefaultClassLoader.java:107)
at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:249)
at net.sf.jasperreports.engine.util.JRClassLoader.loadClassForRealName(JRClassLoader.java:175)
at net.sf.jasperreports.data.ds.DataSourceDataAdapterService.contributeParameters(DataSourceDataAdapterService.java:80)
... 3 more

I've even copied and pasted the attachment from that article into my CustomDataAdapter/MyImplementation.java file to ensure that I've not made a typo.

I'm using "MyReports" as my project name and it's also configured as the source folder on build path. I am completely new to Jaspersoft Studio so I'm hoping it's not something I'm doing incorrectly that is obvious and I'm missing it.

v5.5.1
cmg1248's picture
Joined: Feb 14 2014 - 8:19pm
Last seen: 3 years 7 months ago

10 Comments:

#1
  • Status:New» Feedback Requested
#2
  • Assigned:» chicuslavic

Hi,

I have moved this tracker to JSS, in case you are still facing this problem. Please let us know.

Thanks,
Teodor

#3

could you attach you project to look at it? just zip the folder

#4
  • Priority:Normal» High
  • Severity:Minor» Major

If you use build in sample class like "com.jaspersoft.studio.data.sample.SampleJRDataSourceFactory", no problem will happen. But if you use your own jar file, you will be surely get ClassNotFound Error. It happens on all customer data adapter such as "JRDatasource, JRDataSourceProvide, BeanCollectionAdatper". See attached screen copy and source code.

AttachmentSize
capture.jpg62.06 KB
simplejasperbeandatasource.zip50.87 KB
#5

what you have in your classpath? this zip does not contains any .class files

#6

I am having the same issue. I am able to see my customized file on clicking the "factory class browser button" but it gives the same "ClassNotFoundException" no matter what I try. Any help would be highly appreciated.

AttachmentSize
secproject.zip2.67 KB
#7

Hi there - I could also use some assistance with this article. I follow all of the steps but, like the others here, I am getting errors. As a matter of fact, the same exact error posted at the top. Any assistance is appreciated. Hugo Mendoza

#8
  • Priority:High» None
  • Severity:Major» Text
  • Resolution:Open» Fixed

My solution for your "ClassNotFoundException" problems is building project. Menu-Project/Build.... I think this step should be added into tutorial.

#9

There is a note in the url http://community.jaspersoft.com/wiki/how-create-and-use-jrdatasource-ada...
NOTE: If after building your project you still get ClassNotFound exeption when executing the report try to close and reopen Jaspersoft Studio and rebuild the project, because in some rare cases it could be possible that the Java Classloader is not able to load correctly a just created class.

And in my case, after (unintentionally) shutdown the computer and power up again, the problem is gone.

#10
Feedback
randomness