Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 49 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,55 @@ The Liberty session caching feature builds on top of an existing technology call
RUN configure.sh
```

* **Beta: Enhanced Infinispan Client Configuration** - The beta images include enhanced configurability for the Infinispan client setup. The [infinispan-client-setup.sh](releases/latest/beta/helpers/build/infinispan-client-setup.sh) script supports the following environment variables to ensure compatibility between your Liberty features and the Infinispan client:
* `INFINISPAN_CLIENT_VERSION`
- Description: Sets the Infinispan client version. Refer to [Infinispan Release Notes](https://infinispan.org/release-notes) for major version and compatibility details.
- Default: `"15.2.6.Final"`
- **Automatic Dependency Management**: For Infinispan versions < 11.0.0 (e.g., `10.1.3.Final`, `10.1.9.Final`), reactive-streams and rxjava dependencies are automatically removed as they are not required. For versions >= 11.0.0, these dependencies are included as they are required by Liberty's sessionCache-1.0 feature.
* `INFINISPAN_USE_LATEST_PATCH`
- Description: When set to `"true"`, `INFINISPAN_CLIENT_VERSION` will resolve to the latest patch update within its specified major.minor version.
- Default: `"false"`
- Note: This will resolve the highest version string found in [Maven Central](https://mvnrepository.com/artifact/org.infinispan/infinispan-jcache), which includs any non-final releases (e.g., .Dev01, .Beta, or .RC versions).
* **TIP** - Liberty enforces specific API namespaces based on the Java EE / Jakarta EE specification level of your enabled features. When using Jakarta EE 10 features, the runtime environment is strictly `jakarta.*`, necessitating an Infinispan client that aligns with that specification. For further details on lifecycle and Java baseline requirements, refer to the [Infinispan Release Posts](https://infinispan.org/blog/tag/release/) and official [Download pages](https://infinispan.org/download/).

<details>
<summary><b>Infinispan Client Compatibility Table</b></summary>

| Major Version | Java Baseline | Support Until | Notes |
| :--- | :--- | :--- | :--- |
| **16.0** | Java 17+ | 6 months after 17.0 (Full) | Release versions no longer end with .Final |
| **15.2** | Java 17+ | May 2026 (Full) | |
| **14.0** | Java 11+ | October 2027 (Limited) | |
| **13.0** | Java 8+ | November 2026 (Limited) | |
| **10.x - 12.0**| Java 8 | **javax.*** | End of life | Unsupported |

</details>

Example Dockerfile for beta with custom Infinispan version:
```dockerfile
### Infinispan Session Caching (Beta) ###
FROM icr.io/appcafe/open-liberty:beta AS infinispan-client

# Specify Infinispan client version (optional, defaults to 15.2.6.Final)
ENV INFINISPAN_CLIENT_VERSION=14.0.5.Final
# Optionally resolve latest patch version
# ENV INFINISPAN_USE_LATEST_PATCH=true

USER root
RUN infinispan-client-setup.sh
USER 1001

FROM icr.io/appcafe/open-liberty:beta AS open-liberty-infinispan

# Copy Infinispan client jars to Open Liberty shared resources
COPY --chown=1001:0 --from=infinispan-client /opt/ol/wlp/usr/shared/resources/infinispan /opt/ol/wlp/usr/shared/resources/infinispan

ENV INFINISPAN_SERVICE_NAME=example-infinispan

