Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.java.programmer > #34390 > unrolled thread
| Started by | Philipp Kraus <philipp.kraus.flashpixx@gmail.com> |
|---|---|
| First post | 2016-05-26 05:48 -0700 |
| Last post | 2016-05-26 12:46 -0700 |
| Articles | 4 — 2 participants |
Back to article view | Back to comp.lang.java.programmer
property reading within framework Philipp Kraus <philipp.kraus.flashpixx@gmail.com> - 2016-05-26 05:48 -0700
Re: property reading within framework Andreas Leitgeb <avl@logic.at> - 2016-05-26 13:25 +0000
Re: property reading within framework Andreas Leitgeb <avl@logic.at> - 2016-05-26 13:45 +0000
Re: property reading within framework Philipp Kraus <philipp.kraus.flashpixx@gmail.com> - 2016-05-26 12:46 -0700
| From | Philipp Kraus <philipp.kraus.flashpixx@gmail.com> |
|---|---|
| Date | 2016-05-26 05:48 -0700 |
| Subject | property reading within framework |
| Message-ID | <45d9471f-7c05-41fb-b539-02a79a9ca27a@googlegroups.com> |
Hello, I try to read a property file from a framework. At the moment I'm using: final Properties l_property = new Properties(); l_property.load( a_class_within_my_framework.getResourceAsStream( "configuration.properties" ) ); For all within the framework this works fine. If I include my framework e.g. with Maven dependency in another project, the getResourceAsStream fails with a NPE or it read the configuration.properties from the project and not from the framework. I try also /configuration.properties or /groupid/artifactid/configuration.properties but I don't get a working solution. I would like to read the "configuration.properties" file, which is stored in the resource directory of a Maven project always from this framework. How I do this in a correct way? Thanks Phil
[toc] | [next] | [standalone]
| From | Andreas Leitgeb <avl@logic.at> |
|---|---|
| Date | 2016-05-26 13:25 +0000 |
| Message-ID | <slrnnkdugi.456.avl@login.logic.tuwien.ac.at> |
| In reply to | #34390 |
Philipp Kraus <philipp.kraus.flashpixx@gmail.com> wrote: > I try to read a property file from a framework. At the moment I'm using: > final Properties l_property = new Properties(); > l_property.load( a_class_within_my_framework.getResourceAsStream( "configuration.properties" ) ); It depends on what classloader actually loaded the class on which you are calling getResourceAsStream(...) Perhaps, when your framework is used by the other project, then somewhere you "accidentally" load some class of the framework using the system classloader. That class is then already known, and won't be reloaded through the specific classloader.
[toc] | [prev] | [next] | [standalone]
| From | Andreas Leitgeb <avl@logic.at> |
|---|---|
| Date | 2016-05-26 13:45 +0000 |
| Message-ID | <slrnnkdvmf.456.avl@login.logic.tuwien.ac.at> |
| In reply to | #34391 |
Andreas Leitgeb <avl@logic.at> wrote: > Philipp Kraus <philipp.kraus.flashpixx@gmail.com> wrote: >> a_class.getResourceAsStream( "configuration.properties" ) > > It depends on what classloader actually loaded the class on which > you are calling getResourceAsStream(...) > > Perhaps, when your framework is used by the other project, then somewhere > you "accidentally" load some class of the framework using the system > classloader. That class is then already known, and won't be reloaded > through the specific classloader. One way to find where the class really gets loaded is setting a breakpoint in a static initializer block of the class. (If there's none, create one.)
[toc] | [prev] | [next] | [standalone]
| From | Philipp Kraus <philipp.kraus.flashpixx@gmail.com> |
|---|---|
| Date | 2016-05-26 12:46 -0700 |
| Message-ID | <c596fcf5-f5f1-4ba6-9411-2d3a5d5812ab@googlegroups.com> |
| In reply to | #34392 |
Am Donnerstag, 26. Mai 2016 15:49:15 UTC+2 schrieb Andreas Leitgeb: > Andreas Leitgeb wrote: > > Philipp Kraus wrote: > >> a_class.getResourceAsStream( "configuration.properties" ) > > > > It depends on what classloader actually loaded the class on which > > you are calling getResourceAsStream(...) > > > > Perhaps, when your framework is used by the other project, then somewhere > > you "accidentally" load some class of the framework using the system > > classloader. That class is then already known, and won't be reloaded > > through the specific classloader. > > One way to find where the class really gets loaded is setting a breakpoint > in a static initializer block of the class. (If there's none, create one.) Yes, thanks, it was my mistake, the path has got a typo error Phil
[toc] | [prev] | [standalone]
Back to top | Article view | comp.lang.java.programmer
csiph-web