Table of Contents

Using Eclipse for SavaPage Development

This is a guide for SavaPage Development Partners on how to install and configure Eclipse IDE for SavaPage development.

Status : reviewed/approved

Installation

Download latest stable version of Eclipse IDE for Java EE Developers.

cd ~/applications
tar -zxvf eclipse-jee-2019-03-R-linux-gtk-x86_64.tar.gz # Ubuntu 16.04, Trisquel 8.0, ...
tar -zxvf eclipse-jee-2020-06-R-linux-gtk-x86_64.tar.gz
Important Eclipse-2020-06 (SWT requires GTK 3.20.0) is not compatible with Ubuntu 16.04 (GTK 3.18.9).
# libgtk check on Ubuntu 20.04.1
rijk@sperwer:~$ dpkg -s libgtk-3-0 | grep '^Version'
Version: 3.24.20-0ubuntu1

Marketplace

Install from Eclipse Marketplace:

Configure

Show Hidden Files

In the package explorer, in the upper right corner of the view, there is a little icon with tool tip text “View Menu”. From that menu, select “Filters and Customization”. On the “Pre-set filters” tab, uncheck .* resources.

Compiler compliance level

Select Window → Preferences → Java → Compiler

Installed JREs

Select Window → Preferences → Java → Installed JREs

Important Make sure the openjdk source package is installed, so its Javadoc is available in Eclipse.
# if openjdk-11 is installed, then ...
sudo apt install openjdk-11-source

JPA Validation

To prevent “Duplicate generator defined in this persistence unit” messages:

Select Window → Preferences → Java Persistence →JPA → Errors/Warnings

Under “Queries and generators” mark “Duplicate generator defined” as Ignore.

Java Code Style

Formatter

Select Window → Preferences → Java → Code Style → Formatter

Code Templates

Select Window → Preferences → Java → Code Style → Code Templates → Comments → Types

JavaScript Code Style

Formatter

Select Window → Preferences. Select JavaScript, or Web → HTML Files → Client-side JavaScript. Select Code Style → Formatter

Editors

Text

Select Window → Preferences → General → Editors → Text Editors

Check the following items:

XML

Select Window → Preferences → XML → XML Files → Editor

Java

Select Window → Preferences → Java → Editor → Save Actions

Not applicable in Eclipse 2019-03 (4.11.0) ?

Eclipse 2020-06

CSS

Select Window → Preferences → Web → CSS Files → Editor

HTML

Select Window → Preferences → Web → HTML Files → Editor

Maven

Maven is integrated into Eclipse, but the central repository index needs to be rebuild, so we can select dependencies.

Select Window → Show View → Other

Also set up index to update on Eclipse start-up.

Problem: Rebuild Index does not have any effect.
Solution: Delete your cached index. It is somewhere in workspace\ .metadata\ .plugins\org.eclipse.m2e.core\nexus (just delete the entire content of the nexus-folder). See stackoverflow 37749785 and 7065478.

Projects

Prerequisite All relevant repositories are cloned into ~/savapage/repos/ as explained in the “Getting started” section of savapage-make/README.md.
Important To contribute code, fork/clone the target SavaPage repositories. Edit/commit in develop branch, and create Merge Requests to push changes upstream.

savapage-make

Create savapage-make/.project file …

savapage-make/.project
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
    <name>savapage-make</name>
    <comment/>
    <projects/>
    <buildSpec/>
    <natures/>
</projectDescription>

… and import this project via “Import → General → Existing Projects” into Workspace.

thirdparty

Download/install thirdparty files in addition to SavaPage.

cd ~/savapage
wget https://www.savapage.org/download/development/thirdparty-savapage-fonts.tar.gz -O - | tar -xz

Maven projects

Add each Maven project with: File → Import → Maven → Existing Maven Projects.

For each project, select the project in the Project Explorer and select the project properties.

savapage-core

Select the savapage-core project, right-click and select from main menu: Run As → Run Configurations… and Right-click on “Java Application”.


Select “New Configuration” and enter the following on tab “Main”:

Name AppDb
Main class org.savapage.core.cli.AppDb

On tab “Arguments” enter the following “Program Arguments”:

On tab “Arguments” enter the following “VM arguments”:

-Dserver.home=${project_loc}/../savapage-server/server.home    
-Dlog4j.configuration=file://${project_loc}/../savapage-server/server.home/lib/log4j.properties

Select “New Configuration” and enter the following on tab “Main”:

Name App
Main class org.savapage.core.cli.server.App

On tab “Arguments” enter the following “Program Arguments”:

On tab “Arguments” enter the following “VM arguments”:

-Dserver.home=${project_loc}/../savapage-server/server.home    
-Dlog4j.configuration=file://${project_loc}/../savapage-server/server.home/lib/log4j.properties

Fonts

Embed fonts:

