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
36 changes: 35 additions & 1 deletion .github/workflows/build-linux.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,43 @@ jobs:
- name: List ports
run: ss -tulpn
- name: Build with Maven
id: maven-build
# qa skips documentation - we check it on Jenkins CI
# We skip checkstyle too - we check it on Jenkins CI
run: mvn -B -e -ntp install -Pstaging -Pqa '-Dcheckstyle.skip=true'
run: |
set -o pipefail
mvn -B -e -ntp install -Pstaging -Pqa '-Dcheckstyle.skip=true' 2>&1 | tee build.log
- name: Extract build failure info
if: failure() && steps.maven-build.outcome == 'failure'
run: |
echo "## Build Failure Summary" >> $GITHUB_STEP_SUMMARY
echo "### Last 100 lines of Maven output:" >> $GITHUB_STEP_SUMMARY
echo '```' >> $GITHUB_STEP_SUMMARY
tail -100 build.log >> $GITHUB_STEP_SUMMARY
echo '```' >> $GITHUB_STEP_SUMMARY

echo "### Error Analysis:" >> $GITHUB_STEP_SUMMARY
if grep -q "BUILD FAILURE" build.log; then
echo "- ❌ Maven build failed" >> $GITHUB_STEP_SUMMARY
# Extract the failure reason
echo "### Failure Reason:" >> $GITHUB_STEP_SUMMARY
echo '```' >> $GITHUB_STEP_SUMMARY
grep -A 10 "BUILD FAILURE" build.log | head -15 >> $GITHUB_STEP_SUMMARY
echo '```' >> $GITHUB_STEP_SUMMARY
fi
if grep -q "COMPILATION ERROR" build.log; then
echo "- ❌ Compilation errors detected" >> $GITHUB_STEP_SUMMARY
fi
if grep -q "Tests run:.*Failures: [1-9]" build.log; then
echo "- ❌ Test failures detected" >> $GITHUB_STEP_SUMMARY
fi
- name: Upload build log
uses: actions/upload-artifact@v4
if: failure()
with:
name: build-log
path: build.log
retention-days: 3
- name: Upload server logs
uses: actions/upload-artifact@v4
if: failure()
Expand Down
41 changes: 39 additions & 2 deletions .github/workflows/build-macos.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,48 @@ jobs:
distribution: 'temurin'
cache: maven
- name: Build with Maven
id: maven-build
# qa skips documentation - we check it on Jenkins CI
# We skip checkstyle too - we check it on Jenkins CI
run: mvn -B -e -ntp install -Pstaging -Pqa '-Dcheckstyle.skip=true' -Pfastest
run: |
set -o pipefail
mvn -B -e -ntp install -Pstaging -Pqa '-Dcheckstyle.skip=true' -Pfastest 2>&1 | tee build.log
- name: Test Starts
run: mvn -B -e -ntp install -Pstaging '-Dcheckstyle.skip=true' -pl :glassfish-itest-tools
id: test-starts
run: |
set -o pipefail
mvn -B -e -ntp install -Pstaging '-Dcheckstyle.skip=true' -pl :glassfish-itest-tools 2>&1 | tee -a build.log
- name: Extract build failure info
if: failure() && (steps.maven-build.outcome == 'failure' || steps.test-starts.outcome == 'failure')
run: |
echo "## Build Failure Summary" >> $GITHUB_STEP_SUMMARY
echo "### Last 100 lines of Maven output:" >> $GITHUB_STEP_SUMMARY
echo '```' >> $GITHUB_STEP_SUMMARY
tail -100 build.log >> $GITHUB_STEP_SUMMARY
echo '```' >> $GITHUB_STEP_SUMMARY

