Java jUnit Birt ClassNotFoundException: org.eclipse.osgi.util.NLS
Java jUnit Birt ClassNotFoundException: org.eclipse.osgi.util.NLS
当我尝试使用 Birt 创建 .pdf 文件时,出现以下 ClassNotFoundException 异常:
我使用 jUnit 来测试我的代码。在处女座一切正常,但 jUnit 不行。
java.lang.NoClassDefFoundError: org/eclipse/osgi/util/NLS
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:760)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
at java.net.URLClassLoader.defineClass(URLClassLoader.java:455)
at java.net.URLClassLoader.access0(URLClassLoader.java:73)
at java.net.URLClassLoader.run(URLClassLoader.java:367)
at java.net.URLClassLoader.run(URLClassLoader.java:361)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:360)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
at org.eclipse.core.runtime.Platform.<clinit>(Platform.java:433)
at org.eclipse.birt.core.framework.jar.ServicePlatform.getExtensionRegistry(ServicePlatform.java:72)
at org.eclipse.birt.core.framework.jar.ServicePlatform.createFactoryObject(ServicePlatform.java:98)
at org.eclipse.birt.core.framework.Platform.run(Platform.java:297)
at java.security.AccessController.doPrivileged(Native Method)
at org.eclipse.birt.core.framework.Platform.createFactoryObject(Platform.java:293)
...
Caused by: java.lang.ClassNotFoundException: org.eclipse.osgi.util.NLS
at java.net.URLClassLoader.run(URLClassLoader.java:372)
at java.net.URLClassLoader.run(URLClassLoader.java:361)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:360)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
... 44 more
在我将它添加到我的 pom.xml 之后(在带有 jUnit-test 的项目中)一切正常:
<dependency>
<groupId>org.eclipse.birt.runtime</groupId>
<artifactId>org.eclipse.birt.runtime</artifactId>
<version>4.3.0</version>
<exclusions>
<exclusion>
<groupId>org.eclipse.birt.runtime</groupId>
<artifactId>org.apache.poi</artifactId>
</exclusion>
</exclusions>
<scope>test</scope>
</dependency>
当我尝试使用 Birt 创建 .pdf 文件时,出现以下 ClassNotFoundException 异常:
我使用 jUnit 来测试我的代码。在处女座一切正常,但 jUnit 不行。
java.lang.NoClassDefFoundError: org/eclipse/osgi/util/NLS
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:760)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
at java.net.URLClassLoader.defineClass(URLClassLoader.java:455)
at java.net.URLClassLoader.access0(URLClassLoader.java:73)
at java.net.URLClassLoader.run(URLClassLoader.java:367)
at java.net.URLClassLoader.run(URLClassLoader.java:361)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:360)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
at org.eclipse.core.runtime.Platform.<clinit>(Platform.java:433)
at org.eclipse.birt.core.framework.jar.ServicePlatform.getExtensionRegistry(ServicePlatform.java:72)
at org.eclipse.birt.core.framework.jar.ServicePlatform.createFactoryObject(ServicePlatform.java:98)
at org.eclipse.birt.core.framework.Platform.run(Platform.java:297)
at java.security.AccessController.doPrivileged(Native Method)
at org.eclipse.birt.core.framework.Platform.createFactoryObject(Platform.java:293)
...
Caused by: java.lang.ClassNotFoundException: org.eclipse.osgi.util.NLS
at java.net.URLClassLoader.run(URLClassLoader.java:372)
at java.net.URLClassLoader.run(URLClassLoader.java:361)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:360)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
... 44 more
在我将它添加到我的 pom.xml 之后(在带有 jUnit-test 的项目中)一切正常:
<dependency>
<groupId>org.eclipse.birt.runtime</groupId>
<artifactId>org.eclipse.birt.runtime</artifactId>
<version>4.3.0</version>
<exclusions>
<exclusion>
<groupId>org.eclipse.birt.runtime</groupId>
<artifactId>org.apache.poi</artifactId>
</exclusion>
</exclusions>
<scope>test</scope>
</dependency>