gpt4 book ai didi

maven - 无法从类加载器层次结构中扫描某些 Jar

转载 作者:行者123 更新时间:2023-11-28 21:57:47 26 4
gpt4 key购买 nike

我在我的项目中使用 Spring Boot 2.0.0.M2 和 Vaadin 8.1.0.rc1。由于我需要使用自定义小部件,我已将 vaadin-client-compiler 依赖项添加到我的项目中。发生的第一件奇怪的事情是嵌入式 Tomcat 自动被嵌入式 Jetty 取代。第二个问题是我在应用程序初始化期间开始收到类似这样的警告:

2017-08-01 11:07:27.822  WARN 1012 --- [           main] o.a.tomcat.util.scan.StandardJarScanner  : Failed to scan [file:/Users/mac/.m2/repository/com/vaadin/vaadin-sass-compiler/0.9.13/sac-1.3.jar] from classloader hierarchy

java.io.FileNotFoundException: /Users/mac/.m2/repository/com/vaadin/vaadin-sass-compiler/0.9.13/sac-1.3.jar (No such file or directory)
at java.util.zip.ZipFile.open(Native Method) ~[na:1.8.0_101]
at java.util.zip.ZipFile.<init>(ZipFile.java:219) ~[na:1.8.0_101]
at java.util.zip.ZipFile.<init>(ZipFile.java:149) ~[na:1.8.0_101]
at java.util.jar.JarFile.<init>(JarFile.java:166) ~[na:1.8.0_101]
at java.util.jar.JarFile.<init>(JarFile.java:130) ~[na:1.8.0_101]
at org.apache.tomcat.util.scan.JarFileUrlJar.<init>(JarFileUrlJar.java:60) ~[tomcat-embed-core-8.5.5.jar:8.5.5]
at org.apache.tomcat.util.scan.JarFactory.newInstance(JarFactory.java:43) ~[tomcat-embed-core-8.5.5.jar:8.5.5]
at org.apache.tomcat.util.scan.StandardJarScanner.process(StandardJarScanner.java:327) ~[tomcat-embed-core-8.5.5.jar:8.5.5]
at org.apache.tomcat.util.scan.StandardJarScanner.scan(StandardJarScanner.java:277) ~[tomcat-embed-core-8.5.5.jar:8.5.5]
at org.apache.jasper.servlet.TldScanner.scanJars(TldScanner.java:262) [apache-jsp-8.5.9.1.jar:2.3]
at org.apache.jasper.servlet.TldScanner.scan(TldScanner.java:104) [apache-jsp-8.5.9.1.jar:2.3]
at org.apache.jasper.servlet.JasperInitializer.onStartup(JasperInitializer.java:101) [apache-jsp-8.5.9.1.jar:2.3]
at org.springframework.boot.web.embedded.jetty.JasperInitializer.doStart(JasperInitializer.java:91) [spring-boot-2.0.0.M2.jar:2.0.0.M2]
at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:68) [jetty-util-9.4.6.v20170531.jar:9.4.6.v20170531]
at org.eclipse.jetty.util.component.ContainerLifeCycle.start(ContainerLifeCycle.java:131) [jetty-util-9.4.6.v20170531.jar:9.4.6.v20170531]
at org.eclipse.jetty.util.component.ContainerLifeCycle.doStart(ContainerLifeCycle.java:105) [jetty-util-9.4.6.v20170531.jar:9.4.6.v20170531]
at org.eclipse.jetty.server.handler.AbstractHandler.doStart(AbstractHandler.java:113) [jetty-server-9.4.6.v20170531.jar:9.4.6.v20170531]
at org.eclipse.jetty.server.handler.ScopedHandler.doStart(ScopedHandler.java:120) [jetty-server-9.4.6.v20170531.jar:9.4.6.v20170531]
at org.eclipse.jetty.server.handler.ContextHandler.startContext(ContextHandler.java:844) [jetty-server-9.4.6.v20170531.jar:9.4.6.v20170531]
at org.eclipse.jetty.servlet.ServletContextHandler.startContext(ServletContextHandler.java:344) [jetty-servlet-9.4.6.v20170531.jar:9.4.6.v20170531]
at org.eclipse.jetty.webapp.WebAppContext.startWebapp(WebAppContext.java:1501) [jetty-webapp-9.4.6.v20170531.jar:9.4.6.v20170531]
at org.eclipse.jetty.webapp.WebAppContext.startContext(WebAppContext.java:1463) [jetty-webapp-9.4.6.v20170531.jar:9.4.6.v20170531]
at org.eclipse.jetty.server.handler.ContextHandler.doStart(ContextHandler.java:785) [jetty-server-9.4.6.v20170531.jar:9.4.6.v20170531]
at org.eclipse.jetty.servlet.ServletContextHandler.doStart(ServletContextHandler.java:261) [jetty-servlet-9.4.6.v20170531.jar:9.4.6.v20170531]
at org.eclipse.jetty.webapp.WebAppContext.doStart(WebAppContext.java:545) [jetty-webapp-9.4.6.v20170531.jar:9.4.6.v20170531]
at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:68) [jetty-util-9.4.6.v20170531.jar:9.4.6.v20170531]
at org.eclipse.jetty.util.component.ContainerLifeCycle.start(ContainerLifeCycle.java:131) [jetty-util-9.4.6.v20170531.jar:9.4.6.v20170531]
at org.eclipse.jetty.server.Server.start(Server.java:452) [jetty-server-9.4.6.v20170531.jar:9.4.6.v20170531]
at org.eclipse.jetty.util.component.ContainerLifeCycle.doStart(ContainerLifeCycle.java:105) [jetty-util-9.4.6.v20170531.jar:9.4.6.v20170531]
at org.eclipse.jetty.server.handler.AbstractHandler.doStart(AbstractHandler.java:113) [jetty-server-9.4.6.v20170531.jar:9.4.6.v20170531]
at org.eclipse.jetty.server.Server.doStart(Server.java:419) [jetty-server-9.4.6.v20170531.jar:9.4.6.v20170531]
at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:68) [jetty-util-9.4.6.v20170531.jar:9.4.6.v20170531]
at org.springframework.boot.web.embedded.jetty.JettyWebServer.initialize(JettyWebServer.java:103) [spring-boot-2.0.0.M2.jar:2.0.0.M2]
at org.springframework.boot.web.embedded.jetty.JettyWebServer.<init>(JettyWebServer.java:81) [spring-boot-2.0.0.M2.jar:2.0.0.M2]
at org.springframework.boot.web.embedded.jetty.JettyServletWebServerFactory.getJettyWebServer(JettyServletWebServerFactory.java:537) [spring-boot-2.0.0.M2.jar:2.0.0.M2]
at org.springframework.boot.web.embedded.jetty.JettyServletWebServerFactory.getWebServer(JettyServletWebServerFactory.java:175) [spring-boot-2.0.0.M2.jar:2.0.0.M2]
at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.createWebServer(ServletWebServerApplicationContext.java:161) [spring-boot-2.0.0.M2.jar:2.0.0.M2]
at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.onRefresh(ServletWebServerApplicationContext.java:134) [spring-boot-2.0.0.M2.jar:2.0.0.M2]
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:536) [spring-context-5.0.0.RC2.jar:5.0.0.RC2]
at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:122) [spring-boot-2.0.0.M2.jar:2.0.0.M2]
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:750) [spring-boot-2.0.0.M2.jar:2.0.0.M2]
at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:386) [spring-boot-2.0.0.M2.jar:2.0.0.M2]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:327) [spring-boot-2.0.0.M2.jar:2.0.0.M2]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1245) [spring-boot-2.0.0.M2.jar:2.0.0.M2]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1233) [spring-boot-2.0.0.M2.jar:2.0.0.M2]

仍然应用程序正常工作:我只是想摆脱这些警告。所以我决定退回 Tomcat 而不是 Jetty,并像这样排除 Jetty:

<dependency>
<groupId>com.vaadin</groupId>
<artifactId>vaadin-client-compiler</artifactId>
<version>${vaadin.version}</version>
<exclusions>
<exclusion>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-server</artifactId>
</exclusion>
</exclusions>
</dependency>

完成后,警告并没有消失,而是发生了一点变化:

java.io.FileNotFoundException: /Users/mac/.m2/repository/com/vaadin/vaadin-sass-compiler/0.9.13/sac-1.3.jar (No such file or directory)
at java.util.zip.ZipFile.open(Native Method) ~[na:1.8.0_101]
at java.util.zip.ZipFile.<init>(ZipFile.java:219) ~[na:1.8.0_101]
at java.util.zip.ZipFile.<init>(ZipFile.java:149) ~[na:1.8.0_101]
at java.util.jar.JarFile.<init>(JarFile.java:166) ~[na:1.8.0_101]
at java.util.jar.JarFile.<init>(JarFile.java:130) ~[na:1.8.0_101]
at org.apache.tomcat.util.scan.JarFileUrlJar.<init>(JarFileUrlJar.java:60) ~[tomcat-embed-core-8.5.15.jar:8.5.15]
at org.apache.tomcat.util.scan.JarFactory.newInstance(JarFactory.java:49) ~[tomcat-embed-core-8.5.15.jar:8.5.15]
at org.apache.tomcat.util.scan.StandardJarScanner.process(StandardJarScanner.java:338) ~[tomcat-embed-core-8.5.15.jar:8.5.15]
at org.apache.tomcat.util.scan.StandardJarScanner.scan(StandardJarScanner.java:288) ~[tomcat-embed-core-8.5.15.jar:8.5.15]
at org.apache.jasper.servlet.TldScanner.scanJars(TldScanner.java:262) [apache-jsp-8.5.9.1.jar:2.3]
at org.apache.jasper.servlet.TldScanner.scan(TldScanner.java:104) [apache-jsp-8.5.9.1.jar:2.3]
at org.apache.jasper.servlet.JasperInitializer.onStartup(JasperInitializer.java:101) [apache-jsp-8.5.9.1.jar:2.3]
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5196) [tomcat-embed-core-8.5.15.jar:8.5.15]
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150) [tomcat-embed-core-8.5.15.jar:8.5.15]
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1419) [tomcat-embed-core-8.5.15.jar:8.5.15]
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1409) [tomcat-embed-core-8.5.15.jar:8.5.15]
at java.util.concurrent.FutureTask.run(FutureTask.java:266) [na:1.8.0_101]
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) [na:1.8.0_101]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) [na:1.8.0_101]
at java.lang.Thread.run(Thread.java:745) [na:1.8.0_101]