cd ~/savapage/repos/savapage-core
cd src/main/java/org/savapage/core/fonts/
mkdir truetype
# copy font directories from thirdparty
cp -r ~/savapage/thirdparty-savapage/fonts/savapage/0.9.7/* truetype/

Java Build Path

Beware Java Build Path settings might be (bug?) overwritten when performing a “Maven → Update project” action.
Note Also see savapage-server build path problems.

savapage-server

Select the savapage-server project, right-click and select from main menu: Run As → Run Configurations…

Right-click on “Java Application”, select “New Configuration” and enter the following on tab “Main”:

Name WebServer
Main class org.savapage.server.WebServer

On tab “Arguments” enter the following “VM arguments”:

-Dserver.home=${project_loc}/server.home 
-Dclient.home=${project_loc}/client.home 
-Dwicket.configuration=development
-Dlog4j.configuration=file://${project_loc}/server.home/lib/log4j.properties
-Dcom.sun.management.config.file=${project_loc}/server.home/jmxremote.properties
-Djava.net.preferIPv4Stack=true
-Djava.io.tmpdir=${project_loc}/server.home/tmp
Java-11 As explained in java –help-extra add –illegal-access=debug as first line to “VM arguments”. This will write a stack-trace to stdout so “Illegal reflective access warnings” can be pinpointed. Add –add-opens jdk.management/com.sun.management.internal=ALL-UNNAMED as second line.
Note Use -Dwicket.configuration=deployment if you want to run in deployment mode.

Java Build Path

IMPORTANT

IMPORTANT :

Note Also see build savapage-core path problems.

Create directory savapage-server/client.home/ and copy SAVAPAGE.ppd to it.


log4j

Copy content from savapage-make/setup-template/savapage/server/lib/log4j.properties to savapage-server/server.home/lib/log4j.properties and add/replace:

server.home/lib/log4j.properties
# ...
### log messages to stdout  ###
log4j.appender.stdout=org.apache.log4j.ConsoleAppender
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
log4j.appender.stdout.layout.ConversionPattern=%d{ISO8601} %5p %c{1}:%L - %m [%t]%n
log4j.appender.stdout.encoding=UTF8
# ...
log4j.rootLogger=ERROR, file, stdout
# ...
# end-of-file

server.properties

Copy content from: savapage-make/setup-template/savapage/server/server.properties to savapage-server/server.home/server.properties, and:

server.home/server.properties
server.port=8080
server.ssl.port=8443
server.print.port.raw=9101

savapage-client

Create directory savapage-client/client.home/ with the following files:

savapage-client/client.home/log4j.properties
### direct log messages to stdout ###
log4j.appender.Stdout=org.apache.log4j.ConsoleAppender
log4j.appender.Stdout.layout=org.apache.log4j.PatternLayout
log4j.appender.Stdout.layout.conversionPattern=%d{ISO8601} %-5p %c{1}:%L - %m [%t]\n
 
### direct messages to file  ###
log4j.appender.file=org.apache.log4j.RollingFileAppender
log4j.appender.file.MaxFileSize=10MB
log4j.appender.file.MaxBackupIndex=10
log4j.appender.file.File=${app.home}/logs/client.log
log4j.appender.file.layout=org.apache.log4j.PatternLayout
log4j.appender.file.layout.ConversionPattern=%d{ISO8601} %5p %c{1}:%L - %m [%t]%n
log4j.appender.file.encoding=UTF8
 
###
log4j.rootLogger=ERROR, Stdout, file
 
###
log4j.logger.org.savapage=WARN
 
#log4j.logger.org.eclipse.jetty=DEBUG
#log4j.logger.org.cometd=DEBUG
 
# end-of-file

Select the savapage-client project, right-click and select from main menu: Run As → Run Configurations…

Right-click on “Java Application”, select “New Configuration” and enter the following on tab “Main”:

Name ClientApp
Main class org.savapage.client.ClientApp

On tab “Arguments” enter the following “Program Arguments”:

On tab “Arguments” enter the following “VM arguments”:

-Dapp.home=${project_loc}/client.home 
-Dapp.name=savapage-client
-Dlog4j.configuration=file://${project_loc}/client.home/log4j.properties

savapage-util

Select the savapage-util project, right-click and select from main menu: Run As → Run Configurations…

Right-click on “Java Application”, select “New Configuration” and enter the following on tab “Main”:

Name AppUtil
Main class org.savapage.util.App

On tab “Arguments” enter the following “Program Arguments”:

On tab “Arguments” enter the following “VM arguments”:

-Dserver.home=${project_loc}/../savapage-server/server.home
-Dlog4j.configuration=file://${project_loc}/../savapage-server/server.home/lib/log4j.properties

Running and Debugging

WebServer Select “savapage-server” from Project Explorer and press F11
ClientApp Select “savapage-client” from Project Explorer and press F11
App Select “savapage-core” from Project Explorer → Run Configurations → Java Application → App → Run
AppDb Select “savapage-core” from Project Explorer → Run Configurations → Java Application → AppDb → Run

Database Tooling

Squirrel

Download/install from http://www.squirrelsql.org/

Configure Drivers

Open the “Drivers” view and configure each driver used.

Apache Derby :

PostgreSQL :

Add Databases

Open the “Aliases” View and “Create a New Alias” for your databases. For example:

Name Driver URL User Name Password Auto Logon
savapage-dev-derby Apache Derby Embedded jdbc:derby:[absolute-path-to]/savapage-server/server.home/data/internal/Derby Y
savapage-dev-postgres PostgreSQL jdbc:postgresql://localhost/your-db-name user password Y

https://www.savapage.org/download/design/savapage-database-schema-1.10.pdf