Hot deployment of earlier versions of JBoss to JBoss7

Source: Internet
Author: User

1. New Features of Jboss7
 
1.1 is built on Modular Service Container, which fully utilizes the capabilities of multi-core processors and starts services concurrently and on demand. The startup speed is faster and the memory usage is smaller.
 
1.2 fully compatible with Java EE6
 
1.3 Support for JDK 6/7
 
1.4 unified configuration and management
 
1.5 compatible with OSGI 4.2 and supports OSGI and Java EE Component Model Integration.
 
1.6 easy to test: Use the Arquillian test platform-an integrated test component model for easier testing and change-compilation-shorter testing cycles.
 
1.7 two modes
 
Standalone mode (started with standalone. bat) is equivalent to the previous versions 3, 4, 5, and 6. The configuration file and published content are stored in the standalone directory.
 
Domain mode (started with domain. bat) is a new feature of Jboss7. You can manage multiple servers at one control point.
 
1.8 class loading
 
Class loading is based on the Jboss Module, which replaces the hierarchical class loading environment to avoid class loading errors when the class has multiple versions. Because classes are loaded Based on modules, the module dependencies must be displayed. The deployment is also modular. If no definition class dependency is displayed, you cannot access the classes in the Application Server jar.
 
2. Migration steps
 
The Jboss7 deployment project is very different from the jboss5 project. The main reason is that the class loading mode has changed. Jboss5 is relatively simple to deploy. You only need to deploy the corresponding packages to the lib and deploy directories. The class loader automatically loads the packages at different layers without configuring dependencies. Jboss7 is completely different. jboss7 is loaded in modular mode, and different modules are loaded by different class loaders. jar packages of other modules are invisible to them, in this case, you must manually configure the dependency between packages. Otherwise, errors such as ClassNotFoundException will be reported. In addition, the configuration of the data source and JNDI has also changed. Therefore, the project migration from Jboss5 to Jboss7 can be divided into the following three steps:
 
2.1 dependency Configuration
 
In Jboss7, dependencies between modules are classified into implicit dependency and explicit dependency.
 
2.1.1 implicit dependency
 
Although modules in Jboss7 are isolated by default, some module dependencies defined by the Application Server are automatically assembled during deployment. For example, if a Java EE application is deployed, Java ee api dependencies are automatically added, which is also called implicit module dependency.
 
2.1.2 explicit dependency
 
For explicit dependency, it must be explicitly defined in the "Dependencies:" or "Class-Path:" item of the MANIFEST. MF file or in the Jboss7-specific deployment file jboss-deployment-structure.xml. It is time-consuming and labor-consuming to manually find dependencies between various modules for existing projects. You can use the Tattletale tool to analyze the dependencies, click "JBoss A7" in the OUTPUT_DIRECTORY/index.html file of the analysis report to obtain some dependencies. Other dependencies can be obtained in "Depends On.
 
In Jboss7, the class loading priority (from high to low ):
 
(1) system dependency-module dependencies automatically loaded by the server, including Java EE APIs.
 
(2) User Dependencies-in the jboss-deployment-structure.xml (within the META-INF of the ear, within the META-INF or WEB-INF of the war) or Dependencies: Dependencies configured within the item.
 
(3) local resources-release Directory class files, such as war package under the WEB-INF/classes or WEB-INF/lib.
 
(4) Inter-deployment dependency-Other deployment dependencies within the ear. Including classes in the ear lib directory or in other ejb packages.
 
At deployment, the War package is considered to be a separate module, and classes in the WEB-INF/lib and WEB-INF/classes are the same, all loaded by the same class loader. The Ear package is deployed in multiple modules. This means that not all classes in the ear can access all other classes in the ear, unless explicit dependencies are specified. By default, the EAR/lib directory is a separate module, and each WAR or EJB jar is a separate module. Sub-deployment (war and ejb-jar) always rely on the parent module and can access classes in the EAR/lib. However, they do not always have automatic dependencies between each other. You can modify the following configuration to control this behavior:
 
<Subsystem xmlns = "urn: jboss: domain: ee: 1.0">
 
<Ear-subdeployments-isolated> false </ear-subdeployments-isolated>
 
</Subsystem>
 
The default value of ear-subdeployments-isolated is false, which allows sub-deployment to access other sub-deployment classes. In an Ear package, war can access the classes in the jar package, and jar packages can also access each other. However, jar packages cannot access the classes in the war package, whether the value of ear-subdeployments-isolated is true or false.
 
2.1.3 global module
 
You can set some modules as global modules so that all deployments can access this module. This method can be used to solve the module dependency problem during project migration. The format is as follows:
 
<Subsystem xmlns = "urn: jboss: domain: ee: 1.0"/>
 
<Global-modules>
 
<Module name = "org. apache. log4j"/>
 
</Global-modules>
 
2.2 Data Source Configuration
 
In Jboss5, the data source configuration file is *-ds. xml file, which is placed in the deploy directory of the server, the corresponding JDBC driver is placed in the lib directory of the server or the WEB-INF/lib directory of the application. These are not required in Jboss7. The configuration file is Jboss7_home/standalone/configuration/standalone. xml or Jboss7_home/domain/configuration/domaion. xml. You can use the IronJacamar tool to convert the original *-ds. xml file to the format required in Jboss7.
 
2.2.1 install the JDBC driver
 
Install the JDBC driver in two ways: (1) As a deployment (recommended) (2) as a module
 
2.2.1.1 as a deployment
 
Directly put the JDBC driver as a common jar package in the deployment directory, the JDBC driver should be a compatible JDBC4 (Jdbc 4 compatible driver contains META-INF/services/java in the jar package. SQL. driver file, which specifies the name of the Driver class .) . If the JDBC driver contains more than one jar package, it should be deployed as a module.
 
2.2.1.2 as a module
 
You need to create a directory structure under the modules Directory, which contains the driver jar package and module. xml file. The following describes how to install the mysql driver. First, create the com/mysql/main folder under the modules directory and put the mysql driver and module. xml file in the main folder. The content of module. xml is as follows:
 
<? Xml version = "1.0" encoding = "UTF-8"?>
 
<Module xmlns = "urn: jboss: module: 1.1" name = "com. mysql">
 
<Resources>
 
<Resource-root path = "mysql-connector-java-5.1.15.jar"/>
 
</Resources>
 
<Dependencies>
 
<Module name = "javax. api"/>
 
</Dependencies>
 
</Module>
 
Note that the name and the created folder must have the same name and cannot start with a space in the module. xml file. Otherwise, the error "New missing/unsatisfied dependencies" will occur.
 
2.2.2 register the JDBC driver
 
2.2.2.1 register as the module's JDBC driver
 
<Datasource jndi-name = "java:/YourDatasourceName" pool-name = "YourDatasourceName">
 
<Connection-url> jdbc: mysql: // localhost: 3306/YourApplicationURL </connection-url>
 
<Driver> mysql-connector-java-5.1.15.jar </driver>
 
<Transaction-isolation> TRANSACTION_READ_COMMITTED </transaction-isolation>
 
<Pool>
 
<Min-pool-size> 100 </min-pool-size>
 
<Max-pool-size> 200 </max-pool-size>
 
</Pool>
 
<Security>
 
<User-name> USERID </user-name>
 
<Password> PASSWORD </password>
 
</Security>
 
<Statement>
 
<Prepared-statement-cache-size> 100 </prepared-statement-cache-size>
 
<Share-prepared-statements/>
 
</Statement>
 
</Datasource>
 
2.2.2.2 register as the deployed JDBC driver
 
<Datasource jndi-name = "java:/MySqlDS" pool-name = "MySqlDS" enabled = "true" use-java-context = "true">
 
<Connection-url> jdbc: mysql: // localhost: 3306/gg </connection-url>
 
<Driver> mysql </driver>
 
<Pool>
 
<Min-pool-size> 20 </min-pool-size>
 
<Max-pool-size> 20 </max-pool-size>
 
<Prefill> true </prefill>
 
</Pool>
 
<Security>
 
<User-name> root </user-name>
 
& Lt; password & gt; 111 & lt;/password & gt;
 
</Security>
 
<Driver name = "mysql" module = "com. mysql">
 
<Driver-class> com. mysql. jdbc. Driver </driver-class>
 
</Driver>
 
</Datasources>

  • 1
  • 2
  • Next Page

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.