简体   繁体   English

剥离项目后,tomcat不会从eclipse中启动

[英]tomcat wont start from within eclipse after stripping project

I have been stripping down a spring mvc eclipse/maven project to get a bare minimal example of certain functionality, but the process of stripping out files has resulted in an error that causes tomcat not to launch. 我一直在剥离spring mvc eclipse / maven项目,以获取某些功能的最小示例,但是剥离文件的过程导致了导致无法启动tomcat的错误。 I have uploaded the minimalist version of the project to a file sharing site, so that you can reproduce the problem in a minute or two on your own machine. 我已将项目的简约版本上载到文件共享站点,以便您可以在一两分钟内在自己的计算机上重现该问题。 You can download the eclipse project by clicking on this link. 您可以通过单击此链接下载eclipse项目 Just import the project into eclipse as a maven project and do maven... update project and maven... download sources , then try Run As...Run on server to reproduce the problem. 只需将项目作为Maven项目导入到eclipse中,然后执行maven... update projectmaven... download sources ,然后尝试Run As...Run on server方式重现该问题。

I have set this up with a simplified, compact download so that you can isolate the problem in minutes instead of wasting hours exchanging question and answer. 我已经通过简化,紧凑的下载进行了设置,以便您可以在几分钟之内隔离问题,而不必浪费大量时间来交换问题和答案。

How can I resolve this error so that tomcat will launch and the app can run in a web browser from within eclipse? 如何解决此错误,以便Tomcat启动并可以在Eclipse中从Web浏览器中运行该应用程序?

The eclipse project is only 114kb, so this should be very easy to isolate. eclipse项目只有114kb,因此应该很容易隔离。

I have not made changes to server.xml, or to any of the other tomcat config files. 我尚未更改server.xml或任何其他tomcat配置文件。 I was able to launch tomcat and run this project numerous times during the strip down process, so I think the problem has to do with something missing from the project. 在精简过程中,我能够启动tomcat并多次运行该项目,所以我认为问题与项目中缺少的东西有关。 Other projects in the workspace are able to Run As...Run on server successfully , thus pointing the cause of the problem to something inside this project. 工作区中的其他项目都能够成功Run As...Run on server ,从而将问题的根源指向该项目中的某些内容。 However, the one line in server.xml that refers to this project is: 但是, server.xml中引用此项目的一行是:

<Context docBase="NoClassDefFoundError" path="/NoClassDefFoundError" reloadable="true" source="org.eclipse.jst.jee.server:NoClassDefFoundError"/></Host>

The complete stack trace of the error is: 该错误的完整堆栈跟踪为:

Apr 17, 2015 9:30:50 PM org.apache.catalina.core.ContainerBase startInternal
SEVERE: A child container failed during start
java.util.concurrent.ExecutionException: org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Catalina].StandardHost[localhost].StandardContext[/NoClassDefFoundError]]
    at java.util.concurrent.FutureTask.report(FutureTask.java:122)
    at java.util.concurrent.FutureTask.get(FutureTask.java:188)
    at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:917)
    at org.apache.catalina.core.StandardHost.startInternal(StandardHost.java:868)
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
    at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1409)
    at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1399)
    at java.util.concurrent.FutureTask.run(FutureTask.java:262)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
    at java.lang.Thread.run(Thread.java:745)
Caused by: org.apache.catalina.LifecycleException: Failed to start component  [StandardEngine[Catalina].StandardHost[localhost].StandardContext[/NoClassDefFoundError]]
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:154)
    ... 6 more
