0
我在maven項目中有這樣的依賴關係。並使用OpenEJB的測試EJB豆OpenEJB NoClassDefFoundError
<dependency>
<groupId>net.sf.jasperreports</groupId>
<artifactId>jasperreports</artifactId>
<version>${jasperreports.version}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.apache.openejb</groupId>
<artifactId>openejb-junit</artifactId>
<version>${openejb-junit.version}</version>
<scope>test</scope>
<exclusions>
<exclusion>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-jdk14</artifactId>
</exclusion>
</exclusions>
</dependency>
我的測試IReportService
@RunWith(EJBContainerRunner.class)
public class ReportFacadeBeanTest {
@EJB
private IReportService iReportService;
@Test
public void testPrintReport() throws Exception {
Asserts.assertNotNull(iReportService);
}
}
當我嘗試運行測試我有錯誤
java.lang.NoClassDefFoundError: net/sf/jasperreports/engine/JRDataSource
at java.lang.Class.getDeclaredMethods0(Native Method)
at java.lang.Class.privateGetDeclaredMethods(Class.java:2701)
at java.lang.Class.privateGetPublicMethods(Class.java:2902)
at java.lang.Class.getMethods(Class.java:1615)
at org.apache.openejb.config.AnnotationDeployer$ProcessAnnotatedBeans.processApplicationExceptions(AnnotationDeployer.java:2873)
at org.apache.openejb.config.AnnotationDeployer$ProcessAnnotatedBeans.deploy(AnnotationDeployer.java:2383)
at org.apache.openejb.config.AnnotationDeployer$ProcessAnnotatedBeans.deploy(AnnotationDeployer.java:1819)
at org.apache.openejb.config.AnnotationDeployer.deploy(AnnotationDeployer.java:360)
at org.apache.openejb.config.ConfigurationFactory$Chain.deploy(ConfigurationFactory.java:403)
at org.apache.openejb.config.ConfigurationFactory.configureApplication(ConfigurationFactory.java:971)
at org.apache.openejb.OpenEjbContainer$Provider.createEJBContainer(OpenEjbContainer.java:364)
at javax.ejb.embeddable.EJBContainer.createEJBContainer(EJBContainer.java:77)
at org.apache.openejb.junit.jee.statement.StartingStatement.before(StartingStatement.java:96)
at org.apache.openejb.junit.jee.statement.DecoratingStatement.evaluate(DecoratingStatement.java:30)
at org.apache.openejb.junit.jee.statement.DecoratingStatement.evaluate(DecoratingStatement.java:32)
at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
at org.junit.runner.JUnitCore.run(JUnitCore.java:137)
at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:68)
at com.intellij.rt.execution.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:51)
at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:242)
at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:70)
Caused by: java.lang.ClassNotFoundException: net.sf.jasperreports.engine.JRDataSource
at org.apache.openejb.core.TempClassLoader.loadClass(TempClassLoader.java:176)
at org.apache.openejb.core.TempClassLoader.loadClass(TempClassLoader.java:80)
... 21 more
當我改變範圍內的所有做工精細=(
如何運行測試範圍 - 提供?我不'想要使用編譯