Академический Документы
Профессиональный Документы
Культура Документы
Edition 5.2.0
Legal Notice
Legal Notice
Copyright 2012 Red Hat, Inc. T he text of and illustrations in this document are licensed by Red Hat under a Creative Commons AttributionShare Alike 3.0 Unported license ("CC-BY-SA"). An explanation of CC-BY-SA is available at http://creativecommons.org/licenses/by-sa/3.0/. In accordance with CC-BY-SA, if you distribute this document or an adaptation of it, you must provide the URL for the original version. Red Hat, as the licensor of this document, waives the right to enforce, and agrees not to assert, Section 4d of CC-BY-SA to the fullest extent permitted by applicable law. Red Hat, Red Hat Enterprise Linux, the Shadowman logo, JBoss, MetaMatrix, Fedora, the Infinity Logo, and RHCE are trademarks of Red Hat, Inc., registered in the United States and other countries. Linux is the registered trademark of Linus T orvalds in the United States and other countries. Java is a registered trademark of Oracle and/or its affiliates. XFS is a trademark of Silicon Graphics International Corp. or its subsidiaries in the United States and/or other countries. MySQL is a registered trademark of MySQL AB in the United States, the European Union and other countries. All other trademarks are the property of their respective owners.
Abstract
T his Getting Started Guide documents information regarding the initial use of the JBoss Enterprise Application Platform 5 and its patch releases.
Table of Contents
Table of Contents
Preface 1. Document Conventions 1.1. T ypographic Conventions 1.2. Pull-quote Conventions 1.3. Notes and Warnings 2. Getting Help and Giving Feedback 2.1. Do You Need Help? 2.2. Give us Feedback 1. Other Conventions 2. JBoss Enterprise Application Platform Overview 2.1. Server Profiles 3. Starting and Stopping the Server 3.1. Starting the Server 3.1.1. Starting the Server with Alternate Configuration 3.2. Stopping the Server 4. Server as a Service 4.1. Running as a Service on Microsoft Windows 4.1.1. Removing the Service 4.2. Running as a Service on Red Hat Enterprise Linux 5. Basic Configuration Changes 5.1. Security Configuration 5.1.1. Security Configuration: JMX Console, Admin Console, HttpInvoker 5.1.2. Securing the HT T PInvoker 5.1.3. Security Configuration: Web Console 5.1.4. Security Configuration of JBoss Messaging 5.2. Memory Settings for the Enterprise Application Platform 5.3. Setting the Default Server Application 5.4. Configuring Legacy Core Services 5.5. Configuring Logging Service 5.6. Additional Services 6. Hot Deployment of Services 6.1. Hot-Deployment Configuration 6.2. Adding a Custom Deploy Directory 7. Console Pages 7.1. Admin Console 7.2. JMX Console 7.3. JBoss Web Console 7.4. T omcat Status 8. Datasources 8.1. Configuring Datasources 8.2. MySQL as the Default Datasource 8.2.1. Creating a Database and User 8.2.2. Installing the JDBC Driver and Deploying the Datasource
A. Revision History
Preface
Preface
1. Document Conventions
T his manual uses several conventions to highlight certain words and phrases and draw attention to specific pieces of information. In PDF and paper editions, this manual uses typefaces drawn from the Liberation Fonts set. T he Liberation Fonts set is also used in HT ML editions if the set is installed on your system. If not, alternative but equivalent typefaces are displayed. Note: Red Hat Enterprise Linux 5 and later includes the Liberation Fonts set by default. 1.1. T ypographic Conventions Four typographic conventions are used to call attention to specific words and phrases. T hese conventions, and the circumstances they apply to, are as follows. Mono-spaced Bold Used to highlight system input, including shell commands, file names and paths. Also used to highlight keys and key combinations. For example: T o see the contents of the file m y_next_bestselling_novel in your current working directory, enter the cat m y_next_bestselling_novel command at the shell prompt and press Enter to execute the command. T he above includes a file name, a shell command and a key, all presented in mono-spaced bold and all distinguishable thanks to context. Key combinations can be distinguished from an individual key by the plus sign that connects each part of a key combination. For example: Press Enter to execute the command. Press Ctrl + Alt+ F2 to switch to a virtual terminal. T he first example highlights a particular key to press. T he second example highlights a key combination: a set of three keys pressed simultaneously. If source code is discussed, class names, methods, functions, variable names and returned values mentioned within a paragraph will be presented as above, in m ono-spaced bold . For example: File-related classes include filesystem for file systems, file for files, and dir for directories. Each class has its own associated set of permissions. Proportional Bold T his denotes words or phrases encountered on a system, including application names; dialog box text; labeled buttons; check-box and radio button labels; menu titles and sub-menu titles. For example: Choose System Preferences Mouse from the main menu bar to launch Mouse Preferences. In the Buttons tab, click the Left-handed m ouse check box and click Close to switch the primary mouse button from the left to the right (making the mouse suitable for use in the left hand). T o insert a special character into a gedit file, choose Applications Accessories Character Map from the main menu bar. Next, choose Search Find from the
Character Map menu bar, type the name of the character in the Search field and click Next. T he character you sought will be highlighted in the Character T able . Double-click this highlighted character to place it in the T ext to copy field and then click the Copy button. Now switch back to your document and choose Edit Paste from the gedit menu bar. T he above text includes application names; system-wide menu names and items; application-specific menu names; and buttons and text found within a GUI interface, all presented in proportional bold and all distinguishable by context. Mono-spaced Bold Italic or Proportional Bold Italic Whether mono-spaced bold or proportional bold, the addition of italics indicates replaceable or variable text. Italics denotes text you do not input literally or displayed text that changes depending on circumstance. For example: T o connect to a remote machine using ssh, type ssh username@ domain.name at a shell prompt. If the remote machine is exam ple.com and your username on that machine is john, type ssh john@ exam ple.com . T he m ount -o rem ount file-system command remounts the named file system. For example, to remount the /hom e file system, the command is m ount -o rem ount /hom e . T o see the version of a currently installed package, use the rpm -q package command. It will return a result as follows: package-version-release. Note the words in bold italics above username, domain.name, file-system, package, version and release. Each word is a placeholder, either for text you enter when issuing a command or for text displayed by the system. Aside from standard usage for presenting the title of a work, italics denotes the first use of a new and important term. For example: Publican is a DocBook publishing system. 1.2. Pull-quote Conventions T erminal output and source code listings are set off visually from the surrounding text. Output sent to a terminal is set in m ono-spaced rom an and presented thus:
books books_tests Desktop Desktop1 documentation downloads drafts images mss notes photos scripts stuff svgs svn
Source-code listings are also set in m ono-spaced rom an but add syntax highlighting as follows:
Preface
package org.jboss.book.jca.ex1; import javax.naming.InitialContext; public class ExClient { public static void main(String args[]) throws Exception { InitialContext iniCtx = new InitialContext(); Object ref = iniCtx.lookup("EchoBean"); EchoHome home = (EchoHome) ref; Echo echo = home.create(); System.out.println("Created Echo"); System.out.println("Echo.echo('Hello') = " + echo.echo("Hello")); } }
1.3. Notes and Warnings Finally, we use three visual styles to draw attention to information that might otherwise be overlooked.
Note
Notes are tips, shortcuts or alternative approaches to the task at hand. Ignoring a note should have no negative consequences, but you might miss out on a trick that makes your life easier.
Important
Important boxes detail things that are easily missed: configuration changes that only apply to the current session, or services that need restarting before an update will apply. Ignoring a box labeled 'Important' will not cause data loss but may cause irritation and frustration.
Warning
Warnings should not be ignored. Ignoring warnings will most likely cause data loss.
technology. You can find a list of publicly available mailing lists at https://www.redhat.com/mailman/listinfo. Click on the name of any mailing list to subscribe to that list or to access the list archives. 2.2. Give us Feedback If you find a typographical error, or know how this guide can be improved, we would love to hear from you. Submit a report in Bugzilla against the product JBoss Enterprise Application Platform 5 and the component doc-Getting_Started_Guide . T he following link will take you to a pre-filled bug report for this product: http://bugzilla.redhat.com/. Fill out the following template in Bugzilla's Description field. Be as specific as possible when describing the issue; this will help ensure that we can fix it quickly.
Document URL:
Additional information:
Be sure to give us your name so that you can receive full credit for reporting the issue.
10
11
12
starts only the server: no web container, EJB, or JMS support is available. standard T he standard profile is the JavaEE 5 certified configuration of services. web T he web profile is a lightweight web-container oriented profile that previews the JavaEE 6 web profile.
T he default profile is used if you do not specify a configuration when running a server.
13
More options for the JBoss Enterprise Application Platform run script are discussed in Section 3.1.1, Starting the Server with Alternate Configuration below.
Note
T here is no Server Started message shown at the console when the server is started using the production profile. T his message may be observed in the server.log file located in the server/production/log subdirectory.
14
3.1.1. Starting the Server with Alternate Configuration Using run.sh without any arguments starts the server using the default server profile file set. T o start with an alternate profile file set, pass the name of the server configuration file set (same as the name of the server configuration directory under <JBOSS_HOME>/jboss-as/server/<PROFILE>/) that you want to use, as the value to the -c command line option. For example, to start with the m inim al profile file set you should specify:
[bin]$ ./run.sh -c minimal ... ... ... 15:05:40,301 INFO [Server] JBoss (MX MicroKernel) [5.0.0 (build: SVNTag=JBoss_5_0_0 date=200801092200)] Started in 5s:75ms
15
Note
For a full list of profiles and the services they include, refer to the Standard Server Profiles section of the Administration and Configuration Guide. 5. Run the service installation script. service.bat install 6. Check that the service is installed. Under the Windows services list you will find this listed by the short name JBAS52SVC and the long name JBoss Application Server 5.2 . 4 .1.1. Removing the Service T o remove the service, do the following: 1. Stop the service. Stop the service using Service Manager. 2. Delete the service. Issue the following command from the command prompt with elevated privileges: sc delete JBAS52SVC
16
T he profile used by the service is configured in /etc/sysconfig/jbossas. If you want a profile other than "default" used, change the "JBOSSCONF=" line, specifying the required profile. T he service must be restarted for this change to take effect.
Note
Make sure that the line is not commented out (remove the # character if present).
Note
For a full list of profiles and the services they include, refer to the Administration and Configuration Guide.
17
Important
T his section describes only basic security configuration. T his configuration is not sufficient for use in production environment. Refer to the Security Guide for comprehensive information on how to configure security in JBoss Enterprise Application Platform 5.
Important
T he authentication system applied to the JMX Console, Admin Console and Web Console does not block brute-force password attacks. It is recommended that in production environments, JBoss servers are protected by firewalls or reverse proxies that include measures to mitigate brute force attacks.
5.1.1. Security Configuration: JMX Console, Admin Console, HttpInvoker Procedure 5.1. Create jmx-console, admin-console, and http invoker user account T his procedure creates user with access permissions to the admin and jmx consoles, and the http invoker 1. Create a user in the default JAAS security domain a. Edit the file $JBOSS_HOME/server/$PROFILE/conf/props/jm x-consoleusers.properties. b. Create a username = password pair.
18
username=JBossAdmin,HttpInvoker
JBossAdmin Grant the user permission to access the JMX Console and Admin Console. HttpInvoker Grant the user permission to access the httpinvoker
5.1.2. Securing the HT T PInvoker T he HT T P Invoker is a service that provides HT T P and Remote Method Invocation (RMI) access for EJBs and the JNDI Naming service. Secure this service to prevent unauthorized access. Procedure 5.2. Secure the HT T P Invoker 1. Edit the <JBOSS_HOME>/server/<PROFILE>/conf/bindingservice.beans/MET AINF/bindings-jboss-beans.xm l file. 2. Add the hostName and fixedHostName properties to the deploy/legacy-invokers-service.xml section:
<!-- ************ deploy/legacy-invokers-service.xml ************ --> <!-- RMI/JRMP invoker --> <bean class="org.jboss.services.binding.ServiceBindingMetadata"> <property name="serviceName">jboss:service=invoker,type=jrmp</property> <property name="port">4444</property> <property name="description">Socket for the legacy RMI/JRMP invoker</property> <property name="hostName">localhost</property> <property name="fixedHostName">true</property> </bean> <!-- Pooled invoker --> <bean class="org.jboss.services.binding.ServiceBindingMetadata"> <property name="serviceName">jboss:service=invoker,type=pooled</property> <property name="port">4445</property> <property name="description">Socket for the legacy Pooled invoker</property> <property name="hostName">localhost</property> <property name="fixedHostName">true</property> </bean>
5.1.3. Security Configuration: Web Console Procedure 5.3. Creating Web Console User Account T his procedure creates a user with access permissions to the web console 1. Create a user in the web-console JAAS security domain. a. Edit the file web-console-users.properties in jbossas/server/$PROFILE/deploy/m anagem ent/console-m gr.sar/webconsole.war/WEB-INF/classes/. b. Create a username = password pair.
19
JBossAdmin Grant the user permission to access the Web-Console HttpInvoker Grant the user permission to access the HT T P Invoker
5.1.4 . Security Configuration of JBoss Messaging JBoss Messaging makes internal connections between nodes in order to redistribute messages between clustered destinations. T hese connections are made with the user name of a special reserved user whose password is specified in the property suckerPassword in the messaging and server configuration files. T he suckerPassword used by JBoss Messaging in a clustered environment is contained in the jbossas/server/$PROFILE/deploy/m essaging/m essaging-jboss-beans.xm l file and the m essaging-service.xm l file. T hese files contain directives that specify the encrypted suckerPassword . Changing the Password in m essaging-jboss-beans.xm l Complete this task to change the distribution placeholder password in m essaging-jbossbeans.xm l . Procedure 5.4 . Setting suckerPassword for JBoss Messaging 1. Navigate to the <JBOSS_HOME>/server/<PROFILE>/deploy/m essaging/ directory. 2. Open the m essaging-jboss-beans.xm l file in your preferred text editor. 3. Change the suckerPassword placeholder value from "CHANGE ME!!" to a plain text password:
<property name="suckerPassword">CHANGE ME!!</property>
Make note of the new password; it will be used in the next task. 4. Save the file. Creating the encrypted JBoss Messaging suckerPassword Complete this task to create an encrypted suckerPassword using the JBoss Messaging SecurityUtil tool.
20
3. PLAIN_TEXT_PASSWORD is the password you set in m essaging-jboss-beans.xm l in the previous task. As an example: Example 5.1. T est Encrypted Password Running the following command (from the JBOSS_HOME/jbossas/server/$PROFILE/deploy/m essaging/ directory) ...
/usr/bin/java -cp ../../../../client/jboss-messaging-client.jar org.jboss.messaging.util.SecurityUtil test
4. Make note of the encrypted password output; it will be used in the next task. Specifying an encrypted suckerPassword for JBoss Messaging Complete this task to add an encrypted suckerPassword value to JBoss Messaging configuration files. Prerequisites Creating the encrypted JBoss Messaging suckerPassword You have a terminal open at the <JBOSS_HOME>/server/<PROFILE>/deploy/m essaging/ directory.
1. In a text editor, open the m essaging-service.xm l file. 2. Paste the encrypted password from the previous procedure into the SuckerPassword attribute:
<attribute name="SuckerPassword">ENCRYPTED_PASSWORD</attribute>
21
-Xm x1303m : maximum heap size in megabytes Follow the guidelines below when defining memory settings: Allocate the same values for initial and maximum heap sizes. Use values smaller than the host's allocatable memory. Be aware of other services and applications running on the host, and allow for their usage of memory. Fine tuning the memory settings beyond these guidelines requires production-like load testing and analysis of memory usage logs, and can vary dramatically between installations and applications used with the JBoss Enterprise Application Platform. Procedure 5.5. Changing Memory Settings for the Enterprise Application Platform on Linux 1. Navigate to $JBOSS_HOME/jboss-as/bin . 2. Open run.conf for editing. 3. Locate the line with the memory options:
JAVA_OPTS="-Xms1303m -Xmx1303m -XX:MaxPermSize=256m Dorg.jboss.resolver.warning=true -Dsun.rmi.dgc.client.gcInterval=3600000 Dsun.rmi.dgc.server.gcInterval=3600000 Dsun.lang.ClassLoader.allowArraySyntax=true"
4. Edit the line to include the new initial and maximum heap sizes for the JVM:
JAVA_OPTS="-XmsINITIAL_HEAP_SIZE -XmxMAX_HEAP_SIZE -XX:MaxPermSize=256m Dorg.jboss.resolver.warning=true -Dsun.rmi.dgc.client.gcInterval=3600000 Dsun.rmi.dgc.server.gcInterval=3600000 Dsun.lang.ClassLoader.allowArraySyntax=true"
5. If the server is runnning, restart it to apply the new settings. Procedure 5.6. Changing Memory Settings for the Enterprise Application Platform on Windows 1. Navigate to $JBOSS_HOME/jboss-as/bin . 2. Open run.conf.bat for editing. 3. Locate the line with the memory options:
set "JAVA_OPTS=-Xms1303m -Xmx1303m -XX:MaxPermSize=256m Dorg.jboss.resolver.warning=true -Dsun.rmi.dgc.client.gcInterval=3600000 Dsun.rmi.dgc.server.gcInterval=3600000 -Dsun.lang.ClassLoader.allowArraySyntax=true"
4. Edit the line to include the new initial and maximum heap sizes for the JVM:
set "JAVA_OPTS=-XmsINITIAL_HEAP_SIZEm -XmxMAX_HEAP_SIZEm XX:MaxPermSize=256m -Dorg.jboss.resolver.warning=true Dsun.rmi.dgc.client.gcInterval=3600000 Dsun.rmi.dgc.server.gcInterval=3600000 Dsun.lang.ClassLoader.allowArraySyntax=true"
22
By setting the context-root to / you are making your application the default application. Your application will now be available at http://localhost:8080/.
Note
Renaming the ROOT .war to jboss.war will make that application be available at http://localhost:8080/jboss
Note
T his file will be dropped as the services are converted to microcontainer Beans or MBeans that are deployed as deploy directory services. Note that if an MBeans definition has nested comments, you need to comment out the MBean in two sections, leaving the original comment as it was.
23
If you then restart JBoss, you will see that the JNDIView service no longer appears in the JMX Management Console (JMX Console) listing. In practice, you should rarely, if ever, need to modify this file, though there is nothing to stop you adding extra MBean entries in here if you want to. T he alternative is to use a separate file in the deploy directory, which allows your service to be hot deployable.
Log Levels
T here are six basic log levels in log4j: T RACE , DEBUG , INFO , WARN , ERROR and FAT AL. T he logging threshold on the console is INFO , so that any informational messages, warning messages and error messages are returned to the console, while general debug and trace messages are only available in the log file. If no logging level is set for the server.log file, it defaults to DEBUG . Always when demanding debug information, check the server.log file to see if there are any debug messages which might help you to track down the problem. However, be aware that just because the logging threshold allows debug messages to be displayed, that does not mean that all of JBoss produces detailed debug information for the log file. You should also consider increasing the logging limits set for individual categories.
24
In Example 5.3, Example Log Limits, the level of logging is set to INFO for all JBoss classes, with the exception of classes with more specific overrides. By default the root logger in the jboss-log4 j.xm l is set to INFO : any T RACE or DEBUG logger from any logger categories is not logged in any files or the console appenders. T his setting is controlled through the jboss.server.log.threshold property. By default this is INFO . If changed to DEBUG , more detailed logging output is produced. Yuo can change this as follows: Pass the -Djboss.server.log.threshold=DEBUG parameter when starting the server:
./run.sh -Djboss.server.log.threshold=DEBUG
Note
T he <JBOSS_HOME>/jboss-as/server/<PROFILE>/conf/jboss-log4 j.xm l is scanned every 60 seconds (by default) on any changes. T herefore changing this file does not require a server restart. As another example, lets say you wanted to set the output from the container-managed persistence engine to DEBUG level and to redirect it to a separate file, cm p.log , in order to analyze the generated SQL commands. You would add the following code to the conf/jboss-log4 j.xm l file:
<appender name="CMP" class="org.jboss.logging.appender.RollingFileAppender"> <errorHandler class="org.jboss.logging.util.OnlyOnceErrorHandler"/> <param name="File" value="${jboss.server.home.dir}/log/cmp.log"/> <param name="Append" value="false"/> <param name="MaxFileSize" value="500KB"/> <param name="MaxBackupIndex" value="1"/> <layout class="org.apache.log4j.PatternLayout"> <param name="ConversionPattern" value="%d %-5p [%c] %m%n"/> </layout> </appender> <category name="org.jboss.ejb.plugins.cmp"> <priority value="DEBUG" /> <appender-ref ref="CMP"/> </category>
T his creates a new file appender and specifies that it should be used by the logger (or category) for the package org.jboss.ejb.plugins.cm p . T he file appender is set up to produce a new log file every day rather than producing a new one every time you restart the server or writing to a single file indefinitely. T he current log file is cm p.log . Older files have the date they were written added to their file names. Please note that the log directory also contains HT T P request logs which are produced by the web container. By default the server.log appender is configured to retain log messages between server restarts. T his is controlled by the Append property on the FILE appender which corresponds to the
25
server.log file. By default this property is set to true; if you want the server.log contents to be wiped out on server restarts then you can edit the <JBOSS_HOME>/jbossas/server/<PROFILE>/conf/jboss-log4 j.xm l file to set this property value to false. For example:
<appender name="FILE" class="org.jboss.logging.appender.DailyRollingFileAppender"> <errorHandler class="org.jboss.logging.util.OnlyOnceErrorHandler"/> <param name="File" value="${jboss.server.log.dir}/server.log"/> <param name="Append" value="false"/> ...
26
Then replace the file and watch JBoss re-install the service: 13:58:54,331 INFO [MailService] Mail Service bound to java:/Mail
You have just undeployed the mail service during server runtime: this is hot-deployment in action.
27
Important
Not adding the custom deployment directory to the VFSCache bean might result in growing disk space usage by the server.
28
29
Example 7.1. JMX Console Usage Procedure 7.1. View the JNDI Service 1. Open the JMX Console. 2. Find the service=JNDIView link and click on it. T his particular MBean provides a service to allow you to view the structure of the JNDI namespaces within the server. 3. Now find the operation called list near the bottom of the MBean view page and click the invoke button. T he operation returns a view of the current names bound into the JNDI tree, which is very useful when you start deploying your own applications and want to know why you cant resolve a particular EJB name.
Look at some of the other MBeans and their listed operations; try changing some of the configuration attributes and see what happens. With a very few exceptions, none of the changes made through the console are persistent. T he original configuration will be reloaded when you restart JBoss, so you can experiment freely without doing any permanent damage.
30
Chapter 8. D atasources
Chapter 8. Datasources
JBoss Enterprise Application Platform is shipped with an example datasource configured to allow it to operate out of the box with the included Hypersonic database. T he datasource is bound to the JNDI name java:/DefaultDS and its descriptor is the <$JBOSS_HOME>/jbossas/server/<PROFILE>/deploy/hsqldb-ds.xm l file. T he DefaultDS JNDI name and hsqldb-ds.xm l configuration is not required for normal platform operation. Delete this datasource before deploying a production instance. Accessing the Database Manager of the Default Hypersonic Database T o access and edit the Hypersonic database that is available by default, do the following: 1. Make sure JBoss Enterprise Application Platform is running. 2. Open the JMX console located by default on http://localhost:8080/jmx-console/. 3. On the displayed JMX Console page, click the database=localDB,service=Hypersonic entry in the jboss section. 4. On the JMX MBean View page of the Hypersonic MBean, click Invoke in the startDatabaseManager row to invoke the GUI interface of the database manager. T he HSQL Database Manager window with the default local Hypersonic database appears.
31
Local transaction datasources are configured using the local-tx-datasource element and XAcompliant ones using xa-datasource . T he example file generic-ds.xm l shows how to use both types and also some of the other elements that are available for things like connection pool configuration. Examples of both local and XA configurations are available for Oracle, DB2 and Informix. T he example files firebird-ds.xm l , facets-ds.xm l and sap3-ds.xm l are defined with the connection-factories root element rather than datasources. T hat is because they use an alternative, more generic JCA configuration syntax used with a pre-packaged JCA resource adapter. T he syntax is not specific to datasource configuration and is used, for example, in the <JBOSS_HOME>/jboss-as/server/<PROFILE>/deploy/m essaging/jm s-ds.xm l file to configure the JMS resource adapter.
Next, create a user called jboss with 'password' as the password to access the database:
mysql> GRANT ALL PRIVILEGES ON jboss.* TO jboss@localhost IDENTIFIED BY 'password'; Query OK, 0 rows affected (0.06 sec)
32
Chapter 8. D atasources
mysql> select User,Host,Password from mysql.user; +-------+-----------+------------------+ | User | Host | Password | +-------+-----------+------------------+ | root | localhost | | | root | % | | | | localhost | | | | % | | | jboss | localhost | 5d2e19393cc5ef67 | +-------+-----------+------------------+ 5 rows in set (0.02 sec)
8.2.2. Installing the JDBC Driver and Deploying the Datasource T o add MySQL database connection support to JBoss Enterprise Application Platform: Procedure 8.1. Red Hat Enterprise Linux 6 1. Run the following command to install the connector:
yum install mysql-connector-java
2. Run the following command to link the new connector to the JBoss Enterprise Application Platform installation:
ln -s /usr/lib[64]/gcj/mysql-connector-java/mysql-connectorjava<version>.jar.so jboss-as/server/common/lib/mysql-connector-java.jar
Procedure 8.2. Other Platforms 1. Download the MySQL Connector/J JDBC Connector from http://www.mysql.com 2. Deploy the connector: a. T o make the connector available to all server profiles; Extract the m ysql-connector-java-<version>.jar file to <JBOSS_HOME>/server/com m on/lib . b. T o make the connector available to selected profiles only; Extract the file to the lib directory in those server profile directories. T hen create a file in the deploy directory called m ysql-ds.xm l with the following datasource configuration. Note that the database user name and password corresponds to the MySQL user that we created in the previous section:
<?xml version="1.0" encoding="UTF-8"?> <datasources> <local-tx-datasource> <jndi-name>DefaultDS</jndi-name> <connection-url>jdbc:mysql://localhost:3306/jboss</connection-url> <driver-class>com.mysql.jdbc.Driver</driver-class> <user-name>jboss</user-name> <password>password</password> <metadatda> <type-mapping>mySQL</type-mapping> </metadata> <transaction-isolation>TRANSACTION_READ_COMMITTED</transaction-isolation> </local-tx-datasource> </datasources>
33
T o ensure that you have correctly configured the datasource in <JBOSS_HOME>/jbossas/server/<PROFILE>/deploy folder, start the server and you will notice messages like these in the logs:
INFO [ConnectionFactoryBindingService] Bound ConnectionManager 'jboss.jca:service=DataSourceBinding,name=MySqlDS' to JNDI name 'java:MySqlDS'
Note
Configuring other datasources is a similar process.
34
Revision History
Revision History
Revision 5.2.0-100 Wed 23 Jan 2013 Russell Dickenson Incorporated changes for JBoss Enterprise Application Platform 5.2.0 GA. For information about documentation changes to this guide, refer to Release Notes 5.2.0. Revision 5.1.2-100 T hu Dec 8 2011 Jared Morgan Incorporated changes for JBoss Enterprise Application Platform 5.1.2 GA. For information about documentation changes to this guide, refer to Release Notes 5.1.2. Revision 5.1.1-100 Mon Jul 18 2011 Jared Morgan Incorporated changes for JBoss Enterprise Application Platform 5.1.1 GA. For information about documentation changes to this guide, refer to Release Notes 5.1.1. Revision 5.1.0-100 Wed Sep 15 2010 Laura Bailey Changed version number in line with new versioning requirements. Revised for JBoss Enterprise Application Platform 5.1.0.GA.