|
View:
New views
13 Messages
—
Rating Filter:
Alert me
|
|
|
Dynamically adding to classpathI'm working on a module for managing Websphere, using Jruby and
Websphere MBeans. It works great, but I've modified jruby.sh to add the (numerous) needed $WAS_HOME/lib jar files to the classpath. I'd prefer to give my module the name of the WAS_HOME/lib directory, and have my module add the needed jars to the load path or classpath programmatically, leaving jruby.sh untouched ( and my command line clean and simple) Possible? Thanks, Chris --------------------------------------------------------------------- To unsubscribe from this list, please visit: http://xircles.codehaus.org/manage_email |
|
|
Re: Dynamically adding to classpathOn Mar 4, 2008, at 8:37 PM, Chris Evans wrote:
> I'm working on a module for managing Websphere, using Jruby and > Websphere MBeans. It works great, but I've modified jruby.sh to add > the (numerous) needed $WAS_HOME/lib jar files to the classpath. > > I'd prefer to give my module the name of the WAS_HOME/lib directory, > and have my module add the needed jars to the load path or classpath > programmatically, leaving jruby.sh untouched ( and my command line > clean and simple) > > Possible? Sure -- try Dir[ENV['WAS_HOME'] + '/lib/*.jar'].each {|jar| require jar} -- assuming WAS_HOME is present in the environment. Cheers, /Nick --------------------------------------------------------------------- To unsubscribe from this list, please visit: http://xircles.codehaus.org/manage_email |
|
|
Re: Dynamically adding to classpathIf I require the jars this way, do I also need to include_class the
classes I need, or will they be available because of the require? Because that would be really cool :) Chris On Tue, Mar 4, 2008 at 11:31 PM, Nick Sieger <nicksieger@...> wrote: > > On Mar 4, 2008, at 8:37 PM, Chris Evans wrote: > > > I'm working on a module for managing Websphere, using Jruby and > > Websphere MBeans. It works great, but I've modified jruby.sh to add > > the (numerous) needed $WAS_HOME/lib jar files to the classpath. > > > > I'd prefer to give my module the name of the WAS_HOME/lib directory, > > and have my module add the needed jars to the load path or classpath > > programmatically, leaving jruby.sh untouched ( and my command line > > clean and simple) > > > > Possible? > > Sure -- try > > Dir[ENV['WAS_HOME'] + '/lib/*.jar'].each {|jar| require jar} > > -- assuming WAS_HOME is present in the environment. > > Cheers, > /Nick > > --------------------------------------------------------------------- > To unsubscribe from this list, please visit: > > http://xircles.codehaus.org/manage_email > > > --------------------------------------------------------------------- To unsubscribe from this list, please visit: http://xircles.codehaus.org/manage_email |
|
|
Re: Dynamically adding to classpathNo, you still need to use "import" or "include_class" unfortunately.
This is just shorthand for making them available on the classpath. /Nick On Mar 5, 2008, at 9:40 AM, Chris Evans wrote: > If I require the jars this way, do I also need to include_class the > classes I need, or will they be available because of the require? > Because that would be really cool :) > > Chris > > On Tue, Mar 4, 2008 at 11:31 PM, Nick Sieger <nicksieger@...> > wrote: >> >> On Mar 4, 2008, at 8:37 PM, Chris Evans wrote: >> >>> I'm working on a module for managing Websphere, using Jruby and >>> Websphere MBeans. It works great, but I've modified jruby.sh to add >>> the (numerous) needed $WAS_HOME/lib jar files to the classpath. >>> >>> I'd prefer to give my module the name of the WAS_HOME/lib directory, >>> and have my module add the needed jars to the load path or classpath >>> programmatically, leaving jruby.sh untouched ( and my command line >>> clean and simple) >>> >>> Possible? >> >> Sure -- try >> >> Dir[ENV['WAS_HOME'] + '/lib/*.jar'].each {|jar| require jar} >> >> -- assuming WAS_HOME is present in the environment. >> >> Cheers, >> /Nick >> >> --------------------------------------------------------------------- >> To unsubscribe from this list, please visit: >> >> http://xircles.codehaus.org/manage_email >> >> >> > > --------------------------------------------------------------------- > To unsubscribe from this list, please visit: > > http://xircles.codehaus.org/manage_email > > --------------------------------------------------------------------- To unsubscribe from this list, please visit: http://xircles.codehaus.org/manage_email |
|
|
Re: Dynamically adding to classpathwell, its still pretty cool :)
On Wed, Mar 5, 2008 at 11:33 AM, Nick Sieger <nicksieger@...> wrote: > No, you still need to use "import" or "include_class" unfortunately. > This is just shorthand for making them available on the classpath. > > /Nick > > > On Mar 5, 2008, at 9:40 AM, Chris Evans wrote: > > > If I require the jars this way, do I also need to include_class the > > classes I need, or will they be available because of the require? > > Because that would be really cool :) > > > > Chris > > > > On Tue, Mar 4, 2008 at 11:31 PM, Nick Sieger <nicksieger@...> > > wrote: > >> > >> On Mar 4, 2008, at 8:37 PM, Chris Evans wrote: > >> > >>> I'm working on a module for managing Websphere, using Jruby and > >>> Websphere MBeans. It works great, but I've modified jruby.sh to add > >>> the (numerous) needed $WAS_HOME/lib jar files to the classpath. > >>> > >>> I'd prefer to give my module the name of the WAS_HOME/lib directory, > >>> and have my module add the needed jars to the load path or classpath > >>> programmatically, leaving jruby.sh untouched ( and my command line > >>> clean and simple) > >>> > >>> Possible? > >> > >> Sure -- try > >> > >> Dir[ENV['WAS_HOME'] + '/lib/*.jar'].each {|jar| require jar} > >> > >> -- assuming WAS_HOME is present in the environment. > >> > >> Cheers, > >> /Nick > >> > >> --------------------------------------------------------------------- > >> To unsubscribe from this list, please visit: > >> > >> http://xircles.codehaus.org/manage_email > >> > >> > >> > > > > --------------------------------------------------------------------- > > To unsubscribe from this list, please visit: > > > > http://xircles.codehaus.org/manage_email > > > > > > > --------------------------------------------------------------------- > To unsubscribe from this list, please visit: > > http://xircles.codehaus.org/manage_email > > > --------------------------------------------------------------------- To unsubscribe from this list, please visit: http://xircles.codehaus.org/manage_email |
|
|
Re: Dynamically adding to classpathYou can also append to the $CLASSPATH global at runtime(unless that's
frowned upon these days). Here's an old post about what we were doing (still more or less the same). http://archive.jruby.codehaus.org/user/B5A15A45-71F7-4432-8F10- C892023A157F%40aps.org Also.. http://wiki.jruby.org/wiki/FAQs#How_come_Java_can. 27t_find_resources_in_class_folders_that_I.27ve_appended_to_the_. 24CLASSPATH_global_variable_at_runtime.3F -lenny On Mar 5, 2008, at 11:39 AM, Chris Evans wrote: > well, its still pretty cool :) > > On Wed, Mar 5, 2008 at 11:33 AM, Nick Sieger <nicksieger@...> > wrote: >> No, you still need to use "import" or "include_class" unfortunately. >> This is just shorthand for making them available on the classpath. >> >> /Nick >> >> >> On Mar 5, 2008, at 9:40 AM, Chris Evans wrote: >> >>> If I require the jars this way, do I also need to include_class the >>> classes I need, or will they be available because of the require? >>> Because that would be really cool :) >>> >>> Chris >>> >>> On Tue, Mar 4, 2008 at 11:31 PM, Nick Sieger <nicksieger@...> >>> wrote: >>>> >>>> On Mar 4, 2008, at 8:37 PM, Chris Evans wrote: >>>> >>>>> I'm working on a module for managing Websphere, using Jruby and >>>>> Websphere MBeans. It works great, but I've modified jruby.sh to >>>>> add >>>>> the (numerous) needed $WAS_HOME/lib jar files to the classpath. >>>>> >>>>> I'd prefer to give my module the name of the WAS_HOME/lib >>>>> directory, >>>>> and have my module add the needed jars to the load path or >>>>> classpath >>>>> programmatically, leaving jruby.sh untouched ( and my command line >>>>> clean and simple) >>>>> >>>>> Possible? >>>> >>>> Sure -- try >>>> >>>> Dir[ENV['WAS_HOME'] + '/lib/*.jar'].each {|jar| require jar} >>>> >>>> -- assuming WAS_HOME is present in the environment. >>>> >>>> Cheers, >>>> /Nick >>>> >>>> ------------------------------------------------------------------- >>>> -- >>>> To unsubscribe from this list, please visit: >>>> >>>> http://xircles.codehaus.org/manage_email >>>> >>>> >>>> >>> >>> -------------------------------------------------------------------- >>> - >>> To unsubscribe from this list, please visit: >>> >>> http://xircles.codehaus.org/manage_email >>> >>> >> >> >> >> --------------------------------------------------------------------- >> To unsubscribe from this list, please visit: >> >> http://xircles.codehaus.org/manage_email >> >> >> > > --------------------------------------------------------------------- > To unsubscribe from this list, please visit: > > http://xircles.codehaus.org/manage_email > > --------------------------------------------------------------------- To unsubscribe from this list, please visit: http://xircles.codehaus.org/manage_email |
|
|
Re: Dynamically adding to classpathFor some reason, neither of these worked for me. My app is making a
SOAP connection to the Websphere server. When I add the websphere jars to the classpath in the jruby executable, it works. If I append the jars in the script, either through $CLASSPATH << or 'require blah.jar', the script fails. It doesn't look like a ClassNotFound error, either, it seems to be loading the classes but the SOAP connection fails. Chris On Wed, Mar 5, 2008 at 3:05 PM, Lenny Marks <lenny@...> wrote: > You can also append to the $CLASSPATH global at runtime(unless that's > frowned upon these days). Here's an old post about what we were doing > (still more or less the same). > > http://archive.jruby.codehaus.org/user/B5A15A45-71F7-4432-8F10- > C892023A157F%40aps.org > > Also.. > > http://wiki.jruby.org/wiki/FAQs#How_come_Java_can. > 27t_find_resources_in_class_folders_that_I.27ve_appended_to_the_. > 24CLASSPATH_global_variable_at_runtime.3F > > -lenny > > > > On Mar 5, 2008, at 11:39 AM, Chris Evans wrote: > > > well, its still pretty cool :) > > > > On Wed, Mar 5, 2008 at 11:33 AM, Nick Sieger <nicksieger@...> > > wrote: > >> No, you still need to use "import" or "include_class" unfortunately. > >> This is just shorthand for making them available on the classpath. > >> > >> /Nick > >> > >> > >> On Mar 5, 2008, at 9:40 AM, Chris Evans wrote: > >> > >>> If I require the jars this way, do I also need to include_class the > >>> classes I need, or will they be available because of the require? > >>> Because that would be really cool :) > >>> > >>> Chris > >>> > >>> On Tue, Mar 4, 2008 at 11:31 PM, Nick Sieger <nicksieger@...> > >>> wrote: > >>>> > >>>> On Mar 4, 2008, at 8:37 PM, Chris Evans wrote: > >>>> > >>>>> I'm working on a module for managing Websphere, using Jruby and > >>>>> Websphere MBeans. It works great, but I've modified jruby.sh to > >>>>> add > >>>>> the (numerous) needed $WAS_HOME/lib jar files to the classpath. > >>>>> > >>>>> I'd prefer to give my module the name of the WAS_HOME/lib > >>>>> directory, > >>>>> and have my module add the needed jars to the load path or > >>>>> classpath > >>>>> programmatically, leaving jruby.sh untouched ( and my command line > >>>>> clean and simple) > >>>>> > >>>>> Possible? > >>>> > >>>> Sure -- try > >>>> > >>>> Dir[ENV['WAS_HOME'] + '/lib/*.jar'].each {|jar| require jar} > >>>> > >>>> -- assuming WAS_HOME is present in the environment. > >>>> > >>>> Cheers, > >>>> /Nick > >>>> > >>>> ------------------------------------------------------------------- > >>>> -- > >>>> To unsubscribe from this list, please visit: > >>>> > >>>> http://xircles.codehaus.org/manage_email > >>>> > >>>> > >>>> > >>> > >>> -------------------------------------------------------------------- > >>> - > >>> To unsubscribe from this list, please visit: > >>> > >>> http://xircles.codehaus.org/manage_email > >>> > >>> > >> > >> > >> > >> --------------------------------------------------------------------- > >> To unsubscribe from this list, please visit: > >> > >> http://xircles.codehaus.org/manage_email > >> > >> > >> > > > > --------------------------------------------------------------------- > > To unsubscribe from this list, please visit: > > > > http://xircles.codehaus.org/manage_email > > > > > > > --------------------------------------------------------------------- > To unsubscribe from this list, please visit: > > http://xircles.codehaus.org/manage_email > > > --------------------------------------------------------------------- To unsubscribe from this list, please visit: http://xircles.codehaus.org/manage_email |
|
|
Re: Dynamically adding to classpathI had run into problems with things loading classes with
Thread.contextClassLoader(see below). Sounds like it could be a similar issue for you. http://www.ruby-forum.com/topic/127354#568081 -lenny On Mar 11, 2008, at 2:18 PM, Chris Evans wrote: > For some reason, neither of these worked for me. My app is making a > SOAP connection to the Websphere server. When I add the websphere > jars to the classpath in the jruby executable, it works. If I append > the jars in the script, either through $CLASSPATH << or 'require > blah.jar', the script fails. It doesn't look like a ClassNotFound > error, either, it seems to be loading the classes but the SOAP > connection fails. > > Chris > > On Wed, Mar 5, 2008 at 3:05 PM, Lenny Marks <lenny@...> wrote: >> You can also append to the $CLASSPATH global at runtime(unless that's >> frowned upon these days). Here's an old post about what we were >> doing >> (still more or less the same). >> >> http://archive.jruby.codehaus.org/user/B5A15A45-71F7-4432-8F10- >> C892023A157F%40aps.org >> >> Also.. >> >> http://wiki.jruby.org/wiki/FAQs#How_come_Java_can. >> 27t_find_resources_in_class_folders_that_I.27ve_appended_to_the_. >> 24CLASSPATH_global_variable_at_runtime.3F >> >> -lenny >> >> >> >> On Mar 5, 2008, at 11:39 AM, Chris Evans wrote: >> >>> well, its still pretty cool :) >>> >>> On Wed, Mar 5, 2008 at 11:33 AM, Nick Sieger <nicksieger@...> >>> wrote: >>>> No, you still need to use "import" or "include_class" >>>> unfortunately. >>>> This is just shorthand for making them available on the classpath. >>>> >>>> /Nick >>>> >>>> >>>> On Mar 5, 2008, at 9:40 AM, Chris Evans wrote: >>>> >>>>> If I require the jars this way, do I also need to include_class >>>>> the >>>>> classes I need, or will they be available because of the require? >>>>> Because that would be really cool :) >>>>> >>>>> Chris >>>>> >>>>> On Tue, Mar 4, 2008 at 11:31 PM, Nick Sieger >>>>> <nicksieger@...> >>>>> wrote: >>>>>> >>>>>> On Mar 4, 2008, at 8:37 PM, Chris Evans wrote: >>>>>> >>>>>>> I'm working on a module for managing Websphere, using Jruby and >>>>>>> Websphere MBeans. It works great, but I've modified jruby.sh to >>>>>>> add >>>>>>> the (numerous) needed $WAS_HOME/lib jar files to the classpath. >>>>>>> >>>>>>> I'd prefer to give my module the name of the WAS_HOME/lib >>>>>>> directory, >>>>>>> and have my module add the needed jars to the load path or >>>>>>> classpath >>>>>>> programmatically, leaving jruby.sh untouched ( and my command >>>>>>> line >>>>>>> clean and simple) >>>>>>> >>>>>>> Possible? >>>>>> >>>>>> Sure -- try >>>>>> >>>>>> Dir[ENV['WAS_HOME'] + '/lib/*.jar'].each {|jar| require jar} >>>>>> >>>>>> -- assuming WAS_HOME is present in the environment. >>>>>> >>>>>> Cheers, >>>>>> /Nick >>>>>> >>>>>> ----------------------------------------------------------------- >>>>>> -- >>>>>> -- >>>>>> To unsubscribe from this list, please visit: >>>>>> >>>>>> http://xircles.codehaus.org/manage_email >>>>>> >>>>>> >>>>>> >>>>> >>>>> ------------------------------------------------------------------ >>>>> -- >>>>> - >>>>> To unsubscribe from this list, please visit: >>>>> >>>>> http://xircles.codehaus.org/manage_email >>>>> >>>>> >>>> >>>> >>>> >>>> ------------------------------------------------------------------- >>>> -- >>>> To unsubscribe from this list, please visit: >>>> >>>> http://xircles.codehaus.org/manage_email >>>> >>>> >>>> >>> >>> -------------------------------------------------------------------- >>> - >>> To unsubscribe from this list, please visit: >>> >>> http://xircles.codehaus.org/manage_email >>> >>> >> >> >> >> --------------------------------------------------------------------- >> To unsubscribe from this list, please visit: >> >> http://xircles.codehaus.org/manage_email >> >> >> > > --------------------------------------------------------------------- > To unsubscribe from this list, please visit: > > http://xircles.codehaus.org/manage_email > > --------------------------------------------------------------------- To unsubscribe from this list, please visit: http://xircles.codehaus.org/manage_email |
|
|
Re: Dynamically adding to classpathI had/have the same issue with a SOAP stub. A workaround that works
for me is to set up classpath via env variable CLASSPATH before JVM starts. e.g. export CLASSPATH=jar1.jar:jar2.jar cheers, Igor On Mar 11, 2008, at 5:56 PM, Lenny Marks wrote: > I had run into problems with things loading classes with > Thread.contextClassLoader(see below). Sounds like it could be a > similar issue for you. > > http://www.ruby-forum.com/topic/127354#568081 > > -lenny > > On Mar 11, 2008, at 2:18 PM, Chris Evans wrote: > >> For some reason, neither of these worked for me. My app is making a >> SOAP connection to the Websphere server. When I add the websphere >> jars to the classpath in the jruby executable, it works. If I append >> the jars in the script, either through $CLASSPATH << or 'require >> blah.jar', the script fails. It doesn't look like a ClassNotFound >> error, either, it seems to be loading the classes but the SOAP >> connection fails. >> >> Chris >> >> On Wed, Mar 5, 2008 at 3:05 PM, Lenny Marks <lenny@...> wrote: >>> You can also append to the $CLASSPATH global at runtime(unless >>> that's >>> frowned upon these days). Here's an old post about what we were >>> doing >>> (still more or less the same). >>> >>> http://archive.jruby.codehaus.org/user/B5A15A45-71F7-4432-8F10- >>> C892023A157F%40aps.org >>> >>> Also.. >>> >>> http://wiki.jruby.org/wiki/FAQs#How_come_Java_can. >>> 27t_find_resources_in_class_folders_that_I.27ve_appended_to_the_. >>> 24CLASSPATH_global_variable_at_runtime.3F >>> >>> -lenny >>> >>> >>> >>> On Mar 5, 2008, at 11:39 AM, Chris Evans wrote: >>> >>>> well, its still pretty cool :) >>>> >>>> On Wed, Mar 5, 2008 at 11:33 AM, Nick Sieger <nicksieger@...> >>>> wrote: >>>>> No, you still need to use "import" or "include_class" >>>>> unfortunately. >>>>> This is just shorthand for making them available on the classpath. >>>>> >>>>> /Nick >>>>> >>>>> >>>>> On Mar 5, 2008, at 9:40 AM, Chris Evans wrote: >>>>> >>>>>> If I require the jars this way, do I also need to include_class >>>>>> the >>>>>> classes I need, or will they be available because of the require? >>>>>> Because that would be really cool :) >>>>>> >>>>>> Chris >>>>>> >>>>>> On Tue, Mar 4, 2008 at 11:31 PM, Nick Sieger <nicksieger@... >>>>>> > >>>>>> wrote: >>>>>>> >>>>>>> On Mar 4, 2008, at 8:37 PM, Chris Evans wrote: >>>>>>> >>>>>>>> I'm working on a module for managing Websphere, using Jruby and >>>>>>>> Websphere MBeans. It works great, but I've modified jruby.sh to >>>>>>>> add >>>>>>>> the (numerous) needed $WAS_HOME/lib jar files to the classpath. >>>>>>>> >>>>>>>> I'd prefer to give my module the name of the WAS_HOME/lib >>>>>>>> directory, >>>>>>>> and have my module add the needed jars to the load path or >>>>>>>> classpath >>>>>>>> programmatically, leaving jruby.sh untouched ( and my command >>>>>>>> line >>>>>>>> clean and simple) >>>>>>>> >>>>>>>> Possible? >>>>>>> >>>>>>> Sure -- try >>>>>>> >>>>>>> Dir[ENV['WAS_HOME'] + '/lib/*.jar'].each {|jar| require jar} >>>>>>> >>>>>>> -- assuming WAS_HOME is present in the environment. >>>>>>> >>>>>>> Cheers, >>>>>>> /Nick >>>>>>> >>>>>>> ------------------------------------------------------------------- >>>>>>> -- >>>>>>> To unsubscribe from this list, please visit: >>>>>>> >>>>>>> http://xircles.codehaus.org/manage_email >>>>>>> >>>>>>> >>>>>>> >>>>>> >>>>>> -------------------------------------------------------------------- >>>>>> - >>>>>> To unsubscribe from this list, please visit: >>>>>> >>>>>> http://xircles.codehaus.org/manage_email >>>>>> >>>>>> >>>>> >>>>> >>>>> >>>>> --------------------------------------------------------------------- >>>>> To unsubscribe from this list, please visit: >>>>> >>>>> http://xircles.codehaus.org/manage_email >>>>> >>>>> >>>>> >>>> >>>> --------------------------------------------------------------------- >>>> To unsubscribe from this list, please visit: >>>> >>>> http://xircles.codehaus.org/manage_email >>>> >>>> >>> >>> >>> --------------------------------------------------------------------- >>> To unsubscribe from this list, please visit: >>> >>> http://xircles.codehaus.org/manage_email >>> >>> >>> >> >> --------------------------------------------------------------------- >> To unsubscribe from this list, please visit: >> >> http://xircles.codehaus.org/manage_email >> >> > > > --------------------------------------------------------------------- > To unsubscribe from this list, please visit: > > http://xircles.codehaus.org/manage_email > > --------------------------------------------------------------------- To unsubscribe from this list, please visit: http://xircles.codehaus.org/manage_email |
|
|
Re: Dynamically adding to classpathBless you Lenny - you've just told me why I'm getting my error. Did you find out "is there a reason why JRuby doesn't set the current Java thread's contextClassLoader to the JRubyClassLoader?" Is it a bug or by design? On Mar 11, 2008, at 5:56 PM, Lenny Marks wrote: > I had run into problems with things loading classes with > Thread.contextClassLoader(see below). Sounds like it could be a > similar issue for you. > > http://www.ruby-forum.com/topic/127354#568081 > > -lenny > -- View this message in context: http://www.nabble.com/Dynamically-adding-to-classpath-tp15841856p16048163.html Sent from the JRuby - User mailing list archive at Nabble.com. --------------------------------------------------------------------- To unsubscribe from this list, please visit: http://xircles.codehaus.org/manage_email |
|
|
|
|
|
|
|
|
Re: Dynamically adding to classpathAt 6:15 PM -0400 3/17/08, Lenny Marks wrote:
>On Mar 14, 2008, at 10:54 AM, bemmi wrote: > >> >>Bless you Lenny - you've just told me why I'm getting my error. >>Did you find >>out "is there a reason why JRuby doesn't set the current Java thread's >>contextClassLoader to the JRubyClassLoader?" Is it a bug or by design? > >I never found out. In my case we deploy to a servlet container in production. Everything is loaded by the web app classloader there so technically I only have to manually set the Thread.contextClassLoader in development. I haven't run into any problems yet, but I imagine it could cause ClassNotFound/ClassCastExteption type problems if a class that was loaded before the switch tries to load additional resources or pass around references to pre-switch stuff after the switch. Anyone else have any input on this? > >-lenny FYI: I just created a Jira issue for this with a simple test case. http://jira.codehaus.org/browse/JRUBY-2495 Requiring and using a Java library that ends up using a Thread Context classloader doesn't work --------------------------------------------------------------------- To unsubscribe from this list, please visit: http://xircles.codehaus.org/manage_email |
| Free Forum Powered by Nabble | Forum Help |