Jump to content
JasperReports Library 7.0 is now available ×
  • This documentation is an older version of JasperReports Server Community Project Administrator Guide. View the latest documentation.

    MongoDB is a big data architecture based on the NoSQL model that is neither relational nor SQL-based. We provide connectors that allow reports to use a MongoDB data source or a MongoDB JDBC data source. JasperReports Server also supports Kerberos, SSL, and x509 authentication for MongoDB data sources.

    As with all big data stores, MongoDB data sources have the following limitations and usage guidelines within JasperReports Server:

    MongoDB data sources are not supported for OLAP connections
    You must configure your JVM memory to handle the expected amount of data (see the JasperReports Server Community Project Installation Guide).

    Creating a MongoDB Data Source with the Native MongoDB Driver

    To create a MongoDB data source with the native driver:

    Follow these steps to create a MongoDB data source with the native MongoDB driver.

    1. Log on as an administrator.
    2. Click View > Repository, expand the folder tree, and right-click a folder to select Add Resource > Data Source from the context menu. If you have installed the sample data, the suggested folder is Data Sources. The New Data Source page appears.
    3. In the Type field, select MongoDB Data Source. The information on the page changes to reflect what's needed to define a MongoDB data source.

    You have the option to use attributes in the values of data source parameters. See Attributes in Data Source Definitions.

    js-DataSource-MongoDB.png.7a8c23038fb043b69860aabb6183bccf.png

    MongoDB Data Source Page

    4. Fill in the required fields, along with any optional information.

    The MongoDB URI has the form: mongodb://<hostname>:27017/<database>

    To enable SSL include the argument ssl=true in the URI. For example:

    mongodb://<hostname>:27017/<database>?ssl=true

    To enable x509 authentication for the data source include it as well in the URI. For example:

    mongodb://<hostname>:27017/<database>?ssl=true&authMechanism=MONGODB-X509

    To enable Kerberos authentication for the data source include the data source and Kerberos user name in the URI. For example:

    mongodb://<hostname>:27017/<database>?authMechanism=GSSAPI

    note-icon-ns.png.0f4d235824df5127b64332beb8194dfa.png

    Before you can enable x509 authentication you need to set up the Java Secure Socket Extension (JSSE) in your application server. Before you can enable Kerberos authentication you need to perform the steps in Using Kerberos Authentication with MongoDB Data Sources.

    5. Click Test Connection to validate the data source.
    6. When the test is successful, click Save. The Save dialog appears.
    7. Enter a name for the data source and an optional description. The Resource ID is generated from the name you enter. If you haven't already specified a location, expand the folder tree and select the location for your data source.
    8. Click Save in the dialog. The data source appears in the repository.

    The Jaspersoft MongoDB Query Language

    MongoDB is designed to be accessed through API calls in an application or a command shell. As a consequence, it does not have a defined query language. In order to write queries for MongoDB data sources, we have developed a query language based on the JSON-like objects upon which MongoDB operates. JSON is the JavaScript Object Notation, a textual representation of data structures that is both human- and machine-readable.

    The Jaspersoft MongoDB Query Language is a declarative language for specifying what data to retrieve from MongoDB. The connector converts this query into the appropriate API calls and uses the MongoDB Java connector to query the MongoDB instance. The following examples give an overview of the Jaspersoft MongoDB Query Language, with the equivalent SQL terms in parentheses:

    Retrieve all documents (rows) in the given collection (table):
    From all documents in the given collection, select the named fields (columns) and sort the results:
    Retrieve only the documents (rows) in the given collection (table) that match the query (where clause). In this case, the date is greater-than-or-equal to the input parameter, and the name matches a string (starts with N):

    The Jaspersoft MongoDB Query Language also supports advanced features of MongoDB such as map-reduce functions and aggregation that are beyond the scope of this document. For more information, see the language reference on the Community website.

    Creating a MongoDB JDBC Data Source

    If you want to use your MongoDB data source with an SQL query, create a MongoDB JDBC data source. The MongoDB JDBC driver can create a default normalized schema for your data or, if you prefer, you can load a schema from the repository or your server file system.

    To create a MongoDB JDBC data source:

    1. Log on as an administrator.
    2. Click View > Repository, expand the folder tree, and right-click a folder to select Add Resource > Data Source from the context menu. If you have installed the sample data, the suggested folder is Data Sources. The New Data Source page appears.
    3. In the Type field, select MongoDB JDBC Data Source. The information on the page changes to reflect what's needed to define a MongoDB JDBC data source.

    You have the option to use attributes in the values of data source parameters. See Attributes in Data Source Definitions.

    js-DataSource-MongoDB-JDBC.png.3659f078c2cad1f390bde47b7f953a2d.png

    MongoDB JDBC Data Source Page

    4. Fill in the required fields, along with any optional information.
    5. Specify your Connection Options. For example, if you're using MongoDB 3.0 and you want to enable SSL, enter:

    EncryptionMethod=SSL;ValidateServerCertificate=false

    To enable both SSL encryption and self-signed CA, enter the TrustStore and KeyStore paths and the KeyStore password. For example:

    EncryptionMethod=SSL;TrustStore=<path>;KeyStore=<path>;KeyStorePassword=<password>;

    The Auto Generate Schema Definition check box is checked by default. With this option selected, When you first connect to a MongoDB server, the driver automatically creates a normalized schema of the data and generates a SchemaDefinition for housing and sharing the normalized schema.

    6. To specify a schema you've created, uncheck this box and:
    a. Use the File Source drop down to select your schema file location: Repository or Server File System. To create a schema using the schema tool, see Creating a Schema with the Schema Tool
    b. If your file is in the repository, click the Browse button and locate it in the repository. If your file is in your server file system, enter the path in the Server File Location text box. To upload a schema to the repository, see Uploading a Schema to the Repository
    7. Click Test Connection to validate the data source.
    8. When the test is successful, click Save. The Save dialog appears.
    9. Enter a name for the data source and an optional description. The Resource ID is generated from the name you enter. If you haven't already specified a location, expand the folder tree and select the location for your data source.
    10. Click Save in the dialog. The data source appears in the repository.

    Using Kerberos Authentication with MongoDB Data Sources

    The native MongoDB driver can connect to MongoDB Enterprise using Kerberos Authentication. Kerberos is a network authentication protocol that allows clients and servers on a non-secure network to use "tickets" to identify themselves.

    To use Kerberos authentication, you need to set up the following:

    1. Install the Kerberos client tools on the JasperReports Server host. The client tools are included in the JDK/JRE for Windows. Client tools packages are available for Linux and OS X. You will be prompted to enter information on your Kerberos system during the installation.
    2. Download the Java Cryptography Extension (JCE) Unlimited Strength Jurisdiction Policy files from Oracle and install them on the JasperReports Server. The files are available for download at the Oracle Java SE Downloads page.
    3. Set these Java system properties for JasperReports Server:
    java.security.krb5.realm=<Kerberos_realm>java.security.krb5.kdc=<KDC_server_hostname>javax.security.auth.useSubjectCredsOnly=falsejava.security.auth.login.config=<path>/jaas.conf[/code]                    
    4. Edit the jaas.conf file to add the following:
    com.sun.security.jgss.krb5.initiate {   com.sun.security.auth.module.Krb5LoginModule   required     useTicketCache=true   doNotPrompt=true;};[/code]                    
    5. Run the kinit mongodb/[mongo-db-hostname]@<Kerberos_realm> command on the JasperReports Server host to create or renew a ticket for the Kerberos user. This is the account you will enter as the user name for the data source.

    Creating a Schema with the Schema Tool

    To create a schema with the schema tool:

    1. Go to <js-install>/buildomatic/tools and double click the schematool.jar file.
    2. Follow the instructions in the schema tool documentation found here:

    https://documentation.progress.com/output/DataDirect/jdbcmongohelp/index.html#page/mongohelp/starting-the-schema-tool.html

    Uploading a Schema to the Repository

    To upload a schema to the repository:

    1. Click View > Repository and expand the folder tree.
    2. Right-click a folder and select Add Resource > File > MongoDB JDBC Schema from the context menu.
    3. Use the Upload File From Your Local Computer page to locate and upload your schema file.

    Open topic with navigation


    User Feedback

    Recommended Comments

    There are no comments to display.



    Guest
    This is now closed for further comments

×
×
  • Create New...