Jump to content
JasperReports Library 7.0 is now available ×

Eclipse JasperStudio Plugin: custom data adapter throws class not found exception


anette.engel

Recommended Posts

I have inherited code in our application which generates Jasper Reports. I want to create a new report with a custom data source. To test the report I want to create custom data adapter which returns mock data. For advice I looked at (and related articles)

https://community.jaspersoft.com/documentation/tibco-jaspersoft-studio-user-guide/v630/working-jrdatasource-interface

I created a very simple data adapter (see below). When creating the new data adapter I try testing the new data apater by clickin on "test" but I get a class not found exception. I noticed that within the Data Adpater Wizard it is possible to add jar files. This option isn't really practical during development for me. Is it not possible to configure my workspace, project or JasperStudio to find the class in my project? Please note I don't have a JasperStudio project. Is this required? It would make things a bit complicated since classes and Jasper Reports files are in an existing project.

Does anyone know how to create and successfully use a custom data adapter to test the report design with Eclipse in the Report Designer View?

Thanks,

Anette

 

import net.sf.jasperreports.engine.JRDataSource;
import net.sf.jasperreports.engine.data.JRBeanArrayDataSource;

public class MySampleDataSourceFactory {

 
    public static JRDataSource createStaticDatasource() {

        final TestBean testBean = new MySampleDataSourceFactory.TestBean();
        testBean.setFirstname( "Grommit" );
        testBean.setLastname( "The Dog" );
        final TestBean[] data = new TestBean[1];
        data[0] = testBean;

        return new JRBeanArrayDataSource( data );
    }

    public static class TestBean {
        private String firstname;
        private String lastname;

        public String getFirstname() {

            return this.firstname;
        }

        public void setFirstname( final String firstname ) {

            this.firstname = firstname;
        }

        public String getLastname() {

            return this.lastname;
        }

        public void setLastname( final String lastname ) {

            this.lastname = lastname;
        }

    }

}

 

Link to comment
Share on other sites

  • Replies 0
  • Created
  • Last Reply

Top Posters In This Topic

Popular Days

Top Posters In This Topic

Popular Days

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