gpt4 book ai didi

java - Tomcat TLD 扫描上的 ClassNotFoundException oracle.i18n.util.LocaleMapper。 ojdbc7 maven dep (xmlparserv2-12.1.0.2.jar transitive) 导致这个错误

转载 作者:行者123 更新时间:2023-11-30 06:48:03 32 4
gpt4 key购买 nike

我在使用 embedded-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 的先前版本在版本 11.2.0.3 中包含此类,但较新的 (12.1.0.2) 文件不包含它。

最佳答案

经过许多麻烦,我找到了根本原因(编辑:实际上提供的更好的答案有更合适的原因/解决方案,请参阅 Serri 的回答):

根据 this bug comment in spring-boot神谕 SaxParserFactory impl 和(后来解决了第一个之后遇到)DocumentBuilderFactory选择实现而不是默认的 xerces impls。使用 META-INF/services/<class-name> 更改实现文件解决了问题:

my.jar :

enter image description here

和每个文件:

// javax.xml.parsers.DocumentBuilderFactory
com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderFactoryImpl

// javax.xml.parsers.SAXParserFactory
com.sun.org.apache.xerces.internal.jaxp.SAXParserFactoryImpl

这会导致每个服务查找器解析标准 Java 库中的默认 xerces 实现。

关于java - Tomcat TLD 扫描上的 ClassNotFoundException oracle.i18n.util.LocaleMapper。 ojdbc7 maven dep (xmlparserv2-12.1.0.2.jar transitive) 导致这个错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44916255/

32 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com