尝试在Netbeans上运行Vaadin Web应用程序项目,但遇到nosuchmethoderror

时间:2018-07-10 00:42:07

标签: netbeans vaadin guava glassfish-4

当前,我正在使用Glassfish 4服务器在Netbeans上开发Vaadin Web应用程序项目。服务器部署了WITHOUT错误,但是当我尝试通过项目上的链接转到另一页时(基本上我只是单击一个按钮),它会遇到以下错误:

java.lang.NoSuchMethodError: com.google.common.base.Splitter.splitToList(Ljava/lang/CharSequence;)Ljava/util/List;

在网上进行了一些研究之后,我发现以下有用的东西:

https://github.com/firebase/firebase-admin-java/issues/50

(StackOverflow上存在类似的响应)

基本上,番石榴的某种冲突版本最终出现在类路径中。在Netbeans本身上,我确保检查了我的Guava版本是否为18.0(由于我使用的是FutureCallback,所以我不能超过19.0,因为该版本在19.0之后就不再使用了),该版本应该支持splitToList。这不仅仅是来自在线验证;我从字面上看了一下Netbeans的依赖关系,找到了Splitter类,并确保该方法存在(确实如此)。

因此,我对番石榴文件冲突的怀疑使我检查了我的Maven存储库(在我的.m2文件中)。然后,我看到有多个版本:特别是10.0.0、18.0、19.0、20.0,以及最新版本(25);我以为可能是这些罪犯,所以我只删除了10.0、20.0和25(因为它们对我而言不起作用-如果我的在线研究正确无误,splitToList从15.0开始就存在)。但是,当我再次构建并运行Netbeans项目时,.m2文件夹只是重新填充了那些已删除的元素。因此,我强烈倾向于相信“两个版本的Guava最终出现在类路径中”(如第一个链接中的响应者所说)。我的检查方式只涉及两件事:

1)检查Netbeans项目上列出的依赖项,以确保正在使用guava-18.0.jar 2)验证guava-18.0是pom.xml文件中唯一使用的版本

不幸的是,这两个显然还不够,因为我仍然遇到NoSuchMethodError ...如果有人对我的方法有任何建议

1)在类路径上找到(潜在地)多个版本的Guava,并消除它们 2)采取其他措施尝试解决NoSuchMethodError

请让我知道。


上述问题的我的解决方案:

因此,我最终手动检查了所有依赖项,这很痛苦,但这仍然没有真正解释问题的产生原因,因为看起来好像Netbeans中没有显示任何Guava依赖项(右键单击任何依赖项,选择构件属性,单击类路径)是问题的来源。原来,问题出在那是glassfish jar文件...在glassfish的模块中,有一个guava.jar,对于Glassfish 4.1.2(我在该项目中使用的那个),它只是guava版本13.如上所述,SplitToList仅在版本15和更高版本中发生。为了解决这个问题,我只用.m2存储库中的最新文件替换了该jar文件(具体来说,我用guava-18.0.jar替换了它)


更新:

尝试使用mvn依赖项:树使我遇到此错误(使用mvn全新安装来构建项目会产生非常相似的输出):

