简体   繁体   English

在Eclipse中运行Tomcat服务器时出错

[英]Error on running tomcat server in Eclipse

I am so new in Java and I have cloned one project from Gitlab and imported it into Eclipse. 我是Java的新手,我从Gitlab克隆了一个项目并将其导入Eclipse。

I also added tomcat server and also set properties for project as well as for tomcat server. 我还添加了tomcat服务器,还设置了项目以及tomcat服务器的属性。

I have currently 2 projects added in Eclipse and one is working fine but another is failing. 我目前在Eclipse中添加了2个项目,其中一个工作正常,但另一个失败。 I have changed ports for server of another project. 我已经更改了另一个项目服务器的端口。

It looks like some files are missing? 看起来有些文件丢失了?

I have gone through many answers here but none helped. 我在这里经历了许多答案,但没有一个帮助。

But upon running second project, I am getting below errors: 但是在运行第二个项目时,出现以下错误:

INFO: Initializing ProtocolHandler ["ajp-bio-8009"]
Nov 15, 2016 7:41:27 AM org.apache.catalina.startup.Catalina load
INFO: Initialization processed in 411 ms
Nov 15, 2016 7:41:27 AM org.apache.catalina.core.StandardService startInternal
INFO: Starting service Catalina
Nov 15, 2016 7:41:27 AM org.apache.catalina.core.StandardEngine startInternal
INFO: Starting Servlet Engine: Apache Tomcat/7.0.72
Nov 15, 2016 7:41:27 AM 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[/ProductEngine]]
    at java.util.concurrent.FutureTask.report(FutureTask.java:122)
    at java.util.concurrent.FutureTask.get(FutureTask.java:192)
    at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:1119)
    at org.apache.catalina.core.StandardHost.startInternal(StandardHost.java:819)
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:145)
    at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1571)
    at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1561)
    at java.util.concurrent.FutureTask.run(FutureTask.java:266)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
    at java.lang.Thread.run(Thread.java:745)
Caused by: org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Catalina].StandardHost[localhost].StandardContext[/ProductEngine]]
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:162)
    ... 6 more
Caused by: java.lang.NoClassDefFoundError: Lorg/apache/commons/logging/Log;
    at java.lang.Class.getDeclaredFields0(Native Method)
    at java.lang.Class.privateGetDeclaredFields(Class.java:2583)
    at java.lang.Class.getDeclaredFields(Class.java:1916)
    at org.apache.catalina.util.Introspection.getDeclaredFields(Introspection.java:106)
    at org.apache.catalina.startup.WebAnnotationSet.loadFieldsAnnotation(WebAnnotationSet.java:270)
    at org.apache.catalina.startup.WebAnnotationSet.loadApplicationListenerAnnotations(WebAnnotationSet.java:89)
    at org.apache.catalina.startup.WebAnnotationSet.loadApplicationAnnotations(WebAnnotationSet.java:63)
    at org.apache.catalina.startup.ContextConfig.applicationAnnotationsConfig(ContextConfig.java:417)
    at org.apache.catalina.startup.ContextConfig.configureStart(ContextConfig.java:891)
    at org.apache.catalina.startup.ContextConfig.lifecycleEvent(ContextConfig.java:388)
    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:5522)
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:145)
    ... 6 more
Caused by: java.lang.ClassNotFoundException: org.apache.commons.logging.Log
    at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1892)
    at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1735)
    ... 20 more

Update: my pom.xml is as below and it does not have provided state 更新:我的pom.xml如下,它没有提供状态

在此处输入图片说明

It seems the Java Common Logging lib is on provided scope in your project. 似乎Java Common Logging库位于项目中提供的范围内。

Either you modify the pom.xml to remove the "provided" scope, or you put the common logging JAR in your tomcat lib directory. 您可以修改pom.xml来删除“提供的”范围,或者将通用日志记录JAR放在您的tomcat lib目录中。 I would suggest you to use the first possibility 我建议您使用第一种可能性

Edit : After talking will Neel, the problem was that the maven project wasn't exactly well set up. 编辑 :在与Neel交谈之后,问题是Maven项目的设置不完全正确。 Indeed, Eclipse was not deploying the maven dependencies while deploying the project on Tomcat. 实际上,Eclipse在Tomcat上部署项目时并未部署Maven依赖项。
So the way to solve this is: 因此解决此问题的方法是:
right click on project > deployment assembly > Add > Java Build path entry > Maven dependencies

Right click on your project, Maven -> Update project. 右键单击您的项目,Maven->更新项目。 Then you have to select your project and update it. 然后,您必须选择项目并进行更新。

If you don't see the "Maven" option when right clicking on the project, you have to do this: Right click on your project, Configure -> Convert to Maven Project. 如果右键单击项目时没有看到“ Maven”选项,则必须执行以下操作:右键单击项目,依次单击“配置”->“转换为Maven项目”。

Hope it helps. 希望能帮助到你。

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

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