echo "### Error Analysis:" >> $GITHUB_STEP_SUMMARY
if grep -q "BUILD FAILURE" build.log; then
echo "- ❌ Maven build failed" >> $GITHUB_STEP_SUMMARY
# Extract the failure reason
echo "### Failure Reason:" >> $GITHUB_STEP_SUMMARY
echo '```' >> $GITHUB_STEP_SUMMARY
grep -A 10 "BUILD FAILURE" build.log | head -15 >> $GITHUB_STEP_SUMMARY
echo '```' >> $GITHUB_STEP_SUMMARY
fi
if grep -q "COMPILATION ERROR" build.log; then
echo "- ❌ Compilation errors detected" >> $GITHUB_STEP_SUMMARY
fi
if grep -q "Tests run:.*Failures: [1-9]" build.log; then
echo "- ❌ Test failures detected" >> $GITHUB_STEP_SUMMARY
fi
- name: Upload build log
uses: actions/upload-artifact@v4
if: failure()
with:
name: build-log
path: build.log
retention-days: 3
- name: Upload server logs
uses: actions/upload-artifact@v4
if: failure()
Expand Down
37 changes: 36 additions & 1 deletion .github/workflows/build-windows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,44 @@ jobs:
distribution: 'temurin'
cache: maven
- name: Build with Maven
id: maven-build
# qa skips documentation - we check it on Jenkins CI
# We skip checkstyle too - we check it on Jenkins CI
run: mvn -B -e -ntp install -Pstaging -Pqa '-Dcheckstyle.skip=true'
run: |
mvn -B -e -ntp install -Pstaging -Pqa '-Dcheckstyle.skip=true' 2>&1 | Tee-Object build.log
- name: Extract build failure info
if: failure() && steps.maven-build.outcome == 'failure'
shell: pwsh
run: |
echo "## Build Failure Summary" >> $env:GITHUB_STEP_SUMMARY
echo "### Last 100 lines of Maven output:" >> $env:GITHUB_STEP_SUMMARY
echo '```' >> $env:GITHUB_STEP_SUMMARY
Get-Content build.log -Tail 100 >> $env:GITHUB_STEP_SUMMARY
echo '```' >> $env:GITHUB_STEP_SUMMARY

echo "### Error Analysis:" >> $env:GITHUB_STEP_SUMMARY
$content = Get-Content build.log -Raw
if ($content -match "BUILD FAILURE") {
echo "- ❌ Maven build failed" >> $env:GITHUB_STEP_SUMMARY
# Extract the failure reason
echo "### Failure Reason:" >> $env:GITHUB_STEP_SUMMARY
echo '```' >> $env:GITHUB_STEP_SUMMARY
($content | Select-String -Pattern "BUILD FAILURE" -Context 0,10).Context.PostContext[0..14] -join "`n" >> $env:GITHUB_STEP_SUMMARY
echo '```' >> $env:GITHUB_STEP_SUMMARY
}
if ($content -match "COMPILATION ERROR") {
echo "- ❌ Compilation errors detected" >> $env:GITHUB_STEP_SUMMARY
}
if ($content -match "Tests run:.*Failures: [1-9]") {
echo "- ❌ Test failures detected" >> $env:GITHUB_STEP_SUMMARY
}
- name: Upload build log
uses: actions/upload-artifact@v4
if: failure()
with:
name: build-log
path: build.log
retention-days: 3
- name: Upload server logs
uses: actions/upload-artifact@v4
if: failure()
Expand Down
2 changes: 2 additions & 0 deletions appserver/admin/template/src/main/resources/config/domain.xml
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,7 @@
<jvm-options>--add-exports=java.naming/com.sun.jndi.ldap=ALL-UNNAMED</jvm-options>
<jvm-options>--add-exports=java.base/jdk.internal.vm.annotation=ALL-UNNAMED</jvm-options>
<jvm-options>--add-opens=java.base/jdk.internal.vm.annotation=ALL-UNNAMED</jvm-options>
<jvm-options>--add-exports=java.base/jdk.internal.loader=ALL-UNNAMED</jvm-options>

<!-- To enable attaching the flashlight agent to the current VM in OpenJDK 9+ -->
<jvm-options>-Djdk.attach.allowAttachSelf=true</jvm-options>
Expand Down Expand Up @@ -421,6 +422,7 @@
<jvm-options>--add-exports=java.naming/com.sun.jndi.ldap=ALL-UNNAMED</jvm-options>
<jvm-options>--add-exports=java.base/jdk.internal.vm.annotation=ALL-UNNAMED</jvm-options>
<jvm-options>--add-opens=java.base/jdk.internal.vm.annotation=ALL-UNNAMED</jvm-options>
<jvm-options>--add-exports=java.base/jdk.internal.loader=ALL-UNNAMED</jvm-options>

<!-- To enable attaching the flashlight agent to the current VM in OpenJDK 9+ -->
<jvm-options>-Djdk.attach.allowAttachSelf=true</jvm-options>
Expand Down
16 changes: 14 additions & 2 deletions appserver/extras/embedded/all/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,17 @@
</executions>
</plugin>

<plugin>
<groupId>org.codehaus.gmaven</groupId>
<artifactId>groovy-maven-plugin</artifactId>
<executions>
<execution>
<id>merge-manifest-values-to-properties</id>
<phase>prepare-package</phase>
</execution>
</executions>
</plugin>