lab@SIT-Dev:~/NetBeansProjects/nchandlerv2$ mvn dependency:tree
[WARNING]
[WARNING] Some problems were encountered while building the effective settings
[WARNING] 'proxies.proxy.id' must be unique but found duplicate proxy with id default @ /usr/share/maven/conf/settings.xml
[WARNING] 'proxies.proxy.id' must be unique but found duplicate proxy with id default @ /home/lab/.m2/settings.xml
[WARNING]
[INFO] Scanning for projects...
Downloading: https://repo.maven.apache.org/maven2/org/apache/maven/plugins/maven-compiler-plugin/3.2/maven-compiler-plugin-3.2.pom
Downloaded: https://repo.maven.apache.org/maven2/org/apache/maven/plugins/maven-compiler-plugin/3.2/maven-compiler-plugin-3.2.pom (12 KB at 38.8 KB/sec)
Downloading: https://repo.maven.apache.org/maven2/org/apache/maven/plugins/maven-compiler-plugin/3.2/maven-compiler-plugin-3.2.jar
Downloaded: https://repo.maven.apache.org/maven2/org/apache/maven/plugins/maven-compiler-plugin/3.2/maven-compiler-plugin-3.2.jar (45 KB at 2111.2 KB/sec)
Downloading: https://repo.maven.apache.org/maven2/org/apache/maven/plugins/maven-surefire-plugin/2.17/maven-surefire-plugin-2.17.pom
Downloaded: https://repo.maven.apache.org/maven2/org/apache/maven/plugins/maven-surefire-plugin/2.17/maven-surefire-plugin-2.17.pom (5 KB at 348.8 KB/sec)
Downloading: https://repo.maven.apache.org/maven2/org/apache/maven/surefire/surefire/2.17/surefire-2.17.pom
Downloaded: https://repo.maven.apache.org/maven2/org/apache/maven/surefire/surefire/2.17/surefire-2.17.pom (17 KB at 889.5 KB/sec)
Downloading: https://repo.maven.apache.org/maven2/org/apache/maven/plugins/maven-surefire-plugin/2.17/maven-surefire-plugin-2.17.jar
Downloaded: https://repo.maven.apache.org/maven2/org/apache/maven/plugins/maven-surefire-plugin/2.17/maven-surefire-plugin-2.17.jar (34 KB at 1671.4 KB/sec)
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building nchandlerv2 1.0-SNAPSHOT
[INFO] ------------------------------------------------------------------------
Downloading: http://maven.vaadin.com/vaadin-addons/org/opendaylight/yangtools/yang-model-util/0.8.3-Beryllium-SR3/yang-model-util-0.8.3-Beryllium-SR3.pom
Downloading: https://repo.maven.apache.org/maven2/org/opendaylight/yangtools/yang-model-util/0.8.3-Beryllium-SR3/yang-model-util-0.8.3-Beryllium-SR3.pom
[WARNING] The POM for org.opendaylight.yangtools:yang-model-util:jar:0.8.3-Beryllium-SR3 is missing, no dependency information available
Downloading: http://maven.vaadin.com/vaadin-addons/org/opendaylight/yangtools/yang-parser-api/0.8.3-Beryllium-SR3/yang-parser-api-0.8.3-Beryllium-SR3.pom
Downloading: https://repo.maven.apache.org/maven2/org/opendaylight/yangtools/yang-parser-api/0.8.3-Beryllium-SR3/yang-parser-api-0.8.3-Beryllium-SR3.pom
[WARNING] The POM for org.opendaylight.yangtools:yang-parser-api:jar:0.8.3-Beryllium-SR3 is missing, no dependency information available
Downloading: http://maven.vaadin.com/vaadin-addons/org/opendaylight/yangtools/yang-parser-impl/0.8.3-Beryllium-SR3/yang-parser-impl-0.8.3-Beryllium-SR3.pom
Downloading: https://repo.maven.apache.org/maven2/org/opendaylight/yangtools/yang-parser-impl/0.8.3-Beryllium-SR3/yang-parser-impl-0.8.3-Beryllium-SR3.pom
[WARNING] The POM for org.opendaylight.yangtools:yang-parser-impl:jar:0.8.3-Beryllium-SR3 is missing, no dependency information available
Downloading: http://maven.vaadin.com/vaadin-addons/org/opendaylight/yangtools/yang-model-api/0.8.3-Beryllium-SR3/yang-model-api-0.8.3-Beryllium-SR3.pom
Downloading: https://repo.maven.apache.org/maven2/org/opendaylight/yangtools/yang-model-api/0.8.3-Beryllium-SR3/yang-model-api-0.8.3-Beryllium-SR3.pom
[WARNING] The POM for org.opendaylight.yangtools:yang-model-api:jar:0.8.3-Beryllium-SR3 is missing, no dependency information available
Downloading: http://maven.vaadin.com/vaadin-addons/io/grpc/grpc-core/maven-metadata.xml
Downloading: https://repo.maven.apache.org/maven2/io/grpc/grpc-core/maven-metadata.xml
Downloaded: https://repo.maven.apache.org/maven2/io/grpc/grpc-core/maven-metadata.xml (2 KB at 112.2 KB/sec)
Downloading: http://maven.vaadin.com/vaadin-addons/io/netty/netty-codec-http2/maven-metadata.xml
Downloading: https://repo.maven.apache.org/maven2/io/netty/netty-codec-http2/maven-metadata.xml
Downloaded: https://repo.maven.apache.org/maven2/io/netty/netty-codec-http2/maven-metadata.xml (2 KB at 117.1 KB/sec)
Downloading: http://maven.vaadin.com/vaadin-addons/org/opendaylight/yangtools/yang-model-util/0.8.3-Beryllium-SR3/yang-model-util-0.8.3-Beryllium-SR3.jar
Downloading: http://maven.vaadin.com/vaadin-addons/org/opendaylight/yangtools/yang-parser-api/0.8.3-Beryllium-SR3/yang-parser-api-0.8.3-Beryllium-SR3.jar
Downloading: http://maven.vaadin.com/vaadin-addons/org/opendaylight/yangtools/yang-parser-impl/0.8.3-Beryllium-SR3/yang-parser-impl-0.8.3-Beryllium-SR3.jar
Downloading: http://maven.vaadin.com/vaadin-addons/org/opendaylight/yangtools/yang-model-api/0.8.3-Beryllium-SR3/yang-model-api-0.8.3-Beryllium-SR3.jar
Downloading: http://maven.vaadin.com/vaadin-addons/org/slf4j/slf4j-api/1.7.21/slf4j-api-1.7.21.jar
Downloading: http://maven.vaadin.com/vaadin-addons/org/antlr/antlr4-runtime/4.5.3/antlr4-runtime-4.5.3.jar
Downloading: https://repo.maven.apache.org/maven2/org/opendaylight/yangtools/yang-model-util/0.8.3-Beryllium-SR3/yang-model-util-0.8.3-Beryllium-SR3.jar
Downloading: https://repo.maven.apache.org/maven2/org/opendaylight/yangtools/yang-parser-impl/0.8.3-Beryllium-SR3/yang-parser-impl-0.8.3-Beryllium-SR3.jar
Downloading: https://repo.maven.apache.org/maven2/org/opendaylight/yangtools/yang-model-api/0.8.3-Beryllium-SR3/yang-model-api-0.8.3-Beryllium-SR3.jar
Downloading: https://repo.maven.apache.org/maven2/org/slf4j/slf4j-api/1.7.21/slf4j-api-1.7.21.jar
Downloading: https://repo.maven.apache.org/maven2/org/opendaylight/yangtools/yang-parser-api/0.8.3-Beryllium-SR3/yang-parser-api-0.8.3-Beryllium-SR3.jar
Downloaded: https://repo.maven.apache.org/maven2/org/slf4j/slf4j-api/1.7.21/slf4j-api-1.7.21.jar (41 KB at 786.4 KB/sec)
Downloading: https://repo.maven.apache.org/maven2/org/antlr/antlr4-runtime/4.5.3/antlr4-runtime-4.5.3.jar
Downloaded: https://repo.maven.apache.org/maven2/org/antlr/antlr4-runtime/4.5.3/antlr4-runtime-4.5.3.jar (296 KB at 3107.0 KB/sec)
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 3.715 s
[INFO] Finished at: 2018-07-10T03:22:13-07:00
[INFO] Final Memory: 20M/485M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal on project nchandlerv2: Could not resolve dependencies for project com.mycompany:nchandlerv2:war:1.0-SNAPSHOT: The following artifacts could not be resolved: org.opendaylight.yangtools:yang-model-util:jar:0.8.3-Beryllium-SR3, org.opendaylight.yangtools:yang-parser-api:jar:0.8.3-Beryllium-SR3, org.opendaylight.yangtools:yang-parser-impl:jar:0.8.3-Beryllium-SR3, org.opendaylight.yangtools:yang-model-api:jar:0.8.3-Beryllium-SR3: Could not find artifact org.opendaylight.yangtools:yang-model-util:jar:0.8.3-Beryllium-SR3 in vaadin-addons (http://maven.vaadin.com/vaadin-addons) -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/DependencyResolutionException

这对我来说特别令人困惑,因为NetBeans项目构建得很好(如前所述,它甚至可以很好地部署在服务器上);的确,在该项目的生命周期中必须解决一些依赖关系,但是现在肯定在NetBeans中,在构建该项目时不会发出类似于这些依赖关系的错误。另外,至于出现的错误(和警告),我不明白为什么会这样:

1)对于警告说某些pom文件丢失的警告,我可以在.m2文件夹内的正确子文件夹中直接看到它们。有4种这样的警告,但是我将只发布一个屏幕截图,因为它们看起来都完全相同(尽管显然名称不同)。这是yang-model-api:

enter image description here

再次,我检查了yang-model-api,yang-model-util,yang-parser-api和yang-parser-impl,它们都具有上述pom文件。

2)对于错误,这些警告与警告高度相似:jar文件都在其中,如从上一张图像中可以看到的那样。

注意:我将在项目的pom中尝试对这4个对象使用scope =提供的标记,看看它是否有作用;如果没有,我会在这里提及。

如果能帮助任何人,这是NetBeans上成功的构建输出:

cd /home/lab/NetBeansProjects/nchandlerv2; JAVA_HOME=/usr/lib/jvm/java-8-openjdk-amd64 /home/lab/.netbeans/8.1/maven/bin/mvn clean install
Scanning for projects...

------------------------------------------------------------------------
Building nchandlerv2 1.0-SNAPSHOT
------------------------------------------------------------------------

--- maven-clean-plugin:3.0.0:clean (default-clean) @ nchandlerv2 ---
Deleting /home/lab/NetBeansProjects/nchandlerv2/target
Deleting /home/lab/NetBeansProjects/nchandlerv2/src/main/webapp/VAADIN/themes (includes = [**/styles.css, **/styles.scss.cache], excludes = [])

--- vaadin-maven-plugin:8.0.4:update-theme (default) @ nchandlerv2 ---
Updating theme VAADIN/themes/mytheme
Widgetsets found from classpath:
        com.vaadin.DefaultWidgetSet in jar:file:/home/lab/.m2/repository/com/vaadin/vaadin-client/8.0.4/vaadin-client-8.0.4.jar!/
