Skip to content

Commit

Permalink
Revoke stripping the dependency JARs from the WAR.
Browse files Browse the repository at this point in the history
Due to Servlet 3.0 spec, web fragments like OmniFaces
need to live inside WEB-INF/lib path.
See also:
* https://stackoverflow.com/questions/30535024
* http://showcase.omnifaces.org/#installation

```
OmniFaces is designed as a WAR library (web fragment library)
and therefore can’t be placed elsewhere in the webapp’s runtime
classpath outside WAR’s own /WEB-INF/lib, such as EAR’s /lib
or even server’s or JRE’s own /lib. When OmniFaces JAR file
is misplaced this way, then the webapp will be unable to find
OmniFaces-bundled JSF/CDI annotated classes and throw exceptions
related to this during deploy or runtime.
```

Developing a solution to include only some dependencies seems
possible, but not easy to achieve or maintenance free... :-(

This leads to a bigger layer in the Docker image, as the nice
split cannot be made anymore. Thus pushes and pulls to and from
a registry will be huger than necessary.
  • Loading branch information
poikilotherm committed Dec 10, 2018
1 parent adf1c9f commit 43ccd30
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 30 deletions.
6 changes: 1 addition & 5 deletions conf/docker/app/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,6 @@ FROM quay.io/poikilotherm/payara-full:latest
# Disable "phone home"
RUN rm ${PAYARA_DIR}/glassfish/modules/phonehome-bootstrap.jar

ARG LIB_PATH="${PAYARA_DIR}/glassfish/domains/${DOMAIN_NAME}/lib/"

COPY --chown=payara maven/lib/* ${LIB_PATH}

COPY maven/${project.build.finalName}.war ${DEPLOY_DIR}

COPY --chown=payara init_2_configure.sh ${SCRIPT_DIR}
COPY init_2_configure.sh ${SCRIPT_DIR}
33 changes: 8 additions & 25 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -704,12 +704,13 @@
<profile>
<id>container</id>
<dependencies>
<!-- Adding this as a dependency will copy it to the domains /lib folder, where it needs to be. -->
<!-- FIXME: Gassfish should be capable to load the driver directly from the WAR, too. That would render
the installer a tiny bit simpler and make distribution easier.
Needs testing. See also:
https://github.com/eclipse-ee4j/glassfish/issues/19451
https://github.com/eclipse-ee4j/glassfish/issues/20944
TODO: Tested and works for Payara 5 in WEB-INF/lib of WAR
-->
<dependency>
<groupId>org.postgresql</groupId>
Expand All @@ -719,22 +720,6 @@
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>3.2.2</version>
<configuration>
<packagingExcludes>WEB-INF/lib/*.jar</packagingExcludes>
<attachClasses>true</attachClasses>
<failOnMissingWebXml>false</failOnMissingWebXml>
<archive>
<manifest>
<addDefaultImplementationEntries>true</addDefaultImplementationEntries>
<addDefaultSpecificationEntries>true</addDefaultSpecificationEntries>
</manifest>
</archive>
</configuration>
</plugin>
<!-- Build docker images (defaults to "install" phase) -->
<plugin>
<groupId>io.fabric8</groupId>
Expand All @@ -753,21 +738,19 @@
<inline>
<includeBaseDirectory>false</includeBaseDirectory>
<dependencySets>
<!-- copy the WAR artifact -->
<!-- Copy the (big) WAR artifact with dependencies inside -->
<!-- FIXME: Think of a way to split this in multiple layers for Docker.
Be aware that things like OmniFaces need to be on
WEB-INF/lib, due to Servlet 3.0 spec.
See also: https://stackoverflow.com/questions/30535024
-->
<dependencySet>
<useProjectArtifact>true</useProjectArtifact>
<includes>
<include>${project.groupId}:${project.artifactId}</include>
</includes>
<outputFileNameMapping>${project.build.finalName}.${artifact.extension}</outputFileNameMapping>
</dependencySet>
<!-- copy dependencies to maven/lib folder -->
<dependencySet>
<outputDirectory>lib</outputDirectory>
<useProjectArtifact>false</useProjectArtifact>
<scope>runtime</scope>
<fileMode>0644</fileMode>
</dependencySet>
</dependencySets>
</inline>
</assembly>
Expand Down

0 comments on commit 43ccd30

Please sign in to comment.