Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

trouble loading java class from jar #840

Closed
homanchou opened this issue Jul 1, 2013 · 4 comments
Closed

trouble loading java class from jar #840

homanchou opened this issue Jul 1, 2013 · 4 comments

Comments

@homanchou
Copy link

I'm having trouble wrapping the amazon-merchant-web-service-java-sdk in jruby.

The java sdk, jar and source, can be found at: https://developer.amazonservices.com/doc/bde/feeds/v20090901/java.html/182-0022359-5036344 (click the yellow download button in upper right)

I am able to instantiate some classes ....

require 'java'
require 'lib/MaWSJavaClientLibrary-1.1.jar'

module MWS
  include_package 'com.amazonaws.mws'
  include_package 'com.amazonaws.mws.model'
end

config = MWS::MarketplaceWebServiceConfig.new  #this works!!

... but not others

client = MWS::MarketplaceWebServiceClient.new  #this does NOT work!!!
NameError: MarketplaceWebServiceClient not found in packages com.amazonaws.mws, com.amazonaws.mws.model; last error: cannot load Java class com.amazonaws.mws.model.MarketplaceWebServiceClient
const_missing at file:/Users/...

Why is it not found?

@BanzaiMan
Copy link
Member

It seems that MarketplaceWebServiceClient does not have a no-arg constructor.

If you try to use an existing one, you get a different error:

irb(main):006:0> MWS::MarketplaceWebServiceConfig.new
=> #<Java::ComAmazonawsMws::MarketplaceWebServiceConfig:0x5ab9f791>
irb(main):007:0> x=_
=> #<Java::ComAmazonawsMws::MarketplaceWebServiceConfig:0x5ab9f791>
irb(main):008:0> MWS::MarketplaceWebServiceClient.new('','','','',x)
NameError: MarketplaceWebServiceClient not found in packages com.amazonaws.mws; last error: cannot link Java class com.amazonaws.mws.MarketplaceWebServiceClient, probable missing dependency: org/apache/http/HttpEntity

You'll need to get the necessary apache libraries, load them, etc., and go from there.

I don't think this is a JRuby bug.

@BanzaiMan BanzaiMan reopened this Jul 1, 2013
@BanzaiMan
Copy link
Member

Actually there is an opportunity to provide a better error message.

@homanchou
Copy link
Author

Also, at first I thought the issue was related to MarketplaceWebServiceClient being an implementation of an interface, and by accident, I found I was able to instantiate the Java interface using MWS::MarketplaceWebService.new, which I shouldn't be able to do (but perhaps that is a topic for a different ticket?).

@enebo enebo modified the milestone: JRuby 9.0.0.0 Jul 14, 2015
@kares
Copy link
Member

kares commented Aug 23, 2015

original issue is fine and the error message is improved, opened a new one for iface.new at #3275

@kares kares closed this as completed Aug 23, 2015
@kares kares added this to the Invalid or Duplicate milestone Aug 23, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants