• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Framework resources folder and Maven
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Framework resources folder and Maven


  • Subject: Re: Framework resources folder and Maven
  • From: Nikolay <email@hidden>
  • Date: Wed, 13 Apr 2016 21:57:17 +0200

I had the same issue with access to resource inside a framework from application. The workaround was not so nice, but anyway: 

NSBundle servicesFw = NSBundle.bundleForName("servicesFw");
URL a = services.pathURLForResourcePath("my-resouce.txt“);

See also: NSBundle#frameworkBundles(), NSBundle#isJar()

Nick

2016-04-12 23:23 GMT+02:00 Ramsey Gurley <email@hidden>:
So, yeah. It works in my maven helloworld/hellowframework combo. I guess I need to dig around in my business logic and application pom files to see what might be foul.

Thanks again Chuck.

On Apr 12, 2016, at 2:17 PM, Ramsey Gurley <email@hidden> wrote:

> Okay. Good to know. I’m going to try this in a hello world app/framework and see if I can get a simple input stream from framework resources there.
>
> Thanks Chuck
>
> On Apr 12, 2016, at 1:58 PM, Chuck Hill <email@hidden> wrote:
>
>> It should work.  It sounds like the problem is that your business logic framework is not getting built correctly and so not recognized as a framework.
>>
>> pathForResourceNamed is deprecated (in reality if not JavaDoc), use pathURLForResourceNamed instead.  But that won’t work unless your framework is recognized.
>>
>> The other alternative is to move it so that Maven includes it as a Java, not WO, resource and use java.lang.Class.getResource*
>>
>> Chuck
>>
>>
>>
>>
>>
>>
>> On 2016-04-12, 1:47 PM, "webobjects-dev-bounces+chill=email@hidden on behalf of Ramsey Gurley" <webobjects-dev-bounces+chill=email@hidden on behalf of email@hidden> wrote:
>>
>>> I have an application with a business logic framework, and in that framework there is a Resources/known_hosts file. I’ve discovered that with maven, ERXFileUtilities.pathForResourceNamed just returns null and logs out “Can’t get path when run as jar: …”.
>>>
>>> In this case, I’m using the JSch library to do SFTP, and that happens to accept a path or an input stream for the known hosts file. So I switch to ERXFileUtilities.inputStreamForResourceNamed, and I still get a null return value. It just fails silently.
>>>
>>> So I put together a test case and stepped through until I get to the point where it tries to load the known_hosts file. What I discover is that my business logic framework isn’t listed in NSBundle.allBundles() or even NSBundle._allBundlesReally(). Since the bundle isn’t found, it checks the WOA for Resources/known_hosts instead.
>>>
>>> Moving the known_hosts up to the app seems to work.
>>>
>>> Is there some proper way to access files in a dependent framework’s Resources, or does this sound strange to the maven people?
>>>
>>> Thanks,
>>>
>>> Ramsey
>>> _______________________________________________
>>> 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



--
Regards,
Nikolay Ilkevich
 _______________________________________________
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

References: 
 >Framework resources folder and Maven (From: Ramsey Gurley <email@hidden>)
 >Re: Framework resources folder and Maven (From: Chuck Hill <email@hidden>)
 >Re: Framework resources folder and Maven (From: Ramsey Gurley <email@hidden>)
 >Re: Framework resources folder and Maven (From: Ramsey Gurley <email@hidden>)

  • Prev by Date: Re: NPE on startup from Mavenized project
  • Next by Date: Re: NPE on startup from Mavenized project
  • Previous by thread: Re: Framework resources folder and Maven
  • Next by thread: You backtracked too far?
  • Index(es):
    • Date
    • Thread