In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-09 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/02 Report--
Description of phenomenon:
The project uses springboot to start a web project. During the startup phase, you see an exception "1.10.3-1.4.3\hdf5.jar system cannot find the specified file" in the console. Although these exceptions do not affect the normal operation of the project, as a rigorous technician, seeing these exceptions is like seeing enemies. You must get rid of them quickly.
java. io. FileNotFoundException: D:\.m2\repository\org\bytedeco\javacpp-presets\hdf5-platform\1.10.3-1.4.3\hdf5.jar (The specified file was not found.) at java.util.zip.ZipFile.open(Native Method) at java.util.zip.ZipFile. (ZipFile.java:225) at java.util.zip.ZipFile. (ZipFile.java:155) at java.util.jar.JarFile. (JarFile.java:166) at java.util.jar.JarFile. (JarFile.java:130) at org.apache.tomcat.util.compat.JreCompat.jarFileNewInstance(JreCompat.java:188) at org.apache.tomcat.util.scan.JarFileUrlJar. (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: 101) at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5204) at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150) at org.apache.catalina.core.ContainerBase$www.example.com (ContainerBase.java:1421) at org.apache.catalina.core.ContainerBase$www.example.com (ContainerBase.java:1411) at www.example.com $$$capture(www.example.com:266) at java.util.concurrent.FutureTask.run StartChild.call 08.303 WARN 16940---[ost-startStop-1] o. a. tomcat. util. scan. StandardJarScanner: Failed to scan [file:/D:/.m2/repository/org/bytedeco/javacpp-presets/hdf5-platform/1.10.3-1.4.3/hdf5-linux-x86.jar] from classloader hierarchy yjava. io. FileNotFoundException: D:\.m2\repository\org\bytedeco\javacpp-presets\hdf5-platform\1.10.3-1.4.3\hdf5-linux-x86.jar 2019 - 03 - 29 18:09: 08.578 WARN 16940---[ost-startStop-1] o. a. tomcat. util. scan. StandardJarScanner: Failed to scan [file:/D:/.m2/repository/org/bytedeco/javacpp-presets/hdf5-platform/1.10.3-1.4.3/hdf@-linux-x86_64.jar] from classloader hierarchyjava. io. FileNotFoundException: D:\.m2\repository\org\bytedeco\javacpp-presets\hdf5-platform\1.10.3-1.4.3\hdf5-linux-x86_64.jar (The system could not find the specified file.)
Description of project environment
tomcat:Dependency management using springboot built-in version 8.5.29 using Maven springboot version 2.0.1 spring framework version 5.0.5 project references Deep Learn 4 Java org.deeplearning4j deeplearning 4j-core 1.0.0-beta3
problematic jar dependency
tracking analysis
Since it is an error reported in the startup phase, then find the startup class to add a breakpoint, step by step track which phase reported the error, and then analyze the cause of the error. I followed the springboot code and found the jar loading location. The main classes and methods are as follows:
Tracking class org.apache.tomcat.util.scan.StandardJarScanner
Method doScanClassPath (...)
This method iterates over all classloaders and loads jar packages in each classloader
The red part of the icon is the key code. The variable classPathUrlsToProcess stores all the jar information to be loaded, mainly the jar package path information. We can see that this is the same as the jar package we saw in maven.
Method processURLs (...)
This method stacks all jars of the current classloader, that is, classPathUrlsToProcess, and then processes each jar package. Key codes are shown below.
method (process)
This method loads and analyzes each jar, focusing on
processManifest(jar, isWebapp, classPathUrlsToProcess)
Method processManifest
This method will process the Manifest file in the jar, separate the Class-Path in the Manifest file, and insert the contents into classPathUrlsToProcess as a new dependent jar (the processURLs method will load the jars in it according to the stack result)
cause analysis
In fact, the problem is the classpath in the manifest file. Through analyzing the code, we know that tomcat not only loads the jar packages managed by our maven, but also analyzes the manifest file in the jar. If there is classpath, he will add the contents to the jar package dependency and load these jar packages.
Let's open the manifest file where hdf 5 - 1.10.3 - 1.4.3.jar is as an example to see where the error is.
You notice that there is no, the jar package here has no path and no version number, which causes tomcat to load according to the path hdf 5 - 1.10.3 - 1.4.3.jar.
However, these jars do not exist in the corresponding positions in our project, which also leads to the exception that jar cannot be found. We actually have these jars in our project, but the paths and names are different. On the left side of the figure above, you can see that these jars are already in maven, but the version number is added after the name, and the path is in the respective maven repository.
Now that we have figured out the cause of the problem, let's consider how to solve it.
solutions
Option 1:
Remove the classpath from the Manifest or delete the Manifest file to avoid loading jar packages that do not exist. But each time maven updates, it may overwrite your changes, causing the exception to reappear.
Option 2:
Follow the path of loading prompt, copy the corresponding jar package and rename it to remove the version number, but this will cause jar redundancy, and the same jar will load two.
Option 3:
Downgrade tomcat version to use version 8.5.0 or below. 8.5.0 The manifest is not loaded for analysis in the release, so our exception does not occur.
programme IV
Add a code setting that doesn't scan Manifests.
@Bean public TomcatServletWebServerFactory tomcatFactory() { return new TomcatServletWebServerFactory() { @Override protected void postProcessContext(Context context) { ((StandardJarScanner) context.getJarScanner()).setScanManifest(false); } }; }
Summary:
The above is all the content of this article, I hope the content of this article for everyone's study or work has a certain reference learning value, thank you for your support.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.