-
1. Deploying maven artifacts directly
denis_k May 17, 2011 10:44 AM (in response to psychollek)You may want to investigate org.jboss.shrinkwrap.api.spec.EnterpriseArchive interface to see what you can do with ears
-
2. Deploying maven artifacts directly
psychollek May 17, 2011 2:44 PM (in response to denis_k)No no, you didn't uderstand ;] - I have ears in maven repo - I don't want to construct them - I want to deploy them directly .
-
3. Re: Deploying maven artifacts directly
aslak May 17, 2011 4:28 PM (in response to psychollek)@Deployment public static EnterpriseArchive import() { return DependencyResolvers.use(MavenDependencyResolver.class) .artifact("org.artifactid:groupid:ear:4.2.1.FINAL") .resolveAs(EnterpriseArchive.class); }
?
-
4. Re: Deploying maven artifacts directly
psychollek May 18, 2011 1:47 AM (in response to aslak)Thanks,
Could you point where some normal documentation, on the maven in shrinkwrap topic is ? or even where it should be - I think we could contribute some of our company time to write at aleast about our usecases.
-
5. Re: Deploying maven artifacts directly
aslak May 18, 2011 4:35 AM (in response to psychollek)Currently ShrinkWrap only has JavaDoc, but I assume we'll end up with a Space on the new docs.jboss.org/author confluence instance in time.
For now, you can always create a Article on the community space, http://community.jboss.org/en/shrinkwrap and we'll mix it into the docs when time comes..
-
6. Re: Deploying maven artifacts directly
psychollek May 18, 2011 6:11 AM (in response to aslak)Ok, after some modifications to your code :
@Deployment(order=1) public static EnterpriseArchive getUserManager() { return DependencyResolvers.use(MavenDependencyResolver.class).loadReposFromPom("pom.xml") .artifact("<groupId>:<artifactId>:ear:<version>") .resolveAs(EnterpriseArchive.class).iterator().next(); }
it somewhat works. It downloads the ear correctly, but than it complains about :
java.lang.UnsupportedOperationException: Multiple WebArchives found in survey-application-1.0-SNAPSHOT.ear. Can not determine which to enrich
(of course it works flawlesly on normal deployment)
-
7. Re: Deploying maven artifacts directly
aslak May 18, 2011 7:39 AM (in response to psychollek)You just wanted the EAR deployed right? You don't want incontainer testing in the EAR itself ?
The exception is, that unless you specify which WAR to enrich for incontainer testing, the Servlet Protocol can't figure it out, since the EAR contains multiple. (and it's lacking a way of specifying which to use atm)
But if you only want it deployed, use @Deployment.testable = false
-
8. Re: Deploying maven artifacts directly
psychollek May 18, 2011 8:05 AM (in response to aslak)Wellll, I want to inject ejb's which are part of this ear ... but let's say I can figure this out somehow.
but why would container want to enrich any of my wars at all ?
or why can't it enrich all of them ?
-
9. Re: Deploying maven artifacts directly
aslak May 18, 2011 8:36 AM (in response to psychollek)Injecting EJBs from another application is not a problem. You'll need to use @EJB.mappedName for the lookup but beyond that it should work as long as the Test deployment has the client libs or they share Class path or similar.
To be able to execute tests incontainer, Arquillian needs to communicate with the Deployment somehow.. So in the case of the Servlet Protocol implementation, it needs to bundle along a Servlet. The Servlet is used by the client to forward the @Test execution request to the container, where the @Test is actually executed. It can only handle a single point of communication pr Deployment, hench it need to know which of the Wars it should enrich.
In theory we could enrich all wars, but you would then need some kind of Qualifier on the @Test method to specify which War to hit. But we havn't looked at that yet.
-
10. Re: Deploying maven artifacts directly
psychollek May 18, 2011 9:08 AM (in response to aslak)Wouldn't it be simpler to package test as a separate app and simply invoke it ?
one would loose abiolity to inject local beans though.
-
11. Re: Deploying maven artifacts directly
aslak May 18, 2011 9:50 AM (in response to psychollek)Well, we can in theory support both. But you would loose the in deployment testing. as you say, local lookups and locally defined 'things'
-
12. Re: Deploying maven artifacts directly
aslak May 18, 2011 9:51 AM (in response to aslak)or actaully, we do support both out of the box.
Define one @Deployment as testable=false which is your 'target' then define one that's testable=true which is only your testclasses etc..
-
13. Re: Deploying maven artifacts directly
edevera Dec 2, 2012 5:06 PM (in response to aslak)This post seems a bit old and I guess the MavenResolver way has been replaced by Maven.resolver one.
How do I have to deploy an ear (available in my maven repository) now?
Thanks.
-
14. Re: Deploying maven artifacts directly
kpiwko Dec 4, 2012 2:46 AM (in response to edevera)Hi Eduardo,
exactly the same way, although the API is a bit different now.
Follow this document: https://community.jboss.org/wiki/HowToIAddMavenArtifactsToMyShrinkWrapArchives
Your call would look like:
Maven.resolver() // get resolver instance .resolve("groupId:artifactId:ear:version") // get EAR from Maven repository - note you might want to set your own Maven repository first via document above .withoutTransitivity() // you don't need any ear's transitive deps .asSingle(EnterpriseArchive.class); // wrap the result as single object of type EnterpriseArchive
HTH,
Karel