cheald / manticore

Manticore is a JRuby HTTP client built on the Apache HttpClient 4.x components
https://gitlab.com/cheald/manticore
MIT License
54 stars 34 forks source link

Getting error SSLConnectionSocketFactory not found in packages ? #87

Closed shubhamjaincav closed 2 years ago

shubhamjaincav commented 4 years ago

NameError: SSLConnectionSocketFactory not found in packages org.apache.http.client.methods, org.apache.http.client.entity, org.apache.http.client.config, org.apache.http.config, org.apache.http.conn.socket, org.apache.http.impl, org.apache.http.impl.client, org.apache.http.impl.conn, org.apache.http.impl.auth, org.apache.http.entity, org.apache.http.message, org.apache.http.params, org.apache.http.protocol, org.apache.http.auth, java.util.concurrent, org.apache.http.client.protocol, org.apache.http.conn.ssl, java.security.cert, java.security.spec, java.security, org.apache.http.client.utils; last error: cannot load Java class org.apache.http.client.utils.SSLConnectionSocketFactory>, :backtrace=>["uri:classloader:/jruby/java/core_ext/module.rb:45:in `const_missing'"

vendor/bundle/jruby/2.5.0/gems/manticore-0.6.4-java/lib/manticore/client.rb:606:in `ssl_socket_factory_from_options'

shubhamjaincav commented 4 years ago

any update

cheald commented 4 years ago

Can you provide a reproduction case?

kares commented 3 years ago

weird issue, haven't really tackled into why this happens but smt seems wrong at JRuby's, given:

#<NameError: SSLConnectionSocketFactory not found in packages 
org.apache.http.client.methods, 
org.apache.http.client.entity, 
org.apache.http.client.cooptionig, 
org.apache.http.cooptionig, 
org.apache.http.conn.socket, 
org.apache.http.impl, 
org.apache.http.impl.client, 
org.apache.http.impl.conn, 
org.apache.http.impl.auth, 
org.apache.http.entity, 
org.apache.http.message, 
org.apache.http.params, 
org.apache.http.protocol, 
org.apache.http.auth, 
java.util.concurrent, 
org.apache.http.client.protocol, 
org.apache.http.conn.ssl, 
java.security.cert, 
java.security.spec, 
java.security, 
org.apache.http.client.utils; 

last error: cannot load Java class org.apache.http.client.utils.SSLConnectionSocketFactory>,

clearly tried loading org.apache.http.conn.ssl.SSLConnectionSocketFactory but got a NameError

The problem with the include_package trick JRuby uses is that it tries all the packages rescue-ing NameError. But the underlying code puts more than just a ClassNotFoundException into a NameError. A way to observer what's going on underneath would be to run with -Xlog.exceptions -Xlog.backtraces.

Never really liked how include_package works as it feels like a :hammer: (catching 2 exceptions per included package) and I wanted to improve this for a while, hopefully a rewrite to native would make it to JRuby 9.3. In the mean-time it might be best to directly java_import classes esp. ones that are on the hot-path or there's only one name used from a given package ...

olleolleolle commented 3 years ago

@kares Awesome digging! Thanks for the detailed rundown.

If you have even a patchy patch, like explicitly including some require, in order to avoid this situation, please make a PR and I'll review it right away.

kares commented 3 years ago

Thanks Olle, reviewed a few imports and came up with: https://github.com/cheald/manticore/pull/90 would be great if you could review.

olleolleolle commented 3 years ago

@kares Alright! Thanks again for taking on these changes!

olleolleolle commented 3 years ago

@shubhamjaincav Does this change fix your situation?

If you can try the latest commits, does that work?

In the project's Gemfile:

gem "manticore", github: "cheald/manticore"
kares commented 2 years ago

going to optimistically close this one - let's see if it still pops up. should be a JRuby issue anyway.