JBoss Environment Build and deploy Web project

Source: Internet
Author: User
Tags jboss jboss server

http://blog.csdn.net/pop303/article/details/7210290
After learning about JBoss a few years ago, I thought there would be a lot of information about JBoss, but now I find very little, and there is very little in Amazon, only one "JBoss Combat: Server Configuration Guide", but I found the English version, there is a need to mail to everyone. I don't think I'll ever start with JBoss, and I'll see the end of my hello! page when I'm packaged and deployed to JBoss.

The first thing to do is lower JBoss, JBoss plug-ins, and the development of Eclipse as the platform, all of which require JEE mode.

JBoss, there are a lot of projects under the Http://www.jboss.org/projects Web page, and later, after Redhat, JBoss has a lot of extended themes, but the main people are in use or servers under the application Server, to my download is already AS7, I next found that AS7 and the previous version of the script is too big, for my beginner's related documents are 7 below, I later re-AS6 version.

JBOSS tool is a must for Eclipse-platform plug-ins. But I was on eclipse directly select the source download installed. Source: http://download.jboss.org/jbosstools/updates/stable/helios/. The plugin is installed under Eclipse help->insall new software->avaliable software. (This is not)

Eclipse is the platform I chose Eclipse Java EE IDE for WEB developers.

JEE Environment I chose java_ee_sdk-6u3-jdk7-windows-ml.

Configure the Environment:

Jboss_home=d:\jboss\jboss-6.0.0.final

Java_home=c:\glassfish3\jdk7

Classpath=.; %java_home%/lib/dt.jar;:%java_home%/lib/tools.jar

path=%java_home%\bin;:%java_home%\jre\bin;:D: \ Oracle ... Slightly

Two directories for JBoss to focus on:

Bin directory, Operation script directory; Server\default\deploy, deployment Directory of the completed war package

JBoss installation and start-stop:

For JBoss to unpack the package that even if the installation is complete, just configure the JEE environment and preferably add the jboss_home environment variable. and install the package Linux and Windows is a package, the startup script is divided into bat and sh two to correspond to two kinds of system

Start:./run.sh//linux

Run.bat//windows

You can also add parameters at startup, such as Run.bat-c all

usage:run.sh [Options]

Options
-h,–help Show This Help message
-v,–version Show Version Information
–stop processing Options
-d<name>[=<value>] Set a system property
-d,–bootdir=<dir> Set the boot patch directory; Must be absolute or URL
-p,–patchdir=<dir> Set the patch directory; Must be absolute or URL
-n,–netboot=<url> Boot from net with the given URL as base
-c,–configuration=<name> Set the server configuration name
-b,–bootlib=<filename> Add a extra library to the front Bootclasspath
-l,–library=<filename> Add a extra library to the loaders Classpath
-c,–classpath=<url> Add a extra URL to the loaders classpath
-p,–properties=<url> Load System Properties from the given URL
-b,–host=-g,–partition=<name> HA partition name (Default=defaultdomain)
-u,–udp=<ip> UDP multicast Address
-l,–log=<log4j|jdk> Specify the Logger plugin type

There are several common parameters

-C service Configuration name, which specifies which service configuration JBoss initiates, default defaults, and typically-C all

-B binds the IP of the JBoss service, especially when the EJB service is deployed, only through the bound IP lookup EJB, under Linux, the non-binding IP will not find the EJB service. For simple Web applications, an unbound IP can implement full-address binding. The environment for dual NICs or multiple IPs can be accessed through different IP.

-G binds the HA partition name for the EJB cluster grouping.

-u UDP multicast address for clustered JBoss environment, default is 230.0.0.4, if the local area network has multiple start all configuration (with cluster configuration) of the JBoss service, then in the JBoss log can see the occasional multicast information appears, can be set to different multicast address, Avoid these distractions. The legal value is the broadcast segment mentioned in the IP protocol.

You can see the webpage after you start: http://127.0.0.1:8080

Stop service:

./shutdown.sh-s//linux

Shutdown.bat-s//windows

(Stop mode I did not try to succeed, not in the solution, are the CTRL + C shutdown).

It's all about deployment, and I'm working on the Eclipe platform. As mentioned above, the use of Jee's Eclipse and JBoss plug-ins also has a JEE environment.

After the JBoss tool is installed, there are three more directories in new, and there is an optional jboss6.0 runtime environment for the Java EE.

There are a number of options available, and I've chosen to create a dynamic Web project (or Enterprise Application project) project, which is the war or ear. After the project is created, create the package com.clo.tAction in the SRC with this project and create the Hello.java:

Package com.clo.tAction;


Import java.io.IOException;
Import javax.servlet.ServletException;
Import Javax.servlet.annotation.WebServlet;
Import Javax.servlet.http.HttpServlet;
Import javax.servlet.http.HttpServletRequest;
Import Javax.servlet.http.HttpServletResponse;

/**
* Servlet Implementation Class Hello
*/
@WebServlet ("/hello")
public class Hello extends HttpServlet {
Private static final long serialversionuid = 1L;

/**
* @see Httpservlet#httpservlet ()
*/
Public Hello () {
Super ();
TODO auto-generated Constructor stub
}
public void Service (HttpServletRequest request,httpservletresponse response) throws Servletexception, ioexception{
Java.io.PrintWriter out = Response.getwriter ();
Out.println ("Out.close ();
}

}

You can then configure the Web. xml

Web. XML content:
<?xml version= "1.0" en Coding= "UTF-8",
<web-app xmlns:xsi= "http://www.w3.org/2001/XMLSchema-instance" xmlns= "http:// Java.sun.com/xml/ns/javaee "xmlns:web=" http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd "xsi:schemalocation=" Http://java.sun.com/xml/ns/javaeehttp://java.sun.com/xml/ns/javaee/web-app_3_0.xsd "id=" webapp_id "version=" 3.0 "
  <servlet>
   <servlet-name>hello</servlet-name>
    <servlet-class>
   com.clo.taction.hello
   </servlet-class>
  < /servlet>
  <servlet-mapping>
   <servlet-name>Hello</servlet-name>
  <url-pattern>/sayhello</url-pattern>
  </servlet-mapping>
  </web-app>

Note: The previous web. XML content has been modified from under the <servlet> tag. The header label to be retained.

You can then generate the war.

In this work run use right-click to select Export->war file

The resulting war file can be placed in JBoss Server\default\deploy, the deployment directory. At this point, if it has been started, it will be loaded successfully. Logs are generated:

The corresponding directory on the browser page will be displayed:

Note: The catalog OK for the project I created before, in this project to do the page.   In fact, other ways can be done, but I did not succeed, have time to say! Other articles reference: JBoss configuration environment Variables and deployment Web Project JBoss Deployment Java EE Project method and environment variable configuration _java_home

JBoss Environment Build and deploy Web project

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.