Skip to content

Commit 0339f0b

Browse files
tnagao7k2sd
authored andcommitted
Cumulative bug fixes (#5)
1 parent 3a915cd commit 0339f0b

File tree

25 files changed

+1422
-137
lines changed

25 files changed

+1422
-137
lines changed

README.adoc

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,3 +35,7 @@ Refer to link:docs/Usage.adoc[].
3535

3636
== Downloads
3737
Binary distributions can be obtained from link:https://github.com/fujitsu/launcher/releases[].
38+
39+
== Configuration file example
40+
41+
An example of configuration file which can be used with `--config-file` option is available from link:examples/domain-xml[].

examples/domain-xml/domain.xml

Lines changed: 167 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,167 @@
1+
<!--
2+
3+
Copyright (c) 2010, 2018 Oracle and/or its affiliates. All rights reserved.
4+
Copyright (c) 2019 Fujitsu Limited.
5+
6+
This program and the accompanying materials are made available under the
7+
terms of the Eclipse Public License v. 2.0, which is available at
8+
http://www.eclipse.org/legal/epl-2.0.
9+
10+
This Source Code may also be made available under the following Secondary
11+
Licenses when the conditions for such availability set forth in the
12+
Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
13+
version 2 with the GNU Classpath Exception, which is available at
14+
https://www.gnu.org/software/classpath/license.html.
15+
16+
SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
17+
18+
-->
19+
20+
<domain log-root="${com.sun.aas.instanceRoot}/logs" application-root="${com.sun.aas.instanceRoot}/applications" version="10.0">
21+
<security-configurations>
22+
<authorization-service default="true" name="authorizationService">
23+
<security-provider name="simpleAuthorization" type="Simple" provider-name="simpleAuthorizationProvider">
24+
<authorization-provider-config support-policy-deploy="false" name="simpleAuthorizationProviderConfig"></authorization-provider-config>
25+
</security-provider>
26+
</authorization-service>
27+
</security-configurations>
28+
<system-applications/>
29+
<applications/>
30+
<resources>
31+
<jdbc-resource pool-name="__TimerPool" jndi-name="jdbc/__TimerPool" object-type="system-admin"/>
32+
<jdbc-resource pool-name="DerbyPool" jndi-name="jdbc/__default" object-type="system-all"/>
33+
<jdbc-connection-pool name="__TimerPool" datasource-classname="org.apache.derby.jdbc.EmbeddedXADataSource" res-type="javax.sql.XADataSource">
34+
<property value="${com.sun.aas.instanceRoot}/lib/databases/ejbtimer" name="databaseName"/>
35+
<property value=";create=true" name="connectionAttributes"/>
36+
</jdbc-connection-pool>
37+
<jdbc-connection-pool is-isolation-level-guaranteed="false" name="DerbyPool" datasource-classname="org.apache.derby.jdbc.EmbeddedDataSource" res-type="javax.sql.DataSource">
38+
<property name="databaseName" value="${com.sun.aas.instanceRoot}/lib/databases/embedded_default"/>
39+
<property name="connectionAttributes" value=";create=true"/>
40+
</jdbc-connection-pool>
41+
</resources>
42+
<servers>
43+
<server name="server" config-ref="server-config">
44+
<resource-ref ref="jdbc/__TimerPool"/>
45+
<resource-ref ref="jdbc/__default"/>
46+
</server>
47+
</servers>
48+
<configs>
49+
<config name="server-config">
50+
<http-service>
51+
<access-log rotation-interval-in-minutes="15" rotation-suffix="yyyy-MM-dd"/>
52+
<virtual-server id="server" network-listeners="http-listener, https-listener"/>
53+
</http-service>
54+
<admin-service type="das-and-server" system-jmx-connector-name="system">
55+
<jmx-connector enabled="false" auth-realm-name="admin-realm" security-enabled="false" address="0.0.0.0" port="8686" name="system"/>
56+
<das-config autodeploy-enabled="false" dynamic-reload-enabled="true" deploy-xml-validation="full" autodeploy-dir="${com.sun.aas.instanceRoot}/autodeploy"/>
57+
<property value="/admin" name="adminConsoleContextRoot"/>
58+
<property value="${com.sun.aas.installRoot}/lib/install/applications/admingui.war" name="adminConsoleDownloadLocation"/>
59+
<property value="${com.sun.aas.installRoot}/.." name="ipsRoot"/>
60+
</admin-service>
61+
<connector-service shutdown-timeout-in-seconds="30">
62+
</connector-service>
63+
<ejb-container steady-pool-size="0" max-pool-size="32" session-store="${com.sun.aas.instanceRoot}/session-store" pool-resize-quantity="8">
64+
<ejb-timer-service/>
65+
</ejb-container>
66+
<mdb-container steady-pool-size="0" max-pool-size="32" pool-resize-quantity="8">
67+
</mdb-container>
68+
<log-service file="${com.sun.aas.instanceRoot}/logs/server.log" log-rotation-limit-in-bytes="2000000">
69+
<module-log-levels/>
70+
</log-service>
71+
<security-service activate-default-principal-to-role-mapping="true" jacc="simple">
72+
<auth-realm classname="com.sun.enterprise.security.auth.realm.file.FileRealm" name="admin-realm">
73+
<property value="${com.sun.aas.instanceRoot}/config/admin-keyfile" name="file"/>
74+
<property value="fileRealm" name="jaas-context"/>
75+
</auth-realm>
76+
<auth-realm classname="com.sun.enterprise.security.auth.realm.file.FileRealm" name="file">
77+
<property value="${com.sun.aas.instanceRoot}/config/keyfile" name="file"/>
78+
<property value="fileRealm" name="jaas-context"/>
79+
</auth-realm>
80+
<auth-realm classname="com.sun.enterprise.security.auth.realm.certificate.CertificateRealm" name="certificate"/>
81+
<jacc-provider policy-configuration-factory-provider="com.sun.enterprise.security.provider.PolicyConfigurationFactoryImpl" policy-provider="com.sun.enterprise.security.provider.PolicyWrapper" name="default">
82+
<property value="${com.sun.aas.instanceRoot}/generated/policy" name="repository"/>
83+
</jacc-provider>
84+
<jacc-provider policy-configuration-factory-provider="com.sun.enterprise.security.jacc.provider.SimplePolicyConfigurationFactory" policy-provider="com.sun.enterprise.security.jacc.provider.SimplePolicyProvider" name="simple"/>
85+
<audit-module classname="com.sun.enterprise.security.ee.Audit" name="default">
86+
<property value="false" name="auditOn"/>
87+
</audit-module>
88+
<message-security-config auth-layer="SOAP">
89+
<provider-config provider-id="XWS_ClientProvider" class-name="com.sun.xml.wss.provider.ClientSecurityAuthModule" provider-type="client">
90+
<request-policy auth-source="content"/>
91+
<response-policy auth-source="content"/>
92+
<property value="s1as" name="encryption.key.alias"/>
93+
<property value="s1as" name="signature.key.alias"/>
94+
<property value="false" name="dynamic.username.password"/>
95+
<property value="false" name="debug"/>
96+
</provider-config>
97+
<provider-config provider-id="ClientProvider" class-name="com.sun.xml.wss.provider.ClientSecurityAuthModule" provider-type="client">
98+
<request-policy auth-source="content"/>
99+
<response-policy auth-source="content"/>
100+
<property value="s1as" name="encryption.key.alias"/>
101+
<property value="s1as" name="signature.key.alias"/>
102+
<property value="false" name="dynamic.username.password"/>
103+
<property value="false" name="debug"/>
104+
<property value="${com.sun.aas.instanceRoot}/config/wss-server-config-1.0.xml" name="security.config"/>
105+
</provider-config>
106+
<provider-config provider-id="XWS_ServerProvider" class-name="com.sun.xml.wss.provider.ServerSecurityAuthModule" provider-type="server">
107+
<request-policy auth-source="content"/>
108+
<response-policy auth-source="content"/>
109+
<property value="s1as" name="encryption.key.alias"/>
110+
<property value="s1as" name="signature.key.alias"/>
111+
<property value="false" name="debug"/>
112+
</provider-config>
113+
<provider-config provider-id="ServerProvider" class-name="com.sun.xml.wss.provider.ServerSecurityAuthModule" provider-type="server">
114+
<request-policy auth-source="content"/>
115+
<response-policy auth-source="content"/>
116+
<property value="s1as" name="encryption.key.alias"/>
117+
<property value="s1as" name="signature.key.alias"/>
118+
<property value="false" name="debug"/>
119+
<property value="${com.sun.aas.instanceRoot}/config/wss-server-config-1.0.xml" name="security.config"/>
120+
</provider-config>
121+
</message-security-config>
122+
<property value="SHA-256" name="default-digest-algorithm"/>
123+
</security-service>
124+
<monitoring-service>
125+
<module-monitoring-levels/>
126+
</monitoring-service>
127+
<transaction-service tx-log-dir="${com.sun.aas.instanceRoot}/logs">
128+
</transaction-service>
129+
<java-config>
130+
<jvm-options>-Djavax.net.ssl.keyStore=${com.sun.aas.instanceRoot}/config/keystore.jks</jvm-options>
131+
<jvm-options>-Djavax.net.ssl.trustStore=${com.sun.aas.instanceRoot}/config/cacerts.jks</jvm-options>
132+
<jvm-options>-Dorg.glassfish.jms.InitializeOnDemand=true</jvm-options>
133+
</java-config>
134+
<network-config>
135+
<protocols>
136+
<protocol name="http-listener">
137+
<http default-virtual-server="server" max-connections="250">
138+
<file-cache enabled="false"></file-cache>
139+
</http>
140+
</protocol>
141+
<protocol security-enabled="true" name="https-listener">
142+
<http default-virtual-server="server" max-connections="250">
143+
<file-cache enabled="false"></file-cache>
144+
</http>
145+
<ssl classname="com.sun.enterprise.security.ssl.GlassfishSSLImpl" ssl3-enabled="false" cert-nickname="s1as"></ssl>
146+
</protocol>
147+
</protocols>
148+
<network-listeners>
149+
<network-listener port="8080" protocol="http-listener" transport="tcp" name="http-listener" thread-pool="http-thread-pool" enabled="true"/>
150+
<network-listener port="8181" protocol="https-listener" transport="tcp" name="https-listener" thread-pool="http-thread-pool" enabled="true"/>
151+
</network-listeners>
152+
<transports>
153+
<transport name="tcp"></transport>
154+
</transports>
155+
</network-config>
156+
<thread-pools>
157+
<thread-pool name="http-thread-pool" max-thread-pool-size="64"/>
158+
<thread-pool name="thread-pool-1" max-thread-pool-size="200"/>
159+
</thread-pools>
160+
</config>
161+
</configs>
162+
<property name="administrative.domain.name" value="domain1"/>
163+
<secure-admin>
164+
<secure-admin-principal dn="CN=localhost,OU=Launcher,O=Fujitsu Limited"/>
165+
<secure-admin-principal dn="CN=localhost-instance,OU=Launcher,O=Fujitsu Limited"/>
166+
</secure-admin>
167+
</domain>

launcher-dist/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@
9191
<manifestEntries>
9292
<Main-Class>com.fujitsu.launcher.LauncherMain</Main-Class>
9393
<!-- do not forget to update uber-jar_MANIFEST.MF -->
94-
<Add-Opens>java.base/java.lang java.base/java.lang.invoke java.base/java.util java.naming/javax.naming.spi java.rmi/sun.rmi.transport java.xml/com.sun.org.apache.bcel.internal.classfile</Add-Opens>
94+
<Add-Opens>java.base/java.lang java.base/java.lang.invoke java.base/java.util java.base/sun.net.www.protocol.jar java.naming/javax.naming.spi java.rmi/sun.rmi.transport java.xml/com.sun.org.apache.bcel.internal.classfile</Add-Opens>
9595
</manifestEntries>
9696
</transformer>
9797
<transformer implementation="org.apache.maven.plugins.shade.resource.ApacheNoticeResourceTransformer">

launcher-impl/bootstrap/src/main/java/com/fujitsu/launcher/LauncherMain.java

Lines changed: 80 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -26,16 +26,21 @@
2626
import java.nio.file.Paths;
2727
import java.util.HashMap;
2828
import java.util.Map;
29+
import java.util.Properties;
2930
import java.util.logging.Level;
3031
import java.util.logging.Logger;
32+
3133
import org.glassfish.embeddable.GlassFish;
3234
import org.glassfish.embeddable.GlassFishProperties;
3335
import org.glassfish.embeddable.GlassFishRuntime;
36+
import org.glassfish.hk2.api.ServiceLocator;
3437
import org.glassfish.internal.api.Globals;
3538
import org.kohsuke.args4j.CmdLineException;
3639
import org.kohsuke.args4j.CmdLineParser;
3740
import org.kohsuke.args4j.Option;
3841

42+
import com.sun.enterprise.glassfish.bootstrap.Constants;
43+
import com.sun.enterprise.module.bootstrap.StartupContext;
3944
import com.sun.enterprise.server.logging.GFFileHandler;
4045

4146
/**
@@ -155,32 +160,20 @@ private void generate() {
155160

156161
private void launch() {
157162
try {
163+
Thread preInitShutdownHook = createPreInitShutdownHook();
164+
Runtime.getRuntime().addShutdownHook(preInitShutdownHook);
165+
158166
GlassFish glassfish = GlassFishRuntime.bootstrap().newGlassFish(glassfishProperties);
159-
160-
// add shutdown hook to clean up temporary files
161-
Runtime.getRuntime().addShutdownHook( new Thread() {
162-
public void run() {
163-
try {
164-
glassfish.stop();
165-
// work-around for deleting server.log on disposal
166-
forceCloseLog();
167-
glassfish.dispose();
168-
} catch (Exception e) {
169-
// fall through;
170-
}
171-
}
172167

173-
private void forceCloseLog() {
174-
GFFileHandler h = Globals.get(GFFileHandler.class);
175-
h.preDestroy();
176-
h.close();
177-
}
178-
});
179-
168+
Thread postInitShutdownHook = createPostInitShutdownHook(glassfish);
169+
Runtime.getRuntime().addShutdownHook(postInitShutdownHook);
170+
Runtime.getRuntime().removeShutdownHook(preInitShutdownHook);
171+
180172
glassfish.start();
181173
glassfish.getDeployer().deploy(new File(inputWar), deployProperties.getDeployOptions());
182174
} catch (Throwable th) {
183175
Logger.getLogger(this.getClass().getName()).log(Level.SEVERE, "Server was stopped.", th);
176+
cleanInstanceRoot();
184177
System.exit(1);
185178
}
186179
}
@@ -194,4 +187,71 @@ private Path getTemplate() throws IOException {
194187
JarURLConnection jarURLConnection = (JarURLConnection) url.openConnection();
195188
return Paths.get(jarURLConnection.getJarFile().getName());
196189
}
190+
191+
public static Thread createPreInitShutdownHook() {
192+
return new Thread() {
193+
public void run() {
194+
cleanInstanceRoot();
195+
}
196+
};
197+
}
198+
199+
public static Thread createPostInitShutdownHook(GlassFish glassfish) {
200+
return new Thread() {
201+
public void run() {
202+
try {
203+
glassfish.stop();
204+
// work-around for deleting server.log on disposal
205+
forceCloseLog();
206+
glassfish.dispose();
207+
} catch (Exception e) {
208+
// fall through;
209+
}
210+
}
211+
212+
private void forceCloseLog() {
213+
GFFileHandler h = Globals.get(GFFileHandler.class);
214+
h.preDestroy();
215+
h.close();
216+
}
217+
};
218+
}
219+
220+
public static void cleanInstanceRoot() {
221+
String instanceRootProp = getInstanceRoot();
222+
if (instanceRootProp != null) {
223+
File instanceRoot = new File(instanceRootProp);
224+
deleteRecursively(instanceRoot);
225+
}
226+
}
227+
228+
private static String getInstanceRoot() {
229+
Properties arguments = getStartupContextArguments();
230+
if (arguments == null) {
231+
return System.getProperty(Constants.INSTANCE_ROOT_PROP_NAME);
232+
} else {
233+
return arguments.getProperty(Constants.INSTANCE_ROOT_PROP_NAME);
234+
}
235+
}
236+
237+
private static Properties getStartupContextArguments() {
238+
ServiceLocator habitat = Globals.getDefaultHabitat();
239+
if (habitat == null) {
240+
return null;
241+
}
242+
StartupContext startupContext = habitat.getService(StartupContext.class);
243+
if (startupContext == null) {
244+
return null;
245+
}
246+
return startupContext.getArguments();
247+
}
248+
249+
private static boolean deleteRecursively(File file) {
250+
if (file.isDirectory()) {
251+
for (File f : file.listFiles()) {
252+
deleteRecursively(f);
253+
}
254+
}
255+
return file.delete();
256+
}
197257
}

launcher-impl/bootstrap/src/main/java/com/fujitsu/launcher/uberjar/Launcher.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@
1111
package com.fujitsu.launcher.uberjar;
1212

1313
import com.fujitsu.launcher.DeployProperties;
14+
import com.fujitsu.launcher.LauncherMain;
15+
1416
import java.io.InputStream;
1517
import java.net.URL;
1618
import java.util.logging.Level;
@@ -45,11 +47,20 @@ private void start() {
4547
DeployProperties deployProperties = new DeployProperties();
4648
deployProperties.load(dpis);
4749

50+
Thread preInitShutdownHook = LauncherMain.createPreInitShutdownHook();
51+
Runtime.getRuntime().addShutdownHook(preInitShutdownHook);
52+
4853
GlassFish glassfish = GlassFishRuntime.bootstrap().newGlassFish(glassfishProperties);
54+
55+
Thread postInitShutdownHook = LauncherMain.createPostInitShutdownHook(glassfish);
56+
Runtime.getRuntime().addShutdownHook(postInitShutdownHook);
57+
Runtime.getRuntime().removeShutdownHook(preInitShutdownHook);
58+
4959
glassfish.start();
5060
glassfish.getDeployer().deploy(wis, deployProperties.getDeployOptions());
5161
} catch (Throwable th) {
5262
Logger.getLogger(this.getClass().getName()).log(Level.SEVERE, "Server was stopped.", th);
63+
LauncherMain.cleanInstanceRoot();
5364
System.exit(1);
5465
}
5566
}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
Manifest-Version: 1.0
22
Bundle-SymbolicName: org.glassfish.main.embedded.web
33
Main-Class: com.fujitsu.launcher.uberjar.Launcher
4-
Add-Opens: java.base/java.lang java.base/java.lang.invoke java.base/java.util java.naming/javax.naming.spi java.rmi/sun.rmi.transport java.xml/com.sun.org.apache.bcel.internal.classfile
4+
Add-Opens: java.base/java.lang java.base/java.lang.invoke java.base/java.util java.base/sun.net.www.protocol.jar java.naming/javax.naming.spi java.rmi/sun.rmi.transport java.xml/com.sun.org.apache.bcel.internal.classfile

launcher-impl/glassfish/pom.xml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -288,6 +288,12 @@
288288
</exclusion>
289289
</exclusions>
290290
</dependency>
291+
<!-- required to compile ssl-impl sources -->
292+
<dependency>
293+
<groupId>org.glassfish.annotations</groupId>
294+
<artifactId>logging-annotation-processor</artifactId>
295+
<optional>true</optional>
296+
</dependency>
291297
<!-- JDK 11 -->
292298
<dependency>
293299
<groupId>jakarta.xml.bind</groupId>

launcher-impl/glassfish/src/main/java/com/sun/appserv/connectors/internal/api/ConnectorsClassLoaderUtil.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
/*
22
* Copyright (c) 1997, 2018 Oracle and/or its affiliates. All rights reserved.
3+
* Copyright (c) 2019 Fujitsu Limited.
34
*
45
* This program and the accompanying materials are made available under the
56
* terms of the Eclipse Public License v. 2.0, which is available at
@@ -13,9 +14,6 @@
1314
*
1415
* SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
1516
*/
16-
/*
17-
* Portions Copyright 2019 Fujitsu Limited.
18-
*/
1917

2018
package com.sun.appserv.connectors.internal.api;
2119

0 commit comments

Comments
 (0)