Caused by: java.lang.NoClassDefFoundError: org/springframework/core/io/Resource
    at java.lang.Class.getDeclaredFields0(Native Method)
    at java.lang.Class.privateGetDeclaredFields(Class.java:2499)
    at java.lang.Class.getDeclaredFields(Class.java:1811)
    at org.apache.catalina.util.Introspection.getDeclaredFields(Introspection.java:106)
    at org.apache.catalina.startup.WebAnnotationSet.loadFieldsAnnotation(WebAnnotationSet.java:256)
    at org.apache.catalina.startup.WebAnnotationSet.loadApplicationListenerAnnotations(WebAnnotationSet.java:86)
    at org.apache.catalina.startup.WebAnnotationSet.loadApplicationAnnotations(WebAnnotationSet.java:63)
    at org.apache.catalina.startup.ContextConfig.applicationAnnotationsConfig(ContextConfig.java:334)
    at org.apache.catalina.startup.ContextConfig.configureStart(ContextConfig.java:774)
    at org.apache.catalina.startup.ContextConfig.lifecycleEvent(ContextConfig.java:305)
    at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:117)
    at org.apache.catalina.util.LifecycleBase.fireLifecycleEvent(LifecycleBase.java:90)
    at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5095)
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
    ... 6 more
Caused by: java.lang.ClassNotFoundException: org.springframework.core.io.Resource
    at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1295)
    at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1147)
    ... 20 more

Apr 17, 2015 9:30:50 PM org.apache.jasper.servlet.TldScanner scanJars
INFO: At least one JAR was scanned for TLDs yet contained no TLDs. Enable debug logging for this logger for a complete list of JARs that were scanned but no TLDs were found in them. Skipping unneeded JARs during scanning can improve startup time and JSP compilation time.
Apr 17, 2015 9:30:50 PM org.apache.catalina.core.ContainerBase startInternal
SEVERE: A child container failed during start
java.util.concurrent.ExecutionException: org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Catalina].StandardHost[localhost]]
    at java.util.concurrent.FutureTask.report(FutureTask.java:122)
    at java.util.concurrent.FutureTask.get(FutureTask.java:188)
    at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:917)
    at org.apache.catalina.core.StandardEngine.startInternal(StandardEngine.java:262)
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
    at org.apache.catalina.core.StandardService.startInternal(StandardService.java:439)
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
    at org.apache.catalina.core.StandardServer.startInternal(StandardServer.java:760)
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
    at org.apache.catalina.startup.Catalina.start(Catalina.java:625)
    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.apache.catalina.startup.Bootstrap.start(Bootstrap.java:351)
    at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:485)
Caused by: org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Catalina].StandardHost[localhost]]
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:154)
    at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1409)
    at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1399)
    at java.util.concurrent.FutureTask.run(FutureTask.java:262)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
    at java.lang.Thread.run(Thread.java:745)
Caused by: org.apache.catalina.LifecycleException: A child container failed during start
    at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:925)
    at org.apache.catalina.core.StandardHost.startInternal(StandardHost.java:868)
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
    ... 6 more

Apr 17, 2015 9:30:50 PM org.apache.catalina.startup.Catalina start
SEVERE: The required Server component failed to start so Tomcat is unable to start.
org.apache.catalina.LifecycleException: Failed to start component [StandardServer[8005]]
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:154)
    at org.apache.catalina.startup.Catalina.start(Catalina.java:625)
    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.apache.catalina.startup.Bootstrap.start(Bootstrap.java:351)
    at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:485)
Caused by: org.apache.catalina.LifecycleException: Failed to start component [StandardService[Catalina]]
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:154)
    at org.apache.catalina.core.StandardServer.startInternal(StandardServer.java:760)
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
    ... 7 more
Caused by: org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Catalina]]
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:154)
    at org.apache.catalina.core.StandardService.startInternal(StandardService.java:439)
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
    ... 9 more
Caused by: org.apache.catalina.LifecycleException: A child container failed during start
    at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:925)
    at org.apache.catalina.core.StandardEngine.startInternal(StandardEngine.java:262)
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
    ... 11 more

