Spring DI applicationContext.xml how exactly is xsi:schemaLocation used? - spring

Note: the test project I'm mentioning can be downloaded with:
git clone https://github.com/mperdikeas/so-spring-di-appcontext-schemalocation.git
.. and run with 'ant run'.
I 'understand' that XML namespace names are just used as opaque identifiers and not meant to be used as URIs (wikipedia). I also 'understand' that the XML schema locations are meant to provide hints as to the actual location of schema documents and, being hints, not used in practice (w3.org). With that in mind I 've been experimenting with a simple Spring DI application (used in a simple J2SE setting) by modifying the applicationContext.xml. Here is the starting version:
<beans xmlns = "http://www.springframework.org/schema/beans"
xmlns:xsi = "http://www.w3.org/2001/XMLSchema-instance"
xmlns:context = "http://www.springframework.org/schema/context"
xmlns:p = "http://www.springframework.org/schema/p"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-2.5.xsd">
<context:component-scan base-package="atm"/>
<context:property-placeholder location="classpath:META-INF/spring/atm.properties"/>
<bean id="soapTransport_" class="atm.SoapATMTransport" p:retries="${transport.retries}"/>
When I did a 'sudo ifconfig eth0 down' the project ran perfectly which is consistent with the runtime not bothering to fetch anything from the schemaLocations. However, when I mangled the schemaLocations by adding a simple underscore to the second URL in each pair I received the following complaint:
[java] org.springframework.beans.factory.xml.XmlBeanDefinitionStoreException: Line 10 in XML document from class path resource [META-INF/spring/applicationContext.xml] is invalid; nested exception is org.xml.sax.SAXParseException; lineNumber: 10; columnNumber: 100; cvc-elt.1: Cannot find the declaration of element 'beans'.
[java] at org.apache.tools.ant.taskdefs.ExecuteJava.execute(ExecuteJava.java:194)
[java] at org.apache.tools.ant.taskdefs.Java.run(Java.java:771)
[java] at org.apache.tools.ant.taskdefs.Java.executeJava(Java.java:221)
[java] at org.apache.tools.ant.taskdefs.Java.executeJava(Java.java:135)
[java] at org.apache.tools.ant.taskdefs.Java.execute(Java.java:108)
[java] at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:291)
[java] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
[java] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
[java] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
[java] at java.lang.reflect.Method.invoke(Method.java:601)
[java] at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:106)
[java] at org.apache.tools.ant.Task.perform(Task.java:348)
[java] at org.apache.tools.ant.Target.execute(Target.java:390)
[java] at org.apache.tools.ant.Target.performTasks(Target.java:411)
[java] at org.apache.tools.ant.Project.executeSortedTargets(Project.java:1399)
[java] at org.apache.tools.ant.Project.executeTarget(Project.java:1368)
[java] at org.apache.tools.ant.helper.DefaultExecutor.executeTargets(DefaultExecutor.java:41)
[java] at org.apache.tools.ant.Project.executeTargets(Project.java:1251)
[java] at org.apache.tools.ant.Main.runBuild(Main.java:809)
[java] at org.apache.tools.ant.Main.startAnt(Main.java:217)
[java] at org.apache.tools.ant.launch.Launcher.run(Launcher.java:280)
[java] at org.apache.tools.ant.launch.Launcher.main(Launcher.java:109)
Which seems to suggest that Spring DI runtime uses the second URL in each pair at the xsi:schemaLocation as some kind of identifier (hardcoded in its logic since there is no network access). So my assumption would be that the Spring DI runtime uses two kind of identifiers for each namespace: the xmlns identifier to uniquely identify the namespace (used as an opaque string) and the schemaLocation identifier to uniquely identify the schema version for that namespace (again used as an opaque string). I.e. the schemaLocation is actually used (in a contorted way ? as that doesn't seem to be the intention of the w3c documents) to version the namespace.
Moreover, in such a case, why doesn't the Spring DI runtime complain about the lack of a schemaLocation for the "p" namespace. Is my mental model correct?

Here is what happens:
XML schema allows you to define aliases (short names) to XML namespaces. Technically all namespaces are identified by full URI but that would be very cumbersome - so you can use short aliases like context and p. There is also a default namespace denoted by xmlns attribute
By default XML parsers assume namespace URI is also a XSD file URL location. This is often the case, but is not required by the spec. This is also how XML parser in Spring works if you don't provide schemaLocation attribute.
schemaLocation is used to map from namespace URI to XSD file physical location (URL). It is used when schema namespace does not point to valid XSD URL (see MSDN on schemaLocation).
Last but not least, Spring adds yet another layer that translates Internet URLs to local files on CLASSPATH. This way your application can start without Internet connection (or when springframework.org site is down).
If you search your project libraries you'll find several files named spring.schemas. These files contain lines similar to below (extract from the file found in spring-context.jar, I added alignment):
http\://www.springframework.org/schema/context/spring-context.xsd= org/springframework/context/config/spring-context-3.1.xsd
http\://www.springframework.org/schema/jee/spring-jee.xsd= org/springframework/ejb/config/spring-jee-3.1.xsd
http\://www.springframework.org/schema/lang/spring-lang.xsd= org/springframework/scripting/config/spring-lang-3.1.xsd
http\://www.springframework.org/schema/cache/spring-cache.xsd= org/springframework/cache/config/spring-cache-3.1.xsd

Related

Jitsi include external jar for customization

Currently I am working on customization of Open Source Jitsi. And Somehow, I want to add 3rd party jar for customization.
I tried a lot to include 3rd party jar but I am facing this error.
So please help me to get rid of this error or provide some guidance to add 3rd party jar .
Auto-properties install: reference:file:sc-bundles/commons-vfs2-2.0.jar (org.osgi.framework.BundleException: Unable to cache bundle: reference:file:sc-bundles/commons-vfs2-2.0.jar - java.io.IOException: Referenced file does not exist: sc-bundles\commons-vfs2-2.0.jar)
[java] org.osgi.framework.BundleException: Unable to cache bundle: reference:file:sc-bundles/commons-vfs2-2.0.jar
[java] at org.apache.felix.framework.Felix.installBundle(Felix.java:2876)
[java] at org.apache.felix.framework.BundleContextImpl.installBundle(BundleContextImpl.java:165)
[java] at org.apache.felix.main.AutoProcessor.processAutoProperties(AutoProcessor.java:296)
[java] at org.apache.felix.main.AutoProcessor.process(AutoProcessor.java:79)
[java] at org.apache.felix.main.Main.main(Main.java:292)
[java] at net.java.sip.communicator.launcher.SIPCommunicator.main(SIPCommunicator.java:219)
[java] Caused by: java.io.IOException: Referenced file does not exist: sc-bundles\commons-vfs2-2.0.jar
[java] at org.apache.felix.framework.cache.BundleArchive.createRevisionFromLocation(BundleArchive.java:852)
[java] at org.apache.felix.framework.cache.BundleArchive.reviseInternal(BundleArchive.java:550)
[java] at org.apache.felix.framework.cache.BundleArchive.<init>(BundleArchive.java:153)
[java] at org.apache.felix.framework.cache.BundleCache.create(BundleCache.java:277)
[java] at org.apache.felix.framework.Felix.installBundle(Felix.java:2872)
[java] ... 5 more
Add your JAR file (custom.jar) to the lib/ directory. Then edit the two files as indicated below:
jitsi.eml - Add the following entry to the file :
<lib name="custom.jar" scope="COMPILE">
<relative-module-cls project-related="jar://$PROJECT_DIR$/lib/custom.jar!/"/>
</lib>
nbproject/project.xml - Search for <classpath mode="compile"> (there are two such occurences) and enlist your jar file as
<classpath mode="compile">lib/custom.jar:lib/felix.jar:[MORE JARS HERE]</classpath>
and
<classpath mode="compile">classes:lib/custom.jar:lib/felix.jar:[MORE JARS HERE]</classpath>
After editing the files, run ant clean; ant clean-bundles; ant make
And you are good to go.

ClassNotFoundException with SIGAR API

I'm trying to work with the SIGAR API, and I added the external jar "sigar.jar" to my Build Path eclipse project.
It compiles with no problem, but when I try to run the main class, that only does :
Cpu cpu = new Cpu();
it gives me this error:
[java] Exception in thread "main" java.lang.NoClassDefFoundError: org/hyperic/sigar/Cpu
[java] at pt.client.User.main(User.java:90)
[java] Caused by: java.lang.ClassNotFoundException: org.hyperic.sigar.Cpu
[java] at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
[java] at java.security.AccessController.doPrivileged(Native Method)
[java] at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
[java] at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
[java] at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
[java] at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
[java] ... 1 more
[java] Java Result: 1
What may be missing?
I think you missed to include .so file specific for your platform.
These files are located ../hyperic-sigar-folder/sigar-bin/lib.
For example, if you are running under Linux 32 Bit, you have to include the file libsigar-x86-linux.so into your class-path as well.

How to use local xsd for EhCache with Spring

We are facing one issue about EhCache and Spring, when we point XSD file in ehcache.xml to http://ehcache.org/ehcache.xsd, everything is ok, our application can startup correct.
But our server can't access external website, so we changed XSD location to local as below, but the application can't startup with following exception (already copy ehcache.xsd to classes folder, same as ehcache.xml).
I have googled many solution, but it still can't be fixed. I need your help about this. Thank you very much.
Spring: 3.1.0
EhCache: 2.4.2
Server: Tomcat 6.0
Java : 1.6
Config:
<ehcache xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="ehcache.xsd"
updateCheck="false" monitoring="autodetect" dynamicConfig="true">
Exception:
2012-11-07 16:54:42,003 WARN [org.springframework.beans.factory.xml.XmlBeanDefinitionReader] - <Ignored XML validation warning>
org.xml.sax.SAXParseException: schema_reference.4: Failed to read schema document 'ehcache.xsd', because 1) could not find the document; 2) the document could not be read; 3) the root element of the document is not <xsd:schema>.
at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.createSAXParseException(ErrorHandlerWrapper.java:195)
at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.warning(ErrorHandlerWrapper.java:96)
at com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(XMLErrorReporter.java:380)
at com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(XMLErrorReporter.java:318)
at com.sun.org.apache.xerces.internal.impl.xs.XMLSchemaValidator.findSchemaGrammar(XMLSchemaValidator.java:2440)
... more
2012-11-07 16:54:42,007 ERROR [org.springframework.web.context.ContextLoader] - <Context initialization failed>
org.springframework.beans.factory.xml.XmlBeanDefinitionStoreException: Line 3 in XML document from ServletContext resource [/WEB-INF/classes/META-INF/ehcache.xml] is invalid; nested exception is org.xml.sax.SAXParseException: cvc-elt.1: Cannot find the declaration of element 'ehcache'.
at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.doLoadBeanDefinitions(XmlBeanDefinitionReader.java:396)
at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:334)
... more
Caused by: org.xml.sax.SAXParseException: cvc-elt.1: Cannot find the declaration of element 'ehcache'.
at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.createSAXParseException(ErrorHandlerWrapper.java:195)
at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.error(ErrorHandlerWrapper.java:131)
... more
Download ehcache.xsd, put it to the same folder where is your config xml file.
modify the xml head like below, notice the classpath prefix:
<ehcache
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="classpath:ehcache.xsd">
This will work in the development and production environment.
usually I set xsi:noNamespaceSchemaLocation="http://ehcache.org/ehcache.xsd", But this can't work in a offline environment.
My Workaround is add this xsd file to absolute path, such as: c:/ehcache.xsd and point to this location in ehcache.xml.
Hope this will help someone who facing the same issue.
Still looking forward to find out other solution.
Thanks.
In my case just downloading the file from http://ehcache.org/ehcache.xsd into src/main/resources solves the problem
cd src/main/resources
wget http://ehcache.org/ehcache.xsd

