JBoss-Servers

Java-Examples

                                                                                                                                                                                                                    Show all | Close all
  • Overview

    • What is server

      In most common use, a server is a physical computer (a computer hardware system) dedicated to run one or more services (as a host), to serve the needs of the users of other computers on the network. Depending on the computing service that it offers it could be a database server, file server, mail server, print server, web server, gaming server, or some other kind of server. In the context of client-server architecture, a server is a computer program running to serve the requests of other programs, the "clients". Thus, the "server" performs some computational task on behalf of "clients". The clients either run on the same computer or connect through the network. In the context of Internet Protocol (IP) networking, a server is a program that operates as a socket listener. Servers often provide essential services across a network, either to private users inside a large organization or to public users via the Internet.
    • Usage

      The term server is used quite broadly in information technology. Despite the many server-branded products available (such as server versions of hardware, software or operating systems), in theory any computerised process that shares a resource to one or more client processes is a server. To illustrate this, take the common example of file sharing. While the existence of files on a machine does not classify it as a server, the mechanism which shares these files to clients by the operating system is the server. Similarly, consider a web server application (such as the multiplatform "Apache HTTP Server"). This web server software can be run on any capable computer. For example, while a laptop or personal computer is not typically known as a server, they can in these situations fulfill the role of one, and hence be labelled as one. It is, in this case, the machine's role that places it in the category of server. In the hardware sense, the word server typically designates computer models intended for hosting software applications under the heavy demand of a network environment. In this client-server configuration one or more machines, either a computer or a computer appliance, share information with each other with one acting as a host for the other[s]. While nearly any personal computer is capable of acting as a network server, a dedicated server will contain features making it more suitable for production environments. These features may include a faster CPU, increased high-performance RAM, and increased storage capacity in the form of a larger or multiple hard drives. Servers also typically have reliability, availability and serviceability (RAS) and fault tolerance features, such as redundancy in power supplies, storage (as in RAID), and network connections. Servers became common in the early 1990s as businesses increasingly began using personal computers to provide services formerly hosted on larger mainframes or minicomputers. Early file servers housed multiple CD-ROM drives, which were used to host large database applications.[citation needed] Between the 1990s and 2000s an increase in the use of dedicated hardware saw the advent of self-contained server appliances. One well-known product is the Google Search Appliance, a unit that combines hardware and software in an out-of-the-box packaging. Simpler examples of such appliances include switches, routers, gateways, and print server, all of which are available in a near plug-and-play configuration. Modern operating systems such as Microsoft Windows or Linux distributions rightfully seem to be designed with a client-server architecture in mind. These operating systems attempt to abstract hardware, allowing a wide variety of software to work with components of the computer. In a sense, the operating system can be seen as serving hardware to the software, which in all but low-level programming languages must interact using an API. These operating systems may be able to run programs in the background called either services or daemons. Such programs, such as the aforementioned Apache HTTP Server software, may wait in a sleep state for their necessity to become apparent. Since any software that provides services can be called a server, modern personal computers can be seen as a forest of servers and clients operating in parallel. The Internet itself is also a forest of servers and clients. Merely requesting a web page from a few kilometers away involves satisfying a stack of protocols that involve many examples of hardware and software servers. The least of these are the routers, modems, domain name servers, and various other servers necessary to provide us the world wide web.
    • Types of servers

      In a general network environment the following types of servers may be found. Application server, a server dedicated to running certain software applications Catalog server, a central search point for information across a distributed network Communications server, carrier-grade computing platform for communications networks Database server, provides database services to other computer programs or computers Fax server, provides fax services for clients File server, provides remote access to files Game server, a server that video game clients connect to in order to play online together Home server, a server for the home Name server or DNS Print server, provides printer services Proxy server, acts as an intermediary for requests from clients seeking resources from other servers Sound server, provides multimedia broadcasting, streaming. Standalone server, an emulator for client-server (web-based) programs Web server, a server that HTTP clients connect to in order to send commands and receive responses along with data contents
  • JBoss

    JavaBeans Open Source Software Application Server (JBoss AS, or simply JBoss) is an application server that implements the Java Platform, Enterprise Edition (Java EE). JBoss is written in Java and as such is cross-platform: usable on any operating system that supports Java. JBoss was developed by JBoss, now a division of Red Hat. Licensed under the terms of the GNU Lesser General Public License, JBoss is free and open source software.
  • Origin

    In 1999, Marc Fleury started a free software project named EJB-OSS (stands for Enterprise Java Bean Open Source Software) implementing the EJB API from J2EE (Java 2 Enterprise Edition). Sun Microsystems asked the project to stop using the EJB trademark within its name. EJB-OSS was then renamed to JBOSS, then JBoss later.[2] .
  • Versions

    JBoss AS 4.0, a Java EE 1.4 application server, features an embedded Apache Tomcat 5.5 servlet container.
    It supports any Java Virtual Machine (JVM) between versions 1.4 and 1.6. JBoss can run on numerous operating systems including many POSIX platforms (like GNU/Linux, FreeBSD and Mac OS X), Microsoft Windows and others, as long as a suitable JVM is present.
    JBoss AS 4.2 also functions as a Java EE 1.4 application server, but deploys Enterprise JavaBeans 3.0 by default. It requires the Java Development Kit version 5, and includes Tomcat 5.5.
    JBoss AS 5.1, released in 2009, operates as a Java EE 5 application server. It is a minor update of the major release JBoss AS 5.0, which was in development for at least three years and was built on top of a new JBoss microcontainer.[3] JBoss AS 5.1 contains a preview of some elements from the Java EE 6 specification.[4]
    JBoss AS 6.0,[5] an unofficial implementation of Java EE 6, was released on December 28, 2010. Although JBoss AS 6 does not support the full Java EE 6 stack,[6] it chose not to support this officially[7][8] by obtaining an official certification from Oracle. It does, however, officially support the Java EE 6 Web Profile.
    JBoss AS 7,[1] was released on July 12, 2011, only six months after the last major release, JBoss AS 6. Unlike previous increments of the major versioning number, JBoss AS 7 supports the same Java EE specification as the last major release, namely Java EE 6. The Java EE profile is only partially implemented in JBoss AS 7, e.g. it includes MDBs, but listening to JMS destinations (which is mandated by the full spec) is not supported.[9] It is, however, certified for the Web Profile. The software code has been completely rewritten for JBoss AS 7.[10][11] Major changes visible to the user are the inability to define resources like JMS destinations and datasources inside archives (war/ear),[12][13] the way datasources are defined,[14][15] a much smaller size (less than half of JBoss AS 6)[1] and a 10-fold reduction in startup time.[16]
    JBoss AS 7.1, the current stable version, was released in February 2012. The remaining parts of the EE spec were implemented, and this version was certified for the EE full profile [17].
  • Installation steps

    JBoss Installation
    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
    Installing JBoss is simple and there are a number of ways that you can install it
    • Binary
    • Using JEMS (GUI)
    The fastest way to install JBoss is to download the binary version from http://www.jboss.org, unzip it and copy it to directory and that's it, it is ready to go, no installation. If you are going to install it straight into Production, then you need to make some changes to the default configuration to secure it, I have a topic on Production configurations. JBoss will work straight out of the box and is ideal for a development environment, the other route is to use JEMS installer which is a GUI based installer that allows you to configure the services that JBoss will use, you need to download the jems-installer file (http://labs.jboss.com/jeminstaller) which is an executable JAR file (90MB), looking at the web site the JEMS installer does not appear to supported very well as the link did not work but you can obtain the file from SourceForge.
    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
    There is a file called "service" in the bin directory which can create a windows JBoss service for you, I had problems when using this, it gave a file error message, this was because of the "jbosssvc" wrapper file was either corrupt or the wrong type, search for a newer version on the web and replace the one in the original install (I have a link below to the one I used)
    create a windows JBoss service c:\jboss6\bin\service install
    Note: downloaded jbosssvc file
    Directory Structure
    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
    • twiddle - we discussed this earlier
    • probe - used to discover JBoss AS clusters
    • wsconsume - Used for web services
    • wsprovide - Used for web services
    • wsrunclient - Used for web services
    • wstools - Used for web services
    • run.sh and run.bat - used to start JBoss
    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
    • Document type definition (DTD) files and XML schemas for the configuration files that JBoss AS uses
    • Configuration examples for various J2EE and JBoss AS
    • Licenses for various libraries included in JBoss AS
    • Unit test results from the tests run against the server for the particular release
    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
    The server directory holds the server configuration, see above for the layout of this directory
    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
    • bootstrap.xml - defines core microcontainer services
    • jboss-service.xml - defines core JMX services
    • jboss-log4j.xml - configures logging
    • login-config.xml - configures authentication and authorization modules for security
    • standardjboss.xml - used to configure the various EJB containers
    • jacorb.properties - Used to configure the Java Object Request Broker (JacORB) service, used in clustering
    • jax-ws-catalog.xml - Used to map XML metadata names to local metadata descriptor files
    • jbossjta-properties.xml - Used to configure the Java Transaction API (JTA) service
    • jboss-service.xml - a variation of the jboss-service.xml file configured for a minimal app server configuration
    • jndi.properties - Used by the JNDI service to define default properties
    • standardjbosscmp-jdbc.xml - Used by the EJB service to define type mappings for various databases for data persistence
    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
    • data - used to write to the filesystem for storing temporary data
    • log - holds three log files: boot.log, server.log, audit.log
    • tmp - stores temporary data by various services
    • work - used by the web server to store compiled JSP files and other temporary data
    Server Configurations
    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.
    JBoss Boot Sequence
    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.
    Starting and Stopping JBoss
    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
    When JBoss has started you should see the below line in the log file, you can also check that JBoss has started by using the following URL http://localhost:8080
    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>
    System Properties
    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
    You can also provide system properties on the commandline by using the "-D" option
    supplying commandline properties c:\> run.bat -Djboss.server.log.dir=d:/log
    There are two more systems properties which are of interest
    jboss.server.name default
    jboss.bind.address 127.0.0.1
    System properties are used in a number of configuration XML files and as stated above you can add your own properties using the "-D" option
    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>
  • Download Jboss

    To download Click Here