Apr 17, 2015 9:30:50 PM org.apache.coyote.AbstractProtocol pause
INFO: Pausing ProtocolHandler ["http-nio-8080"]
Apr 17, 2015 9:30:50 PM org.apache.coyote.AbstractProtocol pause
INFO: Pausing ProtocolHandler ["ajp-nio-8009"]
Apr 17, 2015 9:30:50 PM org.apache.catalina.core.StandardService stopInternal
INFO: Stopping service Catalina
Apr 17, 2015 9:30:50 PM org.apache.coyote.AbstractProtocol destroy
INFO: Destroying ProtocolHandler ["http-nio-8080"]
Apr 17, 2015 9:30:50 PM org.apache.coyote.AbstractProtocol destroy
SEVERE: Failed to destroy end point associated with ProtocolHandler ["http-nio-8080"]
java.lang.NullPointerException
    at org.apache.tomcat.util.net.NioEndpoint.releaseCaches(NioEndpoint.java:307)
    at org.apache.tomcat.util.net.NioEndpoint.unbind(NioEndpoint.java:482)
    at org.apache.tomcat.util.net.AbstractEndpoint.destroy(AbstractEndpoint.java:795)
    at org.apache.coyote.AbstractProtocol.destroy(AbstractProtocol.java:531)
    at org.apache.catalina.connector.Connector.destroyInternal(Connector.java:1023)
    at org.apache.catalina.util.LifecycleBase.destroy(LifecycleBase.java:305)
    at org.apache.catalina.core.StandardService.destroyInternal(StandardService.java:588)
    at org.apache.catalina.util.LifecycleBase.destroy(LifecycleBase.java:305)
    at org.apache.catalina.core.StandardServer.destroyInternal(StandardServer.java:850)
    at org.apache.catalina.util.LifecycleBase.destroy(LifecycleBase.java:305)
    at org.apache.catalina.startup.Catalina.start(Catalina.java:629)
    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.apache.catalina.startup.Bootstrap.start(Bootstrap.java:351)
    at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:485)

Apr 17, 2015 9:30:50 PM org.apache.coyote.AbstractProtocol destroy
INFO: Destroying ProtocolHandler ["ajp-nio-8009"]
Apr 17, 2015 9:30:50 PM org.apache.coyote.AbstractProtocol destroy
SEVERE: Failed to destroy end point associated with ProtocolHandler ["ajp-nio-8009"]
java.lang.NullPointerException
    at org.apache.tomcat.util.net.NioEndpoint.releaseCaches(NioEndpoint.java:307)
    at org.apache.tomcat.util.net.NioEndpoint.unbind(NioEndpoint.java:482)
    at org.apache.tomcat.util.net.AbstractEndpoint.destroy(AbstractEndpoint.java:795)
    at org.apache.coyote.AbstractProtocol.destroy(AbstractProtocol.java:531)
    at org.apache.catalina.connector.Connector.destroyInternal(Connector.java:1023)
    at org.apache.catalina.util.LifecycleBase.destroy(LifecycleBase.java:305)
    at org.apache.catalina.core.StandardService.destroyInternal(StandardService.java:588)
    at org.apache.catalina.util.LifecycleBase.destroy(LifecycleBase.java:305)
    at org.apache.catalina.core.StandardServer.destroyInternal(StandardServer.java:850)
    at org.apache.catalina.util.LifecycleBase.destroy(LifecycleBase.java:305)
    at org.apache.catalina.startup.Catalina.start(Catalina.java:629)
    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.apache.catalina.startup.Bootstrap.start(Bootstrap.java:351)
    at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:485)

