使用嵌入式tomcat运行spring-boot应用程序时收到错误(尚未尝试使用服务器tomcat).
java.lang.IllegalStateException: Tomcat 7 reflection failed
at org.springframework.boot.context.embedded.tomcat.SkipPatternJarScanner.scan(SkipPatternJarScanner.java:77)
at org.apache.catalina.startup.TldConfig.execute(TldConfig.java:271)
at org.apache.catalina.startup.TldConfig.lifecycleEvent(TldConfig.java:590)
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)
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:748)
Caused by: java.lang.reflect.InvocationTargetException: null
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.springframework.boot.context.embedded.tomcat.SkipPatternJarScanner.scan(SkipPatternJarScanner.java:73)
... 12 common frames omitted
Caused by: java.lang.NoClassDefFoundError: oracle/i18n/util/LocaleMapper
at oracle.xml.parser.v2.XMLReader.setEncoding(XMLReader.java:980)
at oracle.xml.parser.v2.XMLReader.checkXMLDecl(XMLReader.java:3284)
at oracle.xml.parser.v2.XMLReader.pushXMLReader(XMLReader.java:570)
at oracle.xml.parser.v2.XMLReader.pushXMLReader(XMLReader.java:274)
at oracle.xml.parser.v2.XMLParser.parse(XMLParser.java:232)
at org.apache.tomcat.util.digester.Digester.parse(Digester.java:1576)
at org.apache.catalina.startup.TldConfig.tldScanStream(TldConfig.java:565)
at org.apache.catalina.startup.TldConfig.tldScanJar(TldConfig.java:513)
at org.apache.catalina.startup.TldConfig.access$200(TldConfig.java:61)
at org.apache.catalina.startup.TldConfig$TldJarScannerCallback.scan(TldConfig.java:300)
at org.apache.tomcat.util.scan.StandardJarScanner.process(StandardJarScanner.java:259)
at org.apache.tomcat.util.scan.StandardJarScanner.scan(StandardJarScanner.java:221)
... 17 common frames omitted
Caused by: java.lang.ClassNotFoundException: oracle.i18n.util.LocaleMapper
at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:335)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
... 29 common frames omitted
经过进一步检查,似乎由ojdbc7 maven dep依赖的orai18n.jar的先前版本在vesion 11.2.0.3中包含了此类,但较新的(12.1.0.2)文件不包含该类.
解决方法:
与xmlparserv2冲突.
尝试这个 :
<dependency>
<groupId>com.oracle.jdbc</groupId>
<artifactId>ojdbc7</artifactId>
<version>12.1.0.2</version>
<exclusions>
<exclusion>
<groupId>com.oracle.jdbc</groupId>
<artifactId>xmlparserv2</artifactId>
</exclusion>
</exclusions>
</dependency>