Axon.ivy 7.0 - the Digital Business Platform - is out now...

In typical Java EE maven project I put resources in src/main/resources and access files with getResourceAsStream().

How to work relative to the current class has been dicussed in this thread. However, I would need an absolute way to access resources.

Background of this question is that I would like to use owner config with fallback to a classpath property file.

Thanks for help.

asked 20.09.2017 at 06:42

adamf's gravatar image

accept rate: 0%

So working with relative path annotating my owner config with @Config.Sources({"classpath:./"}), but this requires having property file in same directory as java files.

(20.09.2017 at 08:34) adamf adamf's gravatar image

The "ivy way" is probably to use the configuration system for configs and other resources as texts or images to CMS system and use Ivy.cms().getContentObject(path) ?

(21.09.2017 at 10:28) adamf adamf's gravatar image

Hi Adam

Create a new folder in your axonivy project, add the folder to your classpath (as shown below) and then make sure you path starts with a forward-slash (e.g. /path/to/my/file.txt).

alt text

Also here's a sample project:

Cheers Lars


answered 20.09.2017 at 13:02

Lars%20Tuchel's gravatar image

Lars Tuchel
accept rate: 60%

Hi @Lars, your example works in Developer, but when deploying on Axon.ivy Engine it throws a NPE (Cannot find the resource). Anything to take care of when deploying on Axon.ivy Engine?

(20.09.2017 at 15:31) adamf adamf's gravatar image

Hi @adamf When you build your project with maven, make sure you add your folder as resources folder in the pom.xml. See

(22.09.2017 at 10:15) Lars Tuchel Lars%20Tuchel's gravatar image

This approach using maven resource still does not work on the stand alone engine for me. Please check that this approach works also on engine before accepting.

(25.09.2017 at 09:11) adamf adamf's gravatar image

can you check whether the resource really exist in the built IAR file? Maybe it is not because some files are filtered by default. You may want to play around with the related parameters of the maven plugin to steer the file inclusion in ivy archives.

(26.09.2017 at 09:46) Reguel Werme... ♦♦ Reguel%20Wermelinger's gravatar image

Hi @Reguel, yes it includes the resources in IAR file. But it looks like in the engine only resources in one of the default src_ folders are considered. It does not matter so much, as there is no real use case for this in Ivy. And one can cope with having java classes mixed with resources if one really needs them.

(24.10.2017 at 06:36) adamf adamf's gravatar image
Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here



Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text]( "Title")
  • image?![alt text](/path/img.jpg "Title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported



Asked: 20.09.2017 at 06:42

Seen: 222 times

Last updated: 24.10.2017 at 06:37