Tomcat 7 - unable to load class X warnings

Recently, I noticed that after deploying a Tomcat 7 web application from Eclipse, I get more than 30 warnings in the Catalina log file, which look like this:

October 17, 2011 3:33:47 p.m. org.apache.catalina.startup.ContextConfig checkHandlesTypes ATTENTION: Unable to load the class [com.sun.codemodel.JArrayClass $ 1] to check for @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) in org.apache.catalina.loader.WebappClassLoader.loadClass (Web 1521) in org.apache.catalina.startup.ContextConfig.checkHandlesTypes (ContextConfig.java:1969) in org.apache.catalina.startup.ContextConfig.processAnnotationsStream (ContextConfig.java:1932) in org.apstuponcatalalatononcatalataloncatalatalontextaligatalon .processAnnotationsJar (ContextConfig.java:1826) in org.apache.catalina.startup.ContextConfig.processAnnotationsUrl (ContextConfig.java:1785) in org.apache.catalina.startup.ContextConfig.processAnnotationsjavaConfon1. apache. java: 316) in org.apache.catalina.util.Lifecyc leSupport.fireLifecycleEvent (LifecycleSupport.java:119) in org.apache.catalina.util.LifecycleBase.fireLifecycleEvent (LifecycleBase.java:89) in org.apache.catalina.core.StandardContext.startInternal (StandardContext.java UP103) org .apache.catalina.util.LifecycleBase.start (LifecycleBase.java:145) in org.apache.catalina.core.ContainerBase.addChildInternal (ContainerBase.java:812) in org.apache.catalina.core.ContainerBase.addChild (ContainerBase .java: 787) in org.apache.catalina.core.StandardHost.addChild (StandardHost.java:607) in org.apache.catalina.startup.HostConfig.deployWAR (HostConfig.java:932) in 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 (HostConfig2java in org.apache.catalina.startup.HostConfig.lifecycleEvent (HostConfig.javahaps11) in org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent (LifecycleSupp ort.java:119) in org.apache.catalina.util.LifecycleBase.fireLifecycleEvent (LifecycleBase.java:89) in org.apache.catalina.util.LifecycleBase.setStateInternal (LifecycleBase.javahaps79) in org.apache.catalina .util.LifecycleBase.setState (LifecycleBase.java:324) in org.apache.catalina.core.ContainerBase.startInternal (ContainerBase.java:1041) in org.apache.catalina.core.StandardHost.startInternal (StandardHost.java:774 ) in org.apache.catalina.util.LifecycleBase.start (LifecycleBase.java:145) in org.apache.catalina.core.ContainerBase.startInternal (ContainerBase.java:1033) in org.apache.catalina.core.StandardEngine. startInternal (StandardEngine.java:291) in org.apache.catalina.util.LifecycleBase.start (LifecycleBase.java:145) in org.apache.catalina.core.StandardService.startInternal (StandardService.java:443) in org.apache .catalina.util.LifecycleBase.start (LifecycleBase.java:145) in org.apache.catalina.core.StandardServer.startInternal (StandardServer.java:727) in org.apache. catalina.util.LifecycleBase.start (LifecycleBase.java:145) at org.apache.catalina.startup.Catalina.start (Catalina.java:620) in sun.reflect.NativeMethodAccessorImpl.invoke0 (native method) in sun.reflect. NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:39) in sun.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:25) in java.lang.reflect.Method.invoke (Method.java=97cat .Bootstrap.start (Bootstrap.java.303) in org.apache.catalina.startup.Bootstrap.main (Bootstrap.java:431)

The application is still working fine, it just hurts to scroll through all of these warnings to go on to debug lines. Any idea on how to fix these warnings?

+4
source share
4 answers

It turns out that jaxb-xjc.jar is not required for deployment, so I just removed it from the class path, which eventually got rid of all the warning messages.

+3
source

The following forum post also describes the problem that occurs when using Metro 2.1.1 with Servlet 3.0 WebApps, it may also be useful: http://www.java.net/forum/topic/glassfish/metro-and-jaxb/metro-211- and-servlet-version-30-tomcat-many-startup-errors

+3
source

Check your dependencies. One (or more) of them contains the file META-INF/services/javax.servlet.ServletContainerInitializer . This file contains class names of type ServletContainerInitializer . ServletContainerInitializer usually have the @HandlesTypes annotation, which refers to classes. One of the specified classes imports / uses com.sun.codemodel.JArrayClass , which is not in your path to the webapp class.

This question may also be useful: A class that implements ServletContainerInitializer in web.xml

+1
source

I ran into the same issue with tomcat version 7.0.23. I did not notice this problem after switching to Tomcat 7.0.33.

Even when I just replaced the bans of $ {tomcat.dir} / lib / * with banks from the latest tomcat, the problem was solved.

Alternatively, if this helps two other solutions work.

  • Change web.xml for each war in webapps and change the version of the web application to 2.5 from 3.0 or
  • Add metadata-complete = true to the web application tag
0
source

All Articles