Netbeans项目不能与Maven一起运行

时间:2015-10-14 17:13:55

标签: java maven netbeans

我正在关注this tutorial。 当我使用依赖项构建时,我得到以下stacktrace:

Test set: com.mycompany.mavenplatformwordapp.ApplicationTest
Tests run: 1, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 0.75 sec <<< FAILURE!
org.netbeans.junit.NbModuleSuite$S@679bde(org.netbeans.junit.NbModuleSuite$S)  Time elapsed: 0.721 sec  <<< ERROR!
java.lang.reflect.InvocationTargetException
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:497)
    at org.netbeans.junit.NbModuleSuite$S.runInRuntimeContainer(NbModuleSuite.java:915)
    at org.netbeans.junit.NbModuleSuite$S.access$100(NbModuleSuite.java:670)
    at org.netbeans.junit.NbModuleSuite$S$1.protect(NbModuleSuite.java:691)
    at junit.framework.TestResult.runProtected(TestResult.java:142)
    at org.netbeans.junit.NbModuleSuite$S.run(NbModuleSuite.java:687)
    at org.junit.internal.runners.JUnit38ClassRunner.run(JUnit38ClassRunner.java:86)
    at org.apache.maven.surefire.junit4.JUnit4Provider.execute(JUnit4Provider.java:252)
    at org.apache.maven.surefire.junit4.JUnit4Provider.executeTestSet(JUnit4Provider.java:141)
    at org.apache.maven.surefire.junit4.JUnit4Provider.invoke(JUnit4Provider.java:112)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:497)
    at org.apache.maven.surefire.util.ReflectionUtils.invokeMethodWithArray(ReflectionUtils.java:189)
    at org.apache.maven.surefire.booter.ProviderFactory$ProviderProxy.invoke(ProviderFactory.java:165)
    at org.apache.maven.surefire.booter.ProviderFactory.invokeProvider(ProviderFactory.java:85)
    at org.apache.maven.surefire.booter.ForkedBooter.runSuitesInProcess(ForkedBooter.java:113)
    at org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:75)
Caused by: java.lang.NoClassDefFoundError: org/openide/util/BaseUtilities
    at org.openide.util.Utilities.isUnix(Utilities.java:313)
    at org.openide.util.Utilities.<clinit>(Utilities.java:222)
    at org.netbeans.JarClassLoader$JarSource.toURI(JarClassLoader.java:467)
    at org.netbeans.JarClassLoader$JarSource.<init>(JarClassLoader.java:438)
    at org.netbeans.JarClassLoader$Source.create(JarClassLoader.java:387)
    at org.netbeans.JarClassLoader.<init>(JarClassLoader.java:157)
    at org.netbeans.JarClassLoader.<init>(JarClassLoader.java:141)
    at org.netbeans.MainImpl$BootClassLoader.<init>(MainImpl.java:256)
    at org.netbeans.MainImpl.execute(MainImpl.java:175)
    at org.netbeans.MainImpl.main(MainImpl.java:85)
    at org.netbeans.Main.main(Main.java:78)
    ... 22 more
Caused by: java.lang.ClassNotFoundException: org.openide.util.BaseUtilities
    at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
    ... 33 more

出现以下错误:

  

无法在项目MavenPlatformWordApp-app上执行目标org.apache.maven.plugins:maven-surefire-plugin:2.12.2:test(default-test):有测试失败。

1 个答案:

答案 0 :(得分:0)

您收到的错误是:

  

引起:java.lang.ClassNotFoundException:org.openide.util.BaseUtilities

这意味着您缺少POM中的库。在这种情况下,它是org-openide-util库。您需要将它添加到您的POM中:

<dependency>
    <groupId>org.netbeans.api</groupId>
    <artifactId>org-openide-util</artifactId>
    <version>RELEASE802</version> <!-- change to match your NetBeans version -->
</dependency>