loading a gem (hpricot) which requires a jar not working in webstart with 
jrubygems
-----------------------------------------------------------------------------------

                 Key: JRUBY-2034
                 URL: http://jira.codehaus.org/browse/JRUBY-2034
             Project: JRuby
          Issue Type: Bug
          Components: Miscellaneous
    Affects Versions: JRuby 1.1
         Environment: MacOS 10.4.11, Java 1.5.0_13, JRuby trunk rev 5716
            Reporter: Stephen Bannasch
            Priority: Critical


I've got a patched trunk version of jrubygems working with webstart and I can 
use a simple gem like uuidtools but I hpricot throws an error when hpricot.rb 
executes this statement:

{code}
require 'hpricot_scan'
{code}

Which when run in JRuby actually requires this:

{code}
require 'universal-java1.5/hpricot_scan.jar'
{code}

Nick Seiger commented:
bq. The hpricot gem metadata adds the universal-java1.5 directory to the load 
path, so JRuby is just translating "require 'hpricot_scan'" into a request to 
load up hpricot_scan.jar and look for a class called HpricotScanService. Looks 
like that (loading additional jars in a new classloader) isn't working under 
web start?

Here's the stack trace:

{code}
Installing gem from Java classpath 
jar:file:/Users/stephen/Library/Caches/Java/cache/javaws/file/D/P-1/signed-jars/RMgems.jar!/gems/hpricot-0.6.159-jruby.gem
 to /Users/stephen/.jruby/lib/ruby/gems/1.8.
=> true
irb(main):006:0> require 'hpricot'
LoadError: IO error -- hpricot_scan
        from 
/Users/stephen/.jruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:in 
`require'
        from 
/Users/stephen/.jruby/lib/ruby/gems/1.8/gems/hpricot-0.6.159-java/lib/hpricot.rb:20
        from 
/Users/stephen/.jruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:in 
`require'
        from 
/Users/stephen/.jruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:in 
`require'
        from (irb):7:in `signal_status'
{code}

I'm using Alon Salont's trunk release of jrubygems:

  http://www.carbonfive.com/community/archives/2008/01/jrubygems_relea_1.html

to deliver a set of gems to my jruby web start program.

His code needed this patch to work with web start:

{code}
Index: ruby/lib/jrubygems.rb
===================================================================
--- ruby/lib/jrubygems.rb       (revision 295)
+++ ruby/lib/jrubygems.rb       (working copy)
@@ -90,7 +90,7 @@
       FileUtils.mkdir_p gem_dir
 
       installer = Gem::Installer.new(gem_source.absolute_path)
-      installer.install(true, @install_dir)
+      installer.install
       Gem.source_index.refresh!
     end
{code}

I'm also using hpricot from svn trunk and need to apply this patch to get 
hpricot to work at all in jruby:

* http://caldersphere.net/hpricot-0.6.157-jruby-trunk.patch

See:

* http://code.whytheluckystiff.net/hpricot/ticket/131
* http://jira.codehaus.org/browse/JRUBY-2008

The jnlp is very similar to samples/jirb except that the jars are signed and 
have been copied to a child directory of where the jnlpfile is stored. Here's 
what the jnlp file looks like:

{code}
<?xml version="1.0" encoding="UTF-8"?>
<jnlp spec="1.0+" codebase="file:.">

  <!-- Create a signed version of jruby-complete.jar and 
  place a copy in the same directory as this program.
  Test this program: javaws signed_jirb.jnlp -->

  <information>
    <title>JRuby IRB Console</title>
    <vendor>The JRuby Team</vendor>
    <description>Sample WebStart Application with JRuby</description>
    <description kind="short">JRuby IRB Console Sample</description>
    <homepage href="http://jruby.codehaus.org/"/>
    <offline-allowed/>
  </information>
  <security>
    <all-permissions/>
  </security>
  <resources>
    <j2se version="1.5+"/>
    <jar href="signed-jars/jruby-complete.jar" download="eager" main="false"/>
    <jar href="signed-jars/jrubygems-0.3-SNAPSHOT.jar" download="eager" 
main="false"/>
    <jar href="signed-jars/gems.jar" download="eager" main="false"/>
  </resources>

  <application-desc main-class="org.jruby.demo.IRBConsole">
  </application-desc>
</jnlp>
{code}

Using the uuid gem works:

{code}
require 'jrubygems'
gem 'uuidtools'
require 'uuidtools'
UUID.timestamp_create().to_s
=> "4c3f3990-cb01-11dc-b730-001b631eb2da"
{code}



-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: 
http://jira.codehaus.org/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

---------------------------------------------------------------------
To unsubscribe from this list please visit:

    http://xircles.codehaus.org/manage_email

Reply via email to