one. Download and install JBoss
In this article, we download the JBoss version as: 4.2.1.GA.
Download Address:
http://sourceforge.net/project/showfiles.php?group_id=22866&package_id=16942&release_id=523619
Download the Jboss-4.2.1.ga.zip file in the download page above.
After the download is complete, unzip it to complete the installation, decompression and put it into a directory without spaces (if the directory with spaces, for example: C: "Program Files, may produce some inexplicable errors in the future), Eg:e:" JBoss4.2.1. Also set the environment variable named Jboss_home in environment variable settings, the value is the installation path for JBoss, as shown in the following illustration:
At this point, the installation of JBoss has ended, and you can test the success of your installation by:
Run the JBoss installation directory "Bin" Run.bat, if no exception appears in the window, and appears: 10:16:19,765 INFO [Server] JBoss (MX microkernel) [4.2.1.GA (build:svntag= Jboss_4_2_1_ga date=200707131605)] started in 30s:828ms indicates successful installation.
We can access the JBoss Welcome interface by visiting: http://localhost:8080, click on the JMX console under JBoss Management to enter JBoss's console.
Failure to start can be caused by the following reasons:
1 The port used by JBoss (8080,1099,1098,8083, etc.) is occupied. Typically 8080 ports are occupied (for example, Oracle occupies 8080 ports), and the JBoss port needs to be modified by entering the JBoss installation directory "Server" default "deploy" Jboss-web.deployer directory, modify the Server.xml directory below, search for 8080 in this file, and change it to the port you want (for example, 8088);
2 The JDK installation is not correct;
3) JBoss download is not complete.
two. Description of JBoss directory structure
Directory |
Description |
Bin |
Start and close JBoss scripts (Run.bat for startup scripts under Windows systems, Shutdown.bat for shutdown scripts under Windows systems). |
Client |
The Java Library (JARs) required by the client to communicate with JBoss. |
Docs |
The configured sample files (database configuration, etc.). |
Docs/dtd |
A DTD for various XML files used in JBoss. |
Lib |
Some jar,jboss are loaded at boot time and are shared by all JBoss configurations. (Don't put your library here) |
Server |
Various JBoss configurations. Each configuration must be placed in a different subdirectory. The name of the subdirectory indicates the name of the configuration. JBoss contains 3 default configurations: Minimial,default and all, which you can choose when you install. |
Server/all |
JBoss is fully configured to start all services, including clustering and IIOP. |
Server/default |
The default configuration for JBoss. Used when the configuration name is not specified in the JBoss command line. (We downloaded the 4.2.1 version by default this configuration). |
Server/default/conf |
JBoss's configuration file. |
Server/default/data |
JBoss's database file. For example, an embedded database, or JBOSSMQ |
Server/default/deploy |
The thermal deployment directory for JBoss. Any files or directories placed here will be automatically deployed by JBoss. EJB, WAR, EAR, and even service. |
Server/default/lib |
Some jar,jboss load them when a specific configuration is started. (The default and Minimial configurations also contain this and the following two directories.) ) |
Server/default/log |
JBoss's log file. |
Server/default/tmp |
The temporary file for JBoss. |
three. The configuration of JBoss
1. log File Settings
If you need to modify the JBoss default log4j setting, modify the Jboss-log4j.xml file under the JBoss installation directory "Server" default conf, where you can see log4j log output in the JBoss installation directory "Server" In the Server.log file under the "Default" log. For log4j settings, readers can search for more detailed information on the web.
2. Modification of the port number of the Web service
This is mentioned in the previous article, that is, modify the Server.xml file under the JBoss installation directory "Server" default "deploy" Jboss-web.deployer, as follows:
<connector port= "8080" address= "${jboss.bind.address}"
maxthreads= "maxhttpheadersize=" "8192"
Emptysessionpath= "true" protocol= "http/1.1"
Enablelookups= "false" redirectport= "8443" acceptcount= "100"
connectiontimeout= "20000" disableuploadtimeout= "true"/>
Change the top 8080 port to the port you want. After restarting JBoss access: http://localhost: The newly set port can see the JBoss welcome interface.
3. JBoss Security Settings
1) Jmx-console login username and password settings
By default access Http://localhost:8080/jmx-console can browse JBoss deployment management of some information, do not need to enter a username and password, use a bit of security risks. Below we configure JBoss for this issue so that access Jmx-console must also know the username and password to access it. The steps are as follows:
i) find the JBoss installation directory/server/default/deploy/jmx-console.war/web-inf/jboss-web.xml file, remove <security-domain>java:/ Jaas/jmx-console</security-domain> 's comment. The contents of the modified file are:
<jboss-web>
<!--uncomment the Security-domain to enable security. You'll
Need to edit the htmladaptor login configuration to setup the
Login modules used to authentication users.-->
<security-domain>java:/jaas/jmx-console</security-domain>
</jboss-web>
(ii) Modify the Web.xml file in the Jboss-web.xml sibling directory in the i), find the <security-constraint/> node, remove its annotations, and modify the contents as follows:
<!--A security constraint which restricts access to the HTML JMX console
To the users and the role jbossadmin. Edit the roles to what you want and
Uncomment the Web-inf/jboss-web.xml/security-domain element to enable
Secured access to the HTML JMX console.-->
<security-constraint>
<web-resource-collection>
<web-resource-name>HtmlAdaptor</web-resource-name>
<description>an Example Security Config This is allows users with the
Role jbossadmin to access the HTML JMX console Web application
</description>
<url-pattern>/*</url-pattern>
</web-resource-collection>
<auth-constraint>
<role-name>JBossAdmin</role-name>
</auth-constraint>
</security-constraint>
This is where you can see that the role Jbossadmin is configured for the login.
III in the first step of the Jmx-console security domain and the second step of the run role Jbossadmin are configured in Login-config.xml, we found it under the JBoss installation directory/server/default/config. Find the name: Jmx-console application-policy:
<application-policy name = "Jmx-console"
<authentication>
<login-module code= " Org.jboss.security.auth.spi.UsersRolesLoginModule "
flag = "Required"
< Module-option name= "Usersproperties" >PROPS/JMX-CONSOLE-USERS.PROPERTIES</MODULE-OPTION>
<module-option name= "Rolesproperties" >props/ Jmx-console-roles.properties</module-option>
</login-module>
</authentication>
< /application-policy>
Here you can see that the login roles, user information, etc. are set in the Jmx-console-roles.properties and jmx-console-users.properties files in the props directory, opening the two files separately.
The contents of the Jmx-console-users.properties file are as follows:
# A Sample Users.properties file for use with the Usersrolesloginmodule
Admin=admin
The file is defined in the format: User name = password, in which the default definition of a user named admin, password is also admin user, readers can change it to the required username and password.
The contents of jmx-console-roles.properties are as follows:
# A Sample Roles.properties file for use with the Usersrolesloginmodule
Admin=jbossadmin, Httpinvoker
The file is defined in the format: User name = role, multiple roles are separated by "," and the file defaults to the Admin user to define Jbossadmin and httpinvoker roles.
After the configuration is complete, the reader can access the Jmx-console page by accessing the user name and password defined in the Jmx-console-roles.properties file via access: http://localhost:8088/jmx-console/.
2) Web-console login username and password settings
By default, users are not required to enter a username and password when accessing JBoss Web-console, and for security reasons, we add a username and password by modifying the configuration. The steps are as follows:
I) Locate the JBoss installation directory "Server" default "deploy" Management "Console-mgr.sar" Web-console.war "Web-inf" Jboss-web.xml file, remove <security-domain>java:/jaas/web-console</security-domain> comments, the modified contents of the file is: