JBoss Configuration Detailed

Source: Internet
Author: User
Tags app service jboss server

A little note on 2.0.1 JBOSS
$JBOSS-home/server/There are 3 directories, All/default/minimal, which represent 3 configurations, all configuration, default configuration, minimum configuration, when we start the JBOSS service, we can specify

Run–c all means to start the all configuration (all services will be loaded); run means to start with the default configuration;

Run–c Mimimal indicates that the Mimimal configuration is started. The three are loaded with different number of services, specific differences can be consulted on the JBoss related documents, you can also define a configuration, such as test, is a master to the performance of the consideration, then this document will not be too much help you.

If you determine the configuration of the JBoss service startup, then your application and related configuration will need to be deployed under the relevant path under the corresponding directory, such as all/,default/,minimal/.

Path to 2.0.1 JBoss Common configuration file
For the sake of convenience, the following description will take the JBOSS3.2.6 version, the default configuration as an example, if you start with a different configuration, look for or configure the relevant files in the corresponding directory.

1. The relevant DTD definition file is located in $jboss-home/docs/dtd, where you can view the meaning of an element or attribute in an XML configuration file.

2, the path of the data source configuration file, $JBOSS-home/server/default/deploy, the file format must be *-ds.xml style. Different database configuration parameters can refer to the sample document under $jboss-home/docs/examples/jca/. The details of the parameters are described below.

3, the public jar package we can put under the $jboss-home/server/default/lib, such as the database JDBC Jar,log4j.jar, etc., if these jars have been placed under the LIB, then our application web-inf/ Lib should not be placed again, or JBoss will load them again, in vain memory.

4, the configuration log file, Log4j.xml is located under $jboss-home/server/default/conf, the specific configuration below will also have a little introduction

5, $JBOSS-home/server/default/work is the JSP compiled after the. Java and. class files, if debugging JSP error, you can go to the directory (level to turn) to find the corresponding files, debugging problems. There is a little tips, sometimes we clearly put a JSP updated to the corresponding directory, but to refresh the page, the content is still old, in order to solve the problem, we can go to work directory, The corresponding. Java and. class files are deleted, and then refreshed, this reason is not good speculation, sometimes can be automatically refreshed, sometimes not. Individual tomcat can be automatically refreshed and somehow integrated into jboss but sometimes not. Also need to pay attention to the matter, you clear the old Java, class file, not for the sake of convenience, and directly delete the directory, or the refresh will be error, waiting for you is to restart the JBoss service.

6, $JBOSS-home/server/default/log is stored in a log file, the default Log4j.xml configuration is to export the log to the folder Server.log file, you can go to view the information for debugging.

7, our application is generally deployed under the $jboss-home/server/default/deploy/jbossweb-tomcat50.sar/, the establishment of a Testcrm.war directory, deploy our entire application in the. War directory, so that the JSP, servlet will be parsed by the Tomcat engine.

8. Configure the port number and parameters of the app's Web service.

JBOSS3.2.6 is in .../deploy/jbossweb-tomcat50.sar/server.xml, find yourself 8080, modify the port you want to set.

JBOSS3.2.3 is configured in the./default/deploy/jbossweb-tomcat41.sar/meta-inf/jboss-service.xml.

Download and installation of the 2.1 JBOSS application
Go to http://www.jboss.com to download the appropriate version. Unzip directly to the relevant directory.


Configuration tuning for 2.2 JBOSS application
2.2.1 Configuring load Balancing, adjusting parameters
The configuration file needs to be modified to accommodate the "session sticky Configuration" configured in Apache. As follows:

Jboss3.2.3 Modification:

%jboss_home%/server/default/deploy/jbossweb-tomcat41.sar/meta-inf/jboss-service.xml

Modify <engine name= "mainengine" defaulthost= "localhost" > for

<engine name= "Mainengine" jvmroute= "server106" defaulthost= "localhost" >

Consistent with the content defined above workers2.properties.

Jboss3.2.6 Modification:

%jboss_home%/server/default/deploy/jbossweb-tomcat50.sar/server.xml

Modify <engine name= "jboss.web" defaulthost= "localhost" > for:

<engine name= "Jboss.web" jvmroute= "server106" defaulthost= "localhost" >

Consistent with the content defined above workers2.properties.

The Jboss4.0 of the changes and the Jboss3.2.6 consistency.

Once configured, the Apache+jboss load balancer can be implemented.

2.2.2 Configuration cluster (clustering), adjusting parameters
If we want to make several JBoss application servers backup (session only), when a JBoss server in the group is down, the user is not affected and continues to work as a login user, we need to configure clustering and start the related services. The related configuration items are described below:

1), modify the app's Web. xml:

Jboss3.2.6:

.. /default/deploy/jbossweb-tomcat50.sar/test.war/web-inf/web.xml

Jboss3.2.3:

.. /default/deploy/jbossweb-tomcat41.sar/test.war/web-inf/web.xml

The contents of the amendment are as follows:

<?xml version= "1.0"?>

<! DOCTYPE Web-app Public

"-//sun Microsystems, INC.//DTD Web application 2.3//en"

"Http://java.sun.com/dtd/web-app_2_3.dtd" >

<web-app>

.......

.....

....

<distributable/>

</web-app>

Getting Started with JBoss configuration (2) 2007-11-01 10:442), you need to start a service cluster-service.xml

If you start the JBoss service with run-c all, the default is to start the Cluster service without doing any configuration work, just confirm that the relevant file exists.

Confirm ... cluster-service.xml file exists under/server/all/deploy/;

Confirm ... the Jgroups.jar file exists under/server/all/lib/, and if not, reinstall JBoss.

If the application is deployed under the default configuration, you will need to copy the above two files into

.../server/default/deploy/、... the/server/default/lib/directory.

The configuration is complete, please check the log if there is an exception. For more detailed information, see the admin.pdf available on jboss.com.

2.2.3 Configuring data sources, adjusting parameters
Various types of databases can be configured according to the sample document under%jboss_home%/docs/examples/jca/, and more detailed parameter configurations can be found on the jboss.com in the documentation or the DTD definition under/docs/dtd/.

The following is an example of Oracle, which provides our configuration in a production machine environment.

The XML file needs to be deployed under the%jboss_home%/server/all (or default)/deploy/, and the corresponding database driver jar needs to be copied to the deployment's configured lib, such as ... all/lib/or ... default/lib/ Under

<datasources>

<local-tx-datasource>

<jndi-name>jdbc/TestDataSource</jndi-name>

<connection-url>jdbc:oracle:thin:@192.168.1.2:1521:test</connection-url>

<!--<connection-url>jdbc:oracle:oci: @youroracle-tns-name</connection-url>-->

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

<user-name>test</user-name>

<password>test</password>

<!--Uses the Pingdatabase method to check a connection are still valid before handing it out from the pool--

<valid-connection-checker-class-name>org.jboss.resource.adapter.jdbc.vendor.oraclevalidconnectionchecker </valid-connection-checker-class-name>

<!--Checks the Oracle error codes and messages for fatal errors-

<exception-sorter-class-name>org.jboss.resource.adapter.jdbc.vendor.oracleexceptionsorter</ Exception-sorter-class-name>

<!--SQL to call when connection is created

<new-connection-sql>some arbitrary sql</new-connection-sql>

-

<min-pool-size>5</min-pool-size><!-minimum number of connection pools--

<max-pool-size>800</max-pool-size><!-maximum number of connection pools--

<idle-timeout-minutes>5</idle-timeout-minutes><!-Database connection idle time, in minutes, if the load is large, can be set to 5, if general, can be set to 3-->

<!-Verify the validity of the connection by executing a simple SQL before getting a connection from the connection pool.

<check-valid-connection-sql>select 1 from Dual</check-valid-connection-sql>

</local-tx-datasource>

</datasources>

If you have more than one data source, the configuration is complete and deployed under the above path, depending on the type of database.

You can get connections from the connection pool through Jndi in your code.

......

Context CTX = new Javax.naming.InitialContext ();

DataSource ds = (DataSource) ctx.lookup ("Java:jdbc/testdatasource");

Connection con = ds.getconnection ();

......

2.2.4 Configuring JBoss Connector Parameters
The following configuration is a service that describes the protocol used by load balancing (AJP 1.3 Connector).

More accurate and effective parameters and http/1.1 connector configuration.

Please refer to:

Http://tomcat.apache.org/tomcat-5.0-doc/config/ajp.html

Http://tomcat.apache.org/tomcat-5.0-doc/config/http.html

jboss3.2.3 configuration .../jbossweb-tomcat41.sar/meta-inf/jboss-service.xml,jboss3.2.6 configuration ..../jbossweb-tomcat50.sar/server.xml

<!--jboss3.2.3 Jboss-service.xml--

<!--A AJP 1.3 Connector on port 8009--

<connector classname= "Org.apache.coyote.tomcat4.CoyoteConnector"

address= "${jboss.bind.address}" port= "8009" minprocessors= "5" maxprocessors= "$" enablelookups= "true" Redirectport= "8443" acceptcount= "debug=" 0 "connectiontimeout=" 20000 "useurivalidationhack=" false "

Protocolhandlerclassname= "Org.apache.jk.server.JkCoyoteHandler"/>

<!--jboss3.2.6 Server.xml--

<!--A AJP 1.3 Connector on port 8009--

<connector port= "8009" address= "${jboss.bind.address}"

Enablelookups= "false" redirectport= "8443" debug= "0"

Maxprocessors = "minprocessors=" 5 "acceptcount=" 100 "

Protocol= "ajp/1.3"/>

Simple explanation of one or two parameters (whichever is tomcat5.0):

Maxprocessors: Maximum concurrency (number of connections)

Minprocessors: Minimum number of processes to start when initializing

Acceptcount: The number of allowed to enter the waiting queue when the number of connections to the current connector reaches maximum

ConnectionTimeout: Connection time-out, in milliseconds

Enablelookups: Whether to allow DNS lookups to return the machine name of the remote client and, if set to false, to return only the IP address. This parameter defaults to TRUE and can be banned if not required, set to false to improve server performance

Maxpostsize: Set the number of bytes allowed through the post upload parameter, the default is 2M (2097152), if you want to ban the limit, then set the value to a value less than or equal to 0, such as 0, 1, if there is upload work in the deployed app, be aware that the configuration

Port= "8009": This value is consistent with the port in "1.4.3.workers2.properties" above

Redirectport= "8443": the port that will be diverted if the service is accessed using the SSL mechanism, see the SSL-related configuration documentation.

debug= "0": This is the configuration log level, which can be ignored because the setting depends on the settings of the log4j configuration file, Server/all/conf/log4j.xml

Getting Started with JBoss configuration (3) 2007-11-01 10:452.2.5 access URL If it is a directory, do not want to display the file under this directory
jboss3.2.3:

Modify .../server/all (or default)/deploy/....sar/web.xml

jboss3.2.6/jboss4.0:

Modify .../server/all (or default)/deploy/....sar/conf/web.xml

View the Purple italic character, set to False to indicate that the directory is not listed. Default is set to True

<servlet>

<servlet-name>default</servlet-name>

<servlet-class>

Org.apache.catalina.servlets.DefaultServlet

</servlet-class>

<init-param>

<param-name>debug</param-name>

<param-value>0</param-value>

</init-param>

<init-param>

<param-name>listings</param-name>

<param-value>false</param-value>

</init-param>

<load-on-startup>1</load-on-startup>

</servlet>

2.2.6 setting an app app as the default app
Typically, if we deploy the application directory for the/server/all (or default)/deploy/....sar/test.war/, then after our application is deployed, we access the path similar to:/HTTP/./test/ Index.htm, if we want to remove the test app Name, the following settings are available.

In the war directory that you need to set as the default app, create a new file under the above test.war/web-inf/, with the file name Jboss-web.xml, with the following:

<jboss-web>

<context-root>/</context-root>

</jboss-web>

After restarting the service, you can access the apps deployed under test.war/with Http://..../index.htm.

2.2.7 configuration data source is valid before app load (each related service is loaded)
It took more than a week to get this experience, and later, with the documentation of the JBoss Wiki/forum, the inspiration came to the solution. Detailed introduction can refer to the post below, this is my hair a post, and then to solve their own after the answer affixed.

http://www.jboss.com/index.html?module=bb&op=viewtopic&t=70600

Http://www.javaworld.com.tw/jute/post/view?bid=9&id=129747&sty=1&tpg=1&age=0 (English)

The following is a brief explanation.

We deploy an application (project), at the beginning of the application is usually a number of initialization, it may be from the file, the database to obtain some basic data or configuration items and so on.

If we get the underlying data from the database, we have to make sure that those data sources that are configured and the related services take effect before our application starts to load (it has been started or loaded); That is, we need to get the data normally in some of the initialization data methods that we deploy the application. If you don't make a few settings, just throw the well-ds_oracle_test.xml into the .../deploy/, then I'm sorry to tell you that your app doesn't get the connection from the connection pool at all during the initialization phase, and gets the data. To achieve the purpose of your initialization data, please follow the link I provided above to view detailed information, below I only provide a workaround.

1), configure the data source:

<!--oracle_ds.xml-->

<datasources>

<local-tx-datasource>

<jndi-name>jdbc/test</jndi-name>

2) Confirm the service name DataSource depends on

Through Http://wiki.jboss.org/wiki/Wiki.jsp?page=DependOnDataSource we find that:
====== Original Quote ==============
! Depending on a DataSource
To specify a dependency in a DataSource deployment, you need to depend on the service which binds the DataSource into JNDI .
The DataSource is not bound to JNDI until the service jboss.jca:service=datasourcebinding,name= (Jndi-name) has been
Started. The (jndi-name) is the value of the Jndi-name attribute for your DataSource as defined in the *-ds.xml.
The associated Connection Manager service is a function of the type of DataSource and its Jndi-name attribute value. The
MBean names for the types of DataSource deployments is:

No-tx-datasource
Jboss.jca:service=notxcm?,name= (Jndi-name)
Local-tx-datasource
Jboss.jca:service=localtxcm?,name= (Jndi-name)
Xa-datasource
Jboss.jca:service=xatxcm?,name= (Jndi-name)
No-tx-connection-factory
Jboss.jca:service=notxcm?,name= (Jndi-name)
Tx-connection-factory
Jboss.jca:service=txcm?,name= (Jndi-name)

As can be known from the above description, the data source configuration is different, the corresponding dependent service name information is also different.
Based on the above description and data source configuration, the relevant service name is:

"Jboss.jca:service=localtxcm,name=jdbc/test".

I modified ... sar/...war/web-inf/jboss-web.xml (if the file does not exist, create it), and then run JBoss, you can find the datasource at initialization and get the data correctly!!!

The configuration file is as follows:
<jboss-web>
<depends>jboss.jca:service=LocalTxCM,name=jdbc/test</depends>
</jboss-web>

2.2.8 log configuration, configuring Log4j.xml
JBOSS's Log module integrates powerful log4j components, and we can configure $jboss_home/server/default/conf/log4j.xml directly to define log levels or to output logs of several classes to a single file.

The following is a simple list of configuration files, the use of specific log4j refer to the log4j documentation or JBoss documentation.

<appender name= "Importcharge" class= "Org.jboss.logging.appender.DailyRollingFileAppender" >

<errorhandler class= "Org.jboss.logging.util.OnlyOnceErrorHandler"/>

<param name= "File" value= "${jboss.server.home.dir}/log/importcharge.log"/>

<param name= "Append" value= "true"/>

<!--Rollover at midnight

<param name= "Datepattern" value= "'. ' Yyyy-mm-dd "/>

<layout class= "Org.apache.log4j.PatternLayout" >

<!--the default pattern:date priority [Category] message\n--

<param name= "Conversionpattern" value= "%d%-5p [%c]%m%n"/>

</layout>

</appender>

<logger name= "Com.tt.bs.action.corp.ImportChargeFileAction" >

<level value= "DEBUG"/>

<appender-ref ref= "Importcharge"/>

</logger>

<category name= "Com.tt.bs.action.corp.UploadChargeFileAction" >

<priority value= "DEBUG"/>

<appender-ref ref= "Importcharge"/>

</category>

The category or logger can be written in the following wording, which is the standard notation in the document.

The last two blocks of code above indicate that the two actions listed will refer to the appender of "Importcharge", and the log of Log.debug ... will be written to the "ImportCharge.log" file at the same time.

You can also refer to:

Http://wiki.jboss.org/wiki/Wiki.jsp?page=Logging

http://logging.apache.org/log4j/docs/

Getting Started with JBoss configuration (4) 2007-11-01 10:462.2.9 configuration contenttype and charset,tomcat5.0 JSP unified configuration
In the JSP header is generally used to specify ContentType and charset with the page statement.

such as: <%@ page contenttype= "text/html; CHARSET=GBK "%>

or write separately:

–<%@ page contenttype= "Mime-type"%>

–<%@ page pageencoding= "Character-set"%>

The statement's purpose is "to specify the MIME type and charset of the page generated by the servlet generated by the JSP page." The default character set is "Iso-8859-1", if you do not specify the correct charset, then our page if there is Chinese, will be garbled.

My main description is the latter, CharSet, character set. The scenario that occurs is in the case where one page contains another page.

The integration of JBOSS3.2.3 under the tomcat4.0*, with the jsp1.2/servlet2.3 standard, requires that the JSP main page and the included pages of the "pageencoding" must be consistent, based on this situation, we generally do not include the page specified " Pageencoding ", its properties are directly inherited from the parent page.

Under JBOSS3.2.6, the integration is tomcat5.0*, which requires "pageencoding" in each JSP, in other words, there is no effect on the specified child pages in the parent page.

There are two ways to resolve this problem:

1, for each page to specify "pageencoding", obviously not advisable!

2, with jsp2.0/servlet2.4 Standard, unified configuration of Web. XML, the unified use of a "pageencoding" when parsing jsp. So we don't need to add a declaration for each JSP.

The configuration details of Method 2 are as follows:

Configure $jboss-home/server/default/deploy/jbossweb-tomcat50.sar/testcrm.war/web-inf/web.xml for the following purple italic content.

Replace the header namespace declaration:

<?xml version= "1.0" encoding= "Iso-8859-1"?>

<web-app xmlns= "Http://java.sun.com/xml/ns/j2ee" xmlns:xsi= "Http://www.w3.org/2001/XMLSchema-instance" xsi: schemalocation= "Http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"

version= "2.4" >

.........

.........

<jsp-config>

<jsp-property-group>

<DESCRIPTION>JSP encoding example</description>

<display-name>JSPConfiguration</display-name>

<url-pattern>*.jsp</url-pattern>

<el-ignored>true</el-ignored>

<page-encoding>GBK</page-encoding>

<scripting-invalid>false</scripting-invalid>

<include-prelude></include-prelude>

<include-coda></include-coda>

</jsp-property-group>

</jsp-config>

</web-app>

Description of the configuration of the:<jsp-config>

You can use the following configuration elements in <jsp-property-group>:

Element
Describe

<el-ignored>
If set to True, the El expression is treated as regular text instead of an El expression in a JSP page that matches the specified URL pattern. This is useful when porting JSP 1.2 pages that appear to have El expression text to JSP 2.0. In the page that has been converted to JSP 2.0, you can use a new "Elignoredpage" property to select whether El is valid

<scripting-invalid>
If set to True, script is used on a matching JSP page

<page-encoding>
Specifies the encoding for the JSP page that matches the specified URL pattern. This is an optional configuration (the encoding of the page is specified in each JSP page), and for JSP pages This is the only way to use certain file encodings (for example: EBCDIC)

<include-coda>
A file is automatically included at the end of all JSP pages that match the specified URL pattern, and the associated context path is specified. You can use it multiple times in a <jsp-property-group>, or through multiple <jsp-property-group> to achieve

<include-prelude>
A file is automatically included at the beginning of all JSP pages that match the specified URL pattern, and the associated context path is specified. You can use it multiple times in a <jsp-property-group>, or through multiple <jsp-property-group> to achieve

<is-xml>
If set to True, all JSP pages that match the specified URL pattern use JSP XML syntax (they are JSP Document)

Refer to Http://www.oreilly.com.cn/news/jsppart2.php?c=java

Getting Started with JBoss configuration (5) 2007-11-01 10:472.3 JVM Minimum and maximum memory settings
If you take the default configuration, the JVM can only be assigned to a maximum of 64M of memory by default (the default size is related to the JVM version), which is certainly not enough in a production environment and will cause users to be unable to access the app service via the web, but there is a strange phenomenon that JBoss service is not down in the system process.

Modify the $jboss/bin/run.conf file, find "#JAVA_OPTS =", if there is no string, add, and remove the first "#", modify the string (including double quotes) to java_opts= "-server-xms512m- Xmx512M ", which is the minimum and maximum memory allocated for the JVM, depending on the size of the hardware physical memory and is recommended to be half the physical memory.

For a more detailed description, see http://java.sun.com/docs/hotspot/VMOptions.html

2.4 OS Character Set issues
If the app service requires OS support for the GBK character set, modify the file/etc/sysconfig/i18n

The contents are:

Lang= "ZH_CN. GB18030 "

Language= "Zh_CN.GB18030:zh_CN.GB2312:zh_CN"

Supported= "Zh_CN.GB18030:zh_CN:zh"

Sysfont= "Lat0-sun16"

Sysfontacm= "8859-15"

2.5 JBoss Service Start-up, stop
$JBOSS _home and%jboss_home% for JBOSS installation of Linux, win under the path, if configured, the same reference can be directly.

Start:

1. For Linux: $JBOSS _home/bin/run.sh

2. For win:%jboss_home%/bin/run.bat

Close/STOP:

1. For Linux: $JBOSS _home/bin/shutdown.sh–s

2. For win:%jboss_home%/bin/shutdown–s

You can use Tail–f $JBOSS _home/server/default/log/server.log to view information about the start or stop of the JBOSS service.


JBoss Configuration Detailed

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.