JBOSS EAP Combat (1)

Source: Internet
Author: User
Tags connection pooling jboss

The birth of JBoss


In 1998, at the SAP Lab in Silicon Valley sun, a young man was sitting in front of a computer thinking and writing something.


No, he's not writing a program, he's writing his resignation. He is making a big decision in his life:


He will quit his job at Sun and devote himself to the development of open source. Next to a lot of friends are persuading him, such practice is "moving down the food chain" (should be lost rice bowl meaning), this is his entire career downhill.


But the young man smiled without hesitation, his eyes full of confidence, and he believed that he would be proud of his decision in a few years ' time, believing it was not the descent of his career, but the beginning of his truly successful career.


This young man is Marc Fleury, who has created JBoss, the open source application server that is used all over the world, and is driving the development of the entire Java open source community.


JBoss and his architects:


The movie The Maxtrix classic lines, remember Neo was Morpheus brought to a small house, and then pulled out two pills scene?


: "If you take the red pill I'll show you what deep the rabbit hole goes. If you take the blue pill, you stay in corporate land and you believe whatever your want to believe. "


That's how Bill Burke, the overall architect of JBoss, was pacified. At that time Bill Burke still do a business application, can not afford Bea's things, on Google search for JBoss, found some bugs, modified and sent an email to Marc Fleury,marc After Fleury asked Bill, he sent an email with only one sentence: "Do want to take the red pill?" "。 So Bill Burke became a member of JBoss.


JBoss begins to be brilliant


In 2001, when I was a dick, I was gnawing and ejb2.x, and when I finally finished writing an EJB using the weblogic5.x at the time, I saw the appearance of a crash scene.


My MMX166 appeared out of memory.


At that time, 32MB of memory is very large, but in 2001 on the same machine installed JBuilder and installed WebLogic, the deployment of an EJB entity bean in its reverse generation of database tables, the need to use more than 50 MB of memory, which was obviously a luxury behavior at that time.


So I started a crazy search on the internet. EJB container, the Java EE APP Server, suddenly we found something that was downloaded more than 1 million in a day.


This is jboss3.x.


It was the jboss3.2.x version that JBoss pushed to real enterprise applications, when only 20 trillion of small things could be second-tier and actually cross-platform, and its start-up was only 11MB. I also met JBoss at the time.


JBoss's performance has to be pretty good, all the heat. The Department is simplifying everything as if it were served by the Java EE.


JBoss has undergone 3.2.X and 4.X and completed the eventual transformation of JBoss after jboss5.x, which is where JBoss entered the jboss7.x and JBoss EAP phases.


First jboss7.x take the open source route, JBOSS EAP6. X Go business route.


With the continuous efforts of the open source community, the JBoss EAP version is finally starting to take the open source route after jbosseap6.x.


JBoss Version Selection





JBoss Installation

JBoss embedded Tomcat from 4.X, and its inline tomcat is a highly optimized tomcat, both in terms of stability, number of threads, and connection pooling, optimized by the high source level.


In general, we chose JBoss EAP6.4 version, and JBoss was no longer called JBoss from 8.x, but changed its name to Wildfly.


JBoss official





JBoss directory Structure Explained





JBoss Basic Configuration-Port


In the bin directory of JBoss EAP6, enter./standalone.sh to start JBoss EAP6




In the boot process, if the problem of port conflict can be modified $jboss_home/standalone/configuration/standalone.xml, the port in the file is changed to the corresponding address, as shown in:




If you want to terminate JBoss It is also very simple, direct CTRL + C.


JBoss Basic Configuration


Allow remote access

JBoss no matter what version, from the beginning of the birth of the default support only localhost access, including Jndi-based access is also supported only local access.


For example, the graphical console,http://ip:9990 of JBoss EAP.


If you are using http://localhost:9990 here, you can visit!


If you are using http://192.168.0.101:9990 here, it will tell you that you cannot access it.


Please modify the $jboss_home/standalone/configuration/standalone.xml file as below.




You can change it to <any-address/> can also specify IP (for security), generally management function if you are not in the development, experiment machine, then I do not recommend to turn on "remote accessible".


Initialize User name password

We open an IE input http://192.168.0.101:9990/, at this time we will get the following screen




This is because we did not configure the default Admin user to follow the following steps in the case of JBoss boot:


cd/opt/jboss/bin./add-user.sh



We add an admin user, remember: admin password must be 8-bit character + number mix




In the above steps we:


    • Added a user admin, whose password is: password_1
    • Admin assigned admin,administrator,root Three Super user privileges
Now, we re-use IE to access http://192.168.0.101:9990 remotely




Once we have entered the username and password we just created, we can log into the graphical management interface of JBoss.





Installing MySQL Database drivers and connections in JBoss

Although from JBoss EAP, we can use http://xxx.xxx.xxx.xxx:9990, the graphical management console, to do any configuration of JBoss (previously all XML file-based configuration), But we still use hand-changing XML in practice, which makes it easier for us to get a deeper impression of jboss configuration.


To increase the drive of a database, we need to go through the following steps:


    • Establishing relevant database-driven module in JBoss
    • Writing module Description
    • Modify Standalone.xml
    • Restart JBoss

Take MySQL for example:


