[
https://issues.jboss.org/browse/SHRINKWRAP-369?page=com.atlassian.jira.pl...
]
Martin Kouba commented on SHRINKWRAP-369:
-----------------------------------------
This issue applies to WAR. Change your testcase to:
{code}
/**
* SHRINKWRAP-369
*/
@Test
public void shouldBeAbleToFindServiceProvider() throws Exception {
final WebArchive archive =
ShrinkWrap.create(WebArchive.class).addAsServiceProvider(Cloneable.class,
String.class);
System.out.println(archive.toString(true));
final ShrinkWrapClassLoader cl = new ShrinkWrapClassLoader((ClassLoader) null,
archive);
final Enumeration<URL> found =
cl.findResources("META-INF/services/java.lang.Cloneable");
if(found.hasMoreElements())
System.out.println(found.nextElement().toString());
else
fail("Resource not found");
}
{code}
Final archive is:
{code}
5a267a22-f1e4-4af8-821f-b00fae01543c.war:
/WEB-INF/
/WEB-INF/classes/
/WEB-INF/classes/META-INF/
/WEB-INF/classes/META-INF/services/
/WEB-INF/classes/META-INF/services/java.lang.Cloneable
{code}
And the resource is not found. The problem is that shrinkwrap builds correct archive
however later on when Weld EE Embedded uses ShrinkWrapClassloader to load service
providers. Its ServiceLoader (that works BTW in the same way as standard
java.util.ServiceLoader) tries to find
"META-INF/services/javax.enterprise.inject.spi.Extension" and fails.
This was discussed in SHRINKWRAP-266 in detail. In the end the *addAsServiceProvider*
method was added in order to add service providers in WEB-INF/classes/META-INF/services.
This works ok for archive building but not for loading service providers via
ShrinkWrapClassloader.
ShrinkWrapClassLoader does not find service provider in WAR
-----------------------------------------------------------
Key: SHRINKWRAP-369
URL:
https://issues.jboss.org/browse/SHRINKWRAP-369
Project: ShrinkWrap
Issue Type: Bug
Components: api
Affects Versions: 1.0.0-beta-3
Reporter: Martin Kouba
I ran into this issue when working with *Arquillian* and *Weld EE 1.1 Embedded container*
(that uses ShrinkWrapClassLoader under the hood). ShrinkWrap correctly builds web archive
with CDI extension (using
org.jboss.shrinkwrap.api.container.ManifestContainer.addAsServiceProvider(Class<?>,
Class<?>...); this was also discussed in SHRINKWRAP-266).
Output:
{code}
test.war
/WEB-INF/
/WEB-INF/classes/
/WEB-INF/classes/META-INF/
/WEB-INF/classes/META-INF/services/
/WEB-INF/classes/META-INF/services/javax.enterprise.inject.spi.Extension
{code}
However no extensions are found.
*org.jboss.shrinkwrap.api.classloader.ShrinkWrapClassLoader* probably does not find any
resource when looking for
"META-INF/services/javax.enterprise.inject.spi.Extension".
Note that I'm not quite sure whether it's ShrinkWrapClassLoader or
WeldEEMockContainer issue.
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators:
https://issues.jboss.org/secure/ContactAdministrators!default.jspa
For more information on JIRA, see:
http://www.atlassian.com/software/jira