-
1. Re: Shrinkwrap addAsLibrary() adds library to a wrong path
kpiwko Dec 2, 2013 3:21 AM (in response to metalhamster)Hi metalhamster,
it depends on how you actually call addAsLibrary(). If you are using String argument, it treads argument as resource on classpath, if you are using File argument - it uses only name of the file.
So, the call you want is addAsLibrary(new File("/path/to/foobar.jar")). If you think that resource loading should behave the same for libraries, please file a request in ShrinkWrap - JBoss Issue Tracker
Thanks,
Karel
Note, here is implementation:
/** * {@inheritDoc} * * @see org.jboss.shrinkwrap.api.container.LibraryContainer#addAsLibrary(java.lang.String) */ @Override public T addAsLibrary(String resourceName) throws IllegalArgumentException { Validate.notNull(resourceName, "ResourceName must be specified"); File file = fileFromResource(resourceName); return addAsLibrary(file, new BasicPath(resourceName)); } /** * {@inheritDoc} * * @see org.jboss.shrinkwrap.api.container.LibraryContainer#addAsLibrary(java.io.File) */ @Override public T addAsLibrary(File resource) throws IllegalArgumentException { Validate.notNull(resource, "Resource must be specified"); return addAsLibrary(resource, resource.getName()); }
-
2. Re: Shrinkwrap addAsLibrary() adds library to a wrong path
metalhamster Dec 4, 2013 2:29 AM (in response to kpiwko)Hi Karel,
I want to call addAsLibrary() with an JavaArchive as argument, not a file.
That's exactly want I want to avoid. I don't want to export my JavaArchive object to the file system in order to be able to add call addAsLibrary() using File as argument.
Regards,
metalhamster
-
3. Re: Shrinkwrap addAsLibrary() adds library to a wrong path
kpiwko Dec 4, 2013 3:46 AM (in response to metalhamster)That's really interesting. May I know how you are creating/getting that JavaArchive? Isn't it named "/WEB-INF/lib/myLib.jar" by any chance?
I'm using this functionality quite often and I have never hit such bug.
Karel
-
4. Re: Shrinkwrap addAsLibrary() adds library to a wrong path
metalhamster Dec 4, 2013 4:51 AM (in response to metalhamster)Ok, I found out what the problem is:
myJar.getName() ergibt: /WEB-INF/lib/myJar.jar
addAsLibrary
T addAsLibrary(Archive<?> archive) throws IllegalArgumentException
- Add another
Archive
to thisArchive
as a library to the container, returning the container itself.
TheArchive
will be placed into the Container Library path underArchive.getName()
. - Parameters:
archive
-Archive
resource to add- Returns:
- This virtual archive
- Throws:
IllegalArgumentException
- ifArchive
is null- See Also:
addAsLibrary(Asset, ArchivePath)
The archive lands then in /WEB-INF/lib with the name /WEB-INF/lib/myJar.jar...
Can I somehow rename the archive?
- Add another
-
5. Re: Shrinkwrap addAsLibrary() adds library to a wrong path
kpiwko Dec 4, 2013 4:45 AM (in response to metalhamster)1 of 1 people found this helpful(Assuming I translated it right from German) - it depends on how are you creating the archive.
For instance
- ShrinkWrap.create(JavaArchive.class, "name-of-the-archive.jar")...
If you are using different means, let me know, I'm pretty interested where the problem is.
Karel
-
6. Re: Shrinkwrap addAsLibrary() adds library to a wrong path
metalhamster Dec 4, 2013 4:50 AM (in response to kpiwko)Ups, didn't even noticed that I continued in German. ;-)
This solved my problem. Thank you.
-
7. Re: Shrinkwrap addAsLibrary() adds library to a wrong path
kpiwko Dec 4, 2013 6:22 AM (in response to metalhamster)Glad to help. Can you share how are you creating the archive? Somebody else might hit the same problem and I'm wondering why "/WEB-INF/lib" is a part of archive name.