# This script will add the requested XML snippets and grow image to be fit-for-purpose
RUN configure.sh
```

* **Mount Infinispan Secret** - Finally, the Infinispan generated secret must be mounted as a volume under the mount point of `/platform/bindings/infinispan/secret/` on Liberty containers. The default , for versions latest and 20.0.0.6+, of `/platform/bindings/infinispan/secret/` can to be overridden by setting the `LIBERTY_INFINISPAN_SECRET_DIR` environment variable. When using the Infinispan Operator, this secret is automatically generated as part of the Infinispan service with the name of `<INFINISPAN_CLUSTER_NAME>-generated-secret`. For the mounting of this secret to succeed, the Infinispan Operator and Liberty must share the same namespace. If they do not share the same namespace, the `INFINISPAN_HOST`, `INFINISPAN_PORT`, `INFINISPAN_USER`, and `INFINISPAN_PASS` environment variables can be used instead(see the Dockerfile example above). For an example of mounting this secret, review the `volumes` and `volumeMounts` portions of the YAML below.

```yaml
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,16 @@
<feature>sessionCache-1.0</feature>
</featureManager>
<httpSessionCache libraryRef="InfinispanLib">
<properties infinispan.client.hotrod.server_list="${INFINISPAN_HOST}:${INFINISPAN_PORT}"/>
<properties infinispan.client.hotrod.server_list="${INFINISPAN_HOST}:${INFINISPAN_PORT};${INFINISPAN_SERVICE_NAME_ORIGINAL}:${INFINISPAN_PORT}"/>
<properties infinispan.client.hotrod.marshaller="org.infinispan.commons.marshall.JavaSerializationMarshaller"/>
<properties infinispan.client.hotrod.java_serial_whitelist=".*"/>
<properties infinispan.client.hotrod.java_serial_allowlist=".*"/>
<properties infinispan.client.hotrod.auth_username="${INFINISPAN_USER}"/>
<properties infinispan.client.hotrod.auth_password="${INFINISPAN_PASS}"/>
<properties infinispan.client.hotrod.auth_realm="default"/>
<properties infinispan.client.hotrod.sasl_mechanism="DIGEST-MD5"/>
<properties infinispan.client.hotrod.auth_server_name="infinispan"/>
</httpSessionCache>
<httpSessionCache enableBetaSupportForInfinispan="true"/> <!-- TODO remove once no longer gated -->
<library id="InfinispanLib">
<fileset dir="${shared.resource.dir}/infinispan" includes="*.jar"/>
</library>
Expand Down
72 changes: 62 additions & 10 deletions releases/latest/beta/helpers/build/infinispan-client-setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,13 @@

set -Eeo pipefail

# Recommended stable baseline for Jakarta EE 10 / JDK 17+ environments.
INFINISPAN_DEFAULT_VERSION="15.2.6.Final"
INFINISPAN_CLIENT_VERSION=${INFINISPAN_CLIENT_VERSION:-$INFINISPAN_DEFAULT_VERSION}

# Resolves the latest patch release (x.y.Z) within the specified major.minor version.
INFINISPAN_USE_LATEST_PATCH=${INFINISPAN_USE_LATEST_PATCH:-false}

pkgcmd=yum
if ! command $pkgcmd
then
Expand All @@ -11,17 +18,62 @@ fi

$pkgcmd update -y
$pkgcmd install -y maven
mkdir -p /opt/ol/wlp/usr/shared/resources/infinispan
echo '<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> <groupId>io.openliberty</groupId> <artifactId>openliberty-infinispan-client</artifactId> <version>1.0</version> <!-- https://mvnrepository.com/artifact/org.infinispan/infinispan-jcache-remote --> <dependencies> <dependency> <groupId>org.infinispan</groupId> <artifactId>infinispan-jcache-remote</artifactId> <version>10.1.3.Final</version> </dependency> </dependencies></project>' > /opt/ol/wlp/usr/shared/resources/infinispan/pom.xml
mvn -f /opt/ol/wlp/usr/shared/resources/infinispan/pom.xml versions:use-latest-releases -DallowMajorUpdates=false
mvn -f /opt/ol/wlp/usr/shared/resources/infinispan/pom.xml dependency:copy-dependencies -DoutputDirectory=/opt/ol/wlp/usr/shared/resources/infinispan

CLIENT_JARS_DIR="/opt/ol/wlp/usr/shared/resources/infinispan"
mkdir -p "${CLIENT_JARS_DIR}"

cat << EOF > ${CLIENT_JARS_DIR}/pom.xml
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>io.openliberty</groupId>
<artifactId>openliberty-infinispan-client</artifactId>
<version>1.0</version>

