Before we start I would like to make one note and that is when you install software try and rename the installation directory (not to use any spaces) because in some environments (Windows) it likes to place JBoss in a pathname that has spaces (c:\program files\...), when you develop applications later, spaces in pathnames will cause you major headaches.
The first task we need to do is to obtain the JDK from Sun (http://java.sun.com), I used version 1.6.0 and JBoss runs perfectly but you might want to try with the latest version, download the JDK and install into your environment following Sun's instructions. Once installed don't forgot to set a JAVA_HOME environment variable that points to your JDK.
JAVA_HOME | set JAVA_HOME=c:/jdk1.6.0_12 |
- Binary
- Using JEMS (GUI)
It appears that the binary installation is the preferred way to go, one note is that there is no installation and everything that you need is contained in one directory (no registry settings or package stuff), this means you just copy the directory and put onto any server (Windows or Unix) and it should start up, the only difference is the way you start JBoss
- Windows - run.bat
- Unix - run.sh
create a windows JBoss service | c:\jboss6\bin\service install Note: downloaded jbosssvc file |
When you have finished installing JBoss you should have a top level directory structure like below (Yes. I know its JBoss 4 but its the same layout)
bin | This directory contains all the scripts (both Unix and Windows) that you will need to start and stop JBoss. There are a number of others files here
|
client | This directory contains many Java libraries that are used to communicate with JBoss server from a client application. These client applications are called standalone client or remote clients and could be Swing applications, remote Web services, JMS clients. If for what ever reason you need to use these libraries use the jbossall-client.jar file, this jar file contains a META-INF/Manifest.mf file that contains a class path reference to all the jar files in this directory. |
common | This directory I believe is from the version 4 JBoss implemention, where all common Java libraries were placed so that all web application could use them, I now believe that all common libraries should be placed in the <server config>/lib directory (see below). |
docs | There are no user manuals in this directory, but it contains the following
|
lib | This directory contains all the libraries that need to start the core JBoss server. Do not put any libraries that you want to use across all web applications, these need to go in <server config>/lib (see below) |
server | This directory only has the server configurations in it, each directory represents a different server configuration that JBoss can be started in (see above). Normally you copy a particular directory that suits you and rename to what ever you want and then configure this directory for your environment, then use the -c option to start your server configuration c:\jboss5\bin\run.bat -c myServerConfig |
conf | Each server configuration has a conf directory that holds files used for servlet-wide configuration. This directory is only scanned once during the boot sequence so any changes that yo make are not picked up until you restart the server. The import files in this directory are
|
deploy | this is where applications and services are deployed. You can deploy any application packages here for example JAR, WAR or EAR that you create. By copying them into this directory JBoss will automatically deploy them to the application server. |
deployers | contains all the JBoss AS services that are used to recognize and deploy different applications and archive types, for example the ejb3.deployer directory contains libraries and configuration files necessary for starting the service that deploys EJB3 applications that you deploy into the deploy directory. |
lib | this directory holds all the Java libraries that can be accessed by all web applications. |
Generated Directories | JBoss creates additional directories when first started
|
JBoss is designed to be modular, this means that you add or remove services very easily, by removing unwanted services you can decrease the memory allocation and increase performance, it also reduces security risks. The picture below shows how the microcontainer runs on top of the JVM and how various application-server services plug into the microcontainer. When you start JBoss you are always starting a server configuration which is a directory structure under the server's server directory, it contains code, libraries and configuration files for a set of services and applications that run when the server starts.
Typically you copy one of the already supplied configurations and adapt it to your environment, then start this configuration using the -c option with run.bat or run.sh, or you can just use one of the supplied configurations.
start a different configuration | run.bat -c minimal run.bat -c <your configuration> |
Pre-Configurations | |
all | Includes everything - clustering, RMI/IIOP support |
default | this is the default configuration if you do not specify anything, it does not include a web container, no ejb or JMS support |
minimal | Includes only JNDI, logging services an a URL deployment scanner to find new deployments |
standard | |
web | Used to contain services which will allow simple web applications (servlet, jsp) to be deployed. |
I have read a number of JBoss books and none of them detailed the JBoss boot sequence, searching the web and using the JBoss log file, I will put a quick summary of the boot sequence below, it may not be to accurate but there is no document that explains this well, I will update this as and when I get more information.
- You start JBoss by running the run.bat or run.sh script, this script sets some variables and then initiates the boot sequence using the org.jboss.Main.main method entry point.
- The main method creates a thread group then starts the microcontainer org.jboss.bootstrap.microcontainer.ServerImpl
- The microcontainer opens the bootstrap.xml, which is a file that contains various MBeans descriptors that should be loaded by the BasicXMLDeployer
- Once the MainDeployer has been invoked it uses the conf/jboss-service.conf file to start the services required for the web application
bootstrap.xml | Defines the core microcontainer services that start when the server first starts. |
bootstrap.xml file | |
vfs.xml | This configures the Virtual filesystem, which is a simple read-only framework abstracting the way we look at the the filesystem. It uses virtual files which can be accessed by a URI/URL (uses a URI/URL:MBean link pairing) |
classloader.xml | This configures the core classloading system and classpath |
aop.xml | Aspect-oriented programming is a programming paradigm that increases modularity by allowing the separation of cross-cutting concerns. (its a post OOP programming paradigm) |
jmx.xml | This configures the JMX Kernel Mbeans |
deployers.xml | This configures the MainDeployer, Structure Deployers, the bootstrap MC and the JMX deployer |
binding.xml | This configures the ServiceBindingManager bean and configuration |
profile-repository.xml | This configures the ProfileService beans which includes management and deployment support. |
To start JBoss using the default configuration, you open a console window and go to the bin directory, then run "run.sh" or "run.bat", you can also use the -c option to change the default server configuration, I have already discussed this above. To stop JBoss use the "shutdown" command
Starting JBoss | # cd <JBoss dir>/bin # run.sh c:\> run.bat # run.sh -c all |
Stopping JBoss | # shutdown.sh c:\> shutdown.bat |
JBoss has started | 2009-04-03 12:05:12,125 INFO [org.jboss.bootstrap.microcontainer.ServerImpl] (main) JBoss (Microcontainer) [5.0.1.GA (build: SVNTag=JBoss_5_0_1_GA date=200902231221)] Started in 1m:907ms |
Logging
JBoss uses log4j an open source logging framework, the configuration file is located at server/xxx/conf/jboss-log4j.xml. I have already discussed log4j in my Tomcat tutorial, so have a look there first then continue back here. JBoss be default has two appenders configured, one for the console and for the server/xxx/log/server.log file. Most configuration setups use a rolling log file, it is created each time JBoss is stopped and restarted and at midnight it is rolled over, you can also specify a size for it to rollover.
Rolling logfile | <log4j: ...> <appender name="FILE" class="org.jboss.logging.appender.RollingFileAppender"> <errorHandler ../> <param name="File" value="${jboss.server.log.dir}/server.log"/> <param name="Append" value="true"/> <param name="MaxFileSize" value="10MB"/> <param name="MaxBackupIndex" value="20"/> <layout ../> </appender> ... </log4j> |
Limiting logging | <log4j:...> ... <category name="org.jboss.jms"> <priority value="WARN"/> </category> </log4j> |
There are a number of system properties that define default directory locations
jboss.home.dir | c:\jboss-5.0.0.GA /opt/jboss-5.0.0.GA |
jboss.home.url | file:/c:\jboss-5.0.0.GA file://opt/jboss-5.0.0.GA |
jboss.lib.url | <jboss.home.url>lib/ |
jboss.patch.url | -none- |
jboss.server.base.dir | <jboss.home.dir>/server |
jboss.server.base.url | <jboss.home.url>server/ |
jboss.server.home.dir | <jboss.server.base.dir>/default |
jboss.server.home.url | <jboss.server.base.url>default/ |
jboss.server.config.url | <jboss.server.home.url>conf/ |
jboss.server.data.dir | <jboss.server.home.dir>/data |
jboss.server.lib.url | <jboss.server.home.url>lib/ |
jboss.server.log.dir | <jboss.server.home.dir>/log |
jboss.server.temp.dir | <jboss.server.home.dir>/tmp |
supplying commandline properties | c:\> run.bat -Djboss.server.log.dir=d:/log |
jboss.server.name | default |
jboss.bind.address | 127.0.0.1 |
Using your own system properties | c:\> run.bat -Dtrading.database.login=trader1 -Dtrading.database.password=traderpw // In your oracle-ds.xml file <user-name>${trading.database.login}</user-name> <password>${trading.database.password}</password> |
No comments:
Post a Comment