]
Antimo Di Comite commented on SHRINKRES-211:
--------------------------------------------
Any help or hint to get me to the right way to import the dependencies?
java.lang.NoClassDefFoundError: com/google/protobuf/GeneratedMessage
--------------------------------------------------------------------
Key: SHRINKRES-211
URL:
https://issues.jboss.org/browse/SHRINKRES-211
Project: ShrinkWrap Resolvers
Issue Type: Bug
Components: maven
Affects Versions: 2.1.0
Environment: Windows 7
Reporter: Antimo Di Comite
Labels: testsuite_stability
I'm having trouble creating a JUnit test using a pom.xml dependency.
The test are being run with Arquillian
@RunWith(Arquillian.class)
In this method
{code}
@Deployment
public static JavaArchive createDeployment() {
First, I create a JavaArchive with the package of the project I'm testing
JavaArchive merge = ShrinkWrap.create(JavaArchive.class).
addPackages(true,
"migrazioneGeaPersistenzaTampone",
"migrazioneGeaPersistenza",
"it.**.mistral.importGEA4.task",
"migrazioneGeaPersistenzaAccess"
).
addClasses(java.sql.Connection.class)
.addAsManifestResource(EmptyAsset.INSTANCE, "beans.xml");
{code}
Then when I launch the test, there are some missing dependencies
Unable to resolve any beans for Types: [class
it.**.**.be.service.EnvironmentRootService]
present in this dependency
{code}
<dependency>
<groupId>it.**.mistral</groupId>
<artifactId>mistral-be</artifactId>
<version>0.1.0</version>
<scope>compile</scope>
</dependency>
{code}
I have tried lots of different things to add these dependencies, the best one seems to be
using the ShrinkWrap Resolvers
(
https://github.com/shrinkwrap/resolver/blob/master/README.asciidoc, particullarry this
paragraph
https://github.com/shrinkwrap/resolver/blob/master/README.asciidoc#resolu...)
a)
{code}
JavaArchive[] archives = Maven.resolver().loadPomFromFile(path_to_pom_file).
importDependencies(ScopeType.TEST,ScopeType.COMPILE).
resolve().withTransitivity().as(JavaArchive.class);
{code}
or
{code}
Maven.resolver().loadPomFromFile("/path/to/pom.xml").importRuntimeDependencies()
.resolve().withTransitivity().asFile();
{code}
The dependency is ignored in either way (i'm missing something?)
b)
{code}
JavaArchive[] mistral_be = Maven.configureResolver().workOffline().
resolve("it.**.mistral:mistral-be:0.1.0").withTransitivity().as(JavaArchive.class);
for (int i = 0; i < mistral_be.length ; i++) {
merge = merge.merge(mistral_be[i]);
}
{code}
With a simple
{code}
System.out.println(merge.toString(true));
{code}
I can see that all files from dependencies are present! Anyway I use local repository
workoffline() Maybe I am missing some dependencies?
But exiting the method with a
{code}
return merge;
throws a "java.lang.NoClassDefFoundError:
com/google/protobuf/GeneratedMessage....Caused by: java.lang.ClassNotFoundException:
com.google.protobuf.GeneratedMessage" error.
{code}
Adding another dependencies to protobuf :
{code}
// Trym'g to add protobuf dependencies
JavaArchive[] prtoo_buf =
Maven.configureResolver().withMavenCentralRepo(true).resolve("com.google.protobuf:protobuf-java:2.3.0").withTransitivity().as(JavaArchive.class);
for (int i = 0; i < prto_buf.length ; i++) {
projectPackages = projectPackages.merge(proto_buf[i]);
}
{code}
Keep ending with the same error
throws a "java.lang.NoClassDefFoundError: com/google/protobuf/GeneratedMessage
These are an extract of dependencies in pom.xml:
{code}
<dependency>
<groupId>org.jboss.spec</groupId>
<artifactId>jboss-javaee-6.0</artifactId>
<version>1.0.0.Final</version>
<type>pom</type>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.jboss.arquillian.junit</groupId>
<artifactId>arquillian-junit-container</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.jboss.arquillian.container</groupId>
<artifactId>arquillian-weld-ee-embedded-1.1</artifactId>
<version>1.0.0.CR3</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.jboss.shrinkwrap.resolver</groupId>
<artifactId>shrinkwrap-resolver-depchain</artifactId>
<version>2.1.0</version>
<scope>test</scope>
</dependency>
</dependencies>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.jboss.arquillian</groupId>
<artifactId>arquillian-bom</artifactId>
<version>1.1.5.Final</version>
<scope>import</scope>
<type>pom</type>
</dependency>
</dependencies>
</dependencyManagement>
{code}