Its drive is called: Mysql-connector-java-5.1.38.jar
Its module layer is called Com\mysql (this name can be casually, you can also call abc\org, generally under each module has a main, which is the module "portal"
Module's description filename is always called Module.xml




As described above:


    • We created this level of folder Com\mysql\main under D:\ $JBOSS _home\modules\system\layers\base\. such as: D:\ $JBOSS _home\modules\system\layers\base\com\mysql\main


    • Create a new module.xml so that it reads as follows:


<?xml version= "1.0" encoding= "UTF-8"? ><module xmlns= "urn:jboss:module:1.1" name= "Com.mysql" >    < properties>        <property name= "Jboss.api" value= "public"/>    </properties>    <resources >        <resource-root path= "Mysql-connector-java-5.1.38.jar"/>        <!--Insert resources here--    </resources>    <dependencies>        <module name= "Javax.api"/>        <module name= " Javax.transaction.api "/>        <module name=" Javax.servlet.api "optional=" true "/>    </dependencies ></module>

    • Copy all Module.xml and Mysql-connector-java-5.1.38.jar to: D:\ in the _home\modules\system\layers\base\com\mysql\main directory $JBOSS




Start modifying the D:\ $JBOSS _home\standalone\configuration\standalone.xml file and find the "<datasources>" segment

<datasources>                <datasource jndi-name= "java:jboss/datasources/exampleds" pool-name= "exampleds" enabled = "true" use-java-context= "true" >                    <connection-url>jdbc:h2:mem:test;db_close_delay=-1;db_close_on_ exit=false</connection-url>                    <driver>h2</driver>                    <security>                        <user-name >sa</user-name>                        <password>sa</password>                    </security>                </datasource>                <drivers>                    <driver name= "H2" module= "COM.H2DATABASE.H2" >                        <xa-datasource-class> org.h2.jdbcx.jdbcdatasource</xa-datasource-class>                    </driver>                </drivers> </ Datasources>

As you can see, this is divided into two segments:

    • Basic description of DataSource
    • A description of the database-driven module, where module= "COM.H2DATABASE.H2" points to: D:\ $JBOSS _home\modules\system\layers\base\ COM\H2DATABASE\H2

According to this principle, let's rewrite our Standalone.xml file.


<datasources> <datasource jndi-name= "java:/comp/env/jdbc/jbpm" pool-name= "Droolsds" enabled= "true" Use-java-context= "true" > <connection-url>jdbc:mysql://192.168.0.101:3306/guvnor?autoreconnect =true&failoverreadonly=false&maxreconnects=10&useunicode=true&characterencoding=utf-8</                        Connection-url> <driver>mysql</driver> <security>                    <user-name>drools</user-name> <password>aaaaaa</password> </security> </datasource> <drivers> <dri ver name= "MySQL" module= "com.mysql" > <driver-class>com.mysql.jdbc.driver</driver-class&                        Gt                    <xa-datasource-class>com.mysql.jdbc.jdbc2.optional.MysqlXADataSource</xa-datasource-class> </driver&gT </drivers></datasources>

Save after you finish changing


To verify that our modifications are correct, we can enter http://192.168.0.101:9990 's JBoss graphical console




When you see the popup:
Successfully connected to ... The typeface indicates that our database connection was established correctly.


Installing the Oracle database in JBoss

This time we built an Oracle connection directly to the GUI using the JBoss self-bring console.


    • Establish Module.xml
    • Preparing the Oracle Driver

<?xml version= "1.0" encoding= "UTF-8"? ><module xmlns= "urn:jboss:module:1.1" name= "com.oracle" >    < properties>        <property name= "Jboss.api" value= "public"/>    </properties>    <resources >        <resource-root path= "Ojdbc6.jar"/>        <!--Insert resources here--    </resources>    <dependencies>        <module name= "Javax.api"/>        <module name= "Javax.transaction.api"/>        <module name= "Javax.servlet.api" optional= "true"/>    </dependencies></module>


    • Modify standalone.xml-Add an Oracle driver

drivers>                    <driver name= "MySQL" module= "com.mysql" >                        <driver-class>com.mysql.jdbc.Driver< /driver-class>                        <xa-datasource-class>com.mysql.jdbc.jdbc2.optional.mysqlxadatasource</ xa-datasource-class>                    </driver>                    <driver name= "Oracle" module= "Com.oracle" >                        < Driver-class>oracle.jdbc.driver.oracledriver</driver-class>                        <xa-datasource-class> Oracle.jdbc.xa.client.oraclexadatasource</xa-datasource-class>                    </driver></drivers>


    • Restart JBoss

Using http://xxx.xxx.xxx.xxx:9990 to enter the JBoss console interface




Using http://xxx.xxx.xxx.xxx:9990 to enter the JBoss console interface









JBoss Basic Parameter configuration
Locate the standalone.conf in the $jboss_home\bin\ directory after this section:


#PRESERVE_JAVA_OPTS =true


#
# Specify options to pass to the Java VM.
#


Join:
Export java_opts= "-xms1024m-xmx1024m-xx:maxpermsize=512m-djava.net.preferipv4stack=true- djboss.modules.system.pkgs= $JBOSS _modules_system_pkgs-djava.awt.headless=true- Djboss.modules.policy-permissions=true "


it overwrites all the java_opts parameters ( all of them) in the original standalone.conf and standalone.sh files.

The WAR (WEB application) deployment

In JBoss, you can either have a deployment ear or a war package.


Of course, it can also be a folder, the name of the folder should be: Myweb.war or myee.ear.


If:


You have a folder like: Kie-wb.war, you have to create a deployment file in the same level directory, the file name must be: Kie-wb.war.dodeploy.


Here, the red bold part must have the same name as your folder.


The contents of this file are "empty" and nothing.


JBoss will automatically change this file name to Kie-wb.war.deploying when it is started.


If the deployment succeeds, the file name will be automatically renamed as: kie-wb.war.deployed


If the deployment fails, the file name will be automatically renamed as: kie-wb.war.failed





JBOSS EAP Combat (1)

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.