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 at 06:42

adamf's gravatar image

adamf
215
accept rate: 0%

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

(20.09 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 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: https://drive.google.com/file/d/0B3V8Sh7Fl7FXWHRxcEw2T29PdkU/view?usp=sharing

Cheers Lars

link

answered 20.09 at 13:02

Lars%20Tuchel's gravatar image

Lars Tuchel
2664813
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 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 https://maven.apache.org/plugins/maven-resources-plugin/examples/resource-directory.html

(22.09 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 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.

http://axonivy.github.io/project-build-plugin/release/7.0/pack-iar-mojo.html

(26.09 at 09:46) Reguel Werme... ♦♦ Reguel%20Wermelinger'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

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "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

Tags:

×40
×9

Asked: 20.09 at 06:42

Seen: 70 times

Last updated: 26.09 at 09:48