<!-- https://mvnrepository.com/artifact/org.infinispan/infinispan-jcache-remote -->
<dependencies>
<dependency>
<groupId>org.infinispan</groupId>
<artifactId>infinispan-jcache-remote</artifactId>
<version>${INFINISPAN_CLIENT_VERSION}</version>
</dependency>
</dependencies>
</project>
EOF

if [ "${INFINISPAN_USE_LATEST_PATCH}" = "true" ]; then
echo "Resolving latest Infinispan client patch release (no major upgrades)..."
mvn -f "${CLIENT_JARS_DIR}"/pom.xml versions:use-latest-releases -DallowMajorUpdates=false -DallowMinorUpdates=false
fi

mvn -f "${CLIENT_JARS_DIR}/pom.xml" dependency:copy-dependencies -DoutputDirectory="${CLIENT_JARS_DIR}"
# This fails with dependency errors using microdnf on ubi-minimal, but it is okay to let it fail
yum remove -y maven || true
rm -f /opt/ol/wlp/usr/shared/resources/infinispan/pom.xml
rm -f /opt/ol/wlp/usr/shared/resources/infinispan/jboss-transaction-api*.jar
rm -f /opt/ol/wlp/usr/shared/resources/infinispan/reactive-streams-*.jar
rm -f /opt/ol/wlp/usr/shared/resources/infinispan/rxjava-*.jar
rm -f "${CLIENT_JARS_DIR}/pom.xml"

# Remove unnecessary spec jars
rm -f "${CLIENT_JARS_DIR}"/jboss-transaction-api*.jar
rm -f "${CLIENT_JARS_DIR}"/jakarta.transaction-api*.jar

# Extract major version set
MAJOR_VERSION=$(echo "${INFINISPAN_CLIENT_VERSION}" | sed -E 's/^([0-9]+)\..*/\1/')
# Reactive streams are required for Infinispan 11+ on Liberty sessionCache-1.0
# For versions < 11.0.0, remove reactive streams
if [ "${MAJOR_VERSION}" -lt 11 ]; then
echo "Removing reactive-streams and rxjava jars as Infinispan version ${INFINISPAN_CLIENT_VERSION} is < 11.0.0..."
rm -f "${CLIENT_JARS_DIR}"/reactive-streams-*.jar
rm -f "${CLIENT_JARS_DIR}"/rxjava-*.jar
fi

rm -rf ~/.m2
chown -R 1001:0 /opt/ol/wlp/usr/shared/resources/infinispan
chmod -R g+rw /opt/ol/wlp/usr/shared/resources/infinispan
chown -R 1001:0 "${CLIENT_JARS_DIR}"
chmod -R g+rw "${CLIENT_JARS_DIR}"

INSTALLED_VERSION=$(find "${CLIENT_JARS_DIR}/" -name "infinispan-jcache-remote-*.jar" -printf "%f" | sed 's/infinispan-jcache-remote-\(.*\).jar/\1/')

if [ -n "$INSTALLED_VERSION" ]; then
echo "Successfully installed Infinispan client version: ${INSTALLED_VERSION}"
fi


2 changes: 2 additions & 0 deletions releases/latest/beta/helpers/runtime/docker-server.sh
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,8 @@ importKeyCert
# Infinispan Session Caching
if [[ -n "$INFINISPAN_SERVICE_NAME" ]]; then
echo "INFINISPAN_SERVICE_NAME(original): ${INFINISPAN_SERVICE_NAME}"
INFINISPAN_SERVICE_NAME_ORIGINAL=${INFINISPAN_SERVICE_NAME}
export INFINISPAN_SERVICE_NAME_ORIGINAL
INFINISPAN_SERVICE_NAME=$(echo ${INFINISPAN_SERVICE_NAME} | sed 's/-/_/g' | sed 's/./\U&/g')
echo "INFINISPAN_SERVICE_NAME(normalized): ${INFINISPAN_SERVICE_NAME}"

Expand Down