2

My pom.xml has ojdbc8 dependency and it pull in other dependencies like ucp, oraclepki, osdt_core, ...

When I package my project and run it as a executable jar, everything is fine! But I got FileNotFoundException about these jars when I run my project using "mvn spring-boot:run". Why and how can I get rid of this problem?

EDIT

The project is a web project using JSP. But other projects which use Thymeleaf don't have this issue and I don't know why...

EDIT 2

    17:37:01.833 WARN  StandardJarScanner.log:175 - Failed to scan [file:/D:/Lib/com/oracle/ojdbc/ojdbc8/19.3.0.0/oraclepki.jar] from classloader hierarchy
    java.io.FileNotFoundException: D:\Lib\com\oracle\ojdbc\ojdbc8\19.3.0.0\oraclepki.jar (系統找不到指定的檔案。)
            at java.util.zip.ZipFile.open(Native Method)
            at java.util.zip.ZipFile.<init>(ZipFile.java:225)
            at java.util.zip.ZipFile.<init>(ZipFile.java:155)
            at java.util.jar.JarFile.<init>(JarFile.java:166)
            at java.util.jar.JarFile.<init>(JarFile.java:130)
            at org.apache.tomcat.util.compat.JreCompat.jarFileNewInstance(JreCompat.java:177)
            at org.apache.tomcat.util.scan.JarFileUrlJar.<init>(JarFileUrlJar.java:65)
            at org.apache.tomcat.util.scan.JarFactory.newInstance(JarFactory.java:49)
            at org.apache.tomcat.util.scan.StandardJarScanner.process(StandardJarScanner.java:374)
            at org.apache.tomcat.util.scan.StandardJarScanner.processURLs(StandardJarScanner.java:309)
            at org.apache.tomcat.util.scan.StandardJarScanner.doScanClassPath(StandardJarScanner.java:266)
            at org.apache.tomcat.util.scan.StandardJarScanner.scan(StandardJarScanner.java:229)
            at org.apache.jasper.servlet.TldScanner.scanJars(TldScanner.java:262)
            at org.apache.jasper.servlet.TldScanner.scan(TldScanner.java:104)
            at org.apache.jasper.servlet.JasperInitializer.onStartup(JasperInitializer.java:83)
            at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5135)
            at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183)
            at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1384)
            at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1374)
            at java.util.concurrent.FutureTask.run(FutureTask.java:266)
            at org.apache.tomcat.util.threads.InlineExecutorService.execute(InlineExecutorService.java:75)
            at java.util.concurrent.AbstractExecutorService.submit(AbstractExecutorService.java:134)
            at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:909)
            at org.apache.catalina.core.StandardHost.startInternal(StandardHost.java:841)
            at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183)
            at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1384)
            at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1374)
            at java.util.concurrent.FutureTask.run(FutureTask.java:266)
            at org.apache.tomcat.util.threads.InlineExecutorService.execute(InlineExecutorService.java:75)
            at java.util.concurrent.AbstractExecutorService.submit(AbstractExecutorService.java:134)
            at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:909)
            at org.apache.catalina.core.StandardEngine.startInternal(StandardEngine.java:262)
            at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183)
            at org.apache.catalina.core.StandardService.startInternal(StandardService.java:421)
            at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183)
            at org.apache.catalina.core.StandardServer.startInternal(StandardServer.java:930)
            at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183)
            at org.apache.catalina.startup.Tomcat.start(Tomcat.java:459)
            at org.springframework.boot.web.embedded.tomcat.TomcatWebServer.initialize(TomcatWebServer.java:107)
            at org.springframework.boot.web.embedded.tomcat.TomcatWebServer.<init>(TomcatWebServer.java:88)
            at org.springframework.boot.web.embedded.tomcat.TomcatServletWebServerFactory.getTomcatWebServer(TomcatServletWebServerFactory.java:438)
            at org.springframework.boot.web.embedded.tomcat.TomcatServletWebServerFactory.getWebServer(TomcatServletWebServerFactory.java:191)
            at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.createWebServer(ServletWebServerApplicationContext.java:180)
            at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.onRefresh(ServletWebServerApplicationContext.java:153)
            at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:544)
            at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:141)
            at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:747)
            at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:397)
            at org.springframework.boot.SpringApplication.run(SpringApplication.java:315)
            at org.springframework.boot.SpringApplication.run(SpringApplication.java:1226)
            at org.springframework.boot.SpringApplication.run(SpringApplication.java:1215)
            at com.sundia.safetycheckinfo.SafetycheckInfoApplication.main(SafetycheckInfoApplication.java:18)

Not only this one but also 4 other jars were reported:
Failed to scan [file:/D:/Lib/com/oracle/ojdbc/oraclepki/19.3.0.0/osdt_core.jar]
Failed to scan [file:/D:/Lib/com/oracle/ojdbc/oraclepki/19.3.0.0/osdt_cert.jar]
Failed to scan [file:/D:/Lib/com/oracle/ojdbc/oraclepki/oracle.osdt/osdt_core.jar]
Failed to scan [file:/D:/Lib/com/oracle/ojdbc/oraclepki/oracle.osdt/osdt_cert.jar]

Magic
  • 149
  • 1
  • 1
  • 12
  • Did you create fat jar i.e jar with dependencies ? – Kris Swat Jun 27 '20 at 23:15
  • When I do mvn package, I think it is a fat jar and also an executable jar. But my question is about using "mvn spring-boot:run" which doesn't related to JAR packaging. – Magic Jun 28 '20 at 06:26
  • What’s the stacktrace of the FileNotFoundException? – Andy Wilkinson Jun 29 '20 at 06:19
  • as far as I understood, this is not an actual problem - these are warnings and they are shown because embedded tomcat searches for some (optional) dependencies that ojdbc8 references - there is a way to turn this auto scanning off in a separate tomcat instance, but you have to do more tweaks to turn this off in embedded tomcat. see https://stackoverflow.com/questions/45460750/tomcat-cannot-find-gdk-custom-jar-oracle-cannot-create-it – hello_earth Feb 18 '21 at 08:42

2 Answers2

1

Edit the context.xml file for Apache Tomcat, and add an entry like the following one to set the value of scanClassPath to false: <JarScanner scanClassPath="false" />

Tomerikoo
  • 18,379
  • 16
  • 47
  • 61
Dan
  • 21
  • 5
0

Spring boot has a property to disable tomcat's jar scanning as needed. In your case you would need this:

server.tomcat.additional-tld-skip-patterns=oraclepki.jar, osdt_core.jar, osdt_cert.jar

or in yaml:

server.tomcat.additional-tld-skip-patterns:
  - oraclepki.jar
  - osdt_core.jar
  - osdt_cert.jar

It also allows basic pattern matching if that's more your style.

See: https://docs.spring.io/spring-boot/docs/current/reference/html/application-properties.html#application-properties.server.server.tomcat.additional-tld-skip-patterns

Planky
  • 3,185
  • 3
  • 29
  • 39