Jump to content
  • Custom JRDataSource Results in ClassNotFoundException

    Assigned User chicuslavic
    CategoryBug report

    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-adapter.


    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.

    User Feedback

    Recommended Comments

    Changed Priority from Normal to High

    Changed Severity from Minor to 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.
    Link to comment
    Share on other sites

    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.
    Link to comment
    Share on other sites

    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
    Link to comment
    Share on other sites

    Changed Priority from High to None

    Changed Severity from Major to Text

    Changed Resolution from Open to Fixed

    My solution for your "ClassNotFoundException" problems is building project. Menu-Project/Build.... I think this step should be added into tutorial.
    Link to comment
    Share on other sites

    There is a note in the url http://community.jaspersoft.com/wiki/how-create-and-use-jrdatasource-adapter

    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.

    Link to comment
    Share on other sites

  • Create New...