wildfly(JBoss AS)應用服務器快速入門


什么是wildfly

JBoss AS 從8版本起名為wildfly。Wildfly是一個開源的基於JavaEE的輕量級應用服務器。可以在任何商業應用中免費使用。

WildFly是一個靈活的、輕量的、強大管理能力的應用程序服務器。Wildfly是一個管理EJB的容器和服務器,但JBoss核心服務不包括支持servlet/JSP的WEB容器,一般與Tomcat或Jetty綁定使用。

特點

  • 無與倫比的速度:快速啟動,無限的網絡性能和可擴展性。
  • 非常的輕量級:瘦內存管理,運行時間可定制化。
  • 強大的管理功能:統一的配置和管理。

Wildfly更多特點及與市面上常見的Web服務對比,可參看《熱門WEB容器TOMCAT、JETTY、 GLASSFISH、WILDFLY對比》。

下載安裝

wildfly下載地址:https://wildfly.org/downloads/

目前,最新版本是18.0.0.Final,選擇“Java EE Full & Web Distribution”項對應的ZIP版本,點擊下載即可。如果官網下載較慢,可關注微信公眾號“程序新視界”,回復“wildfly”獲得下載鏈接。

安裝java環境要求Java8或更高版本。

所謂的安裝即解壓即可。下面看一下該版本的目錄結構:

├── LICENSE.txt
├── README.txt
├── appclient
├── bin
├── copyright.txt
├── docs
├── domain
├── jboss-modules.jar
├── modules
├── standalone
└── welcome-content

standalone目錄下存放的應用將單獨占用進程,可單獨啟動和關閉,之間沒有關聯性。旗下有許多xml文件可供啟動時選擇。

domain目錄下的應用之間有關聯性,managing multiple servers from a single control point。

modules目錄,jboss采用module加載驅動。

readme及啟動命令

重點看一下readme中的內容,提供了啟動相關的指導。

關鍵特性:

Key Features
------------
* Jakarta EE 8 support
* Fast Startup
* Small Footprint
* Modular Design
* Unified Configuration and Management
* Distributed Domain Management

文檔獲取,同時也可以看出啟動時默認是監聽8080端口。

Also, once WildFly is started you can go to http://localhost:8080/
for additional information.

啟動命令:

Starting a Standalone Server
----------------------------
A WildFly standalone server runs a single instance.

<JBOSS_HOME>/bin/standalone.sh      (Unix / Linux)

<JBOSS_HOME>\bin\standalone.bat     (Windows)

啟動腳本位於根目錄/bin目錄中。Windows為standalone.bat,Linux為standalone.sh。

Wildfly還可以啟動一個管理后台來對服務進行管理。

Starting a Managed Domain
-------------------------
A WildFly managed domain allows you to control and configure multiple instances,
potentially across several physical (or virtual) machines. The default 
configuration includes a domain controller and a single server group with three 
servers (two of which start automatically), all running on the localhost.

<JBOSS_HOME>/bin/domain.sh      (Unix / Linux)

<JBOSS_HOME>\bin\domain.bat     (Windows)

啟動腳本位於根目錄/bin目錄中。Windows為domain.bat,Linux為domain.sh。

停止服務,可以通過控制台輸入Ctrl+c命令來操作。如果服務在后台運行,可執行一下命令進行停止。

<JBOSS_HOME>/bin/jboss-cli.sh --connect --command=:shutdown      (Unix / Linux)

<JBOSS_HOME>\bin\jboss-cli.bat --connect --command=:shutdown     (Windows)

啟動操作

現在啟動項目standalone看一下效果。

