How to deploy a library with Java EE 6 / Glassfish 3.x
I have got an EAR with two plain libraries. One of them being scala-library. If I deploy the EAR with Netbeans it works as expected. While this is OK for development the final produc开发者_Go百科t should be deployable via the command line. For this I use:
asadmin --user … deploy --upload ./target/…-ear.ear
which fails with:
org.glassfish.api.admin.CommandException: remote failure: Error occurred during deployment: Exception while deploying the app […-ear] : C:\Work\Workspa
ces\…\Glassfish\…\applications\scala-library-2.8.0.jar. Please see server.log for more details.
Befehl deploy fehlgeschlagen.
Searching the net I found out that handling libraries have become more strict with Java EE 6 / Glassfish 3.x and that it is not enough to add them to the lib
folder inside the ear any more. Only the author neglected to mention what is needed now.
I found new <module><java>
entries for the META-INF\application.xml
— but that did not help either:
<module>
<java>scala-library-2.8.0.jar</java>
</module>
So the question: Does anybody know what you have to do to add libraries to an EAR file for Java EE 6 / Glassfish 3.x?
PS: I use Maven to build - if that makes any difference.
Well it seems I found the solution myself (again). After adding a library-directory
entry to the end of the META-INF\application.xml
the deployment runs thou:
<library-directory>lib</library-directory>
</application>
The strange thing is that lib
the default for library-directory
. So I guess it must be a bug in Glassfish itself not handling the default correctly. If you use Maven make sure to use bundleDir
in your pom.xml
so that the libs are place in the right place:
<jarModule>
<groupId>org.scala-lang</groupId>
<artifactId>scala-library</artifactId>
<bundleDir>lib</bundleDir>
</jarModule>
精彩评论