JRE classes services from netbeans modules (NB6.1)

View: New views
8 Messages — Rating Filter:   Alert me  

JRE classes services from netbeans modules (NB6.1)

by pblemel :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


Hello World,

I have a jar that provides services for javax.sound (via META-INF/services).  A little example main program (not in the jar file) invokes javax.sound classes that use the services.   Compiling the example with javac and running java from the command line works great.  The javax.sound classes use the services from the jar file.

I created a wrapper module for the jar and put an action in a module to invoke the example.   It compiles just fine, but when it runs the javax.sound classes do not find / use the services from the wrapped jar file.

Is there an extra step that must be done so that the JRE will use the services for JRE distribution classes like javax.sound?
 
Thanks
Peter


_________________________________________________________________
Make Windows Vista more reliable and secure with Windows Vista Service Pack 1.
http://www.windowsvista.com/SP1?WT.mc_id=hotmailvistasp1banner

Parent Message unknown Re: JRE classes services from netbeans modules (NB6.1)

by Jesse Glick :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Peter Blemel wrote:

> I have a jar that provides services for javax.sound (via
> META-INF/services). A little example main program (not in the jar
> file) invokes javax.sound classes that use the services.   Compiling
> the example with javac and running java from the command line works
> great.  The javax.sound classes use the services from the jar file.
>
> I created a wrapper module for the jar and put an action in a module
> to invoke the example.   It compiles just fine, but when it runs the
> javax.sound classes do not find / use the services from the wrapped
> jar file.

Perhaps the JavaSound impl looks for services only in the system class
loader.


RE: Re: JRE classes services from netbeans modules (NB6.1)

by pblemel :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


Hi,

It's not clear what this means to me.   Is there a way to configure the module such that it is seen by the system class loader without resorting to adding it to the class path?  

Thanks
Peter
----------------------------------------

> To: dev@...
> From: jesse.glick@...
> Date: Mon, 12 May 2008 19:18:03 -0700
> Subject: [openide-dev]  Re: JRE classes services from netbeans modules (NB6.1)
>
> Peter Blemel wrote:
>> I have a jar that provides services for javax.sound (via
>> META-INF/services). A little example main program (not in the jar
>> file) invokes javax.sound classes that use the services.   Compiling
>> the example with javac and running java from the command line works
>> great.  The javax.sound classes use the services from the jar file.
>>
>> I created a wrapper module for the jar and put an action in a module
>> to invoke the example.   It compiles just fine, but when it runs the
>> javax.sound classes do not find / use the services from the wrapped
>> jar file.
>
> Perhaps the JavaSound impl looks for services only in the system class
> loader.
>

_________________________________________________________________
Windows Live SkyDrive lets you share files with faraway friends.
http://www.windowslive.com/skydrive/overview.html?ocid=TXT_TAGLM_WL_Refresh_skydrive_052008

Re: Re: JRE classes services from netbeans modules (NB6.1)

by Victor Borda :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Peter,

Interesting - you appear to be having the exact same problem as me (just sent an email to the list earlier today about it). It's just that in my case I am needing charsets that an included jar file is making the JVM aware of via a different entry under that jar's services directory.

Jesse's remark is right on target I believe, in that the jar you are using is expecting info contained in that services directory to still be accessed and relevant when the jar file is used in a netbeans app. However, entries in the services directory are found via the classLoader the current thread is using and when you use a NB suite app, that classLoader becomes seriously different. And, you found the same thing I did, which is that adding that jar as a wrapped module does not seem to correctly load into the jvm the entries from the "services directory.

Jesse, please assume this is the case for Peter's javax example, do you have solution for those cases where:

a) a third party jar file is to be included and used by a netbeans module suite app
b) that third party relies on entries in the META-INF/services directory to be set for the jar to operate correctly
c) sample apps with non-NB affected classLoaders work fine with the jar
d) when used in a NB project where the classLoader has been changed, the jar breaks

Do you have a solution for getting this type of situation to work correctly?

Best,
Victor


On Tue, May 13, 2008 at 9:18 PM, Peter Blemel <pblemel@...> wrote:

Hi,

It's not clear what this means to me.   Is there a way to configure the module such that it is seen by the system class loader without resorting to adding it to the class path?