<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<executions>
Expand Down Expand Up @@ -166,8 +177,9 @@
<Multi-Release>true</Multi-Release>
<Bundle-SymbolicName>org.glassfish.main.embedded.all</Bundle-SymbolicName>
<Main-Class>org.glassfish.runnablejar.UberMain</Main-Class>
<Add-Opens>java.base/java.lang java.base/java.io java.base/java.util java.base/sun.nio.fs java.base/sun.net.www.protocol.jrt java.naming/javax.naming.spi java.rmi/sun.rmi.transport jdk.management/com.sun.management.internal java.base/jdk.internal.vm.annotation</Add-Opens>
<Add-Exports>java.naming/com.sun.jndi.ldap java.base/jdk.internal.vm.annotation</Add-Exports>
<Add-Opens>${glassfish.embedded.add-opens}</Add-Opens>
<Add-Exports>${glassfish.embedded.add-exports}</Add-Exports>
<probe-provider-class-names>${probe.provider.class.names}</probe-provider-class-names>
</manifestEntries>
</archive>
</configuration>
Expand Down
64 changes: 63 additions & 1 deletion appserver/extras/embedded/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
-->

<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 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

Expand All @@ -30,6 +29,11 @@
<packaging>pom</packaging>

<name>GlassFish Embedded modules</name>

<properties>
<glassfish.embedded.add-opens>java.base/java.lang java.base/java.io java.base/java.util java.base/sun.nio.fs java.base/sun.net.www.protocol.jrt java.naming/javax.naming.spi java.rmi/sun.rmi.transport jdk.management/com.sun.management.internal java.base/jdk.internal.vm.annotation</glassfish.embedded.add-opens>
<glassfish.embedded.add-exports>java.naming/com.sun.jndi.ldap java.base/jdk.internal.vm.annotation java.base/jdk.internal.loader</glassfish.embedded.add-exports>
</properties>

<modules>
<module>common</module>
Expand All @@ -52,4 +56,62 @@
</dependencies>
</dependencyManagement>

<build>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.codehaus.gmaven</groupId>
<artifactId>groovy-maven-plugin</artifactId>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would prefer using java and exec plugin; not sure if it is doable.
The groovy is not so well readable for us and we tend to do evil things: catching exceptions without processing them, closing jars just when their processing doesn't throw exceptions instead of try-with ...

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was lazy here and asked AI. It couldn't figure out how to do it using Ant. It kept suggesting using exec plugin with a shell script, which obviously wouldn't work on Windows. Then I decided to use Groovy, which works everywhere. Another option would be to create a new maven plugin, but that would have to be a separate project, or part of the buildhelper plugin, which is external and we would have to release it first.

Another option is to create a script in Java and execute it via the exec plugin, maybe that's what you mean. If we can compile it first or execute it directly as a script, then it should work too.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tried. It's just too complicated. Groovy script is the best option. The only other option is to create a separate maven plugin, because we need to set a maven project property, which is used in another plugin to build the final MANIFEST. And I don't want to bother with a separate Maven plugin. The Groovy script is almost like Java and it's pretty simple.

<executions>
<execution>
<!-- Merges all values in the 'probe-provider-class-names'
attribute into a system property 'probe.provider.class.names',
which be used when building the final manifest
-->
<id>merge-manifest-values-to-properties</id>
<goals>
<goal>execute</goal>
</goals>
<configuration>
<source>
import java.util.jar.JarFile
import java.util.jar.Manifest
def probeProviders = [] as Set
project.artifacts.each { artifact ->
if (artifact.type == 'jar') {
try {
def jar = new JarFile(artifact.file)
def manifest = jar.manifest
if (manifest) {
def probeValue = manifest.mainAttributes.getValue('probe-provider-class-names')
if (probeValue) {
probeProviders.add(probeValue)
}
}
jar.close()
} catch (Exception e) {
// Ignore invalid JARs
}
}
}
if (probeProviders) {
project.properties['probe.provider.class.names'] = probeProviders.join(',')
println "Found ${probeProviders.size()} probe providers in project dependencies"
} else {
println "No probe providers found in project dependencies"
}
</source>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</pluginManagement>
</build>

</project>
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--

Copyright (c) 2021, 2024 Contributors to Eclipse Foundation.
Copyright (c) 2021, 2025 Contributors to Eclipse Foundation.
Copyright (c) 1997, 2022 Oracle and/or its affiliates. All rights reserved.

