Tomcat 7 - 无法加载 X 类警告
最近我注意到,从 Eclipse 将 Web 应用程序部署到 Tomcat 7 后,我在 Catalina 日志文件中收到了 30 多个警告,如下所示:
2011 年 10 月 17 日下午 3:33:47 org.apache.catalina.startup.ContextConfig checkHandlesTypes 警告:无法加载类 [com.sun.codemodel.JArrayClass$1] 检查 @HandlesTypes 一个或多个 ServletContentInitializers 的注释。 java.lang.ClassNotFoundException: com.sun.codemodel.JArrayClass$1 位于 org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1676) 在 org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1521) 在 org.apache.catalina.startup.ContextConfig.checkHandlesTypes(ContextConfig.java:1969) 在 org.apache.catalina.startup.ContextConfig.processAnnotationsStream(ContextConfig.java:1932) 在 org.apache.catalina.startup.ContextConfig.processAnnotationsJar(ContextConfig.java:1826) 在 org.apache.catalina.startup.ContextConfig.processAnnotationsUrl(ContextConfig.java:1785) 在 org.apache.catalina.startup.ContextConfig.processAnnotations(ContextConfig.java:1771) 在 org.apache.catalina.startup.ContextConfig.webConfig(ContextConfig.java:1254) 在 org.apache.catalina.startup.ContextConfig.configureStart(ContextConfig.java:881) 在 org.apache.catalina.startup.ContextConfig.lifecycleEvent(ContextConfig.java:316) 在 org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:119) 在 org.apache.catalina.util.LifecycleBase.fireLifecycleEvent(LifecycleBase.java:89) 在 org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5103) 在 org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:145) 在 org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:812) 在 org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:787) 在 org.apache.catalina.core.StandardHost.addChild(StandardHost.java:607) 在 org.apache.catalina.startup.HostConfig.deployWAR(HostConfig.java:932) 在 org.apache.catalina.startup.HostConfig.deployWARs(HostConfig.java:723) 在 org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:470) 在 org.apache.catalina.startup.HostConfig.start(HostConfig.java:1322) 在 org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:311) 在 org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:119) 在 org.apache.catalina.util.LifecycleBase.fireLifecycleEvent(LifecycleBase.java:89) 在 org.apache.catalina.util.LifecycleBase.setStateInternal(LifecycleBase.java:379) 在 org.apache.catalina.util.LifecycleBase.setState(LifecycleBase.java:324) 在 org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:1041) 在 org.apache.catalina.core.StandardHost.startInternal(StandardHost.java:774) 在 org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:145) 在 org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:1033) 在 org.apache.catalina.core.StandardEngine.startInternal(StandardEngine.java:291) 在 org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:145) 在 org.apache.catalina.core.StandardService.startInternal(StandardService.java:443) 在 org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:145) 在 org.apache.catalina.core.StandardServer.startInternal(StandardServer.java:727) 在 org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:145) 在 org.apache.catalina.startup.Catalina.start(Catalina.java:620) 处 sun.reflect.NativeMethodAccessorImpl.invoke0(本机方法) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) 在 sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) 在 java.lang.reflect.Method.invoke(Method.java:597) 处 org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:303) 在 org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:431)
该应用程序仍然可以正常工作,只是必须滚动浏览所有这些警告才能进入调试行,这只是一种痛苦。关于如何解决这些警告有什么想法吗?
Lately I've noticed that after deploying a web application to Tomcat 7 from Eclipse, I'm getting 30+ warnings in the Catalina log file that look like the following:
Oct 17, 2011 3:33:47 PM org.apache.catalina.startup.ContextConfig
checkHandlesTypes WARNING: Unable to load class
[com.sun.codemodel.JArrayClass$1] to check against the @HandlesTypes
annotation of one or more ServletContentInitializers.
java.lang.ClassNotFoundException: com.sun.codemodel.JArrayClass$1 at
org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1676)
at
org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1521)
at
org.apache.catalina.startup.ContextConfig.checkHandlesTypes(ContextConfig.java:1969)
at
org.apache.catalina.startup.ContextConfig.processAnnotationsStream(ContextConfig.java:1932)
at
org.apache.catalina.startup.ContextConfig.processAnnotationsJar(ContextConfig.java:1826)
at
org.apache.catalina.startup.ContextConfig.processAnnotationsUrl(ContextConfig.java:1785)
at
org.apache.catalina.startup.ContextConfig.processAnnotations(ContextConfig.java:1771)
at
org.apache.catalina.startup.ContextConfig.webConfig(ContextConfig.java:1254)
at
org.apache.catalina.startup.ContextConfig.configureStart(ContextConfig.java:881)
at
org.apache.catalina.startup.ContextConfig.lifecycleEvent(ContextConfig.java:316)
at
org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:119)
at
org.apache.catalina.util.LifecycleBase.fireLifecycleEvent(LifecycleBase.java:89)
at
org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5103)
at
org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:145)
at
org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:812)
at
org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:787)
at
org.apache.catalina.core.StandardHost.addChild(StandardHost.java:607)
at
org.apache.catalina.startup.HostConfig.deployWAR(HostConfig.java:932)
at
org.apache.catalina.startup.HostConfig.deployWARs(HostConfig.java:723)
at
org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:470)
at org.apache.catalina.startup.HostConfig.start(HostConfig.java:1322)
at
org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:311)
at
org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:119)
at
org.apache.catalina.util.LifecycleBase.fireLifecycleEvent(LifecycleBase.java:89)
at
org.apache.catalina.util.LifecycleBase.setStateInternal(LifecycleBase.java:379)
at
org.apache.catalina.util.LifecycleBase.setState(LifecycleBase.java:324)
at
org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:1041)
at
org.apache.catalina.core.StandardHost.startInternal(StandardHost.java:774)
at
org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:145)
at
org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:1033)
at
org.apache.catalina.core.StandardEngine.startInternal(StandardEngine.java:291)
at
org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:145)
at
org.apache.catalina.core.StandardService.startInternal(StandardService.java:443)
at
org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:145)
at
org.apache.catalina.core.StandardServer.startInternal(StandardServer.java:727)
at
org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:145)
at org.apache.catalina.startup.Catalina.start(Catalina.java:620) at
sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597) at
org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:303) at
org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:431)
The application still works fine, it's just a pain to have to scroll past all these warnings to get to debugging lines. Any idea on how to fix these warnings?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
事实证明,部署不需要 jaxb-xjc.jar,因此我最终将其从类路径中删除,从而消除了所有警告消息。
Turns out that the jaxb-xjc.jar wasn't needed for deployment so I just ended up removing it from the classpath which ended up getting rid of all the warning messages.
以下论坛帖子还概述了将 Metro 2.1.1 与 Servlet 3.0 WebApps 一起使用时出现的问题 - 可能也有价值:
http://www.java.net/forum/topic/glassfish/metro-and-jaxb/metro-211-and-servlet-version-30-tomcat-many-startup-errors
The following forum post also outlines a problem that occurs when using Metro 2.1.1 with Servlet 3.0 WebApps - may also be of value:
http://www.java.net/forum/topic/glassfish/metro-and-jaxb/metro-211-and-servlet-version-30-tomcat-many-startup-errors
检查你的依赖关系。其中一个(或多个)包含
META-INF/services/javax.servlet.ServletContainerInitializer
文件。此文件包含ServletContainerInitializer
。ServletContainerInitializer
通常具有引用类的@HandlesTypes
注释。引用的类之一导入/使用com.sun.codemodel.JArrayClass
,它不在您的 web 应用程序的类路径中。这个问题也可能有用:Class Implementing ServletContainerInitializer in web.xml
Check your dependencies. One (or more) of them contain
META-INF/services/javax.servlet.ServletContainerInitializer
file. This file contains class names of typeServletContainerInitializer
.ServletContainerInitializer
s usually have@HandlesTypes
annotation which refers classes. One of the referred classes imports/usecom.sun.codemodel.JArrayClass
which is not on your webapp's classpath.This question also could be useful: Class implementing ServletContainerInitializer in web.xml
我在 tomcat 7.0.23 版本中遇到了同样的问题。我切换到Tomcat 7.0.33后没有注意到这个问题。
即使我只是用最新的 tomcat 中的 jar 替换 ${tomcat.dir}/lib/*jars ,问题也解决了。
或者,如果有帮助的话
另外两个解决方案有效
或
I faced the same issue with tomcat version 7.0.23. I didn't notice this issue after I switched to Tomcat 7.0.33.
Even when I just replaced ${tomcat.dir}/lib/*jars with the jars from the latest tomcat, the problem was solved.
Alternatively, if it helps
two other solutions work
or