Jump to content
Changes to the Jaspersoft community edition download ×
  • Driving Reports from Development to Production


    djohnson53
    • Features: Exporters, JasperReports Server Product: JasperReports® Server

    Introduction

    Using import/export scripts allows you to export and import content from the JasperServer repository. This tutorial utilizes import and export scripts to mass upload reports from a development environment to a production environment.

    Additionally, it showcases how to take advantage of the JasperServer plugin for iReport. This tutorial can be used in any development and production environment; especially in situations where both development and production environments are using different technologies.

    Objectives

    This tutorial will enable you to:

    Locating and Configuring js-import and js-export Scripts

    First, we need to configure the js-import and js-export scripts to connect to the JasperServer repository. The scripts are located in the /scripts directory.

    Step Action
    1

    Check your jasperserver configuration in this file : apache-tomcatwebappsjasperserver-proMETA-INFcontext.xml

    Search for the following lines, which contain information about the repository database:

    image01.png.48c670a882efc8eaf0851d98326f19ea.png

    Obtain the following information:

    • Driver : com.mysql.jdbc.Driver
    • Database URL : jdbc:mysql://127.0.0.1:3306/jasperserver?useUnicode=true&characterEncoding=UTF-8
    • Username : jasperdb
    • Password : password
    2

    With the information you obtained above, configure the import/export scripts by editing the file :

    scriptsconfigjs.jdbc.properties

    image02.png.6e592e0880e0be70edba4bb176d45949.png

    3

    The first line configures the hibernate dialect used by the scripts.

    If you are not using MySQL refer to the section 12.2 page 80 on the JasperServer-Pro-Install-Guide.pdf located in the docs folder.

    4

    Configure the driver, url, username, and password according to the values you obtained in Step 1.

    Best Practice: To avoid confusion, a best practice is to use the js-export script on your development server and the js-import script on your production server.

    Exporting Reports

    Assumption: The demo samples that are provided with the installer are deployed on the development server. The production server is installed without the samples.

    Best Practice: Maintain the same folder tree structure between production and other environments (for instance development or test).

    By maintaining the same folder structure, you will avoid having to perform one-offs to upload reports.

    Example: Export all reports within the organization_1/reports/samples folder

    Step Action
    1

    In a terminal (or under cmd on windows) go to your scripts directory

    2

    Type the following command :

    js-export –uris /organizations/organization_1/reports/samples –output-zip organization_1_reports_samples.zip

    --uris = indicates witch folder to extract

    --output-zip = create a zip file with the specified name containing the export.

    image03.png.d225a49f552e35d51eec04297a73354b.png

    Result: The reports within the specified folder are exported along with any dependencies (such as graphics, connections) into a zip file.

    Importing Reports into Production Within the Same Organization

    Reports and dependencies are now safely stored in a zip file. Next, re-import them. The easiest import scenario is categorized by having the same folder structure in development and production environments. First, create the organization in the production environment then upload your reports.

    Note: If you wish to test import/export in a single JasperServer instance reinitialize the repository prior to this step. The initialization scripts are located in the scripts folder.

    Example: For MySQL, run the scriptsMySQLjasper_init.bat (Download here), and then continue with the steps listed below.

    Create the organization in the production environment.

    Step Action
    1 Login as superuser in your production server.
    2 Go to Manage > Organizations
    3 Select the root folder then click the Create Organization button
    4

    Fill the form according to the organization settings you had from development (the organization_id must be the same)

    image04.png.0bb819944d8e924fceef8feddae95a7e.png

    In our sample:

    Organization name = Organization

    Organization_id = organization_1

    Note: organization_1 is an organization that is created by default.

    Once we have our organization correctly configured, then we can upload the reports using the js-import tool.

    Example: In our example, make sure you have copied organization_1_reports_samples.zip into the scripts directory

    Step Action
    1 In a terminal (or under cmd on windows) go to your scripts directory
    2

    Type the following command :

    js-import --input-zip organization_1_reports_samples.zip

    image05.png.882493150a8693b210aa99d20c7ef9b7.png

    3

    Result: The reports and dependencies are uploaded in the organization

    image06.png.e0ffdcbf59859442e9d05c9431077b0d.png

    Importing Reports into Production Environment for a Different Organization

    Assumption: You already have an organization within your production environment, which differs from the development (in our example you do not have an organization using organization_1 as id).

    In our example, the organization id we wish to upload our reports to is demo. This is not a best practice but a common case where development and production do not share same organization structure.

    Js-Import and Js-Export scripts don’t provide a mechanism for specifying the organization id. Essentially, this limitation requires that you perform the transformation manually.

    Below are the steps for defining the transformation.

    Best Practice: Use a text editor such as Notepad++ to find and replace characters strings from multiple files at the same time.

    Notepad ++ is a free text editor that can be downloaded here.

    Step Action
    1 Unzip the exported file organization_1_reports_samples.zip ,and open the contents (we later refer to it simply as the export folder)
    2 Open Notepad++ or your favorite text editor
    3

    Search and drag and drop all .xml files (reports) from your export folder into Notepad++

    image07_preview.png.148bd44fab8d518bf45047e19c3d87f2.png

    4

    Go to Search > Replace, and then specify the following:

    · Find what: /organizations/organization_1 (the original organization id)

    · Replace with: /organizations/demo (the target organization id)

    Then click Replace in all opened documents

    image08_preview.png.fbb96ca6a919cf4960c4255a15afe187.png

    Result : The export folder is now specified as Demo, rather than organization_1

    5

    Create a zip file containing the export folder with the newly modified files.

    Important: The root of your zip file should contain the folder resources and the file index.xml

    image09_preview.png.f0ad2e08dfd3dce722f92f9c5a1cb822.png

    Name the zip file demo_reports_samples.zip

    6 In a terminal (or under cmd on windows) go to your scripts directory
    7

    Type the following command :

    js-import --input-zip demo_1_reports_samples.zip

    image10_0.png.90e65b6e6c8d79b720c06d427c62be1b.png

    Result: The reports are now uploaded in the demo organization

    image11_0.png.37dc896130cfb3e697154a957d569d62.png

    Written by

    This tutorial was written by Guillaume Autier, Sales Engineer, June 2009.

    image01.png.5c7fd5c68a32e2366c497739b9af519c.png

    image02.png.4b79e505dec949d4b19a001ef8001fb5.png

    image03.png.0e8f1921ddb3d1bcc8115af38f176af2.png

    image04.png.b7d5e2c36b84956ad6fad6615017bd95.png

    image05.png.22cd8cbcef19402cc81d3480ab842179.png

    image07_preview.png.6f50fcc939fd39357ffc59b5ee5fa769.png

    image08_preview.png.67456d007ddfc9b13399c86302b52560.png

    image09_preview.png.0bb5bfdd44fab6de3be860b7773cc0a9.png

    image10_0.png.a5da5db9772c5142d8660c1cdc06a507.png

    image11_0.png.093eec7724a8d404b9a378423031cada.png


    User Feedback

    Recommended Comments

    There are no comments to display.



    Guest
    This is now closed for further comments

×
×
  • Create New...