Apr 17, 2015 9:30:50 PM org.apache.catalina.deploy.NamingResourcesImpl cleanUp
WARNING: Failed to retrieve JNDI naming context for container [StandardEngine[Catalina].StandardHost[localhost].StandardContext[/NoClassDefFoundError]] so no cleanup was performed for that container
javax.naming.NamingException: No naming context bound to this class loader
    at org.apache.naming.ContextBindings.getClassLoader(ContextBindings.java:258)
    at org.apache.catalina.deploy.NamingResourcesImpl.cleanUp(NamingResourcesImpl.java:992)
    at org.apache.catalina.deploy.NamingResourcesImpl.stopInternal(NamingResourcesImpl.java:975)
    at org.apache.catalina.util.LifecycleBase.stop(LifecycleBase.java:232)
    at org.apache.catalina.core.StandardContext.stopInternal(StandardContext.java:5427)
    at org.apache.catalina.util.LifecycleBase.stop(LifecycleBase.java:232)
    at org.apache.catalina.util.LifecycleBase.destroy(LifecycleBase.java:272)
    at org.apache.catalina.core.ContainerBase.removeChild(ContainerBase.java:841)
    at org.apache.catalina.core.ContainerBase.destroyInternal(ContainerBase.java:1014)
    at org.apache.catalina.util.LifecycleBase.destroy(LifecycleBase.java:305)
    at org.apache.catalina.core.ContainerBase.removeChild(ContainerBase.java:841)
    at org.apache.catalina.core.ContainerBase.destroyInternal(ContainerBase.java:1014)
    at org.apache.catalina.util.LifecycleBase.destroy(LifecycleBase.java:305)
    at org.apache.catalina.core.StandardService.destroyInternal(StandardService.java:603)
    at org.apache.catalina.util.LifecycleBase.destroy(LifecycleBase.java:305)
    at org.apache.catalina.core.StandardServer.destroyInternal(StandardServer.java:850)
    at org.apache.catalina.util.LifecycleBase.destroy(LifecycleBase.java:305)
    at org.apache.catalina.startup.Catalina.start(Catalina.java:629)
    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.apache.catalina.startup.Bootstrap.start(Bootstrap.java:351)
    at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:485)

Please run mvn clean install before running the project in the server. 在服务器中运行项目之前,请先运行mvn clean install clean makes sure that all the files generated from the previous build are deleted and install makes sure that the generated archive file is put into your local repository clean确保删除了先前版本生成的所有文件,并进行install确保将生成的存档文件放入本地存储库

I downloaded the project from the link that you provided. 我从您提供的链接下载了该项目。 I did mvn clean install and then selected Run on server in eclipse. 我做了mvn clean install ,然后选择Run on server在Eclipse中Run on serverRun on server

The server started successfully and displayed the Click On This Link to reproduce the ERROR page. 服务器成功启动,并显示“ 单击此链接”以重现“错误”页面。 When I clicked on the link, it displayed a page with text If you can see this text, then the ERROR has been resolved . 当我单击链接时,它显示了一个带有文本的页面。 如果您可以看到此文本,则表明ERROR已解决

There are a couple of things I always kept remembering while developing webapps with Eclipse 在使用Eclipse开发Web应用程序时,我经常记住几件事

  1. any change on the file system outside Eclipse, sometimes even when running maven build, is not automatically picked up. Eclipse外部的文件系统上的任何更改(即使在运行maven build时)有时也不会自动获取。 Right click -> refresh on the project does it 右键单击->刷新项目即可
  2. tomcat publishing works shady , as in sometimes it doesn't either publish all the necessary resources or correctly cleanup the previous deploy, and I couldn't figure out why. tomcat发布的工作原理是阴暗的 ,因为有时它既不发布所有必要的资源,也不正确清理先前的部署,我不知道为什么。 It could be related to windows locking files but I had this happening while using antiJARLocking=true or antiResourceLocking=true so I'm not 100% sure 它可能与Windows锁定文件有关,但是我在使用antiJARLocking=trueantiResourceLocking=true时遇到了这种情况,所以我不确定100%

Anyway, when this used to happen in my project, I'd do the following which usually fixed it: 无论如何,当我的项目中曾经发生这种情况时,我通常会执行以下操作来修复它:

  • stop tomcat 停止tomcat
  • refresh, clean & build the project 刷新,清理和构建项目
  • do a clean publish towards tomcat 对Tomcat做一个干净的发布
  • start tomcat 启动tomcat

EDIT 编辑

When it happens again, you can check out what files have been deployed by looking (by default) in the workspace under metadata\\.plugins\\org.eclipse.wst.server.core\\tmp0\\wtpwebapps . 再次发生时,您可以通过在工作空间中(默认情况下)在metadata\\.plugins\\org.eclipse.wst.server.core\\tmp0\\wtpwebapps下查看来检查已部署了哪些文件。 You can check this path to see if it's locked with Process Explorer to see if the files were locked with CTRL+F or with a similar tool of your choice. 您可以检查此路径以查看它是否已被Process Explorer锁定, 以查看文件是否已被CTRL + F或您选择的类似工具锁定

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM