Java 在 Tomcat 5.5 中部署 web-app 时如何解决 Error listenerStart?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/2641338/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-13 10:14:28  来源:igfitidea点击:

How to resolve Error listenerStart when deploying web-app in Tomcat 5.5?

javaspringdeploymenttomcatwicket

提问by John

I've deployed an Apache Wicket web-application that uses Spring and Hibernate to my Tomcat 5.5 instance. When I navigate to the Tomcat Manager interface I see that the web-application I deployed is not running. When I press 'Start' I get the following error message; "FAIL - Application at context path /spaghetti could not be started".

我已将使用 Spring 和 Hibernate 的 Apache Wicket Web 应用程序部署到我的 Tomcat 5.5 实例。当我导航到 Tomcat 管理器界面时,我看到我部署的 Web 应用程序没有运行。当我按“开始”时,我收到以下错误消息;“失败 - 无法启动上下文路径 /spaghetti 上的应用程序”。

My catalina.log contains the following:

我的 catalina.log 包含以下内容:

Apr 15, 2010 1:51:22 AM org.apache.catalina.loader.WebappClassLoader validateJarFile  
INFO: validateJarFile(/var/lib/tomcat5.5/webapps/spaghetti/WEB-INF/lib/jsp-api-6.0.16.jar)   - jar not loaded. See Servlet Spec 2.3, section 9.7.2. Offending class: javax/servlet/jsp/JspPage.class  
Apr 15, 2010 1:51:22 AM org.apache.catalina.loader.WebappClassLoader validateJarFile  
INFO: validateJarFile(/var/lib/tomcat5.5/webapps/spaghetti/WEB-INF/lib/servlet-api-6.0.16.jar) - jar not loaded. See Servlet Spec 2.3, section 9.7.2. Offending class: javax/servlet/Servlet.class  
Apr 15, 2010 1:51:24 AM org.apache.catalina.core.StandardContext start  
SEVERE: Error listenerStart  
Apr 15, 2010 1:51:24 AM org.apache.catalina.core.StandardContext start  
SEVERE: Context [/spaghetti] startup failed due to previous errors

Excerpt from web.xml:

摘自 web.xml:

    <listener>
        <listener-class>
            org.springframework.web.context.ContextLoaderListener
        </listener-class>
    </listener>

Any help is greatly appreciated.

任何帮助是极大的赞赏。

采纳答案by BalusC

/var/lib/tomcat5.5/webapps/spaghetti/WEB-INF/lib/jsp-api-6.0.16.jar
/var/lib/tomcat5.5/webapps/spaghetti/WEB-INF/lib/servlet-api-6.0.16.jar

You should nothave any server-specific libraries in the /WEB-INF/lib. Leave them in the appserver's own library. It would only lead to collisions in the classpath. Get rid of all appserver-specific libraries in /WEB-INF/lib(and also in JRE/liband JRE/lib/extif you have placed any of them there).

你应该不会有在任何服务器专用库/WEB-INF/lib。将它们留在应用程序服务器自己的库中。它只会导致类路径中的冲突。摆脱所有特定于应用程序服务器的库/WEB-INF/libJRE/lib以及JRE/lib/ext如果您已将它们中的任何一个放置在那里)。

A common cause that the appserver-specific libraries are included in the webapp's library is that starters think that it is the right way to fix compilation errors of among others the javax.servletclasses not being resolveable. Putting them in webapp's library is the wrong solution. You should reference them in the classpath during compilation, i.e. javac -cp /path/to/server/lib/servlet.jarand so on, or if you're using an IDE, you should integrate the server in the IDE and associate the web project with the server. The IDE will then automatically take server-specific libraries in the classpath (buildpath) of the webapp project.

将特定于应用程序服务器的库包含在 web 应用程序的库中的一个常见原因是,初学者认为这是修复其中javax.servlet无法解析的类的编译错误的正确方法。将它们放在 webapp 的库中是错误的解决方案。您应该在编译时在类路径中引用它们,iejavac -cp /path/to/server/lib/servlet.jar等等,或者如果您使用的是 IDE,则应该将服务器集成到 IDE 中并将 Web 项目与服务器相关联。然后,IDE 将自动在 webapp 项目的类路径 ( buildpath) 中获取特定于服务器的库。

回答by Tom Saleeba

I found that following these instructions helped with finding what the problem was. For me, that was the killer, not knowing what was broken.

我发现遵循这些说明有助于找到问题所在。对我来说,那是凶手,不知道是什么坏了。

http://mythinkpond.wordpress.com/2011/07/01/tomcat-6-infamous-severe-error-listenerstart-message-how-to-debug-this-error/

http://mythinkpond.wordpress.com/2011/07/01/tomcat-6-inficial-severe-error-listenerstart-message-how-to-debug-this-error/

Quoting from the link

从链接引用

In Tomcat 6 or above, the default logger is the”java.util.logging” logger and not Log4J. So if you are trying to add a “log4j.properties” file – this will NOT work. The Java utils logger looks for a file called “logging.properties” as stated here: http://tomcat.apache.org/tomcat-6.0-doc/logging.html

So to get to the debugging details create a “logging.properties” file under your”/WEB-INF/classes” folder of your WAR and you're all set.

And now when you restart your Tomcat, you will see all of your debugging in it's full glory!!!

Sample logging.properties file:

在 Tomcat 6 或更高版本中,默认记录器是“java.util.logging”记录器而不是 Log4J。因此,如果您尝试添加“log4j.properties”文件 - 这将不起作用。Java utils 记录器查找名为“logging.properties”的文件,如下所述:http: //tomcat.apache.org/tomcat-6.0-doc/logging.html

因此,要获取调试详细信息,请在 WAR 的“/WEB-INF/classes”文件夹下创建一个“logging.properties”文件,然后一切就绪。

现在,当您重新启动 Tomcat 时,您将看到所有调试都在它的全貌中!!!

示例 logging.properties 文件:

org.apache.catalina.core.ContainerBase.[Catalina].level = INFO
org.apache.catalina.core.ContainerBase.[Catalina].handlers = java.util.logging.ConsoleHandler

回答by Colin D

I encountered this error when the JDK that I compiled the app under was different from the tomcat JVM. I verified that the Tomcat manager was running jvm 1.6.0 but the app was compiled under java 1.7.0.

当我编译应用程序的JDK与tomcat JVM不同时,我遇到了这个错误。我确认 Tomcat 管理器正在运行 jvm 1.6.0,但该应用程序是在 java 1.7.0 下编译的。

After upgrading Java and changing JAVA_HOME in our startup script (/etc/init.d/tomcat) the error went away.

在我们的启动脚本 (/etc/init.d/tomcat) 中升级 Java 并更改 JAVA_HOME 后,错误消失了。

回答by Agry

Answered provided by Tom Saleeba is very helpful. Today I also struggled with the same error

Tom Saleeba 提供的回答非常有帮助。今天我也遇到了同样的错误

Apr 28, 2015 7:53:27 PM org.apache.catalina.core.StandardContext startInternal SEVERE: Error listenerStart

2015 年 4 月 28 日下午 7:53:27 org.apache.catalina.core.StandardContext startInternal 严重:错误 listenerStart

I followed the suggestion and added the logging.properties file. And below was my reason of failure:

我按照建议添加了 logging.properties 文件。以下是我失败的原因:

java.lang.IllegalStateException: Cannot set web app root system property when WAR file is not expanded

java.lang.IllegalStateException:未展开 WAR 文件时无法设置 Web 应用程序根系统属性

The root cause of the issue was a listener (Log4jConfigListener) that I added into the web.xml. And as per the link SEVERE: Exception org.springframework.web.util.Log4jConfigListener, this listener cannot be added within a WAR that is not expanded.

问题的根本原因是我添加到 web.xml 中的侦听器 (Log4jConfigListener)。根据链接SEVERE: Exception org.springframework.web.util.Log4jConfigListener,无法在未扩展的 WAR 中添加此侦听器。

It may be helpful for someone to know that this was happening on OpenShift JBoss gear.

有人知道这发生在 OpenShift JBoss 设备上可能会有所帮助。