19:48:11,234 INFO  [org.jboss.as.ejb3] (MSC service thread 1-6) WFLYEJB0482: Strict pool mdb-strict-max-pool is using a max instance size of 32 (per class), which is derived from the number of CPUs on this host.
19:48:11,234 INFO  [org.jboss.as.ejb3] (MSC service thread 1-2) WFLYEJB0481: Strict pool slsb-strict-max-pool is using a max instance size of 128 (per class), which is derived from thread worker pool sizing.
19:48:11,296 INFO  [org.wildfly.extension.undertow] (MSC service thread 1-4) WFLYUT0006: Undertow HTTP listener default listening on 127.0.0.1:8080
19:48:11,409 INFO  [org.jboss.as.ejb3] (MSC service thread 1-6) WFLYEJB0493: EJB subsystem suspension complete
19:48:11,479 INFO  [org.jboss.as.connector.subsystems.datasources] (MSC service thread 1-3) WFLYJCA0001: Bound data source [java:jboss/datasources/ExampleDS]
19:48:11,579 INFO  [org.jboss.as.patching] (MSC service thread 1-3) WFLYPAT0050: WildFly Full cumulative patch ID is: base, one-off patches include: none
19:48:11,596 WARN  [org.jboss.as.domain.management.security] (MSC service thread 1-5) WFLYDM0111: Keystore /Users/zzs/tools/wildfly18/standalone/configuration/application.keystore not found, it will be auto generated on first use with a self signed certificate for host localhost
19:48:11,606 INFO  [org.jboss.as.server.deployment.scanner] (MSC service thread 1-6) WFLYDS0013: Started FileSystemDeploymentService for directory /Users/zzs/tools/wildfly18/standalone/deployments
19:48:11,746 INFO  [org.wildfly.extension.undertow] (MSC service thread 1-2) WFLYUT0006: Undertow HTTPS listener https listening on 127.0.0.1:8443
19:48:11,846 INFO  [org.jboss.ws.common.management] (MSC service thread 1-2) JBWS022052: Starting JBossWS 5.3.0.Final (Apache CXF 3.3.3)
19:48:11,963 INFO  [org.jboss.as.server] (Controller Boot Thread) WFLYSRV0212: Resuming server
19:48:11,965 INFO  [org.jboss.as] (Controller Boot Thread) WFLYSRV0060: Http management interface listening on http://127.0.0.1:9990/management
19:48:11,965 INFO  [org.jboss.as] (Controller Boot Thread) WFLYSRV0051: Admin console listening on http://127.0.0.1:9990
19:48:11,965 INFO  [org.jboss.as] (Controller Boot Thread) WFLYSRV0025: WildFly Full 18.0.0.Final (WildFly Core 10.0.0.Final) started in 3880ms - Started 315 of 577 services (369 services are lazy, passive or on-demand)

通過以上部分日志可以看到,wildfly監聽了8080,8443和9990端口。

訪問服務器的url為:127.0.0.1:8080,訪問管理后台的url為:http://127.0.0.1:9990/。

訪問服務器可看到如下頁面:

image

頁面內包含文檔、快速啟動、管理后台等鏈接。

此時訪問后台管理會提示如下內容:

Welcome to WildFly
Your WildFly Application Server is running.
However you have not yet added any users to be able to access the admin console.

To add a new user execute the add-user.sh script within the bin folder of your WildFly installation and enter the requested information.

By default the realm name used by WildFly is "ManagementRealm" this is already selected by default.

After you have added the user follow this link to Try Again.

也就是說啟動成功了,但沒有配置用戶。同tomcat一樣,wildfly也有自己的服務管理頁面,可以統一管理應用,設置權限用戶。執行add-user腳本來添加管理者用戶。

bin zzs$ ./add-user.sh

What type of user do you wish to add?
 a) Management User (mgmt-users.properties)
 b) Application User (application-users.properties)
 # 輸入a,以添加管理用戶
(a): a

Enter the details of the new user to add.
Using realm 'ManagementRealm' as discovered from the existing property files.
# 輸入用戶名
Username : zzs
Password recommendations are listed below. To modify these restrictions edit the add-user.properties configuration file.
 - The password should be different from the username
 - The password should not be one of the following restricted values {root, admin, administrator}
 - The password should contain at least 8 characters, 1 alphabetic character(s), 1 digit(s), 1 non-alphanumeric symbol(s)
 # 輸入用戶密碼
Password :
# 重新輸入密碼
Re-enter Password :
# 留空即可或輸入ManagementRealm
What groups do you want this user to belong to? (Please enter a comma separated list, or leave blank for none)[  ]: ManagementRealm
About to add user 'zzs' for realm 'ManagementRealm'
# 繼續則輸入yes
Is this correct yes/no? yes
Added user 'zzs' to file '/Users/zzs/tools/wildfly18/standalone/configuration/mgmt-users.properties'
Added user 'zzs' to file '/Users/zzs/tools/wildfly18/domain/configuration/mgmt-users.properties'
Added user 'zzs' with groups ManagementRealm to file '/Users/zzs/tools/wildfly18/standalone/configuration/mgmt-groups.properties'
Added user 'zzs' with groups ManagementRealm to file '/Users/zzs/tools/wildfly18/domain/configuration/mgmt-groups.properties'
Is this new user going to be used for one AS process to connect to another AS process?
e.g. for a slave host controller connecting to the master or for a Remoting connection for server to server EJB calls.
# 繼續則輸入yes
yes/no? yes

這里需要注意,用戶添加完畢后,將回饋給你此用戶的secret value,可在domain與slave 的通信中用到
To represent the user add the following to the server-identities definition <secret value="MTk4NzEwMjlfUXE=" />

每一步操作都會有對應的提示與選項,按照提示填寫即可。

設置完成,再進點擊Administration Console或訪問http://127.0.0.1:9990/,輸入剛剛設置的用戶名密碼,即可登錄管理后台。

image

原文鏈接:《wildfly(JBoss AS)應用服務器快速入門

參考文章:《熱門WEB容器TOMCAT、JETTY、 GLASSFISH、WILDFLY對比


程序新視界:精彩和成長都不容錯過
![程序新視界-微信公眾號](https://img2018.cnblogs.com/blog/1742867/201910/1742867-20191013111755842-2090947098.png)


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM