Java Development-JBoss-based J2EE applications

Source: Internet
Author: User

JBoss, as a J2EE application server, has won the trust of many J2EE developers with its excellent EJB container performance, technical fluency, and convenient development and deployment of J2EE applications. Compared with other commercial servers, the features such as installation-free, JMX-based architecture, Hot Deploy, and quick development of EJB applications are somewhat disappointing. Although it has no major defects, it is a development mode of Open Source with few documents. Therefore, it is still a little effort to master and master JBoss-based applications.

Based on your development experience, this article provides some precautions and rules for developing J2EE under JBoss 3.2.1. Among them, the reader must know that JBoss 3.2.1 is a transitional product of JBoss (with JBoss 3.0.x and JBoss 4. x). Naturally, there are some things similar to JBoss 3.0.x and JBoss 4. x is quite different. However, the content described in this article is generally applicable to different JBoss versions.

After downloading JBoss 3.2.1, decompress it to a directory path without spaces to run JBoss. Therefore, it is very convenient, provided that the target machine has installed Java 2 Standard Edition. When everything is ready, start our journey.

(Assuming JBoss 3.2.1 is installed in: C: jboss-3.2.1_tomcat-4.1.24, this uses the default configuration)

1. Configuration File Settings

To develop J2EE applications, database operations are essential. Adjusting the log output details becomes the key to debugging J2EE applications. The optimization process of EJB applications is the core of J2EE applications. And so on. We need to know the content.

(1) Data Source Configuration:

In JBoss 3.2.1, the steps to configure the data source is very simple, JBoss 3.2.1 itself with the mainstream Database Configuration instance, in the directory: C: jboss-3.2.1_tomcat-4.1.24docsexamplesjca. The specific configuration file used depends on the target user's database. For SQL Server 2000, you need to use a mssql-ds.xml file (supporting local transactions) or a mssql-xa-ds.xml file (supporting global transactions); for an Oracle 9i Database, you need to use a oracle-ds.xml file or a oracle-xa-ds.xml file. And so on. SQL Server 2000 is used as an example.

First copy the mssql-ds.xml file to the directory: C: jboss-3.2.1_tomcat-4.1.24serverdefaultdeploy. Open the file and make the following changes:

<Datasources>

<Local-tx-datasource>

<Jndi-name> VSSDB </jndi-name>

<Connection-url> jdbc: microsoft: sqlserver: // 125.16.45.158: 1433; DatabaseName = DDD </connection-url>

<Driver-class> com. microsoft. jdbc. sqlserver. SQLServerDriver </driver-class>

<User-name> sa </user-name>

<Password> sa </password>

<Min-pool-size> 50 </min-pool-size>

<Max-pool-size> 200 </max-pool-size>

</Local-tx-datasource>

</Datasources>

If the target J2EE application only needs local transactions, the configuration of Datasource is completed in the preceding process, and this configuration will be used for JDBC and EJB through JNDI. If you want to implement EJB to use Datasource, you also need to modify the jboss-3.2.1_tomcat-4.1.24serverdefaultconf file that is located under the Directory: C: standardjbosscmp-jdbc.xml. For example,

<Jbosscmp-jdbc>

<Defaults>

<Datasource> java:/VSSDB1 </datasource>

<Datasource-mapping> MS SQLSERVER2000 </datasource-mapping>

<Create-table> true </create-table>

<Remove-table> false </remove-table>

<Read-only> false </read-only>

<Time-out> 300 </time-out>

<Pk-constraint> true </pk-constraint>

<Fk-constraint> false </fk-constraint>

........

Among them, the VSSDB in <datasource> java:/VSSDB </datasource> is the data source of the mssql-ds.xml configuration, and the "java:/" prefix indicates that the namespace is only visible to the JBoss itself, that is, applications running outside JBoss cannot use the data sources defined here.

Secondly, the MS SQLSERVER2000 in <datasource-mapping> MS SQLSERVER2000 </datasource-mapping> can be found elsewhere in the file. (For other databases, the situation is similar. I hope readers can think about it !)

(2) log output details Configuration:

Since JBoss 3.2.1 is developed using Log4j to manage its log information (strictly speaking, it extends Log4j), understanding the mechanism of Log4j helps to understand how JBoss 3.2.1 manages logs.

JBoss 3.2.1 uses the JMX architecture and uses the. xml file type as the configuration file, so you can find the log4j. xml file in the directory: C: jboss-3.2.1_tomcat-4.1.24serverdefaultconf. For example, a configuration example is as follows:

<Appender name = "CONSOLE" class = "org. apache. log4j. leleappender">

<Param name = "Target" value = "System. out"/>

<Param name = "Threshold" value = "INFO"/>

<Layout class = "org. apache. log4j. PatternLayout">

<! -- The default pattern: Date Priority [Category] Message -->

<Param name = "ConversionPattern" value = "% d {ABSOLUTE} %-5 p [% c {1}] % m % n"/>

</Layout>

</Appender>

For example, to adjust the log output details of the JBoss 3.2.1 Console (adjusted to the DEBUG level), we need to modify value = "INFO" and Change INFO to DEBUG.

If the target reader is developing Entity Beans, you can adjust. standardjboss in the same directory as the xml file. xml file (this file mainly provides modification of EJB-related debugging, running, tuning, and deployment parameters ). If the target reader Entity Beans uses the <container-name> Standard CMP 2.x EntityBean, change the value of the <call-logging> attribute to true.

<Container-configuration>

<Container-name> Standard CMP 2.x EntityBean </container-name>

<Call-logging> false </call-logging>

<Invoker-proxy-binding-name> entity-rmi-invoker </invoker-proxy-binding-name>

<Sync-on-commit-only> false </sync-on-commit-only>

.........

After completing the preceding two steps, you can view the JDBC call details sent by Entity Beans on the console when debugging Entity Beans.

(3) configuration of Tomcat container parameters:

If the target reader uses the integrated version of JBoss 3.2.1 and Tomcat 4.1.24, you can adjust the web in the directory: C: jboss-3.2.1_tomcat-4.1.24serverdefaultdeployjbossweb-tomcat.sar. xml and Directory: C: jboss-3.2.1_tomcat-4.1.24serverdefaultdeployjbossweb-tomcat.sarMETA-INF files under the jboss-service.xml to meet the specific needs of the target reader.

For example, if you want to change the HTTP service port to 80, you can modify the jboss-service.xml

Related Article

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.