I am trying to compile jar for selenium webdriver program #107

Open
navneetkapur opened this Issue Aug 3, 2012 · 6 comments

Comments

Projects
None yet
4 participants
@navneetkapur

navneetkapur commented Aug 3, 2012

the jar file is created but on running the jar created in jruby i get the following error on execute

require "selenium-webdriver"
proxy = Selenium::WebDriver::Proxy.new(:http => ENV['HTTP_PROXY'] || ENV['http_proxy'])
ENV['HTTP_PROXY'] = ENV['http_proxy'] = nil
browser = Selenium::WebDriver.for :firefox , :proxy => proxy
browser.manage.timeouts.implicit_wait = 60
browser.navigate.to "http://www.google.com"


NoMethodError: undefined method `bytesize' for nil:NilClass
read_c_dir_entry at file:C:/loader.jar!/gems/rubyzip-0.9.9/lib/z
ip/zip_entry.rb:302
read_c_dir_entry at file:C:/loader.jar!/gems/rubyzip-0.9.9/lib/z
ip/zip_entry.rb:213
read_central_directory_entries at file:C:/loader.jar!/gems/rubyzip-0.9.9/lib/z
ip/zip_central_directory.rb:79
times at org/jruby/RubyFixnum.java:252
read_central_directory_entries at file:C:/loader.jar!/gems/rubyzip-0.9.9/lib/z
ip/zip_central_directory.rb:78
read_from_stream at file:C:/loader.jar!/gems/rubyzip-0.9.9/lib/z
ip/zip_central_directory.rb:86
initialize at file:C:/loader.jar!/gems/rubyzip-0.9.9/lib/z
ip/zip_file.rb:67
open at org/jruby/RubyIO.java:1139
initialize at file:C:/loader.jar!/gems/rubyzip-0.9.9/lib/z
ip/zip_file.rb:66
open at file:C:/loader.jar!/gems/rubyzip-0.9.9/lib/z
ip/zip_file.rb:87
unzip at file:C:/loader.jar!/gems/selenium-webdriver-
2.25.0/lib/selenium/webdriver/common/zipper.rb:21
create_root at file:C:/loader.jar!/gems/selenium-webdriver-
2.25.0/lib/selenium/webdriver/firefox/extension.rb:38
write_to at file:C:/loader.jar!/gems/selenium-webdriver-
2.25.0/lib/selenium/webdriver/firefox/extension.rb:17
install_extensions at file:C:/loader.jar!/gems/selenium-webdriver-
2.25.0/lib/selenium/webdriver/firefox/profile.rb:193
each at org/jruby/RubyHash.java:1181
install_extensions at file:C:/loader.jar!/gems/selenium-webdriver-
2.25.0/lib/selenium/webdriver/firefox/profile.rb:191
layout_on_disk at file:C:/loader.jar!/gems/selenium-webdriver-
2.25.0/lib/selenium/webdriver/firefox/profile.rb:76
create_profile at file:C:/loader.jar!/gems/selenium-webdriver-
2.25.0/lib/selenium/webdriver/firefox/launcher.rb:58
launch at file:C:/loader.jar!/gems/selenium-webdriver-
2.25.0/lib/selenium/webdriver/firefox/launcher.rb:34
locked at file:C:/loader.jar!/gems/selenium-webdriver-
2.25.0/lib/selenium/webdriver/firefox/socket_lock.rb:20
launch at file:C:/loader.jar!/gems/selenium-webdriver-
2.25.0/lib/selenium/webdriver/firefox/launcher.rb:32
initialize at file:C:/loader.jar!/gems/selenium-webdriver-
2.25.0/lib/selenium/webdriver/firefox/bridge.rb:20
for at file:C:/loader.jar!/gems/selenium-webdriver-
2.25.0/lib/selenium/webdriver/common/driver.rb:31
for at file:C:/loader.jar!/gems/selenium-webdriver-
2.25.0/lib/selenium/webdriver.rb:65
(root) at ./execute.rb:4
load at org/jruby/RubyKernel.java:1058
(root) at ./bin/loader.rb:1
load at org/jruby/RubyKernel.java:1058
(root) at ./execute.rb:1
require at org/jruby/RubyKernel.java:1033
require at file:/C:/loader.jar!/META-INF/main.rb:36
(root) at <script>:3


Want to back this issue? Post a bounty on it! We accept bounties via Bountysource.

@gottlike

This comment has been minimized.

Show comment Hide comment
@gottlike

gottlike Aug 7, 2012

I was able to run a compiled jar if I set the ruby version to jruby via RVM. But I don't know why things are behaving that way.. The same issue was discussed for a bit in this thread: http://code.google.com/p/selenium/issues/detail?id=2940 . Apparently it's an issue with jruby or warbler..

gottlike commented Aug 7, 2012

I was able to run a compiled jar if I set the ruby version to jruby via RVM. But I don't know why things are behaving that way.. The same issue was discussed for a bit in this thread: http://code.google.com/p/selenium/issues/detail?id=2940 . Apparently it's an issue with jruby or warbler..

@navneetkapur

This comment has been minimized.

Show comment Hide comment
@navneetkapur

navneetkapur Aug 7, 2012

it seems that its a rubyzip issue....

it seems that its a rubyzip issue....

@nagarajan-ganesan

This comment has been minimized.

Show comment Hide comment
@nagarajan-ganesan

nagarajan-ganesan Sep 7, 2012

any update on this issue?

any update on this issue?

@nagarajan-ganesan

This comment has been minimized.

Show comment Hide comment
@nagarajan-ganesan

nagarajan-ganesan Sep 7, 2012

how to fix it? am using Windows7 machine

undefined method `bytesize' for nil:NilClass (NoMethodError)
org/jruby/RubyFixnum.java:252:in `times'
org/jruby/RubyIO.java:1139:in `open'
org/jruby/RubyHash.java:1181:in `each'

how to fix it? am using Windows7 machine

undefined method `bytesize' for nil:NilClass (NoMethodError)
org/jruby/RubyFixnum.java:252:in `times'
org/jruby/RubyIO.java:1139:in `open'
org/jruby/RubyHash.java:1181:in `each'
@fcruxen

This comment has been minimized.

Show comment Hide comment
@fcruxen

fcruxen Dec 1, 2014

+1

have the same problem, when running via jruby it works, the JAR works in my mac notebook, but not in the linux server (centOS 7), same error as above.

fcruxen commented Dec 1, 2014

+1

have the same problem, when running via jruby it works, the JAR works in my mac notebook, but not in the linux server (centOS 7), same error as above.

@fcruxen

This comment has been minimized.

Show comment Hide comment
@fcruxen

fcruxen Dec 3, 2014

I've checked this yesterday, and that's what I could understand:

  1. the zipper method in firefox lib is expecting a file, and gets a stream, in the jar the file is not decompressed into the filesystem as the war does (not a java programmer, so forgive any wrong assumptions).

  2. The error occurs when trying to fetch webdriver.xpi to create a default profile. I did not spent too much time on the selenium classes, but my monkey patch was to change the constant in firefox lib ( WEBDRIVER_EXTENSION_PATH in firefox/profile.rb ) to point to some place outside the jar path (that java recognizes as ClassName.jar!/gems/something), like in the same folder as the jar lives.

  3. Without selenium that happens, using just rubyzip to unzip a file but sending a stream.

Hope that helps, thanks.

fcruxen commented Dec 3, 2014

I've checked this yesterday, and that's what I could understand:

  1. the zipper method in firefox lib is expecting a file, and gets a stream, in the jar the file is not decompressed into the filesystem as the war does (not a java programmer, so forgive any wrong assumptions).

  2. The error occurs when trying to fetch webdriver.xpi to create a default profile. I did not spent too much time on the selenium classes, but my monkey patch was to change the constant in firefox lib ( WEBDRIVER_EXTENSION_PATH in firefox/profile.rb ) to point to some place outside the jar path (that java recognizes as ClassName.jar!/gems/something), like in the same folder as the jar lives.

  3. Without selenium that happens, using just rubyzip to unzip a file but sending a stream.

Hope that helps, thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment