Skip to content

Commit 6bd4b52

Browse files
committed
Added --module-path and --add-modules in order to start Glassfish after the bootstrap was redesigned
1 parent 4c6f30a commit 6bd4b52

File tree

1 file changed

+35
-2
lines changed
  • enterprise/glassfish.tooling/src/org/netbeans/modules/glassfish/tooling/server

1 file changed

+35
-2
lines changed

enterprise/glassfish.tooling/src/org/netbeans/modules/glassfish/tooling/server/ServerTasks.java

Lines changed: 35 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,37 @@ private static void addJavaAgent(GlassFishServer server,
103103
}
104104
}
105105
}
106+
107+
/**
108+
* Append module path and add modules to java options when there is at least
109+
* one '--add-opens' without 'ALL-UNNAMED'.
110+
* <p/>
111+
* @param server GlassFish server entity.
112+
* @param optList Returned list of java options.
113+
*/
114+
private static void appendModulePath(GlassFishServer server,
115+
List<String> optList) {
116+
boolean needed = optList
117+
.stream()
118+
.filter(
119+
opt ->
120+
opt.contains("--add-opens")
121+
&&
122+
!opt.contains("ALL-UNNAMED")
123+
)
124+
.findAny()
125+
.isPresent();
126+
if (needed) {
127+
// appending module path and all modules in order to use
128+
// '--add-opens' without 'ALL-UNNAMED'.
129+
// See https://github.com/eclipse-ee4j/glassfish/pull/25537
130+
String modulePath = server.getServerHome() + File.separator
131+
+ ServerUtils.GF_LIB_DIR_NAME + File.separator
132+
+ "bootstrap";
133+
optList.add("--module-path=" + modulePath);
134+
optList.add("--add-modules=ALL-MODULE-PATH");
135+
}
136+
}
106137

107138
/**
108139
* Adds server variables from variables map into Java VM options
@@ -142,8 +173,9 @@ public static ResultProcess startServer(GlassFishServer server,
142173
JvmConfigReader jvmConfigReader = new JvmConfigReader(DAS_NAME);
143174
String domainAbsolutePath = server.getDomainsFolder() + File.separator
144175
+ server.getDomainName();
145-
String domainXmlPath = domainAbsolutePath + File.separator + "config"
146-
+ File.separator + "domain.xml";
176+
String domainXmlPath = domainAbsolutePath + File.separator
177+
+ ServerUtils.GF_DOMAIN_CONFIG_DIR_NAME + File.separator
178+
+ ServerUtils.GF_DOMAIN_CONFIG_FILE_NAME;
147179
if (!TreeParser.readXml(new File(domainXmlPath), jvmConfigReader)) {
148180
// retry with platform default
149181
LOGGER.log(Level.INFO, "Retrying with {0} encoding", Charset.defaultCharset());
@@ -154,6 +186,7 @@ public static ResultProcess startServer(GlassFishServer server,
154186
}
155187
}
156188
List<String> optList = jvmConfigReader.getOptList();
189+
appendModulePath(server, optList);
157190
Map<String, String> propMap = jvmConfigReader.getPropMap();
158191
addJavaAgent(server, jvmConfigReader);
159192
// try to find bootstraping jar - usually glassfish.jar

0 commit comments

Comments
 (0)