代码之家  ›  专栏  ›  技术社区  ›  Snæbjørn

oracle ojdbc驱动程序抛出noclassdeffounderror:oracle/i18n/util/localemapper

  •  0
  • Snæbjørn  · 技术社区  · 6 年前

    当在tomcat 8.5服务器(不是嵌入式tomcat)上运行时,在我的spring引导项目中使用oracleojdbc驱动程序时,我得到了以下错误

    noclassdeffounderror:oracle/i18n/util/localemapper

    如果我使用嵌入式tomcat运行它,一切都会正常工作。不幸的是,我需要它在一个外部容器上运行(我想它被调用了)

    我的项目是从 https://start.spring.io/

    start spring

    除了Oracle驱动程序之外,其他都是默认的。

    build.gradle公司

    buildscript {
        ext {
            springBootVersion = '2.0.2.RELEASE'
        }
        repositories {
            mavenCentral()
        }
        dependencies {
            classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}")
        }
    }
    
    apply plugin: 'java'
    apply plugin: 'eclipse-wtp'
    apply plugin: 'org.springframework.boot'
    apply plugin: 'io.spring.dependency-management'
    apply plugin: 'war'
    
    group = 'com.example'
    version = '0.0.1-SNAPSHOT'
    sourceCompatibility = 1.8
    
    repositories {
        mavenCentral()
    
        maven {
          credentials {
            username = oracleUser
            password = oraclePass
        }
       url 'https://www.oracle.com/content/secure/maven/content'
      }
    }
    
    configurations {
        providedRuntime
    }
    
    dependencies {
        compile('org.springframework.boot:spring-boot-starter-web')
        compile('com.oracle.jdbc:ojdbc8:12.2.0.1')
        providedRuntime('org.springframework.boot:spring-boot-starter-tomcat')
        testCompile('org.springframework.boot:spring-boot-starter-test')
    }
    

    堆栈跟踪

    SEVERE: A child container failed during start
    java.util.concurrent.ExecutionException: org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Catalina].StandardHost[localhost].StandardContext[/centralized-sourcing-backend]]
        at java.util.concurrent.FutureTask.report(FutureTask.java:122)
        at java.util.concurrent.FutureTask.get(FutureTask.java:192)
        at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:939)
        at org.apache.catalina.core.StandardHost.startInternal(StandardHost.java:872)
        at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
        at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1419)
        at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1409)
        at java.util.concurrent.FutureTask.run(FutureTask.java:266)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
        at java.lang.Thread.run(Thread.java:748)
    Caused by: org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Catalina].StandardHost[localhost].StandardContext[/centralized-sourcing-backend]]
        at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:167)
        ... 6 more
    Caused by: java.lang.NoClassDefFoundError: oracle/i18n/util/LocaleMapper
        at oracle.xml.parser.v2.XMLReader.setEncoding(XMLReader.java:990)
        at oracle.xml.parser.v2.XMLReader.checkXMLDecl(XMLReader.java:3542)
        at oracle.xml.parser.v2.XMLReader.pushXMLReader(XMLReader.java:580)
        at oracle.xml.parser.v2.XMLReader.pushXMLReader(XMLReader.java:284)
        at oracle.xml.parser.v2.XMLParser.parse(XMLParser.java:243)
        at org.apache.tomcat.util.digester.Digester.parse(Digester.java:1458)
        at org.apache.tomcat.util.descriptor.web.WebXmlParser.parseWebXml(WebXmlParser.java:119)
        at org.apache.tomcat.util.descriptor.web.FragmentJarScannerCallback.scan(FragmentJarScannerCallback.java:77)
        at org.apache.tomcat.util.scan.StandardJarScanner.process(StandardJarScanner.java:342)
        at org.apache.tomcat.util.scan.StandardJarScanner.scan(StandardJarScanner.java:193)
        at org.apache.catalina.startup.ContextConfig.processJarsForWebFragments(ContextConfig.java:1898)
        at org.apache.catalina.startup.ContextConfig.webConfig(ContextConfig.java:1126)
        at org.apache.catalina.startup.ContextConfig.configureStart(ContextConfig.java:775)
        at org.apache.catalina.startup.ContextConfig.lifecycleEvent(ContextConfig.java:299)
        at org.apache.catalina.util.LifecycleBase.fireLifecycleEvent(LifecycleBase.java:94)
        at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5114)
        at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
        ... 6 more
    Caused by: java.lang.ClassNotFoundException: oracle.i18n.util.LocaleMapper
        at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1285)
        at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1119)
        ... 23 more
    

    我正在像这样运行spring工具套件(sts)的项目

    run

    我发现其他人也有同样的问题,比如

    但我不知道他们在说什么。这是第一次使用Java和Spring、Oracle和Eclipse:

    1 回复  |  直到 6 年前
        1
  •  0
  •   Snæbjørn    6 年前

    解决办法是按照建议去做 here 不要试图去理解它。 把一些神奇的文件放在一个神奇的地方( src/main/resources/META-INF/services/ )当它开始工作时:/