Addon styles found from classpath:

Search took 9ms
Theme "VAADIN/themes/mytheme" updated
Updating theme VAADIN/themes/adtportal
Widgetsets found from classpath:
        com.vaadin.DefaultWidgetSet in jar:file:/home/lab/.m2/repository/com/vaadin/vaadin-client/8.0.4/vaadin-client-8.0.4.jar!/
Addon styles found from classpath:

Search took 4ms
Theme "VAADIN/themes/adtportal" updated

--- vaadin-maven-plugin:8.0.4:update-widgetset (default) @ nchandlerv2 ---
GWT plugin is configured to detect modules, but none were found.
No widgetsets found - generating AppWidgetset if necessary.
Updating widgetset AppWidgetset
Adding resource directory to command classpath: /home/lab/NetBeansProjects/nchandlerv2/src/main/resources
Adding resource directory to command classpath: /home/lab/NetBeansProjects/nchandlerv2/target/generated-resources/gwt
Using com.vaadin:vaadin-client-compiler version 8.4.2
Widgetsets found from classpath:
        com.vaadin.DefaultWidgetSet in jar:file:/home/lab/.m2/repository/com/vaadin/vaadin-client/8.4.2/vaadin-client-8.4.2.jar!/
Addon styles found from classpath:

Search took 4ms

--- vaadin-maven-plugin:8.0.4:compile-theme (default) @ nchandlerv2 ---
Updating theme VAADIN/themes/mytheme
Theme "VAADIN/themes/mytheme" compiled
Updating theme VAADIN/themes/adtportal
Theme "VAADIN/themes/adtportal" compiled

--- maven-resources-plugin:2.5:resources (default-resources) @ nchandlerv2 ---
[debug] execute contextualize
Using 'UTF-8' encoding to copy filtered resources.
Copying 1 resource
Copying 0 resource

--- maven-compiler-plugin:2.3.2:compile (default-compile) @ nchandlerv2 ---
Compiling 230 source files to /home/lab/NetBeansProjects/nchandlerv2/target/classes

--- vaadin-maven-plugin:8.0.4:compile (default) @ nchandlerv2 ---
GWT plugin is configured to detect modules, but none were found.
Using com.vaadin:vaadin-client-compiler version 8.4.2

--- maven-resources-plugin:2.5:testResources (default-testResources) @ nchandlerv2 ---
[debug] execute contextualize
Using 'UTF-8' encoding to copy filtered resources.
skip non existing resourceDirectory /home/lab/NetBeansProjects/nchandlerv2/src/test/resources

--- maven-compiler-plugin:2.3.2:testCompile (default-testCompile) @ nchandlerv2 ---
Nothing to compile - all classes are up to date

--- maven-surefire-plugin:2.10:test (default-test) @ nchandlerv2 ---
No tests to run.
Surefire report directory: /home/lab/NetBeansProjects/nchandlerv2/target/surefire-reports

-------------------------------------------------------
 T E S T S
-------------------------------------------------------

Results :

Tests run: 0, Failures: 0, Errors: 0, Skipped: 0


--- maven-war-plugin:3.0.0:war (default-war) @ nchandlerv2 ---
Packaging webapp
Assembling webapp [nchandlerv2] in [/home/lab/NetBeansProjects/nchandlerv2/target/nchandlerv2-1.0-SNAPSHOT]
Processing war project
Copying webapp resources [/home/lab/NetBeansProjects/nchandlerv2/src/main/webapp]
Webapp assembled in [167 msecs]
Building war: /home/lab/NetBeansProjects/nchandlerv2/target/nchandlerv2-1.0-SNAPSHOT.war

--- maven-install-plugin:2.3.1:install (default-install) @ nchandlerv2 ---
Installing /home/lab/NetBeansProjects/nchandlerv2/target/nchandlerv2-1.0-SNAPSHOT.war to /home/lab/.m2/repository/com/mycompany/nchandlerv2/1.0-SNAPSHOT/nchandlerv2-1.0-SNAPSHOT.war
Installing /home/lab/NetBeansProjects/nchandlerv2/pom.xml to /home/lab/.m2/repository/com/mycompany/nchandlerv2/1.0-SNAPSHOT/nchandlerv2-1.0-SNAPSHOT.pom
------------------------------------------------------------------------
BUILD SUCCESS
------------------------------------------------------------------------
Total time: 10.572s
Finished at: Tue Jul 10 03:47:22 PDT 2018
Final Memory: 46M/1027M
------------------------------------------------------------------------

0 个答案:

没有答案