2017-08-01 70 views
1

我在我的項目中使用Spring Boot 2.0.0.M2和Vaadin 8.1.0.rc1。由於我需要使用自定義小部件,因此我已將vaadin-client-compiler依賴項添加到我的項目中。發生的第一件奇怪事情是嵌入式Tomcat會被嵌入式Jetty自動替換。第二個問題是,我已經開始在應用程序初始化過程中得到這樣一個警告:無法從類加載器層次結構中掃描一些Jar

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和排除碼頭這樣的:

<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] 

我在Vaadin論壇上發現了一個thread,建議使用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依賴版本化?我該如何解決它?這些警告不會使應用程序失敗,但我不希望它們出現在我的啓動日誌中。

UPDATE

這裏是我的POM,應用級和全mvn spring-boot:run輸出:https://gist.github.com/dtitov/ce9c098c8aa64073b3a22d2178f9aac7

回答

2

免責聲明:也許這更適合作爲註釋,但它不適合的空間。


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的版本不匹配/問題。你使用的是Vadin 8.1.0,但是插件版本是8.0.6。您可以使用<version>${vaadin.version}</version>來同步它們。


3)由於每docs不同,Vaadin客戶端編譯器只在編譯的時候,不應與您的應用程序部署:

vaadin客戶端編譯-8 .xxjar
Vaadin客戶端編譯器是一種Java-to-JavaScript編譯器,允許構建客戶端模塊,例如服務器端應用程序所需的客戶端引擎(小部件集)。例如,需要編譯器將附加組件編譯到應用程序窗口小部件集中,如「使用Vaadin插件」中所述。

有關編譯器的詳細信息,請參閱「編譯客戶端模塊」。 請注意,您不應該使用Web應用程序部署此庫。

您可以將<scope>provided</scope>添加到依賴關係,並應該可能修復您的tomcat問題。

重要編輯:我檢查了日誌,它看起來像你甚至不需要它在你的類路徑中爲你的widgetset。該vaadin-mave-plugin用它來編譯視窗元件帷幕背後:

 
[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建議。

+0

好的,很長的回覆:) 1)感謝指向8.1.0(我已經使用'vaadin-spring-boot-starter' 2.0.1),但它沒有幫助。 2)我試着設置'提供的',甚至'編譯',但它也沒有幫助:執行'spring-boot:run'時我仍然看到這些警告。 3)提到POM中'spring-boot-starter-tomcat'的依賴關係顯然不啓用Tomcat,所以Jetty仍然被加載,我必須明確地排除它。 –

+0

@DmytroTitov沒問題。我有一個類似於你的設置,它工作得很好,很可能我們沒有使用完全相同的附加組件,並且依賴性以不同的順序定義。但是,如果在'mvn clean boot:run'之後,你仍然遇到問題,那麼POM中可能會有某些東西關閉。你能分享一個[sscce](http://sscce.org)來重現你的問題(pom,boot啓動類和基本的用戶界面)嗎? – Morfic

+0

我已經用問題更新了這個問題。 –