我找到了 thread在 Vaadin 论坛上建议使用 8.0.32 版本的 Tomcat 来修复它。当我切换到它时,应用程序完全停止工作:

Caused by: java.lang.ClassNotFoundException: org.apache.juli.WebappProperties
at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
... 29 more

然后我发现一些其他线程建议使用 Tomcat 8.5.5,因为它有一些修复(不记得线程的 URL)。我试过 8.5.5:警告回来了。然后我也尝试了 8.5.19 甚至 9.0.0.M25,结果相同。

那么问题出在哪里:Spring、Tomcat、Vaadin 或 Maven 依赖项版本控制?我该如何解决?这些警告不会使应用程序失败,但我不希望它们出现在我的启动日志中。

更新

这是我的 POM、应用程序类和完整的 mvn spring-boot:run 输出:https://gist.github.com/dtitov/ce9c098c8aa64073b3a22d2178f9aac7

最佳答案

免责声明:这可能更适合作为评论,但不适合这个空间。


1) 您可以使用稳定的 Vaadin 8.1.0vaadin-spring-boot-starter 2.0.1 . Vaadin 模块版本由 vaadin-bom 管理(${vaadin.version} 是我的 pom 中的一个属性,值为 8.1.0):

<dependencyManagement>
<dependencies>
<dependency>
<groupId>com.vaadin</groupId>
<artifactId>vaadin-bom</artifactId>
<version>${vaadin.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>

在此之后,每次更改 Vaadin 版本时都不需要更改它们的版本(除非您确实需要使用特定版本):

<dependency>
<groupId>com.vaadin</groupId>
<artifactId>vaadin-spring-boot-starter</artifactId>
</dependency>

2) 你应该使用相同的 vaadin-maven-plugin作为您的 Vaadin 版本以避免 widgetset 版本不匹配/问题。您使用的是 Vaadin 8.1.0,但插件版本是 8.0.6。您可以使用 <version>${vaadin.version}</version>同步它们。


3) 根据 docs , vaadin-client-compiler 仅在编译时使用,不应与您的应用程序一起部署:

vaadin-client-compiler-8.x.x.jar
The Vaadin Client Compiler is a Java-to-JavaScript compiler that allows building client-side modules, such as the Client-Side Engine (widget set) required for server-side applications. The compiler is needed, for example, for compiling add-on components to the application widget set, as described in "Using Vaadin Add-ons".

For detailed information regarding the compiler, see "Compiling a Client-Side Module". Note that you should not deploy this library with a web application.

您可以添加 <scope>provided</scope>依赖关系,这应该可以解决您的 tomcat 问题。

重要编辑:我检查了日志,看起来您甚至不需要在您的 widgetset 的类路径中使用它。 vaadin-maven-plugin用它编译你的 widgetset在幕后:

[INFO] --- vaadin-maven-plugin:8.1.0:compile (default) @ test ---[INFO] Using com.vaadin:vaadin-client-compiler version 8.1.0[INFO] Compiling module MyCustomWidgetSet[INFO]    Computing all possible rebind results for 'com.vaadin.client.metadata.ConnectorBundleLoader'...

删除它后,一切都按预期进行。不完全确定,但可能只需要 certain add-ons or the vaadin-maven-plugin .到目前为止我不需要写任何东西,所以也许真正需要它的人可以提供更多见解。


4) 您还可以删除 vaadin-client-compiled按照相同的 docs建议。

关于maven - 无法从类加载器层次结构中扫描某些 Jar,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45433927/

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