GlassFish尝鲜

参考链接:

https://www.timehorse.com/2020/10/15/how-to-install-glassfish/

https://www.cnblogs.com/feiqiangsheng/p/11242397.html

https://glassfish.org/

https://github.com/javaee/glassfish

https://github.com/eclipse-ee4j/glassfish

glassfish 是一个web服务器, 具有 tomcat 的功能.

下载 GlassFish

目前 glassfish 已迁移到 eclipse/glassfish 仓库

5.0.1 - Full Platform 版本

https://javaee.github.io/glassfish/download

6.0.0-RC3 版本

https://github.com/eclipse-ee4j/glassfish/releases/tag/6.0.0-RC3

运行

5.0.1 - Full Platform

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
PS D:\Users\foyou\TODO\PowerShell\glassfish5> .\bin\asadmin start-domain
Exception in thread "main" java.lang.NullPointerException: Cannot invoke "org.glassfish.hk2.api.DynamicConfigurationService.createDynamicConfiguration()" because "dcs" is null
at com.sun.enterprise.module.common_impl.AbstractModulesRegistryImpl.initializeServiceLocator(AbstractModulesRegistryImpl.java:152)
at com.sun.enterprise.module.common_impl.AbstractModulesRegistryImpl.newServiceLocator(AbstractModulesRegistryImpl.java:144)
at com.sun.enterprise.module.common_impl.AbstractModulesRegistryImpl.createServiceLocator(AbstractModulesRegistryImpl.java:218)
at com.sun.enterprise.module.common_impl.AbstractModulesRegistryImpl.createServiceLocator(AbstractModulesRegistryImpl.java:224)
at com.sun.enterprise.module.single.StaticModulesRegistry.createServiceLocator(StaticModulesRegistry.java:88)
at com.sun.enterprise.admin.cli.CLIContainer.getServiceLocator(CLIContainer.java:217)
at com.sun.enterprise.admin.cli.CLIContainer.getLocalCommand(CLIContainer.java:255)
at com.sun.enterprise.admin.cli.CLICommand.getCommand(CLICommand.java:231)
at com.sun.enterprise.admin.cli.AdminMain.executeCommand(AdminMain.java:371)
at com.sun.enterprise.admin.cli.AdminMain.doMain(AdminMain.java:306)
at org.glassfish.admin.cli.AsadminMain.main(AsadminMain.java:57)
PS D:\Users\foyou\TODO\PowerShell\glassfish5> java -version
java version "15.0.1" 2020-10-20
Java(TM) SE Runtime Environment (build 15.0.1+9-18)
Java HotSpot(TM) 64-Bit Server VM (build 15.0.1+9-18, mixed mode, sharing)

切换 jdk 至 1.8

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
PS D:\Users\foyou\TODO\PowerShell\glassfish5> $env:Path = "C:\Program Files\Java\jdk1.8.0_271\bin\;$env:Path"
PS D:\Users\foyou\TODO\PowerShell\glassfish5> java -version
java version "1.8.0_271"
Java(TM) SE Runtime Environment (build 1.8.0_271-b09)
Java HotSpot(TM) 64-Bit Server VM (build 25.271-b09, mixed mode)
PS D:\Users\foyou\TODO\PowerShell\glassfish5> .\bin\asadmin start-domain
Waiting for domain1 to start .Error starting domain domain1.
The server exited prematurely with exit code 1.
Before it died, it produced the following output:

-Djava.endorsed.dirs=D:\Users\foyou\TODO\PowerShell\glassfish5\glassfish/modules/endorsed;D:\Users\foyou\TODO\PowerShell\glassfish5\glassfish/lib/endorsed is not supported. Endorsed standards and standalone APIs
in modular form will be supported via the concept of upgradeable modules.
OpenJDK 64-Bit Client VM warning: Ignoring option MaxPermSize; support was removed in 8.0
Error: Could not create the Java Virtual Machine.
Error: A fatal exception has occurred. Program will exit.

Command start-domain failed.

image-20201215193350979

解决报错

参考链接:

https://github.com/eclipse-ee4j/glassfish/issues/22736

搜索 -Djava.endorsed.dirs, 找到 domain1.xml 文件, 删除其中包含的 -Djava.endorsed.dirs

image-20201215194521512

1
2
3
4
5
6
7
8
9
10
11
12
13
PS D:\Users\foyou\TODO\PowerShell\glassfish5> java -version
java version "15.0.1" 2020-10-20
Java(TM) SE Runtime Environment (build 15.0.1+9-18)
Java HotSpot(TM) 64-Bit Server VM (build 15.0.1+9-18, mixed mode, sharing)
PS D:\Users\foyou\TODO\PowerShell\glassfish5> $env:Path = "C:\Program Files\Java\jdk1.8.0_271\bin\;$env:Path"
PS D:\Users\foyou\TODO\PowerShell\glassfish5> .\bin\asadmin.bat start-domain
Waiting for domain1 to start ..
Successfully started the domain : domain1
domain Location: D:\Users\foyou\TODO\PowerShell\glassfish5\glassfish\domains\domain1
Log File: D:\Users\foyou\TODO\PowerShell\glassfish5\glassfish\domains\domain1\logs\server.log
Admin Port: 4848
Command start-domain executed successfully.
PS D:\Users\foyou\TODO\PowerShell\glassfish5>

注意: 请排除 java 与 不同 JAVA_HOME 导致的问题

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
PS C:\Users\admin> $env:JAVA_HOME
C:\Program Files\BellSoft\LibericaJDK-15-Full\
PS C:\Users\admin> java -version
java version "1.8.0_271"
Java(TM) SE Runtime Environment (build 1.8.0_271-b09)
Java HotSpot(TM) 64-Bit Server VM (build 25.271-b09, mixed mode)
PS C:\Users\admin> cd .\Desktop\jav\glassfish5\
PS C:\Users\admin\Desktop\jav\glassfish5> .\bin\asadmin start-domain
Waiting for domain1 to start .Error starting domain domain1.
The server exited prematurely with exit code 1.
Before it died, it produced the following output:

-Djava.endorsed.dirs=C:\Users\admin\Desktop\jav\glassfish5\glassfish/modules/endorsed;C:\Users\admin\Desktop\jav\glassfish5\glassfish/lib/endorsed is not supported. Endorsed standards and standalone APIs
in modular form will be supported via the concept of upgradeable modules.
OpenJDK 64-Bit Client VM warning: Ignoring option MaxPermSize; support was removed in 8.0
Error: Could not create the Java Virtual Machine.
Error: A fatal exception has occurred. Program will exit.

Command start-domain failed.
PS C:\Users\admin\Desktop\jav\glassfish5> $env:JAVA_HOME = ''
PS C:\Users\admin\Desktop\jav\glassfish5> .\bin\asadmin start-domain
Waiting for domain1 to start ....
Successfully started the domain : domain1
domain Location: C:\Users\admin\Desktop\jav\glassfish5\glassfish\domains\domain1
Log File: C:\Users\admin\Desktop\jav\glassfish5\glassfish\domains\domain1\logs\server.log
Admin Port: 4848
Command start-domain executed successfully.
PS C:\Users\admin\Desktop\jav\glassfish5>

image-20201215195006768

6.0.0-RC3