Export Application

DEPRECATED Information on this page is deprecated and applicable only to NSF <2019.5. See Import/Export instead.

The Prime Radiant provides functionality to export and import models. This functionality is also available to execute from the cmd line.

The class FullApplicationPrimeToDirectory exports the entire application model. More specifically:

  • application model is exported to applications/<application>/model/<application>-<version>.xml
  • application instances are exported to applications/<application>/model/instances/
  • components are exported to components/<component>/model/ (baseComponents are not included)

The API call looks like this:

java -cp %CP% net.democritus.elements.runner.FullApplicationPrimeToDirectory application version [directory] [options]

e.g. java -cp %CP% net.democritus.elements.runner.FullApplicationPrimeToDirectory euRent 1.0 C:/temp/export


For this to work the Prime Radiant must be running and the following jars must be included in the classpath:

  • client.jar
  • elements-io
  • elements-shared, elements-proxy
  • nsx-shared-common, nsx-common, nsx-logging


Order Argument Optional Description
1 application no Name (shortName) of the application
2 version no Version of the application
3 directory yes Directory to which to export the files. If not defined applicationPath and componentPath will be used.


Option Default Environment variable Description
-a,--applicationPath <arg> <local folder>/applications APPLICATION_PATH Path to the applications folder. Can be multiple paths separated by a ;.
-c,--componentPath <arg> <local folder>/components COMPONENT_PATH Path to the components folder. Can be multiple paths separated by a ;
-f,--useComponentFile false - Use the full component file instead of a component directory.
-n,--createFolders false - Create new folders if they do not exist
-r,--clean false - Clean the target model folders before exporting
-u,--user <arg> admin - Username used to connect to the PR

Target folders

There are 4 ways to define the target folders for the xml files;

  1. By passing the directory argument, the application will be export to <directory>/applications and components to <directory>/applications.
  2. By passing the options --applicationPath and --useComponentFile.
  3. By settings the environment variables APPLICATION_PATH and COMPONENT_PATH.
  4. By executing the script in the correct folder, the paths will default to ./applications and ./components.

Application folder

When executed on an empty folder, the following error message will appear:

Did not find application folder for euRent
Application path is [C:\temp\export\applications]
Exception in thread "main" java.lang.RuntimeException: Could not find application folder
        at net.democritus.elements.context.SourceBasePaths.findApplicationDirectory(SourceBasePaths.java:57)
        at net.democritus.elements.context.SourceBasePaths.makeApplicationModelDirectory(SourceBasePaths.java:190)
        at net.democritus.elements.document.ApplicationFullDirectoryExporter.exportApplication(ApplicationFullDirectoryExporter.java:48)
        at net.democritus.elements.document.ApplicationFullDirectoryExporter.exportStructure(ApplicationFullDirectoryExporter.java:34)
        at net.democritus.elements.runner.FullApplicationPrimeToDirectory.perform(FullApplicationPrimeToDirectory.java:82)
        at net.democritus.elements.runner.FullApplicationPrimeToDirectory.main(FullApplicationPrimeToDirectory.java:65)

This is because the export function expects the application folder for euRent to already be present. This is to prevent the export function from exporting to the wrong folder without yielding any errors.

To solve this, there are a number of solutions:

  1. Create the folder manually. In this case, create the folder C:\temp\export\applications\euRent and leave it empty
  2. Create the applications folder and then pass the –createFolders option. This will create a new folder with the name of the application if none is found.
  3. Export to a directory that was already instantiated. E.g. by the Prime Radiant

If the goal is to create a new repository, option 2 will be the easiest solution.

Component folder

You may experience similar issues if the components folder does not exist:

Making directory C:\temp\export\components\rentWork
Could not create directory C:\temp\export\components\rentWork
Did not find component folder for rentWork 1.0
Component path is [C:\temp\export\components]
Exception in thread "main" java.lang.RuntimeException: Could not find component folder
        at net.democritus.elements.context.SourceBasePaths.findComponentDirectory(SourceBasePaths.java:75)
        at net.democritus.elements.context.SourceBasePaths.makeComponentModelDirectory(SourceBasePaths.java:131)
        at net.democritus.elements.document.ApplicationFullDirectoryExporter.exportComponentToDirectory(ApplicationFullDirectoryExporter.java:119)
        at net.democritus.elements.document.ApplicationFullDirectoryExporter.exportComponentAggregates(ApplicationFullDirectoryExporter.java:95)
        at net.democritus.elements.document.ApplicationFullDirectoryExporter.exportStructure(ApplicationFullDirectoryExporter.java:36)
        at net.democritus.elements.runner.FullApplicationPrimeToDirectory.perform(FullApplicationPrimeToDirectory.java:82)
        at net.democritus.elements.runner.FullApplicationPrimeToDirectory.main(FullApplicationPrimeToDirectory.java:65)

This is again because there is no components folder or no folder with name rentWork under that components folder. The –createFolders option will create a new rentWork folder if it does not exist.


In conclusion, the application can be exported to a fresh folder by first creating the applications and components folders and passing along the –createFolders folders:

mkdir C:\temp\export\applications
mkdir C:\temp\export\components
java -cp %CP% net.democritus.elements.runner.FullApplicationPrimeToDirectory euRent 1.0 C:/temp/export --createFolders

The output will look like the following:

## Reading application
## Reading application instances
## Skipping baseComponent ComponentVersion{name='account', version='1.0'}
## Skipping baseComponent ComponentVersion{name='workflow', version='1.0'}
## Skipping baseComponent ComponentVersion{name='utils', version='1.0'}
## Skipping baseComponent ComponentVersion{name='validation', version='1.0'}
## Reading component ComponentVersion{name='rentWork', version='1.0'}
Starting full export
Exporting application...
Making directory C:\temp\export\applications\euRent
Wrote C:\temp\export\applications\euRent\model\euRent-1.0.xml
Exporting application instances...
EU Rent: Exercises
Wrote C:\temp\export\applications\euRent\model\instances\eu_rent_exercises.xml
Exporting components...
Making directory C:\temp\export\components\rentWork
Wrote C:\temp\export\components\rentWork\model\dataElements\Bank.xml
Wrote C:\temp\export\components\rentWork\model\dataElements\BankAccount.xml
Wrote C:\temp\export\components\rentWork\model\dataElements\BankAccountType.xml
Full export complete