Embulk和Java7
总结
-
- embulk本体はJava7で動作するように作られているようです
-
- embulkの各プラグインは、プラグイン開発者の環境に依存しJava7で動かないこともあるようです。
-
- Java7で動かない場合でも自分でコンパイルをすれば動くことがあるかもしれません。
- build.gradleにオプションを追加することで、Java8上でJava7互換のバイナリを作ることができるようです。
Embulk的开发环境
@h_michael_z 目前我正在用7进行编译 – FURUHASHI Sadayuki (@frsyuki) 2015年7月24日
如果在Java7上运行使用JDK8创建的插件
我之前用Java8编写的embulk-parser-apache-log插件,现在尝试在Java7(OpenJDK1.7)上运行。
OpenJDK Runtime Environment (rhel-2.5.5.1.el7_1-x86_64 u79-b14)
OpenJDK 64-Bit Server VM (build 24.79-b02, mixed mode)
出现了以下错误。
2015-07-24 17:51:36.258 +0900: Embulk v0.6.19
LoadError: load error: embulk/parser/apache-log -- java.lang.UnsupportedClassVersionError: org/embulk/parser/ApacheLogParserPlugin : Unsupported major.minor version 52.0
似乎版本52.0表示的是Java8。
参考:不支持的 major.minor 版本号 51.0 = 只能使用 Java7 或更高版本
自己打造
一般的的构建流程如下。
(请注意,由于我创建的插件使用了Java 8引入的语法,无法编译,因此在其他插件中进行示例。)
git clone https://github.com/civitaspo/embulk-output-hdfs.git
cd embulk-output-hdfs
./gradlew gem
cd pkg
embulk gem install -l embulk-output-hdfs-0.1.0.gem
要想在Java8中制作Java7插件,可以执行以下操作:
如果我們在build.gradle中添加以下行,似乎是正確的。(因為不清楚應在哪里添加,所以我們在版本的地方添加)
version = "0.1.0"
sourceCompatibility = 1.7
targetCompatibility = 1.7
确认
只需一种选择,请将以下句子用中文进行本地化释义:
如果加入了Compatibility (主版本变为51,变成Java 7的二进制文件)。
javap -cp build/libs/embulk-output-hdfs-0.1.0.jar -verbose org/embulk/output/HdfsOutputPlugin | grep version
minor version: 0
major version: 51
如果没有兼容性的话
javap -cp build/libs/embulk-output-hdfs-0.1.0.jar -verbose org/embulk/output/HdfsOutputPlugin | grep version
minor version: 0
major version: 52
请留意这些要点
据看,上述措施可能有不足的情况。
最后出现了这个警告,看起来安装Java 7更快一些… > http://t.co/Uq6dVf6CXs— そのっつ (SEO Naotoshi) (@sonots) 2015, 7月 24
请引用
日志 (rī zhì)
% embulk run test.yml
2015-07-24 17:51:36.258 +0900: Embulk v0.6.19
LoadError: load error: embulk/parser/apache-log -- java.lang.UnsupportedClassVersionError: org/embulk/parser/ApacheLogParserPlugin : Unsupported major.minor version 52.0
require at org/jruby/RubyKernel.java:1071
require at /path/to/embulk/bin/embulk!/META-INF/jruby.home/lib/ruby/shared/rubygems/core_ext/kernel_require.rb:135
require at /path/to/embulk/bin/embulk!/META-INF/jruby.home/lib/ruby/shared/rubygems/core_ext/kernel_require.rb:133
require at /path/to/embulk/bin/embulk!/META-INF/jruby.home/lib/ruby/shared/rubygems/core_ext/kernel_require.rb:124
require_and_show at file:/path/to/embulk/bin/embulk!/embulk/plugin_registry.rb:79
search at file:/path/to/embulk/bin/embulk!/embulk/plugin_registry.rb:39
lookup at file:/path/to/embulk/bin/embulk!/embulk/plugin_registry.rb:26
lookup at file:/path/to/embulk/bin/embulk!/embulk/plugin.rb:196
new_java_parser at file:/path/to/embulk/bin/embulk!/embulk/plugin.rb:166
new_java_parser at /path/to/embulk/bin/embulk!/META-INF/jruby.home/lib/ruby/1.9/forwardable.rb:201
run at file:/path/to/embulk/bin/embulk!/embulk/command/embulk_run.rb:351
(root) at classpath:embulk/command/embulk.rb:47
org.embulk.config.ConfigException: ParserPlugin 'apache-log' is not found.
(LoadError) load error: embulk/parser/apache-log -- java.lang.UnsupportedClassVersionError: org/embulk/parser/ApacheLogParserPlugin : Unsupported major.minor version 52.0
at org.embulk.plugin.PluginManager.buildPluginNotFoundException(org/embulk/plugin/PluginManager.java:59)
at org.embulk.plugin.PluginManager.newPlugin(org/embulk/plugin/PluginManager.java:44)
at org.embulk.spi.ExecSession.newPlugin(org/embulk/spi/ExecSession.java:166)
at org.embulk.spi.Exec.newPlugin(org/embulk/spi/Exec.java:74)
at org.embulk.spi.FileInputRunner.newParserPlugin(org/embulk/spi/FileInputRunner.java:56)
at org.embulk.spi.FileInputRunner$RunnerControl.<init>(org/embulk/spi/FileInputRunner.java:100)
at org.embulk.spi.FileInputRunner.transaction(org/embulk/spi/FileInputRunner.java:63)
at org.embulk.exec.BulkLoader.doRun(org/embulk/exec/BulkLoader.java:480)
at org.embulk.exec.BulkLoader.access$100(org/embulk/exec/BulkLoader.java:36)
at org.embulk.exec.BulkLoader$1.run(org/embulk/exec/BulkLoader.java:342)
at org.embulk.exec.BulkLoader$1.run(org/embulk/exec/BulkLoader.java:338)
at org.embulk.spi.Exec.doWith(org/embulk/spi/Exec.java:25)
at org.embulk.exec.BulkLoader.run(org/embulk/exec/BulkLoader.java:338)
at org.embulk.command.Runner.run(org/embulk/command/Runner.java:149)
at org.embulk.command.Runner.main(org/embulk/command/Runner.java:101)
at java.lang.reflect.Method.invoke(java/lang/reflect/Method.java:606)
at RUBY.run(file:/path/to/embulk/bin/embulk!/embulk/command/embulk_run.rb:351)
at classpath_3a_embulk.command.embulk.(root)(classpath:embulk/command/embulk.rb:47)
at classpath_3a_embulk.command.embulk.(root)(classpath_3a_embulk/command/classpath:embulk/command/embulk.rb:47)
at org.embulk.cli.Main.main(org/embulk/cli/Main.java:11)
Suppressed: org.embulk.plugin.PluginSourceNotMatchException
at org.embulk.plugin.InjectedPluginSource.newPlugin(InjectedPluginSource.java:54)
at org.embulk.plugin.PluginManager.newPlugin(PluginManager.java:38)
at org.embulk.spi.ExecSession.newPlugin(ExecSession.java:166)
at org.embulk.spi.Exec.newPlugin(Exec.java:74)
at org.embulk.spi.FileInputRunner.newParserPlugin(FileInputRunner.java:56)
at org.embulk.spi.FileInputRunner$RunnerControl.<init>(FileInputRunner.java:100)
at org.embulk.spi.FileInputRunner.transaction(FileInputRunner.java:63)
at org.embulk.exec.BulkLoader.doRun(BulkLoader.java:480)
at org.embulk.exec.BulkLoader.access$100(BulkLoader.java:36)
at org.embulk.exec.BulkLoader$1.run(BulkLoader.java:342)
at org.embulk.exec.BulkLoader$1.run(BulkLoader.java:338)
at org.embulk.spi.Exec.doWith(Exec.java:25)
at org.embulk.exec.BulkLoader.run(BulkLoader.java:338)
at org.embulk.command.Runner.run(Runner.java:149)
at org.embulk.command.Runner.main(Runner.java:101)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at org.jruby.javasupport.JavaMethod.invokeDirectWithExceptionHandling(JavaMethod.java:470)
at org.jruby.javasupport.JavaMethod.invokeDirect(JavaMethod.java:328)
at org.jruby.java.invokers.InstanceMethodInvoker.call(InstanceMethodInvoker.java:71)
at org.jruby.runtime.callsite.CachingCallSite.cacheAndCall(CachingCallSite.java:346)
at org.jruby.runtime.callsite.CachingCallSite.call(CachingCallSite.java:204)
at org.jruby.ast.CallTwoArgNode.interpret(CallTwoArgNode.java:59)
at org.jruby.ast.NewlineNode.interpret(NewlineNode.java:105)
at org.jruby.ast.RescueNode.executeBody(RescueNode.java:221)
at org.jruby.ast.RescueNode.interpret(RescueNode.java:116)
at org.jruby.ast.BeginNode.interpret(BeginNode.java:83)
at org.jruby.ast.NewlineNode.interpret(NewlineNode.java:105)
at org.jruby.ast.BlockNode.interpret(BlockNode.java:71)
at org.jruby.ast.CaseNode.interpret(CaseNode.java:138)
at org.jruby.ast.NewlineNode.interpret(NewlineNode.java:105)
at org.jruby.ast.BlockNode.interpret(BlockNode.java:71)
at org.jruby.evaluator.ASTInterpreter.INTERPRET_METHOD(ASTInterpreter.java:74)
at org.jruby.internal.runtime.methods.InterpretedMethod.call(InterpretedMethod.java:182)
at org.jruby.internal.runtime.methods.DefaultMethod.call(DefaultMethod.java:203)
at org.jruby.runtime.callsite.CachingCallSite.cacheAndCall(CachingCallSite.java:326)
at org.jruby.runtime.callsite.CachingCallSite.call(CachingCallSite.java:170)
at classpath_3a_embulk.command.embulk.__file__(classpath:embulk/command/embulk.rb:47)
at classpath_3a_embulk.command.embulk.load(classpath:embulk/command/embulk.rb)
at org.jruby.Ruby.runScript(Ruby.java:866)
at org.jruby.Ruby.runScript(Ruby.java:859)
at org.jruby.Ruby.runNormally(Ruby.java:728)
at org.jruby.Ruby.runFromMain(Ruby.java:577)
at org.jruby.Main.doRunFromMain(Main.java:395)
at org.jruby.Main.internalRun(Main.java:290)
at org.jruby.Main.run(Main.java:217)
at org.jruby.Main.main(Main.java:197)
at org.embulk.cli.Main.main(Main.java:11)
Suppressed: org.embulk.plugin.PluginSourceNotMatchException: org.jruby.exceptions.RaiseException: (LoadError) load error: embulk/parser/apache-log -- java.lang.UnsupportedClassVersionError: org/embulk/parser/ApacheLogParserPlugin : Unsupported major.minor version 52.0
at org.embulk.jruby.JRubyPluginSource.newPlugin(JRubyPluginSource.java:69)
at org.embulk.plugin.PluginManager.newPlugin(PluginManager.java:38)
at org.embulk.spi.ExecSession.newPlugin(ExecSession.java:166)
at org.embulk.spi.Exec.newPlugin(Exec.java:74)
at org.embulk.spi.FileInputRunner.newParserPlugin(FileInputRunner.java:56)
at org.embulk.spi.FileInputRunner$RunnerControl.<init>(FileInputRunner.java:100)
at org.embulk.spi.FileInputRunner.transaction(FileInputRunner.java:63)
at org.embulk.exec.BulkLoader.doRun(BulkLoader.java:480)
at org.embulk.exec.BulkLoader.access$100(BulkLoader.java:36)
at org.embulk.exec.BulkLoader$1.run(BulkLoader.java:342)
at org.embulk.exec.BulkLoader$1.run(BulkLoader.java:338)
at org.embulk.spi.Exec.doWith(Exec.java:25)
at org.embulk.exec.BulkLoader.run(BulkLoader.java:338)
at org.embulk.command.Runner.run(Runner.java:149)
at org.embulk.command.Runner.main(Runner.java:101)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at org.jruby.javasupport.JavaMethod.invokeDirectWithExceptionHandling(JavaMethod.java:470)
at org.jruby.javasupport.JavaMethod.invokeDirect(JavaMethod.java:328)
at org.jruby.java.invokers.InstanceMethodInvoker.call(InstanceMethodInvoker.java:71)
at org.jruby.runtime.callsite.CachingCallSite.cacheAndCall(CachingCallSite.java:346)
at org.jruby.runtime.callsite.CachingCallSite.call(CachingCallSite.java:204)
at org.jruby.ast.CallTwoArgNode.interpret(CallTwoArgNode.java:59)
at org.jruby.ast.NewlineNode.interpret(NewlineNode.java:105)
at org.jruby.ast.RescueNode.executeBody(RescueNode.java:221)
at org.jruby.ast.RescueNode.interpret(RescueNode.java:116)
at org.jruby.ast.BeginNode.interpret(BeginNode.java:83)
at org.jruby.ast.NewlineNode.interpret(NewlineNode.java:105)
at org.jruby.ast.BlockNode.interpret(BlockNode.java:71)
at org.jruby.ast.CaseNode.interpret(CaseNode.java:138)
at org.jruby.ast.NewlineNode.interpret(NewlineNode.java:105)
at org.jruby.ast.BlockNode.interpret(BlockNode.java:71)
at org.jruby.evaluator.ASTInterpreter.INTERPRET_METHOD(ASTInterpreter.java:74)
at org.jruby.internal.runtime.methods.InterpretedMethod.call(InterpretedMethod.java:182)
at org.jruby.internal.runtime.methods.DefaultMethod.call(DefaultMethod.java:203)
at org.jruby.runtime.callsite.CachingCallSite.cacheAndCall(CachingCallSite.java:326)
at org.jruby.runtime.callsite.CachingCallSite.call(CachingCallSite.java:170)
at classpath_3a_embulk.command.embulk.__file__(classpath:embulk/command/embulk.rb:47)
at classpath_3a_embulk.command.embulk.load(classpath:embulk/command/embulk.rb)
at org.jruby.Ruby.runScript(Ruby.java:866)
at org.jruby.Ruby.runScript(Ruby.java:859)
at org.jruby.Ruby.runNormally(Ruby.java:728)
at org.jruby.Ruby.runFromMain(Ruby.java:577)
at org.jruby.Main.doRunFromMain(Main.java:395)
at org.jruby.Main.internalRun(Main.java:290)
at org.jruby.Main.run(Main.java:217)
at org.jruby.Main.main(Main.java:197)
at org.embulk.cli.Main.main(Main.java:11)
Caused by: org.jruby.exceptions.RaiseException: (LoadError) load error: embulk/parser/apache-log -- java.lang.UnsupportedClassVersionError: org/embulk/parser/ApacheLogParserPlugin : Unsupported major.minor version 52.0
at org.jruby.RubyKernel.require(org/jruby/RubyKernel.java:1071)
at Kernel.require(/path/to/embulk/bin/embulk!/META-INF/jruby.home/lib/ruby/shared/rubygems/core_ext/kernel_require.rb:135)
at Kernel.require(/path/to/embulk/bin/embulk!/META-INF/jruby.home/lib/ruby/shared/rubygems/core_ext/kernel_require.rb:133)
at Kernel.require(/path/to/embulk/bin/embulk!/META-INF/jruby.home/lib/ruby/shared/rubygems/core_ext/kernel_require.rb:124)
at RUBY.require_and_show(file:/path/to/embulk/bin/embulk!/embulk/plugin_registry.rb:79)
at RUBY.search(file:/path/to/embulk/bin/embulk!/embulk/plugin_registry.rb:39)
at RUBY.lookup(file:/path/to/embulk/bin/embulk!/embulk/plugin_registry.rb:26)
at RUBY.lookup(file:/path/to/embulk/bin/embulk!/embulk/plugin.rb:196)
at RUBY.new_java_parser(file:/path/to/embulk/bin/embulk!/embulk/plugin.rb:166)
at RUBY.new_java_parser(/path/to/embulk/bin/embulk!/META-INF/jruby.home/lib/ruby/1.9/forwardable.rb:201)
at RUBY.run(file:/path/to/embulk/bin/embulk!/embulk/command/embulk_run.rb:351)
at classpath_3a_embulk.command.embulk.(root)(classpath:embulk/command/embulk.rb:47)
Error: ParserPlugin 'apache-log' is not found.
(LoadError) load error: embulk/parser/apache-log -- java.lang.UnsupportedClassVersionError: org/embulk/parser/ApacheLogParserPlugin : Unsupported major.minor version 52.0