Introduction
This tutorial helps you configure the Eclipse IDE for use with JasperReports Server. Install the Maven Eclipse 2.2.1 plug-in if you want to run builds.
Product Version
This job aid centers on the Indigo version of Eclipse. It assumes you have deployed JasperReports Server to Apache Tomcat. If you are using a different application server, please consult the JasperReports Server Install Guide and the documentation provided with your server to determine where JasperReports Server should be installed.
- In the steps below, x.x.x refers to the version number of JasperReports Server (e.g. 4.5.0) and should be substituted accordingly.
- Note: Not all application servers support JPDA as outlined in Task 3. Please consult your application server documentation for more information.
Objectives:
This guide will enable you to
Prerequisite: Some familiarity with navigating the Windows environment
Task 1: Download and Extract the Source Code Bundle
Download the source code.
- In a web browser, navigate to http://support.jaspersoft.com and enter the credentials provided by your sales rep
- Mouse over the Downloads menu item and select JasperReports Server Commercial Editions
- Scroll about halfway down the page to the Source Code section
- Click the Download link to the right of the JasperReports Server vx.x.x Source Code (x.x.x). If prompted, click the Save File option
Extract the source code.
- After the download completes, open it using a Zip utility such as WinZip or 7-Zip. Note: There have been problems reported when extracting the Zip archive using the Windows Archiving utility
- If necessary, create a folder under the C: drive (on Windows) or /opt (on Linux) called js-workspace and extract the contents of the Zip archive to this folder.
(Optional) Build the source code from the command line using the Buildomatic scripts.
Note: When completing Task 1, you might see some error messages stating that one or more folders called resources are missing. To fix this error, build the source code on the command line using the Buildomatic scripts.
Open a command line window and execute the following commands:
- On Windows:
- cd c:js-workspacejasperreports-server-vx.x.x-srcjasperserverbuildomatic
- copy sample_confsourcepostgresql_master.properties default_master.properties
- On Linux:
- cd /opt/js-workspace/jasperreports-server-vx.x.x-src/jasperserver/buildomatic
- cp sample_conf/source/postgresql_master.properties default_master.properties
Edit the newly created default_master.properties file using a text editor
In Section One, change the appServerDir path to match where Tomcat is installed
In Section Two, edit the following path locations:
- maven = (the path where Apache Maven is installed on your machine)
- On Windows:
- js-path = C:js-workspacejasperreports-server-vx.x.x-srcjasperserver
- js-pro-path = C:js-workspacejasperreports-server-vx.x.x-srcjasperserver-pro
- repo-path = C: js-workspacejasperreports-server-vx.x.x-srcjasperserver-repo
- On Linux:
- js-path = /opt/js-workspace/jasperreports-server-vx.x.x-src/jasperserver
- js-pro-path = /opt/js-workspace/jasperreports-server-vx.x.x-src/jasperserver-pro
- repo-path = /opt/ js-workspace/jasperreports-server-vx.x.x-src/jasperserver-repo
Save and close the file
On the command line, run the following command:
- js-ant build-ce build-pro
For more information on how to configure and run Buildomatic, refer to sections 3.4 and 3.5 of the JasperReports Server Source Build Guide included in the C:js-workspacejasperreports-server-vx.x.x-src folder.
- On Windows:
Open Eclipse.
Start Eclipse and ensure c:js-workspace is selected as the workspace
If you see a dialog box titled Usage Data Upload prompting you to upload usage data, click the Turn UDC Feature Off button and click Finish
Task 2: Set Up Repo Project
Create the Java Project.
- Click File > New > Project…
- Expand the Java node, select Java Project, and click Next >
- Project Name: jasperserver-repo
- Uncheck Use Default Location and click the Browse button to navigate to the jasperserver-repo folder
- Click Finish
Task 3: Set Up the CE Source
Remove unnecessary files (Windows).
- Using Windows Explorer, browse to the c:js-workspacejasperreports-server-x.x.x-srcjasperserver folder
- Delete the .classpath and .project files if they exist
Remove unnecessary files (Linux).
- On the command line, run the following commands
- cd /opt/js-workspace/jasperreports-server-vx.x.x-src/jasperserver-pro
- rm .classpath
- rm .project
- On the command line, run the following commands
Create a new project.
- Click File > New > Project…
- Expand the Java node, select Java Project, and click Next >
- Project Name: jasperserver
- Uncheck Use Default Location and click the Browse button to navigate to the jasperserver folder
- Click Next >
- Click the Allow output folders for source folders and add the following location to the text field below
- jasperserver/eclipse-build-classes
- Click Finish
- A prompt will notify you that the output folder has changed. Click Yes to remove the old generated class files
Clear the build path.
- Right-click on the Project and select Build Path > Configure Build Path
- In the Project tab, click Add…
- Click the checkbox next to jasperserver-repo and click OK
- In the Libraries tab, select all the jar files and click the Remove button
- Ensure you have NOT selected the JRE
- Keep this window open
Add JARs.
- Click the Add Library… button
- Select the JUnit option and click Next >
- Ensure JUnit 4 is selected in the JUnit Library version combo box and click Finish
- Click the Add Library… button again
- Ensure the User Library option is selected in the list and click Next >
- Click the User Libraries… button
- Click the New… button
- In the User library name: text box, enter JasperReports-Server-x.x.x (where x.x.x is the version number) and click OK
- Ensure the new library is selected and click the Add JARs… button
- Browse to the folder which contains the JasperReports Server pro libraries:
- (Windows) C:js-workspacejasperreports-server-vx.x.x-srcjasperserver-projasperserver-wartargetjasperserver-proWEB-INFlib
- (Linux) /opt/js-workspace/jasperreports-server-vx.x.x-src/jasperserver-pro/jasperserver-war/target/jasperserver-pro/WEB-INF/lib
- Select all of the jar files in the folder and click Open
- Click the OK and Finish buttons to close the libraries dialog boxes
- Click the Add External JARs… button
- Browse to the lib folder of your Tomcat server:C:pathtotomcatlib
- Select the jsp-api.jar and servlet-api.jar files and click Open
- Keep this window open
Export the JAR files to other projects
- Click the Order and Export tab
- Click the Select All button
- Uncheck the JRE System Library entry, but ensure all others are checked
- Click OK to close the Properties dialog box
Remove test packages from the build path.
- In the Project Explorer, hold down the CTRL key and select the following folders:
- buildomatic/src/main/java
- jasperserver-api-impl/engine/src/test/java
- jasperserver-api-impl/metadata/src/test/java
- jasperserver-remote-tests/src/test/java
- jasperserver-unit-test/src/test/java
- jasperserver-war-jar/src/test/java
- jasperserver-war/src/test/java
- production-tests/src/test/java
- Right-click on the selected packages and select Build Path > Remove from Build Path
- Expand the jasperserver-war-jar/src/main/java folder
- Expand the com.jaspersoft.jasperserver.war.tiles2 package
- Right-click on the SpringTilesConfigurer.java class and select Build Path > Exclude
- In the Project Explorer, hold down the CTRL key and select the following folders:
Task 4: Set Up the Pro Source
Remove unnecessary files (Windows).
- In Windows Explorer, browse to the c:js-workspacejasperreports-server-vx.x.x-srcjasperserver-pro folder
- Delete both the .classpath and .project files
Remove unnecessary files (Linux).
- On the command line, run the following commands:
- cd /opt/js-workspace/jasperreports-server-vx.x.x-src/jasperserver-pro
- rm .classpath
- rm .project
- On the command line, run the following commands:
Create a new project.
- In Eclipse, click File > New > Java Project
- Project Name: jasperserver-pro
- Uncheck Use Default Location and click the Browse button to navigate to the jasperserver-pro folder
- Click Next >
- Click the Allow output folders for source folders and add jasperserver-pro/eclipse-build-classes to the text field below
- Click the Projects tab
- Click the Add button, click the checkbox next to jasperserver, and click OK
- Click Next >
- In Eclipse, click File > New > Java Project
Fix source paths.
- On the Source tab, expand the src > main > java folders under each of the folders listed below, right-click and select Use as Source Folder:
- analysis
- analysis-export
- common
- common-export
- datarator
- datarator-el
- gyroscope
- gyroscope-export
- gyroscope-ireport-plugin
- jasperserver-common-ws
- jasperserver-war-jar
- jasperserver-ws
- jasperserver-ws-client
- mondrian-aop-woven
- multi-tenancy
- report-options/api
- report-options/export
- report-options/web
- repository-hibernate
- search
- semantic-layer
- semantic-layer-ireport-plugin
Note: Ignore the error messages, which indicate that the OlapConnection.getSchema() method is ambiguous.
- On the Source tab, expand the src > main > java folders under each of the folders listed below, right-click and select Use as Source Folder:
Task 5: Configure Remote Debugging Using JPDA
Configure Tomcat to accept remote connections (Windows Service only).
- In Windows Explorer, locate and execute tomcat6w.exe
- On Windows 7, you may need to run this as an Administrator
- When the Configure Tomcat applet launches, click the Java tab
- In the Java Options text box, add the following all on one line:
- -Xrunjdwp:transport=dt_socket,address=,server=y,suspend=n
(where is an open port on your machine, ex. 8787)
- Click OK to close the applet
- Restart the Tomcat service
- In Windows Explorer, locate and execute tomcat6w.exe
Configure Tomcat to accept remote connections (starting Tomcat using scripts on Windows).
- Depending on the version of Tomcat, open the setclasspath.bat or setenv.bat in a text editor
- Add the following line at the bottom of the file:
- set JAVA_OPTS=%JAVA_OPTS% -Xrunjdwp:transport=dt_socket,address=,server=y,suspend=n
(Where is an open port on your desktop, ex. 8787)
- set JAVA_OPTS=%JAVA_OPTS% -Xrunjdwp:transport=dt_socket,address=,server=y,suspend=n
- Save the file and restart Tomcat
Configure Tomcat to accept remote connections (starting Tomcat using scripts on Linux).
- Depending on the version of Tomcat, open the setclasspath.sh or setenv.sh in a text editor
- Add the following line at the bottom of the file:
- export JAVA_OPTS=$JAVA_OPTS -Xrunjdwp:transport=dt_socket,address=,server=y,suspend=n
(Where is an open port on your desktop, ex. 8787)
- export JAVA_OPTS=$JAVA_OPTS -Xrunjdwp:transport=dt_socket,address=,server=y,suspend=n
- Save the file and restart Tomcat
Configure the Eclipse Debug Launcher.
- In the Eclipse menu bar, click Run > Debug Configurations...
- In the Debug Configurations dialog box, click Remote Java Application and click the New button
- In the Launcher window, enter the name of the launcher (ex: Tomcat6.0)
- Click the Browse button next to the Project textbox and select the jasperserver-pro project
- Ensure Standard (Socket Attached) is selected in the Connection Type combo box
- Specify the host name and port number where Tomcat is running
- This is the same port number specified in step 1
- Click Apply and Debug
Result: Eclipse might prompt to switch to the Debug perspective. If it does, click Yes. In the Debug perspective, Eclipse will show all of the executing threads of the Tomcat server under the Debug tab, as shown here:
- Set some break points in Eclipse if desired
- Open a browser and log in to JasperReports Server
Result: Clicking an action that contains code with break points will cause execution in the browser to pause. This allows you to step through the code in Eclipse and inspect values of variables currently in scope.
What's Next?
Now that you've reviewed how to configure Eclipse, you're ready to take our Extending and Integrating Jaspersoft BI course and learn how developers expand the power of JasperReports Server.
Written by
This tutorial was written by Steve Park, Professional Services Consultant, and Curtis Stallins, Technical Training Specialist, in April 2011. Updated in February, 2012.
Recommended Comments
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 accountSign in
Already have an account? Sign in here.
Sign In Now