Thanks
Peter
----------------------------------------
> To: dev@...
> From: jesse.glick@...
> Date: Mon, 12 May 2008 19:18:03 -0700
> Subject: [openide-dev]  Re: JRE classes services from netbeans modules (NB6.1)
>
> Peter Blemel wrote:
>> I have a jar that provides services for javax.sound (via
>> META-INF/services). A little example main program (not in the jar
>> file) invokes javax.sound classes that use the services.   Compiling
>> the example with javac and running java from the command line works
>> great.  The javax.sound classes use the services from the jar file.
>>
>> I created a wrapper module for the jar and put an action in a module
>> to invoke the example.   It compiles just fine, but when it runs the
>> javax.sound classes do not find / use the services from the wrapped
>> jar file.
>
> Perhaps the JavaSound impl looks for services only in the system class
> loader.
>

_________________________________________________________________
Windows Live SkyDrive lets you share files with faraway friends.
http://www.windowslive.com/skydrive/overview.html?ocid=TXT_TAGLM_WL_Refresh_skydrive_052008


Re: Re: JRE classes services from netbeans modules (NB6.1)

by Victor Borda :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Peter,

I may have an answer for you. At least it has apparently worked for my situation. Search the mailing list archives for an email with subject "NetBeans and CLASSPATH" from 2006. Someone asked a very similar question, but the thing is, unless you know exactly what to search for, you would never find it. The quick answer in my case as gleaned from that email chain has been to drop the jar file into jre{version_num}/lib/ext

Best,
Victor


On Tue, May 13, 2008 at 10:14 PM, Victor Borda <jaguardreams@...> wrote:
Peter,

Interesting - you appear to be having the exact same problem as me (just sent an email to the list earlier today about it). It's just that in my case I am needing charsets that an included jar file is making the JVM aware of via a different entry under that jar's services directory.

Jesse's remark is right on target I believe, in that the jar you are using is expecting info contained in that services directory to still be accessed and relevant when the jar file is used in a netbeans app. However, entries in the services directory are found via the classLoader the current thread is using and when you use a NB suite app, that classLoader becomes seriously different. And, you found the same thing I did, which is that adding that jar as a wrapped module does not seem to correctly load into the jvm the entries from the "services directory.

Jesse, please assume this is the case for Peter's javax example, do you have solution for those cases where:

a) a third party jar file is to be included and used by a netbeans module suite app
b) that third party relies on entries in the META-INF/services directory to be set for the jar to operate correctly
c) sample apps with non-NB affected classLoaders work fine with the jar
d) when used in a NB project where the classLoader has been changed, the jar breaks

Do you have a solution for getting this type of situation to work correctly?

Best,
Victor



On Tue, May 13, 2008 at 9:18 PM, Peter Blemel <pblemel@...> wrote:

Hi,

It's not clear what this means to me.   Is there a way to configure the module such that it is seen by the system class loader without resorting to adding it to the class path?

Thanks
Peter
----------------------------------------
> To: dev@...
> From: jesse.glick@...
> Date: Mon, 12 May 2008 19:18:03 -0700
> Subject: [openide-dev]  Re: JRE classes services from netbeans modules (NB6.1)
>
> Peter Blemel wrote:
>> I have a jar that provides services for javax.sound (via
>> META-INF/services). A little example main program (not in the jar
>> file) invokes javax.sound classes that use the services.   Compiling
>> the example with javac and running java from the command line works
>> great.  The javax.sound classes use the services from the jar file.
>>
>> I created a wrapper module for the jar and put an action in a module
>> to invoke the example.   It compiles just fine, but when it runs the
>> javax.sound classes do not find / use the services from the wrapped
>> jar file.
>
> Perhaps the JavaSound impl looks for services only in the system class
> loader.
>

_________________________________________________________________
Windows Live SkyDrive lets you share files with faraway friends.
http://www.windowslive.com/skydrive/overview.html?ocid=TXT_TAGLM_WL_Refresh_skydrive_052008



RE: Re: JRE classes services from netbeans modules (NB6.1)

by pblemel :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message



Thanks Victor,

It's not me that I'm worried about.  I wanted users of my application to be able to grab this wrapped module via update center, which is quick and clean.  Asking them to find their JRE (assuming they have just one ;-) and copy files there is, for lack of a better word, a kludge.  There must be a better way.  

Thanks
Peter

________________________________

