You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

使用ws4j API时出现ClassNotFoundException问题求助

Fixing ClassNotFoundException for edu.cmu.lti.lexical_db.ILexicalDatabase in ws4j

Hey there, let's get to the bottom of this error you're facing. The ClassNotFoundException for edu.cmu.lti.lexical_db.ILexicalDatabase is happening because ws4j depends on the lexical-db library, which you haven't included in your project yet—you only added jawjaw and ws4j jars, but this missing library is the core dependency that defines the ILexicalDatabase interface.

Here's how to fix it:

Option 1: Use Maven to manage dependencies (recommended)

Add the full set of compatible ws4j-related dependencies to your pom.xml. For your ws4j 1.0.1 version, these are the correct entries:

<dependencies>
    <!-- Lexical DB (the missing dependency) -->
    <dependency>
        <groupId>edu.cmu.lti</groupId>
        <artifactId>lexical-db</artifactId>
        <version>1.0.2</version>
    </dependency>
    <!-- WS4J core -->
    <dependency>
        <groupId>edu.cmu.lti</groupId>
        <artifactId>ws4j</artifactId>
        <version>1.0.1</version>
    </dependency>
    <!-- Jawjaw (WordNet helper for ws4j) -->
    <dependency>
        <groupId>edu.cmu.lti</groupId>
        <artifactId>jawjaw</artifactId>
        <version>1.0.2</version>
    </dependency>
    <!-- Optional: WordNet dictionary data (required for actual similarity calculations) -->
    <dependency>
        <groupId>net.sf.jwordnet</groupId>
        <artifactId>jwnl</artifactId>
        <version>1.4_rc3</version>
    </dependency>
    <dependency>
        <groupId>edu.cmu.lti</groupId>
        <artifactId>wn31</artifactId>
        <version>1.0</version>
    </dependency>
</dependencies>

Run mvn clean install to pull these dependencies into your project.

Option 2: Manual jar installation

If you're not using Maven:

  • Download the lexical-db-1.0.2.jar (make sure it matches your ws4j 1.0.1 version)
  • Place it in your project's WEB-INF/lib directory (for your Spring web app)
  • Double-check that all jars (lexical-db, ws4j, jawjaw) are correctly added to your project's classpath

Additional checks:

  • Ensure there are no version conflicts between your dependencies. Mixing incompatible versions can lead to similar class-loading issues.
  • For your Spring web app, verify that the jars are included in the final WAR file—sometimes build tools exclude dependencies if not configured properly.

Your original error stack trace (for reference):

Caused by: java.lang.NoClassDefFoundError:
edu/cmu/lti/lexical_db/ILexicalDatabase at
java.lang.Class.getDeclaredMethods0(Native Method) at
java.lang.Class.privateGetDeclaredMethods(Class.java:2701) at
java.lang.Class.getDeclaredMethods(Class.java:1975) at
org.springframework.util.ReflectionUtils.doWithMethods(ReflectionUtils.java:467)
at
org.springframework.web.method.HandlerMethodSelector.selectMethods(HandlerMethodSelector.java:58)
at
org.springframework.web.servlet.handler.AbstractHandlerMethodMapping.detectHandlerMethods(AbstractHandlerMethodMapping.java:139)
at
org.springframework.web.servlet.handler.AbstractHandlerMethodMapping.initHandlerMethods(AbstractHandlerMethodMapping.java:109)
at
org.springframework.web.servlet.handler.AbstractHandlerMethodMapping.afterPropertiesSet(AbstractHandlerMethodMapping.java:89)
at
org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping.afterPropertiesSet(RequestMappingHandlerMapping.java:163)
at
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1612)
at
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1549)
... 30 more Caused by: java.lang.ClassNotFoundException:
edu.cmu.lti.lexical_db.ILexicalDatabase at
org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1332)
at
org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1166)
... 41 more

Jan 30, 2018 6:12:55 PM org.apache.catalina.core.StandardContext
loadOnStartup SEVERE: Servlet [appServlet] in web application
[/SpringRestExample] threw load() exception
java.lang.ClassNotFoundException:
edu.cmu.lti.lexical_db.ILexicalDatabase

内容的提问来源于stack exchange,提问作者Kunjan Shah

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.15 06:32:37