Skip to content
Open
Show file tree
Hide file tree
Changes from 14 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
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
@@ -0,0 +1,42 @@
/*
* Copyright (c) 2025 Contributors to the Eclipse Foundation
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0, which is available at
* http://www.eclipse.org/legal/epl-2.0.
*
* SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
*/

package org.glassfish.main.test.app.monitoring;

import jakarta.servlet.ServletException;
import jakarta.servlet.annotation.WebServlet;
import jakarta.servlet.http.HttpServlet;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;

import java.io.IOException;
import java.io.PrintWriter;

@WebServlet("/slow")
public class SlowServlet extends HttpServlet {

@Override
protected void doGet(HttpServletRequest req, HttpServletResponse resp)
throws ServletException, IOException {
String delayParam = req.getParameter("delay");
int delay = delayParam != null ? Integer.parseInt(delayParam) : 5000;
try {
Thread.sleep(delay); // delay to keep threads busy
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
}

resp.setContentType("text/plain");
try (PrintWriter writer = resp.getWriter()) {
writer.println("Slow response completed");
writer.println("Thread: " + Thread.currentThread().getName());
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
/*
* Copyright (c) 2025 Contributors to the Eclipse Foundation
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0, which is available at
* http://www.eclipse.org/legal/epl-2.0.
*
* SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
*/

package org.glassfish.main.test.app.monitoring;

import jakarta.servlet.ServletException;
import jakarta.servlet.annotation.WebServlet;
import jakarta.servlet.http.HttpServlet;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;

import java.io.IOException;
import java.io.PrintWriter;

@WebServlet("/test")
public class TestServlet extends HttpServlet {

@Override
protected void doGet(HttpServletRequest req, HttpServletResponse resp)
throws ServletException, IOException {
resp.setContentType("text/plain");
try (PrintWriter writer = resp.getWriter()) {
writer.println("Thread Pool Test Servlet");
writer.println("Thread: " + Thread.currentThread().getName());
}
}
}
Loading
Loading