> Date: Wed, 14 May 2008 10:23:15 -0700
> From: jaguardreams@...
> To: dev@...
> Subject: Re: [openide-dev] Re: JRE classes services from netbeans modules (NB6.1)
>
> Peter,
>
> I may have an answer for you. At least it has apparently worked for my situation. Search the mailing list archives for an email with subject "NetBeans and CLASSPATH" from 2006. Someone asked a very similar question, but the thing is, unless you know exactly what to search for, you would never find it. The quick answer in my case as gleaned from that email chain has been to drop the jar file into jre{version_num}/lib/ext
>
> Best,
> Victor
>
>
> On Tue, May 13, 2008 at 10:14 PM, Victor Borda
_________________________________________________________________
Stay in touch when you're away with Windows Live Messenger.
http://www.windowslive.com/messenger/overview.html?ocid=TXT_TAGLM_WL_Refresh_messenger_052008

RE: Re: JRE classes services from netbeans modules (NB6.1)

by Wade Chandler :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

--- Peter Blemel <pblemel@...> wrote:
> It's not me that I'm worried about.  I wanted users of my application to be able to grab this
> wrapped module via update center, which is quick and clean.  Asking them to find their JRE
> (assuming they have just one ;-) and copy files there is, for lack of a better word, a kludge.
> There must be a better way.  
>

This may help:
http://wadechandler.blogspot.com/2007/07/sharing-classes-with-modules-and-non.html

That will put the classes in the main loader. You might want to try it out. You have to have a
custom platform setup as I'm not sure how you can get a plain module to install anything
there...if it did it would have to restart NB. Note that a custom platform can be a complete copy
of the IDE with some extra libraries installed. Anyways, if you are developing an RCP application
this isn't so hard, but for a NetBeans module it might be harder. This might be a good RFE to
have the system allow a module to have some of its JAR files added to the main
application/startup libraries.

Wade


==================
Wade Chandler, CCE
Software Engineer and Developer, Certified Forensic Computer Examiner, NetBeans Dream Team Member, and NetBeans Board Member
http://www.certified-computer-examiner.com
http://wiki.netbeans.org/wiki/view/NetBeansDreamTeam
http://www.netbeans.org

RE: Re: JRE classes services from netbeans modules (NB6.1)

by pblemel :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


Thanks Wade,

While technically adequate, I am not sure that this helps me.  Fundamentally I have what you are suggesting (this is an RCP application).  The problem lies in the jar in question's license.  None of my modules use it directly so I don't have any compelling reason to bundle it anyway.

It is up to the end user to accept the jar's license if they want to use the services and add it to the application.  It seemed like adding a wrapped jar from an update center or nbm to install it would be ideal.  I am getting the impression that Netbeans wasn't designed to let the user add services this way.  Unfortunately this means writing an installer and/or instructions for multiple platforms.

Regards,
Peter

----------------------------------------

> Date: Thu, 15 May 2008 09:38:58 -0700
> From: hwadechandler-nb@...
> To: dev@...
> Subject: RE: [openide-dev] Re: JRE classes services from netbeans modules (NB6.1)
>
> --- Peter Blemel  wrote:
>> It's not me that I'm worried about.  I wanted users of my application to be able to grab this
>> wrapped module via update center, which is quick and clean.  Asking them to find their JRE
>> (assuming they have just one ;-) and copy files there is, for lack of a better word, a kludge.
>> There must be a better way.  
>>
>
> This may help:
> http://wadechandler.blogspot.com/2007/07/sharing-classes-with-modules-and-non.html
>
> That will put the classes in the main loader. You might want to try it out. You have to have a
> custom platform setup as I'm not sure how you can get a plain module to install anything
> there...if it did it would have to restart NB. Note that a custom platform can be a complete copy
> of the IDE with some extra libraries installed. Anyways, if you are developing an RCP application
> this isn't so hard, but for a NetBeans module it might be harder. This might be a good RFE to
> have the system allow a module to have some of its JAR files added to the main
> application/startup libraries.
>
> Wade
>
>
> ==================
> Wade Chandler, CCE
> Software Engineer and Developer, Certified Forensic Computer Examiner, NetBeans Dream Team Member, and NetBeans Board Member
> http://www.certified-computer-examiner.com
> http://wiki.netbeans.org/wiki/view/NetBeansDreamTeam
> http://www.netbeans.org

_________________________________________________________________
Stay in touch when you're away with Windows Live Messenger.
http://www.windowslive.com/messenger/overview.html?ocid=TXT_TAGLM_WL_Refresh_messenger_052008