在服务器上运行时,Eclipse - Tomcat - java.lang.NoClassDefFoundError:javax / servlet / ServletConfig

时间:2012-12-04 09:05:41

标签: java eclipse

我整天都在打这个: 我有DynamicWebProject。它工作正常。但在某些时候,我决定清理额外的罐子,而不是在项目中使用。清理完毕后,我遇到了一堆错误。所以我回滚了所有的变化(我的意思是我重新调整了所有的罐子)。但是我还使用了Eclipse的项目Build Path,Debug config。不幸的是我不记得这个变化(使用Path的东西)。当我在服务器上运行时,tomcat向我展示了这个:

`

04.12.2012 16:37:43 org.apache.catalina.core.ApplicationContext log
SEVERE: StandardWrapper.Throwable
java.lang.NoClassDefFoundError: javax/servlet/ServletConfig
    at org.apache.axis2.deployment.WarBasedAxisConfigurator.<init>(WarBasedAxisConfigurator.java:103)
    at org.apache.axis2.transport.http.AxisServlet.initConfigContext(AxisServlet.java:584)
    at org.apache.axis2.transport.http.AxisServlet.init(AxisServlet.java:454)
    at org.apache.axis2.webapp.AxisAdminServlet.init(AxisAdminServlet.java:60)
    at org.apache.catalina.core.StandardWrapper.initServlet(StandardWrapper.java:1266)
    at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1185)
    at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:1080)
    at org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:5027)
    at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5314)
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
    at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1559)
    at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1549)
    at java.util.concurrent.FutureTask$Sync.innerRun(Unknown Source)
    at java.util.concurrent.FutureTask.run(Unknown Source)
    at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(Unknown Source)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
    at java.lang.Thread.run(Unknown Source)
04.12.2012 16:37:43 org.apache.catalina.core.StandardContext loadOnStartup
SEVERE: Servlet /library threw load() exception
java.lang.NoClassDefFoundError: javax/servlet/ServletConfig
    at org.apache.axis2.deployment.WarBasedAxisConfigurator.<init>(WarBasedAxisConfigurator.java:103)
    at org.apache.axis2.transport.http.AxisServlet.initConfigContext(AxisServlet.java:584)
    at org.apache.axis2.transport.http.AxisServlet.init(AxisServlet.java:454)
    at org.apache.axis2.webapp.AxisAdminServlet.init(AxisAdminServlet.java:60)
    at org.apache.catalina.core.StandardWrapper.initServlet(StandardWrapper.java:1266)
    at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1185)
    at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:1080)
    at org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:5027)
    at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5314)
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
    at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1559)
    at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1549)
    at java.util.concurrent.FutureTask$Sync.innerRun(Unknown Source)
    at java.util.concurrent.FutureTask.run(Unknown Source)
    at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(Unknown Source)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
    at java.lang.Thread.run(Unknown Source)
04.12.2012 16:37:43 org.apache.coyote.AbstractProtocol start
INFO: Starting ProtocolHandler ["http-bio-8080"]
04.12.2012 16:37:43 org.apache.coyote.AbstractProtocol start
INFO: Starting ProtocolHandler ["ajp-bio-8009"]
04.12.2012 16:37:43 org.apache.catalina.startup.Catalina start
INFO: Server startup in 3556 ms

`

我真的与这场无休止的斗争并列。我做错了什么? Eclipse和Tomcat试图告诉我什么?


完成。

因此。我如何恢复功能。 首先,我的项目是SVN存储库中的备份。 接下来,我在Eclipse中创建新的Workspace。不同文件夹中的新工作区。来自SVN的Checkout项目。 之后,在步骤 - 在服务器上运行时,我发现了错误,并逐个添加了错过的库(jar)。而且,哇哇,它的作品! 所以我怎么想,问题在于eclipce和项目的配置,也在Run / Debug Configuration中。如何在配置中找到错误,我不知道:(但我会在旧工作区尝试。

2 个答案:

答案 0 :(得分:8)

您在类路径中缺少servlet-api.jar。检查

已更新

1) Right click on project
2) Got to java build path
3) Click on add library in right hand side.
4) Choose server run time.
5) Click next and select your tom cat server.
6) Click on finish.

enter image description here

然后再试一次

答案 1 :(得分:1)

转到Java Build Path,转到Libraries,点击Add Library,选择Server Runtime,点击Next,选择您的网络服务器,然后点击完成。清理并部署以查看它是否有效。