resolveArtifact is loading the pom.xml dependencies
public static File[] resolveArtifact(String... artifacts) {
MavenDependencyResolver mvnResolver = DependencyResolvers
.use(MavenDependencyResolver.class);
mvnResolver.loadMetadataFromPom("pom.xml");
return mvnResolver.artifacts(artifacts).resolveAsFiles();
}
On Sat, Feb 9, 2013 at 4:35 PM, John D. Ament <[email protected]>wrote:
> I hope you don't mind, I created a gist for the info, feel free to clone
> it.
>
> https://gist.github.com/johnament/4745724
>
> The one thing that sticks out is that you're using
> shrinkwrap-resolver-depchain, 2.0.0-alpha-6. This one doesn't include any
> maven dependencies. It's not clear, as a result, what your resolveArtifact
> method is doing.
>
> John
>
>
> On Sat, Feb 9, 2013 at 10:24 AM, Luca Merolla <[email protected]
> >wrote:
>
> > Here it is:
> >
> > @Deployment(name = "war2", testable = false)
> > public static WebArchive createDep2() {
> > return ShrinkWrap
> > .create(WebArchive.class, "application2.war")
> > .addClasses(CountryBean.class, CountryBeanLocal.class,
> > CountryEAO.class, CountryEAOLocal.class, Country.class,
> > SystemPropertyBeanLocal.class,
> > SystemPropertyBean.class, SearchUtilLocal.class,
> > SearchUtil.class, DozerBeanMapperServiceLocal.class,
> > DozerBeanMapperService.class,
> > GametableCacheLocal.class, GametableCache.class)
> > .addAsLibraries(
> > resolveArtifact("org.hibernate.javax.persistence:hibernate-jpa-2.0-api"))
> > .addAsManifestResource("META-INF/persistence.xml",
> > "persistence.xml")
> > .addAsWebResource(new StringAsset("Hello from TomEE 2"),
> > "index.html");
> > }
> >
> > <?xml version="1.0" encoding="UTF-8"?>
> > <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="
> > http://www.w3.org/2001/XMLSchema-instance"
> > xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
> > http://maven.apache.org/maven-v4_0_0.xsd">
> > <modelVersion>4.0.0</modelVersion>
> >
> > <groupId>org.pokernuvola</groupId>
> > <artifactId>core</artifactId>
> > <version>0.6.0</version>
> > <packaging>ejb</packaging>
> >
> > <properties>
> > <!-- Explicitly declaring the source encoding eliminates the following
> > message: -->
> > <!-- [WARNING] Using platform encoding (UTF-8 actually) to copy filtered
> > resources, i.e. build is platform dependent! -->
> > <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
> > <javaee6.web.spec.version>2.0.0.Final</javaee6.web.spec.version>
> > <javaee6.full.spec.version>2.0.0.Final</javaee6.full.spec.version>
> > <tomcat.version>7.0.33</tomcat.version>
> > <slf4j.version>1.6.1</slf4j.version>
> >
> > <arquillian.version>1.0.3.Final</arquillian.version>
> > <junit.version>4.10</junit.version>
> > <tomee.version>1.5.1</tomee.version>
> > </properties>
> >
> > <dependencyManagement>
> > <dependencies>
> > <dependency>
> > <groupId>org.jboss.arquillian</groupId>
> > <artifactId>arquillian-bom</artifactId>
> > <version>${arquillian.version}</version>
> > <scope>import</scope>
> > <type>pom</type>
> > </dependency>
> > </dependencies>
> > </dependencyManagement>
> >
> > <dependencies>
> >
> > <!-- Testing -->
> > <dependency>
> > <groupId>junit</groupId>
> > <artifactId>junit</artifactId>
> > <version>${junit.version}</version>
> > <scope>test</scope>
> > </dependency>
> > <dependency>
> > <groupId>org.apache.openejb</groupId>
> > <artifactId>tomee-embedded</artifactId>
> > <version>${tomee.version}</version>
> > <scope>test</scope>
> > </dependency>
> > <dependency>
> > <groupId>org.jboss.arquillian.container</groupId>
> > <artifactId>arquillian-openejb-embedded-3.1</artifactId>
> > <version>1.0.0.Alpha5</version>
> > <scope>test</scope>
> > </dependency>
> > <dependency>
> > <groupId>org.apache.openejb</groupId>
> > <artifactId>arquillian-tomee-embedded</artifactId>
> > <version>${tomee.version}</version>
> > <scope>test</scope>
> > </dependency>
> > <dependency>
> > <groupId>org.jboss.arquillian.junit</groupId>
> > <artifactId>arquillian-junit-container</artifactId>
> > </dependency>
> > <dependency>
> > <groupId>org.jboss.arquillian.protocol</groupId>
> > <artifactId>arquillian-protocol-servlet</artifactId>
> > <scope>test</scope>
> > </dependency>
> > <dependency>
> > <groupId>org.jboss.shrinkwrap.resolver</groupId>
> > <artifactId>shrinkwrap-resolver-depchain</artifactId>
> > <version>2.0.0-alpha-6</version>
> > <type>pom</type>
> > </dependency>
> >
> > <!-- End of testing dependencies -->
> > <!-- First declare the APIs we depend on and need for compilation. All
> > of them are provided by JBoss -->
> >
> > <!-- Import the CDI API, we use provided scope as the API is included in
> > JBoss -->
> > <dependency>
> > <groupId>javax.enterprise</groupId>
> > <artifactId>cdi-api</artifactId>
> > <version>1.0-SP4</version>
> > <scope>provided</scope>
> > </dependency>
> >
> > <!-- Open EJB -->
> > <dependency>
> > <groupId>org.apache.openejb</groupId>
> > <artifactId>javaee-api</artifactId>
> > <version>6.0-4</version>
> > <scope>provided</scope>
> > </dependency>
> >
> > <!-- Import the JPA API, we use provided scope as the API is included in
> > JBoss -->
> > <dependency>
> > <groupId>org.hibernate.javax.persistence</groupId>
> > <artifactId>hibernate-jpa-2.0-api</artifactId>
> > <version>1.0.1.Final</version>
> > <scope>provided</scope>
> > </dependency>
> >
> > <!-- JSR-303 (Bean Validation) Implementation -->
> > <!-- Provides portable constraints such as @Email -->
> > <!-- Hibernate Validator is shipped in JBoss -->
> > <dependency>
> > <groupId>org.hibernate</groupId>
> > <artifactId>hibernate-validator</artifactId>
> > <version>4.2.0.Final</version>
> > <scope>provided</scope>
> > <exclusions>
> > <exclusion>
> > <groupId>org.slf4j</groupId>
> > <artifactId>slf4j-api</artifactId>
> > </exclusion>
> > </exclusions>
> > </dependency>
> >
> > <!-- Now we declare any tools needed -->
> >
> > <!-- Annotation processor to generate the JPA 2.0 metamodel classes for
> > typesafe criteria queries -->
> > <dependency>
> > <groupId>org.hibernate</groupId>
> > <artifactId>hibernate-jpamodelgen</artifactId>
> > <version>1.1.1.Final</version>
> > <scope>provided</scope>
> > </dependency>
> >
> > <dependency>
> > <groupId>org.pokernuvola</groupId>
> > <artifactId>common</artifactId>
> > <version>${project.version}</version>
> > </dependency>
> > <dependency>
> > <groupId>javax.mail</groupId>
> > <artifactId>mail</artifactId>
> > <version>1.4.4</version>
> > <type>jar</type>
> > <scope>compile</scope>
> > </dependency>
> > <dependency>
> > <groupId>org.slf4j</groupId>
> > <artifactId>slf4j-api</artifactId>
> > <version>${slf4j.version}</version>
> > <type>jar</type>
> > <scope>compile</scope>
> > </dependency>
> > <dependency>
> > <groupId>org.apache.tomcat</groupId>
> > <artifactId>tomcat-catalina</artifactId>
> > <version>${tomcat.version}</version>
> > <scope>provided</scope>
> > </dependency>
> > <dependency>
> > <groupId>org.apache.tomcat</groupId>
> > <artifactId>tomcat-coyote</artifactId>
> > <version>${tomcat.version}</version>
> > <scope>provided</scope>
> > </dependency>
> > </dependencies>
> >
> > <build>
> > <plugins>
> > <!-- plugin> <groupId>org.apache.maven.plugins</groupId>
> > <artifactId>maven-compiler-plugin</artifactId>
> > <version>2.0.2</version> <configuration> <source>1.6</source>
> > <target>1.6</target>
> > </configuration> </plugin -->
> > <plugin>
> > <groupId>org.apache.maven.plugins</groupId>
> > <artifactId>maven-ejb-plugin</artifactId>
> > <version>2.3</version>
> > <configuration>
> > <ejbVersion>3.1</ejbVersion>
> > <archive>
> > <manifestEntries>
> > <Dependencies>net.sf.ehcache, org.apache.commons.lang,
> > com.sun.xml.bind service export, org.pokernuvola.common</Dependencies>
> > </manifestEntries>
> > </archive>
> > </configuration>
> > </plugin>
> > <plugin>
> > <groupId>org.apache.maven.plugins</groupId>
> > <artifactId>maven-compiler-plugin</artifactId>
> > <version>2.3.2</version>
> > <configuration>
> > <source>1.6</source>
> > <target>1.6</target>
> > </configuration>
> > </plugin>
> > <plugin>
> > <groupId>org.codehaus.mojo</groupId>
> > <artifactId>sonar-maven-plugin</artifactId>
> > <version>2.0-beta-2</version>
> > </plugin>
> > </plugins>
> > <finalName>pn-${project.artifactId}</finalName>
> > </build>
> > </project>
> >
> >
> >
> > On Sat, Feb 9, 2013 at 4:14 PM, John D. Ament <[email protected]
> > >wrote:
> >
> > > Also, your entire @Deployment method.
> > >
> > >
> > > On Sat, Feb 9, 2013 at 10:14 AM, John D. Ament <[email protected]
> > > >wrote:
> > >
> > > > Luca,
> > > >
> > > > Can you post your pom.xml?
> > > >
> > > > John
> > > >
> > > >
> > > > On Sat, Feb 9, 2013 at 10:09 AM, Luca Merolla <
> [email protected]
> > > >wrote:
> > > >
> > > >> Hi everyone,
> > > >>
> > > >> I'm trying to add hibernate libraries to use them with Arquillian
> and
> > > >> TomEE.
> > > >> To do so, I have found this example:
> > > >>
> > > >>
> > >
> >
> http://janistoolbox.typepad.com/blog/2012/12/arquillian-rest-client-integration-test-.html
> > > >>
> > http://devtoolbox.googlecode.com/svn/trunk/arquillian-rest-spring-test/
> > > >>
> > > >> which is using REST and spring. Basically I'm using the same
> > approach, I
> > > >> have the hibernate libraries declared in the pom.xml and I'm using
> > > >> the resolveArtifact method to load the pom.xml.
> > > >> Then, when I'm creating the archive with ShrinkWrap I'm using
> > > >>
> > > >>
> > > >>
> > >
> >
> .addAsLibraries(resolveArtifact("org.hibernate.javax.persistence:hibernate-jpa-2.0-api"))
> > > >>
> > > >> and I'm getting the following error: http://pastebin.com/BQ7krrXr
> > > >>
> > > >> Error seems to occur in CountryBeanTest at line 97, where I have:
> > > >> MavenDependencyResolver mvnResolver = DependencyResolvers
> > > >> .use(MavenDependencyResolver.class);
> > > >>
> > > >> and it seems related to some missing dependencies:
> > > >> NoClassDefFoundError:
> > > >> org/sonatype/aether/repository/NoLocalRepositoryManagerException.
> > > >>
> > > >> Any idea? Thanks in advance.
> > > >> LM
> > > >>
> > > >
> > > >
> > >
> >
> >
> >
> > --
> > *Luca Merolla*
> > Management, Business & Technology Consultant
> >
> >
> > <http://maps.google.com/maps?q=&hl=en> *Mobile:* +393774569974
> > *Email:* [email protected]
> > *www.linkedin.com/in/lucamerolla*
> > *Website <http://www.merollaconsulting.com>*
> >
> >
> > Merolla Consulting Limited