Classes not visible to OSGified Spring

I am making a very simple app in which I try to init a spring bean using osgi (apache felix). I manage to read the spring-beans.xml file I include in the bundle with code like that:
ApplicationContext springContext = new GenericApplicationContext();
InputStream in = thisBundle.getEntry("/spring-beans.xml").openStream();
DefaultListableBeanFactory beans = new DefaultListableBeanFactory(springContext);
XmlBeanDefinitionReader reader = new XmlBeanDefinitionReader(beans);
reader.setValidationMode(XmlBeanDefinitionReader.VALIDATION_XSD);
reader.loadBeanDefinitions(new InputStreamResource(in));
beans.preInstantiateSingletons();
in.close();
return springContext;
Where this is the content of the spring-beans.xml:
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-2.5.xsd">
<bean id="crazyClass" class="foo.bar.osgi.SpringInstantiatedBean">
<property name="name" value="YES" />
</bean>
</beans>
The SpringInstantiatedBean class has only one prop (name) and a getter/setter for it. This is all fine if I run it locally through a main class, although the path for locating the spring-beans.xml file is a bit different. However, when I do put this code on felix, here is what I get in my Activator:
Jun 7, 2012 4:37:40 PM org.springframework.beans.factory.xml.XmlBeanDefinitionReader loadBeanDefinitions
INFO: Loading XML bean definitions from resource loaded through InputStream
Jun 7, 2012 4:37:41 PM org.springframework.beans.factory.support.DefaultListableBeanFactory preInstantiateSingletons
INFO: Pre-instantiating singletons in org.springframework.beans.factory.support.DefaultListableBeanFactory#2778c490: defining beans [crazyClass]; root of factory hierarchy
org.osgi.framework.BundleException: Activator start error in bundle foo.bar.osgi.OSGIProject [91].
at org.apache.felix.framework.Felix.activateBundle(Felix.java:2027)
at org.apache.felix.framework.Felix.startBundle(Felix.java:1895)
at org.apache.felix.framework.BundleImpl.start(BundleImpl.java:944)
at org.apache.felix.gogo.command.Basic.start(Basic.java:729)
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.felix.gogo.runtime.Reflective.invoke(Reflective.java:137)
at org.apache.felix.gogo.runtime.CommandProxy.execute(CommandProxy.java:82)
at org.apache.felix.gogo.runtime.Closure.executeCmd(Closure.java:477)
at org.apache.felix.gogo.runtime.Closure.executeStatement(Closure.java:403)
at org.apache.felix.gogo.runtime.Pipe.run(Pipe.java:108)
at org.apache.felix.gogo.runtime.Closure.execute(Closure.java:183)
at org.apache.felix.gogo.runtime.Closure.execute(Closure.java:120)
at org.apache.felix.gogo.runtime.CommandSessionImpl.execute(CommandSessionImpl.java:89)
at org.apache.felix.gogo.shell.Console.run(Console.java:62)
at org.apache.felix.gogo.shell.Shell.console(Shell.java:203)
at org.apache.felix.gogo.shell.Shell.gosh(Shell.java:128)
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.felix.gogo.runtime.Reflective.invoke(Reflective.java:137)
at org.apache.felix.gogo.runtime.CommandProxy.execute(CommandProxy.java:82)
at org.apache.felix.gogo.runtime.Closure.executeCmd(Closure.java:477)
at org.apache.felix.gogo.runtime.Closure.executeStatement(Closure.java:403)
at org.apache.felix.gogo.runtime.Pipe.run(Pipe.java:108)
at org.apache.felix.gogo.runtime.Closure.execute(Closure.java:183)
at org.apache.felix.gogo.runtime.Closure.execute(Closure.java:120)
at org.apache.felix.gogo.runtime.CommandSessionImpl.execute(CommandSessionImpl.java:89)
at org.apache.felix.gogo.shell.Activator.run(Activator.java:75)
at java.lang.Thread.run(Thread.java:662)
Caused by: org.springframework.beans.factory.CannotLoadBeanClassException: Cannot find class [foo.bar.osgi.SpringInstantiatedBean] for bean with name 'crazyClass' defined in resource loaded through InputStream; nested exception is java.lang.ClassNotFoundException: foo.bar.osgi.SpringInstantiatedBean
at org.springframework.beans.factory.support.AbstractBeanFactory.resolveBeanClass(AbstractBeanFactory.java:1262)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.predictBeanType(AbstractAutowireCapableBeanFactory.java:576)
at org.springframework.beans.factory.support.AbstractBeanFactory.isFactoryBean(AbstractBeanFactory.java:1331)
at org.springframework.beans.factory.support.AbstractBeanFactory.isFactoryBean(AbstractBeanFactory.java:897)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:566)
at foo.bar.osgi.Activator.readSpringConfigAndInitContext(Activator.java:54)
at foo.bar.osgi.Activator.start(Activator.java:29)
at org.apache.felix.framework.util.SecureAction.startActivator(SecureAction.java:641)
at org.apache.felix.framework.Felix.activateBundle(Felix.java:1977)
... 32 more
Caused by: java.lang.ClassNotFoundException: foo.bar.osgi.SpringInstantiatedBean
at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
at org.springframework.util.ClassUtils.forName(ClassUtils.java:257)
at org.springframework.beans.factory.support.AbstractBeanDefinition.resolveBeanClass(AbstractBeanDefinition.java:417)
at org.springframework.beans.factory.support.AbstractBeanFactory.doResolveBeanClass(AbstractBeanFactory.java:1283)
at org.springframework.beans.factory.support.AbstractBeanFactory.resolveBeanClass(AbstractBeanFactory.java:1254)
... 40 more
org.springframework.beans.factory.CannotLoadBeanClassException: Cannot find class [foo.bar.osgi.SpringInstantiatedBean] for bean with name 'crazyClass' defined in resource loaded through InputStream; nested exception is java.lang.ClassNotFoundException: foo.bar.osgi.SpringInstantiatedBean
The full stack trace just shows to me that at the moment of resolving the beans, spring internals can't find my bean class, which is weird because I can instantiate it in my Activator with no problem, like that:
SpringInitializedBean bean = new SpringInitializedBean();
This only suggests it is a classloader problem but is it possible that the classloader for the BeanFactory can't access my classes? If so, how do I make it see my classes? In addition, here is an excerpt of my pom.xml where I configure the maven bundle plugin:
<plugin>
<groupId>org.apache.felix</groupId>
<artifactId>maven-bundle-plugin</artifactId>
<version>2.2.0</version>
<extensions>true</extensions>
<configuration>
<instructions>
<Bundle-Activator>foo.bar.osgi.Activator</Bundle-Activator>
<Export-Package>foo.bar.osgi.osgi*</Export-Package>
<Private-Package>foo.bar.osgi*</Private-Package>
<Import-Package>*</Import-Package>
<Include-Resource>src/main/resources/spring-beans.xml</Include-Resource>
</instructions>
</configuration>
</plugin>
Your problem seems to be that Spring tries to load the bean using Class.forName or similar methods. It assumes that the class is visible from the system classloader. Due to the fact that OSGi has strong separation of classes with separate classloaders for each bundle, this assumption is not true.
Where is BeanFactory located? Is it in the system classpath of the OSGi framework, or is it packaged as a bundle itself?
If it is in a bundle, you can try playing with the Import-Package: and Export-Package clauses in the manifests of the two bundles as a temporary solution.
Two cheap things to try to get some clarity:
Use a Dynamic Import It's a bit of a last resort, effectively bypassing modular classloading, but it will tell you if this is indeed your problem.
Try it in Equinox instead of Felix. Felix is a bit more strict than Equinox. I know that Spring and Equinox work fine in Virgo. Again, in itself this won't solve your problem, but it will narrow things down a bit.

Tomcat 7 - unable to load class X warnings

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?
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.
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
Check your dependencies. One (or more) of them contain META-INF/services/javax.servlet.ServletContainerInitializer file. This file contains class names of type ServletContainerInitializer. ServletContainerInitializers usually have #HandlesTypes annotation which refers classes. One of the referred classes imports/use com.sun.codemodel.JArrayClass which is not on your webapp's classpath.
This question also could be useful: Class implementing ServletContainerInitializer in web.xml
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
Modify web.xml for every war in webapps and change the web-app version to 2.5 from 3.0
or
Add metadata-complete=true to web-app tag

Resources