I'm currently in the process of adding the Jasper API to our project, and I've made a JUnit-test to test the connection. Our Maven project architecture is one parent project, with a few inner projects.
I've added the dependencies I need for jasper to the parent pom:
<dependencyManagement>
<dependencies>
...
<dependency>
<groupId>com.jaspersoft.jasperserver</groupId>
<artifactId>jasperserver-common-ws</artifactId>
<version>5.5.0</version>
</dependency>
<dependency>
<groupId>com.jaspersoft.jasperserver</groupId>
<artifactId>jasperserver-ireport-plugin</artifactId>
<version>3.0.0</version>
</dependency>
</dependencies>
</dependencyManagement>
And I've added it to the inner project that requires the jasper dependencies for its unit test:
<dependencies>
...
<dependency>
<groupId>com.jaspersoft.jasperserver</groupId>
<artifactId>jasperserver-common-ws</artifactId>
</dependency>
<dependency>
<groupId>com.jaspersoft.jasperserver</groupId>
<artifactId>jasperserver-ireport-plugin</artifactId>
</dependency>
</dependencies>
After I've done a Maven Update; Maven clean install; and Project built & refresh, I try to execute the UnitTest:
package jasper;
import org.junit.Assert;
import org.junit.Test;
import com.jaspersoft.jasperserver.api.metadata.xml.domain.impl.ResourceDescriptor;
import com.jaspersoft.jasperserver.irplugin.JServer;
import junit.framework.TestCase;
public class JasperApiTest extends TestCase{
private JServer jasperServer;
public ResourceDescriptor get(String uri) throws Exception{
ResourceDescriptor rd = new ResourceDescriptor();
rd.setUriString(uri);
return this.jasperServer.getWSClient().get(rd, null, null);
}
@Override
protected void setUp(){
this.jasperServer = new JServer();
this.jasperServer.setName("__ourName__");
this.jasperServer.setPassword("__ourPassword__");
this.jasperServer.setUrl("__ourServer__/jasperserver-pro/services/repository");
}
@Test
public void testJasperApi(){
try{
ResourceDescriptor rd = get("/test");
Assert.assertNotNull(rd);
} catch(Exception ex){
Assert.fail("Failed: " + ex);
}
}
}
Now the problem is that it gives a java.lang.ClassNotFoundException
. Initially for the org.apache.axis.EngineConfiguration
. When I explicitly add this to the pom
it goes to the next ClassNotFoundException
, but this time for org.apache.commons.logging.LogFactory
. And if I add this one as well, it continues with the next inner dependency.
Since I don't use these dependencies myself, only Jasper is, I don't need to add them, but just let Maven add them for me automatically. So, I've read about Transitive_Dependencies, which is just what I need, but this link didn't really gave an example of how to configure this.
I've also tried the following small 'tutorial', but the inner dependencies aren't added..
How can I add all the inner dependency jars through Maven without adding them all manually to the pom? I thought this was done automatically when the scope is compile
(which is the default, although I've also tried setting it explicitly just in case - without any difference).
EDIT: When I build the project with the mvn dependency:tree
goal, it shows the following two lines for the Jasper jars:
[INFO] | +- com.jaspersoft.jasperserver:jasperserver-common-ws:jar:5.5.0:compile
[INFO] | \- com.jaspersoft.jasperserver:jasperserver-ireport-plugin:jar:3.0.0:compile
But no inner dependencies, which is why they aren't being added.
But, when I debug the UnitTest it goes to the .getWSClient()
line, and the actual error occurs in junit.framework.TestCase#runTest()
, with the following Stacktrace:
java.lang.NoClassDefFoundError: org/apache/axis/EngineConfiguration
at com.jaspersoft.jasperserver.irplugin.JServer.getWSClient(JServer.java:102)
at jasper.JasperApiTest.get(JasperApiTest.java:20)
at jasper.JasperApiTest.testJasperApi(JasperApiTest.java:34)
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:498)
at junit.framework.TestCase.runTest(TestCase.java:176)
at junit.framework.TestCase.runBare(TestCase.java:141)
at junit.framework.TestResult$1.protect(TestResult.java:122)
at junit.framework.TestResult.runProtected(TestResult.java:142)
at junit.framework.TestResult.run(TestResult.java:125)
at junit.framework.TestCase.run(TestCase.java:129)
at junit.framework.TestSuite.runTest(TestSuite.java:252)
at junit.framework.TestSuite.run(TestSuite.java:247)
at org.junit.internal.runners.JUnit38ClassRunner.run(JUnit38ClassRunner.java:86)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:86)
at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:459)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:675)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:382)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:192)
Caused by: java.lang.ClassNotFoundException: org.apache.axis.EngineConfiguration
at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
... 22 more
Is this some kind of UnitTest (TestCase-class) reflection problem which causes the ClassNotFoundException
. So the classes it gives these errors aren't inner dependencies of the two Jasper API jars, so I am forced to add them all manually even though I don't use them directly in my own code? Or can I still use transitivity somehow?