我正在处理一个jruby项目,我收到一些与Nokogiri相关的XML PARSING错误,其控制台日志如下所示:
> XmlDomParserContext.java:94:in `<init>':
> java.lang.NoClassDefFoundError: Could not initialize class
> nokogiri.internals.NokogiriHelpers
> from XmlDocument.java:317:in `newFromData'
> from XmlDocument.java:334:in `read_memory'
> from XmlDocument$INVOKER$s$0$0$read_memory.gen:-1:in `call'
> from CachingCallSite.java:70:in `call'
> from FCallManyArgsNode.java:60:in `interpret'
> from NewlineNode.java:105:in `interpret'
> from BlockNode.java:71:in `interpret'
> from IfNode.java:118:in `interpret'
> from LocalAsgnNode.java:123:in `interpret'
> from NewlineNode.java:105:in `interpret'
> from BlockNode.java:71:in `interpret'
> from ASTInterpreter.java:75:in `INTERPRET_METHOD'
> from InterpretedMethod.java:112:in `call'
> from DefaultMethod.java:158:in `call'
> from CachingCallSite.java:79:in `callBlock'
> from CachingCallSite.java:85:in `call'
> from CallManyArgsBlockPassNode.java:57:in `interpret'
> from NewlineNode.java:105:in `interpret'
> from ASTInterpreter.java:75:in `INTERPRET_METHOD'
> from InterpretedMethod.java:182:in `call'
> from DefaultMethod.java:192:in `call'
> from CachingCallSite.java:326:in `cacheAndCall'
> from CachingCallSite.java:170:in `call'
> from CallOneArgNode.java:57:in `interpret'
> from DAsgnNode.java:110:in `interpret'
> from NewlineNode.java:105:in `interpret'
> from BlockNode.java:71:in `interpret'
> from RescueNode.java:226:in `executeBody'
> from RescueNode.java:123:in `interpretWithJavaExceptions'
> from RescueNode.java:113:in `interpret'
> from BeginNode.java:83:in `interpret'
> from NewlineNode.java:105:in `interpret'
> from BlockNode.java:71:in `interpret'
> from ASTInterpreter.java:112:in `INTERPRET_BLOCK'
> from Interpreted19Block.java:209:in `evalBlockBody'
> from Interpreted19Block.java:197:in `yield'
> from Interpreted19Block.java:128:in `call'
> from Block.java:89:in `call'
> from RubyProc.java:261:in `call'
> from RubyProc.java:213:in `call'
> from Ruby.java:2873:in `tearDown'
> from Ruby.java:2857:in `tearDown'
> from Main.java:267:in `internalRun'
> from Main.java:230:in `run'
> from Main.java:214:in `run'
> from Main.java:194:in `main'
jruby版本是[jruby 1.7.0.RC1(1.9.3p203)2012-09-25 8e849de on Java HotSpot(TM)Client VM 1.6.0_37-b06 [Windows XP-x86]]
操作系统:Windows XP
Java版本: java版“1.6.0_37” Java(TM)SE运行时环境(版本1.6.0_37-b06) Java HotSpot(TM)客户端VM(版本20.12-b01,混合模式,共享)
有没有人对这个问题有任何想法?
答案 0 :(得分:0)
类nokogiri.internals.NokogiriHelpers
可能有一个引发异常的静态初始化块,但异常以某种方式被抑制。
尝试将static
块放在try
- catch
中,并记录所有例外以查找。
class NokogiriHelpers {
static {
try {
// your initialization stuff
} catch (Exception e) {
// log e
}
}
}
请注意,您在NokogiriHelpers
中定义的任何静态常量也都有一个静态初始化程序,因此您可能也希望将它们放在try catch中。如果你有
class NokogiriHelpers {
static int FOO = computeFoo();
}
和computeFoo()
可能会抛出未经检查的异常,您必须将其更改为
class NokogiriHelpers {
static int FOO;
static {
try {
FOO = computeFoo();
} catch (Exception e) {
// log e
}
}
}