This program and the accompanying materials are made available under the
Expand Down Expand Up @@ -1397,8 +1397,8 @@
<Bundle-SymbolicName>org.glassfish.embedded.static-shell</Bundle-SymbolicName>
<Class-Path>${classpath.derby} ../asadmin/server-mgmt.jar ../../admin-cli.jar</Class-Path>
<Main-Class>org.glassfish.runnablejar.UberMain</Main-Class>
<Add-Opens>java.base/java.lang java.base/java.io java.base/java.util java.base/sun.nio.fs java.base/sun.net.www.protocol.jrt java.naming/javax.naming.spi java.rmi/sun.rmi.transport jdk.management/com.sun.management.internal java.base/jdk.internal.vm.annotation</Add-Opens>
<Add-Exports>java.naming/com.sun.jndi.ldap java.base/jdk.internal.vm.annotation</Add-Exports>
<Add-Opens>${glassfish.embedded.add-opens}</Add-Opens>
<Add-Exports>${glassfish.embedded.add-exports}</Add-Exports>
</manifestEntries>
</archive>
</configuration>
Expand Down
16 changes: 14 additions & 2 deletions appserver/extras/embedded/web/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,17 @@
</executions>
</plugin>

<plugin>
<groupId>org.codehaus.gmaven</groupId>
<artifactId>groovy-maven-plugin</artifactId>
<executions>
<execution>
<id>merge-manifest-values-to-properties</id>
<phase>prepare-package</phase>
</execution>
</executions>
</plugin>

<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<executions>
Expand Down Expand Up @@ -190,8 +201,9 @@
<Multi-Release>true</Multi-Release>
<Bundle-SymbolicName>org.glassfish.main.embedded.web</Bundle-SymbolicName>
<Main-Class>org.glassfish.runnablejar.UberMain</Main-Class>
<Add-Opens>java.base/java.lang java.base/java.io java.base/java.util java.base/sun.nio.fs java.base/sun.net.www.protocol.jrt java.naming/javax.naming.spi java.rmi/sun.rmi.transport jdk.management/com.sun.management.internal java.base/jdk.internal.vm.annotation</Add-Opens>
<Add-Exports>java.naming/com.sun.jndi.ldap java.base/jdk.internal.vm.annotation</Add-Exports>
<Add-Opens>${glassfish.embedded.add-opens}</Add-Opens>
<Add-Exports>${glassfish.embedded.add-exports}</Add-Exports>
<probe-provider-class-names>${probe.provider.class.names}</probe-provider-class-names>
</manifestEntries>
</archive>
</configuration>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,19 +96,21 @@ public class GlassFishTestEnvironment {
private static HttpClient client;

static {
LOG.log(Level.INFO, "Using basedir: {0}", BASEDIR);
LOG.log(Level.INFO, "Expected GlassFish directory: {0}", GF_ROOT);
changePassword();
Thread hook = new Thread(() -> {
getAsadmin().exec(30_000, "stop-domain", "--kill", "--force");
});
Runtime.getRuntime().addShutdownHook(hook);
final int timeout = isStartDomainSuspendEnabled()
? ASADMIN_START_DOMAIN_TIMEOUT_FOR_DEBUG : ASADMIN_START_DOMAIN_TIMEOUT;
// This is the absolutely first start - if it fails, all other starts will fail too.
// Note: --suspend implicitly enables --debug
assertThat(getAsadmin().exec(timeout,"start-domain",
isStartDomainSuspendEnabled() ? "--suspend" : "--debug"), asadminOK());
if (!isGlassFishRunningRemotely()) {
LOG.log(Level.INFO, "Using basedir: {0}", BASEDIR);
LOG.log(Level.INFO, "Expected GlassFish directory: {0}", GF_ROOT);
changePassword();
Thread hook = new Thread(() -> {
getAsadmin().exec(30_000, "stop-domain", "--kill", "--force");
});
Runtime.getRuntime().addShutdownHook(hook);
final int timeout = isStartDomainSuspendEnabled()
? ASADMIN_START_DOMAIN_TIMEOUT_FOR_DEBUG : ASADMIN_START_DOMAIN_TIMEOUT;
// This is the absolutely first start - if it fails, all other starts will fail too.
// Note: --suspend implicitly enables --debug
assertThat(getAsadmin().exec(timeout,"start-domain",
isStartDomainSuspendEnabled() ? "--suspend" : "--debug"), asadminOK());
}
}


Expand Down Expand Up @@ -428,6 +430,10 @@ private static boolean isStartDomainSuspendEnabled() {
return envValue == null ? Boolean.getBoolean("glassfish.suspend") : Boolean.parseBoolean(envValue);
}

public static boolean isGlassFishRunningRemotely() {
final String envValue = System.getenv("GLASSFISH_REMOTE");
return envValue == null ? Boolean.getBoolean("glassfish.remote") : Boolean.parseBoolean(envValue);
}

private static <T> T doIO(IOSupplier<T> action) {
try {
Expand Down
Loading