Re: Reading in a framework-level resource in a Maven-built app
Re: Reading in a framework-level resource in a Maven-built app
- Subject: Re: Reading in a framework-level resource in a Maven-built app
- From: "Morris, Mark" <email@hidden>
- Date: Sun, 02 Apr 2017 07:06:37 +0000
- Thread-topic: Reading in a framework-level resource in a Maven-built app
Hi Paul,
I’m not sure if I’m missing the point of your question, but WOResourceManager will find files in frameworks just fine if they’re in the Resources folder. Note that this is not under any XXX.woa/Contents/Resources path as mentioned in your email, you just put the files in the FrameworkName/Resources folder and they end up under FrameworkName.framework/Resources within the jar. You do have to supply the framework name in the call to WOResourceManager, such as:
InputStream is = WOApplication.application().resourceManager().inputStreamForResourceNamed( “foo.txt", “FrameworkName", aLanguagesList );
This is of course different from WebServerResources, which end up under the web server document root.
Hope this helps!
Mark
> On Apr 1, 2017, at 11:45 PM, Paul Hoadley <email@hidden> wrote:
>
> Hello,
>
> I can see reference to this issue a couple of times in the list archives, but I’m not seeing the definitive solution. Could we quickly look at this again?
>
> I have a file ‘foo.txt’ in Bar.framework at ‘src/main/resources/foo.txt’. In an application Baz dependent on Bar.framework, I want to load foo.txt, say as an InputStream. To be clear:
>
> * Bar.jar is present at the appropriate place under Baz.woa/Contents/Resources/Java/.
> * Bar.jar does contain foo.txt under its Resources folder.
> * foo.txt is not present in Baz.woa/Contents/Resources.
>
> All of this seems to be what I’d expect. Further, running out of Eclipse, something as simple as:
>
> getClass().getClassLoader().getResource(BLACKLIST_FILENAME).toURI()
>
> will get a URI for the file, because it can be found on the local filesystem. But if I close that project, forcing it to run using the framework JAR, neither that approach, nor WOResourceManager.inputStreamForResourceNamed() can find the file.
>
> Anyway, rather than trying to debug any of the specifics of what I describe above, let me just ask a simple question: how can I load a framework resource at runtime in deployment given that the resource will be buried deep in a framework JAR?
>
>
> --
> Paul Hoadley
> http://logicsquad.net/
> https://www.linkedin.com/company/logic-squad/
>
>
>
>
> _______________________________________________
> Do not post admin requests to the list. They will be ignored.
> Webobjects-dev mailing list (email@hidden)
> Help/Unsubscribe/Update your Subscription:
>
> This email sent to email@hidden
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden