简体   繁体   中英

Netbeans project doesn't run with Maven

I'm following this tutorial . When I build with dependencies I get the following 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

with the following error:

Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.12.2:test (default-test) on project MavenPlatformWordApp-app: There are test failures.

The error you are getting is:

Caused by: java.lang.ClassNotFoundException: org.openide.util.BaseUtilities

This means you are missing a library in your POM. In this case, it is the org-openide-util library. You need to add it to your POM like this:

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM