Introduction to JBOSS and installation of JBOSS in linux

Source: Internet
Author: User
Tags jboss server

. Install jboss
Extract jboss to a directory such as/usr/local/jboss, add "/usr/local/jboss" to the path, and set jboss_home = "/usr/local/jboss"
Run. sh and open the browser http: // localhost: 8080. If the test page is displayed, the installation is successful!

Configure. bash_profile in the/root directory to add Environment Variables
Run sh run. sh on/usr/local/jboss/bin to start the jboss server.

Jboss BASICS (jboss-4.0.1sp1)

1. After decompression, the following directory should be generated:
Bin: commands and scripts
Client: client jars
Docs: jboss documentation
Lib: Server jars
Server: server Configuration File

2. jboss provides three server configurations:
1) minimal: minimum configuration, which only includes the log, jndi service, and url deployment scanner. You may use this configuration in an application that does not require j2ee, or use this configuration as the basis for custom configuration.
2) default: default configuration, including all j2ee services except rmi/iiop and cluster.
3) all: This configuration includes all jboss services.

3. Start
To start jboss, in windows:
Type: cd % jboss_home % bin;
Type: run [-c default | minimal | all].
In unix:
Type: cd $ jboss_home/bin;
Type:./run [-c default | minimal | all].
If jboss is started successfully, you can see the following output:
12:16:27, 812 info [server] jboss (mx microkernel) [4.0.1sp1 (build: cvstag = jboss_4_0_1_sp1 date = 200611270314)] started in 20 s: 429 ms
Once the server is started successfully, you can open http: // localhost: 8080/jmx-console/in the browser to verify that all j2ee services are started. This is the jboss console. It displays all the services that jboss is running and the details of each service under the current configuration.

4. Disable
To run jboss in a windows command line window or the current unix shell, simply press ctrl + c to close jboss.
If you cannot see the command line window in windows:
Open a new command line window;
Type: cd % jboss_home % bin;
Type: shutdown-s or shutdown -- server = url
If you run the following command in the background of unix shell:
Open a shell;
Type: cd $ jboss_home/bin;
Type:./shutdown-s or./shutdown -- server = url

 

Management

 

JBoss is managed through a web-based console. You only need to enter http: // localhost: 8080/JMX-console/in the browser. To view or change the configuration of a service, simply click the link.

 

Through the console, you can also use public methods of services, such as disabling the server:

 

       1)Open the console;

 

       2)Scroll to the "JBoss. System" option;

 

       3)Click "type = server ";

 

       4)Scroll to the "Void Shutdown ()" option;

 

       5)Click "INVOKE.

 

 

Deploy applications

 

Deploying applications in JBoss is no longer simple. Simply copy the package file of your application :. jar ,. war or. ear to the default deployment directory of the server. If JBoss is running, the file will be detected, automatically decompress the file, and then load the application.

 

The following is an example of deploying an application to a default server configuration in Windows:

 

Copy rotmachine. Ear to % jboss_home %/Server/default/deploy

 

In Unix:

 

Copy rotmachine. Ear to $ jboss_home/Server/default/deploy

 

 

 

During deployment, the JBoss log will output information in the console window and write the log. The log file is located in the configuration directory of the server. If the deployment is successful, you can see the following information:

 

22:21:44, 730 INFO [MainDeployer] Deployed package: file:/C:/jboss-3.2.1/server/default/deploy/rotmachine. ear

 

In addition, if you open the JBoss console, you can list your applications under the "jboss. j2ee" category.

 

 

 

Cancel deployed applications

 

Canceling deployed applications is easier than deploying applications. As long as the corresponding application files are deleted from the deployment directory, JBoss detects that the files have been deleted and then cancels the deployed applications.

 

When you cancel an application deployment, JBoss logs are displayed in the console window and recorded on the server. If the deployment is canceled successfully, you can see the following information:

 

22:59:41, 500 INFO [MainDeployer] Undeployed file:/C:/jboss-3.2.1/server/default/deploy/rotmachine. ear

 

Data Source

 

If your application will connect to the database, you may need to configure a data source for the database. The following describes how to configure a simple Data source:

 

If the JDBC driver of the database you are using is not in the lib directory of the server, copy the driver to this directory and restart JBoss.

 

Create a data source description file for your database, for example, oracle-ds.xml:

 

Deploy the data source description file in the same way as deploying an application.

 

The following is an example of a description file for the oracle Data source:

 

<? Xml version = "1.0" encoding = "UTF-8"?>

 

<Datasources>

 

<Local-tx-datasource>

 

<Jndi-name> OracleDS </jndi-name>

 

<Connection-url> jdbc: oracle: thin: @ serverip: 1521: DB </connection-url>

 

<Driver-class> oracle. jdbc. driver. OracleDriver </driver-class>

 

<User-name> dev </user-name>

 

<Password> secret </password>

 

</Local-tx-datasource>

 

</Datasources>

 

Examples of other data source description files can be found in JBOSS_HOME/docs/examples/jca.

 

 

 

EJB

Creating ejbs for JBoss is the same as any other J2EE application server, but an additional JBoss EJB deployment description file jboss. xml is required. The following is an example:

 

<? Xml version = "1.0" encoding = "UTF-8"?>

 

<! DOCTYPE jboss PUBLIC "-// JBoss // dtd jboss // EN"

 

Http://www.jboss.org/j2ee/dtd/jboss.dtd>

 

<Jboss>

 

<Enterprise-beans>

 

<Session>

 

<Ejb-name> Processor </ejb-name>

 

<Jndi-name> ejb/Processor </jndi-name>

 

</Session>

 

<Entity>

 

<EJB-Name> data </EJB-Name>

 

<JNDI-Name> EJB/Data </JNDI-Name>

 

</Entity>

 

</Enterprise-beans>

 

</JBoss>

 

Note that, unlike other J2EE servers, JBoss does not need to generate stubs and skeletons, which can dynamically call ejbs.

 

 

 

Client

 

As mentioned above, JBoss does not require a client stub (Stubs). You only need to provide the following interfaces to the client:

 

EJB home interface and remote interface;

 

Any objects passed between the client and the EJB;

 

A copy of jboss_home/client/jbossall-client.jar.

 

The following is an example of connecting ejbs deployed in JBoss:

 

// Create an environment:

 

Hashtable env = new Hashtable ();

 

Env. put ("java. naming. factory. initial ",

 

"Org. jnp. interfaces. NamingContextFactory ");

 

Env. put ("java. naming. factory. url. pkgs ",

 

"Org. jboss. naming: org. jnp. interfaces ");

 

Env. put ("java. naming. provider. url", "localhost ");

 

// Create name context:

 

InitialContext context = new InitialContext (env );

 

// Find the Home interface:

 

CipherHome home = (CipherHome) context. lookup ("ejb/org/rotmachine/Cipher ");

 

// Obtain the Remote interface:

 

Cipher cipher = home. create ();

 

A sample application

 

To help you better understand JBoss, this article contains an application named RotMachine. For more information, see the resource link.

 

RotMachine is a simple J2EE application, including an EJB (Stateless Session Bean), a Web client, and a Command-line client. It uses the JBoss Project Template. You may need some additional development tools mentioned above.

 

To compile the RotMachine source file, extract the file to a specified directory. In Windows:

 

Open a command prompt window;

 

Type: cd (extract directory );

 

Type: ant deploy-server.

 

In Unix:

 

Open a Shell;

 

Type: cd (extract directory );

 

Type: ant deploy-server.

 

To test RotMachine on the command line client, in Windows:

 

Open a command prompt window;

 

Type: cd build/bin;

 

Type: run-client.

 

In Unix:

 

Open a Shell;

 

Type: cd build/bin;

 

Type./run-client.sh.

 

To test RotMachine on the Web Client, open your browser and enter "http: // localhost: 8080/rotmachine/index. jsp". Enter some text in the form and click "Go! "Button

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.