2
當我最近決定下載JWNL爲Java接口共發現。繼各種教程(如http://jwordnet.sourceforge.net/handbook.html),我下載的WordNet(2.1),然後JWNL,在file_properties.xml的dictionary_path行設置爲路徑共發現。的ExceptionInInitializerError使用共發現
<param name="dictionary_path" value="c:/res/wordnet/2.1/dict"/>
我添加了所有的罐子到我的類路徑,並在Eclipse中,我創建了測試下面的簡單類:
public static void main(String[] args) throws FileNotFoundException,
JWNLException {
JWNL.initialize(new FileInputStream("C:\\path\\file_properties.xml"));
Dictionary wordnet = Dictionary.getInstance();
IndexWord word = wordnet.getIndexWord(POS.NOUN, "monarch");
for(Synset syn : word.getSenses()) {
System.out.println(syn.getGloss());
}
}
在Eclipse中運行產生以下錯誤:
Exception in thread "main" java.lang.ExceptionInInitializerError
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Unknown Source)
at net.didion.jwnl.util.factory.Element.install(Element.java:31)
at net.didion.jwnl.JWNL.initialize(JWNL.java:169)
at TestingOnWordNet.main(TestingOnWordNet.java:28)
Caused by: org.apache.commons.logging.LogConfigurationException: org.apache.commons.logging.LogConfigurationException: java.lang.NullPointerException (Caused by java.lang.NullPointerException) (Caused by org.apache.commons.logging.LogConfigurationException: java.lang.NullPointerException (Caused by java.lang.NullPointerException))
at org.apache.commons.logging.impl.LogFactoryImpl.newInstance(LogFactoryImpl.java:543)
at org.apache.commons.logging.impl.LogFactoryImpl.getInstance(LogFactoryImpl.java:235)
at org.apache.commons.logging.impl.LogFactoryImpl.getInstance(LogFactoryImpl.java:209)
at org.apache.commons.logging.LogFactory.getLog(LogFactory.java:351)
at net.didion.jwnl.util.MessageLog.<init>(MessageLog.java:11)
at net.didion.jwnl.dictionary.Dictionary.<clinit>(Dictionary.java:24)
... 5 more
Caused by: org.apache.commons.logging.LogConfigurationException: java.lang.NullPointerException (Caused by java.lang.NullPointerException)
at org.apache.commons.logging.impl.LogFactoryImpl.getLogConstructor(LogFactoryImpl.java:397)
at org.apache.commons.logging.impl.LogFactoryImpl.newInstance(LogFactoryImpl.java:529)
... 10 more
Caused by: java.lang.NullPointerException
at org.apache.commons.logging.impl.LogFactoryImpl.getLogConstructor(LogFactoryImpl.java:374)
... 11 more
有我丟失的東西?我正在準備尋找像JAWS這樣的替代方案,但我希望可能有辦法解決這個問題。
謝謝!
如果有人在這篇文章中摔倒了,我強烈建議從JWNL切換到JAWS:http://lyle.smu.edu/~tspell/jaws/index.html,如果沒有其他理由,除了撥打 'System.setProperty( 「wordnet.database.dir」, 「C:/res/wordnet/2.1/dict /」);' 是簡單和更容易比file_properties.xml文件來了解。 –
我也切換到JAWS。 JWPL有複雜的API。 :P –