Skip to content

Conversation

@wiibaa
Copy link
Contributor

@wiibaa wiibaa commented Apr 24, 2014

Building on top of good work of @colinsurprenant in #1233,
logstash can now almost propose a common solution for loading jars present under vendor/jar
I'm working on jdbc related plugin (input/filter) and this patch would permit me to load the required jar in one line in the register method like:

def register LogStash::Environment.load_jars!(@driver_jar) #Cannot use driver manager (https://jira.codehaus.org/browse/JRUBY-7174) @driver = Java::JavaClass.for_name(@driver_class).ruby_class.new end 
@colinsurprenant
Copy link
Contributor

@wiibaa thanks for your contribution. I really like the idea, let me think about it a little bit - in particular I'd like to open the discussion on more generally on dependencies management (for 3rd party jars).

@colinsurprenant colinsurprenant self-assigned this May 7, 2014
@colinsurprenant colinsurprenant added this to the triage milestone May 7, 2014
@elasticsearch-release
Copy link

Can one of the admins verify this patch?

@wiibaa
Copy link
Contributor Author

wiibaa commented Oct 9, 2014

@colinsurprenant I rebased this PR in case you can have a look to get it merged ;)

I suppose the main use case for 3rd party dependencies will soon be resolved by the pluginmanager however my specific use case is to load jdbc drivers or any jar that copyright licencing restrict you from packaging them directly in your own plugin

@electrical
Copy link

This feature should not be needed anymore ( in theory ) since all plugins will take care of their own java dependencies with the new plugin structure.
Or are there still use cases for this?

@wiibaa
Copy link
Contributor Author

wiibaa commented Oct 9, 2014

@electrical as mentioned Ithink it is still required for oracle jdbc due to binary license that avoid it to be present in public maven repository, see http://stackoverflow.com/questions/1074869/find-oracle-jdbc-driver-in-maven-repository

@wiibaa
Copy link
Contributor Author

wiibaa commented Oct 9, 2014

Another example, here is an excerpt of https://github.com/rsim/oracle-enhanced README:

If you are using JRuby then you need to download latest Oracle JDBC driver - either ojdbc7.jar or ojdbc6.jar for Java 7, ojdbc6.jar for Java 6 or ojdbc5.jar for Java 5. And copy this file to one of these locations:
in ./lib directory of Rails application
in some directory which is in PATH
in JRUBY_HOME/lib directory
or include path to JDBC driver jar file in Java CLASSPATH

@electrical
Copy link

Ah okay, i see.Makes sense then

@wiibaa
Copy link
Contributor Author

wiibaa commented Dec 19, 2014

@colinsurprenant @electrical re-rebased this PR to fit in new master (new vendor structure,use jruby-bin jar instead of jruby-complete in test).

Btw the JAR_DIR constant seems now unused, candidate for cleanup?

@jordansissel
Copy link
Contributor

Thought: Can we provide instructions for manually resolving a jar dependency instead of having an custom case for this?

@wiibaa
Copy link
Contributor Author

wiibaa commented Dec 19, 2014

@jordansissel my proposal is just a DRY alternative because all plugin authors would have to manually integrate the jar loading mechanism, no?

@jordansissel
Copy link
Contributor

@wiibaa right right, I totally see that in the works here. I'm trying to think through the workflow for a plugin author who, let's say, doesn't release the plugin - maybe it's for internal only at a company and uses a proprietary jar library.

Would you put the jars in the gem (plugin)'s directory? or outside somewhere? What happens to the jar when you upgrade the plugin?

@wiibaa
Copy link
Contributor Author

wiibaa commented Dec 19, 2014

@jordansissel I fully agree generic case of jar dependencies is now going into gem production, I suppose one could setup a rubygem mirror as we do for maven for private build...maybe

I'm not an expert in licensing neither, but being more in the Java world than Ruby the most speaking example, as mentioned above, is the oracle jdbc driver. Outside of oracle software, you must manually point to the jar files when installing/using them (squirelSQL, DBvisualizer, any JDBC program you write) and depending on the database version, one would need the 9i driver or 10g or 11g... even further when writting a JDBC plugin for logstash, one could use mysql, mariadb,postgres driver jar...without the plugin author being concerned about which jar/version is used by the final user.

In short the plugin development doc should make it clear that "standard" jar dependencies should be managed inside the gem hoping the plugin author do not break any licensing restriction when publicly publishing it and for user custom jar loading this method could be referenced.
Am I right ?

@electrical
Copy link

I do see some use for this. An example is a plugin that pulls the jars from a remote location using the vendor.json file ( see file-dependencies gem ) we then need a simple way to load the jars.
If we can have a generic call that can be used in the plugins would be great instead everyone writing it in their own way.

@wiibaa
Copy link
Contributor Author

wiibaa commented Apr 14, 2015

Made obsolete by #2980

@wiibaa wiibaa closed this Apr 14, 2015
@wiibaa wiibaa deleted the jar-loading branch April 14, 2015 15:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

6 participants