[jboss-cvs] jboss-docs/adminguide/docbook/en/modules ...

Sam Griffith sam.griffith at jboss.com
Mon Feb 26 00:24:40 EST 2007


  User: sgriffith
  Date: 07/02/26 00:24:39

  Modified:    adminguide/docbook/en/modules  appendix-alternative_DBs.xml
  Log:
  Changes that show the full steps need to make MySQL the defaultDS database for JBoss.
  
  Revision  Changes    Path
  1.4       +395 -112  jboss-docs/adminguide/docbook/en/modules/appendix-alternative_DBs.xml
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: appendix-alternative_DBs.xml
  ===================================================================
  RCS file: /cvsroot/jboss/jboss-docs/adminguide/docbook/en/modules/appendix-alternative_DBs.xml,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -b -r1.3 -r1.4
  --- appendix-alternative_DBs.xml	20 Feb 2007 07:24:42 -0000	1.3
  +++ appendix-alternative_DBs.xml	26 Feb 2007 05:24:39 -0000	1.4
  @@ -12,64 +12,64 @@
   			Setting up MySQL
   		</title>
   		<para>
  -			MySQL is available for free from <literal>http://dev.mysql.com/downloads/ </literal> for most major OS's. For this setup sample, we've downloaded the lastest stable MySQL 5 version which happens to be MySQL 5.0.27. Follow the instructions for installing MySQL on your platform. 
  +			MySQL is available for free from <literal>http://dev.mysql.com/downloads/</literal> for most major OS's. For this setup sample, we've downloaded the latest stable MySQL 5 version which happens to be MySQL 5.0.27. Follow the instructions for installing MySQL on your platform. 
   		</para>
   		<para>
  -			MySQL is interacted with and administered by uinsg the <literal>mysql</literal> command. On OS X it is foudn in <literal>/usr/local/mysql/bin/mysql</literal>. To work with the <literal>mysql</literal> client you will most likely want to do it as a root user. To do so, use the<literal>-u</literal> or <literal>-user</literal> option. This allows you to specify the user name used when connecting to the database.
  +			MySQL is interacted with and administered by uinsg the <literal>mysql</literal> command. On Mac OS X it is found in <literal>/usr/local/mysql/bin/mysql</literal>. To work with the <literal>mysql</literal> client you will most likely want to do it as a root user. To do so, use the<literal>-u</literal> or <literal>-user</literal> option. This allows you to specify the user name used when connecting to the database.
   			<programlisting>
  -				$ mysql -u root
  -				Welcome to the MySQL monitor.  Commands end with ; or \g.
  -				Your MySQL connection id is 4 to server version: 5.0.27-standard
  +$ mysql -u root
  +Welcome to the MySQL monitor.  Commands end with ; or \g.
  +Your MySQL connection id is 4 to server version: 5.0.27-standard
   
  -				Type 'help;' or '\h' for help. Type '\c' to clear the buffer.
  +Type 'help;' or '\h' for help. Type '\c' to clear the buffer.
   
  -				mysql>
  +mysql>
   			</programlisting>
   		</para>
   		<para>
  -			After you've connected to the db you'll need to create a database with the name <literal>jboss</literal>. To do so, use the <literal>create database</literal> command like so:
  +			After you've logged into MySQL you'll need to create a database with the name <literal>jboss</literal>. To do so, use the <literal>create database</literal> command like so:
   			<programlisting>
  -				mysql> create database jboss;
  -				Query OK, 1 row affected (0.01 sec)
  +mysql> create database jboss;
  +Query OK, 1 row affected (0.01 sec)
   			</programlisting>
   		</para>
   		<para>
  -			Now that we've created a database we need to create a user for it so that we don't have to be root to access it. To do so, use the <literal>grant</literal> command like so:
  +			Now that you've created a database we need to create a user for it so that we don't have to be root to access it. To do so, use the <literal>grant</literal> command like so:
   			<programlisting>
  -				mysql> grant all privileges on jboss.* to sam at localhost identified by 'password';
  -				Query OK, 0 rows affected (0.00 sec)
  +mysql> grant all privileges on jboss.* to sam at localhost identified by 'password';
  +Query OK, 0 rows affected (0.00 sec)
   			</programlisting>
   			With that grant command we created a user <literal>sam</literal> with a password <literal>password</literal>. User <literal>sam</literal> has access to everything in the <literal>jboss</literal> database.
   		</para>
   		<para>
   			We can look at the MySQL user table to see that <literal>sam</literal> has been added.
   			<programlisting>
  -				mysql> select user, host, password from mysql.user;
  -				+------+-------------------+-------------------------------------------+
  -				| user | host              | password                                  |
  -				+------+-------------------+-------------------------------------------+
  -				| root | localhost         |                                           | 
  -				| root | sam-griffiths.sme |                                           | 
  -				|      | sam-griffiths.sme |                                           | 
  -				|      | localhost         |                                           | 
  -				| sam  | localhost         | *2470C0C06DEE42FD1618BB99005ADCA2EC9D1E19 | 
  -				+------+-------------------+-------------------------------------------+
  -				5 rows in set (0.01 sec)
  +mysql> select user, host, password from mysql.user;
  ++------+-------------------+-------------------------------------------+
  +| user | host              | password                                  |
  ++------+-------------------+-------------------------------------------+
  +| root | localhost         |                                           | 
  +| root | sam-griffiths.sme |                                           | 
  +|      | sam-griffiths.sme |                                           | 
  +|      | localhost         |                                           | 
  +| sam  | localhost         | *2470C0C06DEE42FD1618BB99005ADCA2EC9D1E19 | 
  ++------+-------------------+-------------------------------------------+
  +5 rows in set (0.01 sec)
   			</programlisting>
   			We can now login to the database as <literal>sam</literal> instead of <literal>root</literal>. Let's see that work. Make sure if your still logged into the MySQL client, that you exit by typing in <literal>exit</literal> at the MySQL prompt like so:
   			<programlisting>
  -				mysql> exit
  -				Bye
  +mysql> exit
  +Bye
   			</programlisting>
   			Now you can login as the new user you created (in our case <literal>sam</literal>), like so:
   			<programlisting>
  -				$ mysql -u sam --password=password
  -				Welcome to the MySQL monitor.  Commands end with ; or \g.
  -				Your MySQL connection id is 8 to server version: 5.0.27-standard
  +$ mysql -u sam --password=password
  +Welcome to the MySQL monitor.  Commands end with ; or \g.
  +Your MySQL connection id is 8 to server version: 5.0.27-standard
   
  -				Type 'help;' or '\h' for help. Type '\c' to clear the buffer.
  +Type 'help;' or '\h' for help. Type '\c' to clear the buffer.
   
  -				mysql>
  +mysql>
   			</programlisting>
   			One thing to note is that we did not create our user with remote access permissions, so if you try to login from a remote machine to mysql with user <literal>sam</literal>, you will not be able too. See the MySQL documentation for further information on creating users with remote users.
   		</para>
  @@ -81,20 +81,129 @@
   	<section>
   		<title>Adding the MySQL JDBC driver</title>
   		<para>
  -			For the JBoss Application Server and our applications to use the MySQL database, we also need to install the MySQL JDBC drivers. They can be obtained from: <literal>http://www.mysql.com/products/connector/j/</literal>. For our 5.0.27 version download we need the 5.0 versions which can be obtained from <literal>http://dev.mysql.com/downloads/connector/j/5.0.html</literal>. The download contains documentation, etc. for the JDBC connector, but you really only need the <literal>mysql-connector-java-5.0.4-bin.jar</literal> file to get MySQL to be used by JBoss. You'll need to copy that jar file to your JBoss servers <literal>lib</literal> directory. We copied it to our <literal>server/default/lib</literal> directory. This file will now be loaded when JBoss starts up. So if you have the JBoss server running, you'll need to shut down and restart before this jar is available for the App Server to use.
  +			For the JBoss Application Server and our applications to use the MySQL database, we also need to install the MySQL JDBC drivers. They can be obtained from: <literal>http://www.mysql.com/products/connector/j/</literal>. For our 5.0.27 version download we need the 5.0 versions which can be obtained from <literal>http://dev.mysql.com/downloads/connector/j/5.0.html</literal>. The download contains documentation, etc. for the JDBC connector, but you really only need the <literal>mysql-connector-java-5.0.4-bin.jar</literal> file to get MySQL to with with and be used by JBoss. You'll need to copy that jar file to your JBoss servers <literal>lib</literal> directory. We copied it to our <literal>server/default/lib</literal> directory. This file will now be loaded when JBoss starts up. So if you have the JBoss server running, you'll need to shut down and restart before this jar is available for the App Server to use.
   		</para>
   		<para>
   			How can we tell if JBoss found that new MySQL driver? The quickest way is to look at our JMX console to see check which JDBC driver is loaded. Open your browser and go to: <literal>http://localhost:8080/jmx-console</literal>. Towards the top of the page you'll see the JMImplementation domain. Choose the <literal>name=Default,service=LoaderRepository</literal> MBean. On the screen for the LoaderRepository MBean you'll see a MBean operation for <literal>displayClassInfo()</literal>. In it's parameterValue text field put in <literal> com.mysql.jdbc.Driver</literal> and click the "Invoke" button. you should see something like this:
   			<programlisting>
  -				com.mysql.jdbc.Driver Information
  -				Not loaded in repository cache
  +com.mysql.jdbc.Driver Information
  +Not loaded in repository cache
   
   
  -				### Instance0 found in UCL: org.jboss.mx.loading.UnifiedClassLoader3 at 592141{ url=null ,addedOrder=2}
  +### Instance0 found in UCL: 
  +	org.jboss.mx.loading.UnifiedClassLoader3 at 592141{ url=null ,addedOrder=2}
   			</programlisting>
   			While we haven't used the instance yet which would have caused the class to be loaded into the repository cache, we do have an instance, so JBoss knows about the driver and can see it. If we had used the class already we'd get much more information and it would look like this:
   			<programlisting>
  -				???? TODO .... Need to load up sample app and capture this....
  +com.mysql.jdbc.Driver Information
  +Repository cache version:
  +com.mysql.jdbc.Driver(634bac).ClassLoader=
  +org.jboss.mx.loading.UnifiedClassLoader3 at 3fa2d5{ url=null ,addedOrder=2}
  +..org.jboss.mx.loading.UnifiedClassLoader3 at 3fa2d5{ url=null ,addedOrder=2}
  +....file:/Users/sgriffith/jboss-4.2.0.CR1/server/default/lib/.DS_Store
  +....file:/Users/sgriffith/jboss-4.2.0.CR1/server/default/lib/activation.jar
  +....file:/Users/sgriffith/jboss-4.2.0.CR1/server/default/lib/antlr.jar
  +....file:/Users/sgriffith/jboss-4.2.0.CR1/server/default/lib/autonumber-plugin.jar
  +....file:/Users/sgriffith/jboss-4.2.0.CR1/server/default/lib/bcel.jar
  +....file:/Users/sgriffith/jboss-4.2.0.CR1/server/default/lib/bindingservice-plugin.jar
  +....file:/Users/sgriffith/jboss-4.2.0.CR1/server/default/lib/bsf.jar
  +....file:/Users/sgriffith/jboss-4.2.0.CR1/server/default/lib/bsh-deployer.jar
  +....file:/Users/sgriffith/jboss-4.2.0.CR1/server/default/lib/bsh.jar
  +....file:/Users/sgriffith/jboss-4.2.0.CR1/server/default/lib/cglib.jar
  +....file:/Users/sgriffith/jboss-4.2.0.CR1/server/default/lib/commons-codec.jar
  +....file:/Users/sgriffith/jboss-4.2.0.CR1/server/default/lib/commons-collections.jar
  +....file:/Users/sgriffith/jboss-4.2.0.CR1/server/default/lib/commons-httpclient.jar
  +....file:/Users/sgriffith/jboss-4.2.0.CR1/server/default/lib/commons-logging.jar
  +....file:/Users/sgriffith/jboss-4.2.0.CR1/server/default/lib/dom4j.jar
  +....file:/Users/sgriffith/jboss-4.2.0.CR1/server/default/lib/hibernate3.jar
  +....file:/Users/sgriffith/jboss-4.2.0.CR1/server/default/lib/hsqldb-plugin.jar
  +....file:/Users/sgriffith/jboss-4.2.0.CR1/server/default/lib/hsqldb.jar
  +....file:/Users/sgriffith/jboss-4.2.0.CR1/server/default/lib/javassist.jar
  +....file:/Users/sgriffith/jboss-4.2.0.CR1/server/default/lib/javax.el.jar
  +....file:/Users/sgriffith/jboss-4.2.0.CR1/server/default/lib/javax.servlet.jar
  +....file:/Users/sgriffith/jboss-4.2.0.CR1/server/default/lib/javax.servlet.jsp.jar
  +....file:/Users/sgriffith/jboss-4.2.0.CR1/server/default/lib/jaxen.jar
  +....file:/Users/sgriffith/jboss-4.2.0.CR1/server/default/lib/jboss-backport-concurrent.jar
  +....file:/Users/sgriffith/jboss-4.2.0.CR1/server/default/lib/jboss-common-jdbc-wrapper.jar
  +....file:/Users/sgriffith/jboss-4.2.0.CR1/server/default/lib/jboss-hibernate.jar
  +....file:/Users/sgriffith/jboss-4.2.0.CR1/server/default/lib/jboss-j2ee.jar
  +....file:/Users/sgriffith/jboss-4.2.0.CR1/server/default/lib/jboss-jaxrpc.jar
  +....file:/Users/sgriffith/jboss-4.2.0.CR1/server/default/lib/jboss-jca.jar
  +....file:/Users/sgriffith/jboss-4.2.0.CR1/server/default/lib/jboss-jsr77.jar
  +....file:/Users/sgriffith/jboss-4.2.0.CR1/server/default/lib/jboss-jsr88.jar
  +....file:/Users/sgriffith/jboss-4.2.0.CR1/server/default/lib/jboss-management.jar
  +....file:/Users/sgriffith/jboss-4.2.0.CR1/server/default/lib/jboss-monitoring.jar
  +....file:/Users/sgriffith/jboss-4.2.0.CR1/server/default/lib/jboss-remoting-int.jar
  +....file:/Users/sgriffith/jboss-4.2.0.CR1/server/default/lib/jboss-remoting.jar
  +....file:/Users/sgriffith/jboss-4.2.0.CR1/server/default/lib/jboss-saaj.jar
  +....file:/Users/sgriffith/jboss-4.2.0.CR1/server/default/lib/jboss-serialization.jar
  +....file:/Users/sgriffith/jboss-4.2.0.CR1/server/default/lib/jboss-srp.jar
  +....file:/Users/sgriffith/jboss-4.2.0.CR1/server/default/lib/jboss-transaction.jar
  +....file:/Users/sgriffith/jboss-4.2.0.CR1/server/default/lib/jboss.jar
  +....file:/Users/sgriffith/jboss-4.2.0.CR1/server/default/lib/jbossjta-integration.jar
  +....file:/Users/sgriffith/jboss-4.2.0.CR1/server/default/lib/jbossjta.jar
  +....file:/Users/sgriffith/jboss-4.2.0.CR1/server/default/lib/jbossmq.jar
  +....file:/Users/sgriffith/jboss-4.2.0.CR1/server/default/lib/jbossretro-rt.jar
  +....file:/Users/sgriffith/jboss-4.2.0.CR1/server/default/lib/jbosssx.jar
  +....file:/Users/sgriffith/jboss-4.2.0.CR1/server/default/lib/jbossts-common.jar
  +....file:/Users/sgriffith/jboss-4.2.0.CR1/server/default/lib/jmx-adaptor-plugin.jar
  +....file:/Users/sgriffith/jboss-4.2.0.CR1/server/default/lib/jnpserver.jar
  +....file:/Users/sgriffith/jboss-4.2.0.CR1/server/default/lib/joesnmp.jar
  +....file:/Users/sgriffith/jboss-4.2.0.CR1/server/default/lib/jpl-pattern.jar
  +....file:/Users/sgriffith/jboss-4.2.0.CR1/server/default/lib/jpl-util.jar
  +....file:/Users/sgriffith/jboss-4.2.0.CR1/server/default/lib/log4j-snmp-appender.jar
  +....file:/Users/sgriffith/jboss-4.2.0.CR1/server/default/lib/log4j.jar
  +....file:/Users/sgriffith/jboss-4.2.0.CR1/server/default/lib/mail-plugin.jar
  +....file:/Users/sgriffith/jboss-4.2.0.CR1/server/default/lib/mail.jar
  +....file:/Users/sgriffith/jboss-4.2.0.CR1/server/default/lib/mysql-connector-java-5.0.4-bin.jar
  +....file:/Users/sgriffith/jboss-4.2.0.CR1/server/default/lib/properties-plugin.jar
  +....file:/Users/sgriffith/jboss-4.2.0.CR1/server/default/lib/scheduler-plugin-example.jar
  +....file:/Users/sgriffith/jboss-4.2.0.CR1/server/default/lib/scheduler-plugin.jar
  +....file:/Users/sgriffith/jboss-4.2.0.CR1/server/default/lib/wsdl4j.jar
  +....file:/Users/sgriffith/jboss-4.2.0.CR1/server/default/lib/xmlentitymgr.jar
  +..org.jboss.system.server.NoAnnotationURLClassLoader at 7471e0
  +..sun.misc.Launcher$AppClassLoader at e39a3e
  +....file:/Users/sgriffith/jboss-4.2.0.CR1/bin/run.jar
  +....file:/lib/tools.jar
  +....file:/System/Library/Frameworks/JavaVM.framework/
  +Versions/1.5.0/Classes/.compatibility/14compatibility.jar
  +..sun.misc.Launcher$ExtClassLoader at 92e78c
  +....file:/Library/Java/Extensions/.DS_Store
  +....file:/Library/Java/Extensions/junit-4.1.jar
  +....file:/usr/local/lib/libsvnjavahl-1.0.0.0.dylib
  +....file:/Library/Java/Extensions/OpenBaseJDBC.jar
  +....file:/System/Library/Java/Extensions/CoreAudio.jar
  +....file:/System/Library/Java/Extensions/dns_sd.jar
  +....file:/System/Library/Java/Extensions/j3daudio.jar
  +....file:/System/Library/Java/Extensions/j3dcore.jar
  +....file:/System/Library/Java/Extensions/j3dutils.jar
  +....file:/System/Library/Java/Extensions/jai_codec.jar
  +....file:/System/Library/Java/Extensions/jai_core.jar
  +....file:/System/Library/Java/Extensions/libJ3D.jnilib
  +....file:/System/Library/Java/Extensions/libJ3DAudio.jnilib
  +....file:/System/Library/Java/Extensions/libJ3DUtils.jnilib
  +....file:/System/Library/Java/Extensions/libmlib_jai.jnilib
  +....file:/System/Library/Java/Extensions/mlibwrapper_jai.jar
  +....file:/System/Library/Java/Extensions/MRJToolkit.jar
  +....file:/System/Library/Java/Extensions/QTJava.zip
  +....file:/System/Library/Java/Extensions/QTJSupport.jar
  +....file:/System/Library/Java/Extensions/vecmath.jar
  +....file:/System/Library/Frameworks/JavaVM.framework/Versions/1.5.0/Home/lib/ext/
  +apple_provider.jar
  +....file:/System/Library/Frameworks/JavaVM.framework/Versions/1.5.0/Home/lib/ext/dnsns.jar
  +....file:/System/Library/Frameworks/JavaVM.framework/Versions/1.5.0/Home/lib/ext/localedata.jar
  +....file:/System/Library/Frameworks/JavaVM.framework/Versions/1.5.0/Home/lib/ext/
  +sunjce_provider.jar
  +....file:/System/Library/Frameworks/JavaVM.framework/Versions/1.5.0/Home/lib/ext/sunpkcs11.jar
  +++++CodeSource: (file:/Users/sgriffith/jboss-4.2.0.CR1/server/default/lib/
  +mysql-connector-java-5.0.4-bin.jar )
  +Implemented Interfaces:
  +++interface java.sql.Driver(e86394)
  +++++ClassLoader: null
  +++++Null CodeSource
  +
  +### Instance0 found in UCL: 
  +org.jboss.mx.loading.UnifiedClassLoader3 at 3fa2d5{ url=null ,addedOrder=2}
   			</programlisting>
   		</para>
   	</section>
  @@ -108,21 +217,18 @@
   		</para>
   		<para>
   			A MySQL datasource definition can be found in <literal>jboss-4.2.0.CR1/docs/examples/jca</literal>.  If you look in there you'll find a file called <literal>mysql-ds.xml</literal>. It looks like this:
  -			<programlisting>
  -			
  -				<!-- $Id: appendix-alternative_DBs.xml,v 1.3 2007/02/20 07:24:42 sgriffith Exp $ -->
  -				<!--  Datasource config for MySQL using 3.0.9 available from:
  -				http://www.mysql.com/downloads/api-jdbc-stable.html
  -				-->
   
  -				<datasources>
  +![CDATA[
  +<datasources>
   				  <local-tx-datasource>
   				    <jndi-name>MySqlDS</jndi-name>
   				    <connection-url>jdbc:mysql://mysql-hostname:3306/jbossdb</connection-url>
   				    <driver-class>com.mysql.jdbc.Driver</driver-class>
   				    <user-name>x</user-name>
   				    <password>y</password>
  -				    <exception-sorter-class-name>org.jboss.resource.adapter.jdbc.vendor.MySQLExceptionSorter</exception-sorter-class-name>
  +    <exception-sorter-class-name>
  +			org.jboss.resource.adapter.jdbc.vendor.MySQLExceptionSorter
  +		</exception-sorter-class-name>
   				    <!-- should only be used on drivers after 3.22.1 with "ping" support
   				    <valid-connection-checker-class-name>org.jboss.resource.adapter.jdbc.vendor.MySQLValidConnectionChecker</valid-connection-checker-class-name>
   				    -->
  @@ -138,26 +244,24 @@
   				       <type-mapping>mySQL</type-mapping>
   				    </metadata>
   				  </local-tx-datasource>
  -				</datasources>
  -			</programlisting>
  +</datasources>
  +]]
  +
   		</para>
   		<para>
   			We need to copy that file to the <literal>deploy</literal> directory for our server. (In our case "default"). Once we do that we need to change the <literal>connection-url</literal> to <literal>jdbc:mysql://localhost:3306/jboss</literal>. For the username put <literal>sam</literal> and for the password put <literal>password</literal>.
  -			<programlisting>
  -	
  -				<!-- $Id: appendix-alternative_DBs.xml,v 1.3 2007/02/20 07:24:42 sgriffith Exp $ -->
  -				<!--  Datasource config for MySQL using 3.0.9 available from:
  -				http://www.mysql.com/downloads/api-jdbc-stable.html
  -				-->
   
  -				<datasources>
  +![CDATA[
  +<datasources>
   				  <local-tx-datasource>
   				    <jndi-name>MySqlDS</jndi-name>
   				    <connection-url>jdbc:mysql://localhost:3306/jboss</connection-url>
   				    <driver-class>com.mysql.jdbc.Driver</driver-class>
   				    <user-name>sam</user-name>
   				    <password>password</password>
  -				    <exception-sorter-class-name>org.jboss.resource.adapter.jdbc.vendor.MySQLExceptionSorter</exception-sorter-class-name>
  +    <exception-sorter-class-name>
  +			org.jboss.resource.adapter.jdbc.vendor.MySQLExceptionSorter
  +		</exception-sorter-class-name>
   				    <!-- should only be used on drivers after 3.22.1 with "ping" support
   				    <valid-connection-checker-class-name>org.jboss.resource.adapter.jdbc.vendor.MySQLValidConnectionChecker</valid-connection-checker-class-name>
   				    -->
  @@ -173,16 +277,18 @@
   				       <type-mapping>mySQL</type-mapping>
   				    </metadata>
   				  </local-tx-datasource>
  -				</datasources>
  -			</programlisting>
  +</datasources>
  +]]
  +
   		</para>
   			<para>When you save the file you should see the datasource be bound by JBoss in the console output like below. Each time you save the file the datasource will be bound and unbound, so you may see multiple entries like below.
   			<programlisting>
  -				15:57:26,891 INFO  [WrapperDataSourceService] Bound ConnectionManager 'jboss.jca:service=DataSourceBinding,name=MySqlDS' to JNDI name 'java:MySqlDS'
  +15:57:26,891 INFO  [WrapperDataSourceService] Bound ConnectionManager 
  +'jboss.jca:service=DataSourceBinding,name=MySqlDS' to JNDI name 'java:MySqlDS'
   			</programlisting>
   		</para>
   		<para>
  -			This is how you configure a datasource for use in JBoss application server. Not we did not take the HyperSonic datasource away as it is used by many JBoss services. If you are going to deploy to production, you will want to configure each service to use a specific datasource. Such as configuring JMS to use MySQL instead of the <literal>defaultDS</literal>.
  +			This is how you configure a datasource for use in JBoss application server. Note that we did not take the HyperSonic datasource away as it is used by many JBoss services. If you are going to deploy to production, you will want to configure each service to use a specific datasource. Such as configuring JMS to use MySQL instead of the <literal>defaultDS</literal>. We'll see how to do that in another section.
   		</para>
   	</section>
   	
  @@ -190,21 +296,198 @@
   		<title>Linking a Datasource to your Application</title>
   		<para>
   			To configure your application to use MySQL, look for a *jbosscmp-jdbc.xml deployment descriptor. It is located in your servers <literal>conf</literal> directory. 
  -			<programlisting>
  -				<jbosscmp-jdbc>
  +
  +![CDATA[
  +<jbosscmp-jdbc>
   				   <defaults>
   				      <datasource>java:/MySqlDS</datasource>
   				      <!-- optional since 4.0 <datasource-mapping>Hypersonic SQL</datasource-mapping> -->
   							<datasource-mapping>mySQL</datasource-mapping>
   				   </defaults>
  -				</jbosscmp-jdbc>
  +</jbosscmp-jdbc>
  +]]
  +
  +			Although the <literal>datasource-mapping</literal> is optional, it is nice to know the type of the datasource, as this ties directly back to the type-mapping of the data-source.
  +		</para>
  +		<para>For a full set of default datasource mappings look in <literal>jboss-4.2.0.CR1/server/default/conf/standardjbosscmp-jdbc.xml</literal>. In that file you can look for the <literal>mySQL</literal> type mapping.
  +		</para>
  +		<para>
  +			If you need to change any of the type mappings for mySQL you can put your own custom <literal>jbosscmp-jdbc.xml</literal> file right in your META-INF directory of your EJB JAR with the <literal>ejb-jar.xml</literal> and <literal>jboss.xml</literal> deployment descriptor files. Then you need to add a <literal>-Doptonal.dd=mysql</literal> to your <literal>ant</literal> build commands. When you've done that, your application will now be talking to MySQL. Now when you look at the tables for your MySQL database, you should see some tables that your application deployment created. You can see the tables in a MySQL database by typing <literal>show tables;</literal>.
  +		</para>
  +	</section>
  +	
  +	<section>
  +		<title>Changing the DefaultDS for all of JBoss</title>
  +		<para>
  +			To make our <literal>jboss</literal> database now support the app server we need to create the system administrator user <literal>sa</literal> user on our system. We can do that with this set of MySQL commands which are like the ones we did before but for the <literal>sa</literal> user:
  +			<programlisting>
  +sgriffith$ mysql -u root
  +Welcome to the MySQL monitor.  Commands end with ; or \g.
  +Your MySQL connection id is 27 to server version: 5.0.27-standard
  +
  +Type 'help;' or '\h' for help. Type '\c' to clear the buffer.
  +
  +mysql> grant all privileges on jboss.* to sa at localhost identified by '';
  +Query OK, 0 rows affected (0.83 sec)
   			</programlisting>
  -			Although the <literal>datasource-mapping</literal> is optional, it is nice to know the type of the datasource, as this ties directly back to the type-mapping of the datasource.
   		</para>
  -		<para>For a full set of defautl datasource mappings look in <literal>jboss-4.2.0.CR1/server/default/conf/standardjbosscmp-jdbc.xml</literal>. In that file you can look for the <literal>mySQL</literal> type mapping.
  +		<para>
  +			Now we need to change the <literal>.../server/default/deploy/mysql-ds.xml</literal> file to look like include the following datasource definition:
  +
  +![CDATA[
  +<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>root</user-name>
  +    <password></password>
  +    <exception-sorter-class-name>org.jboss.resource.adapter.jdbc.vendor.MySQLExceptionSorter</exception-sorter-class-name>
  +    <!-- should only be used on drivers after 3.22.1 with "ping" support <valid-connection-checker-class-name>org.jboss.resource.adapter.jdbc.vendor.MySQLValidConnectionChecker</valid-connection-checker-class-name>
  +    -->
  +    <!-- sql to call when connection is created
  +    <new-connection-sql>some arbitrary sql</new-connection-sql>
  +    -->
  +    <!-- sql to call on an existing pooled connection when it is obtained from pool - MySQLValidConnectionChecker is preferred for newer drivers
  +    <check-valid-connection-sql>some arbitrary sql</check-valid-connection-sql>
  +    -->
  +		<!-- Use the security domain defined in conf/login-config.xml -->
  +		<!-- Should really make a security domain for MySQL -->
  +		<security-domain>MySqlDbRealm</security-domain>
  +		<!-- corresponding type-mapping in the standardjbosscmp-jdbc.xml (optional) -->
  +		<metadata>
  +		<type-mapping>mySQL</type-mapping>
  +		</metadata>
  +  </local-tx-datasource>
  +</datasources>
  +]]
  +
   		</para>
   		<para>
  -			If you need to change any of the type mappings for mySQL you can put your own custom <literal>jbosscmp-jdbc.xml</literal> file right in your META-INF directory of your EJB JAR with the <literal>ejb-jar.xml</literal> and <literal>jboss.xml</literal> deployment descriptor files. Then you need to add a <literal>-Doptonal.dd=mysql</literal> to your <literal>ant</literal> build commands. When you've done that, your application will now be talking to MySQL. Now when you look at the tables for your MySQL database, you should see some tables that your application deployment created. You can see the tables in a MySQL database by typeing <literal>show tables;</literal>.
  +			Now we need to go change the <literal>.../server/default/conf/standardjaws.xml</literal> file so that the following elements have the correct values.
  +			<programlisting>
  +<datasource>java:/DefaultDB</datasource>
  +<type-mapping>mySQL</type-mapping>
  +			</programlisting>
  +		</para>
  +		<para>
  +			Now we need to go change the <literal>.../server/default/conf/standardjbosscmp-jdbc.xml file so that the following elements have the correct values.</literal>
  +			
  +			<programlisting>
  +
  +<datasource>java:/DefaultDS</datasource>
  +<datasource-mapping>mySQL</datasource-mapping>
  +<fk-constraint>true</fk-constraint>
  +
  +			</programlisting>
  +
  +		</para>
  +<!--	This was recommended by some articles I read, but did not work so I took it out. Need to look into why?	
  +		<para>
  +			Add the following <literal>application-policy</literal> to login-config.xml.
  +			<programlisting>
  +				<application-policy name="MySqlDbRealm">
  +					<authentication>
  +						<login-module code = "org.jboss.resource.security.ConfiguredIdentityLoginModule" flag = "required" >
  +							<module-option name = "principal">root</module-option>
  +							<module-option name = "userName">root</module-option>
  +							<module-option name = "password"></module-option>
  +							<module-option name = "managedConnectionFactoryName">jboss.jca:service=LocalTxCM, name=DefaultDS</module-option>
  +						</login-module>
  +					</authentication>
  +				</application-policy>
  +			</programlisting>
  +		</para>
  +-->
  +		<para>
  +			Now we change and replace two files in <literal>.../server/default/deploy/jms</literal>. The first file we need to replace the file <literal>hsqldb-jdbc2-service.xml</literal> with <literal>.../docs/examples/jms/mysql-jdbc2-service.xml</literal>. In the mysql-jdbc2-service.xml file change the <literal>MySqlDS</literal> to <literal>DefaultDS</literal>. It's in the <literal>depends</literal> tag for the PersistenceManagers MBean. 
  +		</para>
  +
  +		<para>
  +		Now you've setup all you need to get the server to startup and use mySQL as the default data source.  Here is an example of the output you should see when you run the server with the settings above.
  +		<programlisting>
  +sgriffith$ run.sh
  +=========================================================================
  +
  +  JBoss Bootstrap Environment
  +
  +  JBOSS_HOME: /Users/sgriffith/jboss-4.2.0.CR1
  +
  +  JAVA: java
  +
  +  JAVA_OPTS: -Dprogram.name=run.sh -Xms128m -Xmx512m -Dsun.rmi.dgc.client.gcInterval=3600000 -Dsun.rmi.dgc.server.gcInterval=3600000
  +
  +  CLASSPATH: /Users/sgriffith/jboss-4.2.0.CR1/bin/run.jar:/lib/tools.jar
  +
  +=========================================================================
  +
  +15:55:02,995 INFO  [Server] Starting JBoss (MX MicroKernel)...
  +15:55:02,999 INFO  [Server] Release ID: JBoss [Trinity] 4.2.0.CR1 (build: SVNTag=JBoss_4_2_0_CR1 date=200701180935)
  +15:55:03,062 INFO  [Server] Home Dir: /Users/sgriffith/jboss-4.2.0.CR1
  +15:55:03,062 INFO  [Server] Home URL: file:/Users/sgriffith/jboss-4.2.0.CR1/
  +15:55:03,065 INFO  [Server] Patch URL: null
  +15:55:03,066 INFO  [Server] Server Name: default
  +15:55:03,066 INFO  [Server] Server Home Dir: /Users/sgriffith/jboss-4.2.0.CR1/server/default
  +15:55:03,067 INFO  [Server] Server Home URL: file:/Users/sgriffith/jboss-4.2.0.CR1/server/default/
  +15:55:03,067 INFO  [Server] Server Log Dir: /Users/sgriffith/jboss-4.2.0.CR1/server/default/log
  +15:55:03,068 INFO  [Server] Server Temp Dir: /Users/sgriffith/jboss-4.2.0.CR1/server/default/tmp
  +15:55:03,069 INFO  [Server] Root Deployment Filename: jboss-service.xml
  +15:55:04,125 INFO  [ServerInfo] Java version: 1.5.0_06,Apple Computer, Inc.
  +15:55:04,126 INFO  [ServerInfo] Java VM: Java HotSpot(TM) Client VM 1.5.0_06-64,"Apple Computer, Inc."
  +15:55:04,126 INFO  [ServerInfo] OS-System: Mac OS X 10.4.7,ppc
  +15:55:05,479 INFO  [Server] Core system initialized
  +15:55:10,464 INFO  [WebService] Using RMI server codebase: http://Sam-Griffiths.local:8083/
  +15:55:10,593 INFO  [Log4jService$URLWatchTimerTask] Configuring from URL: resource:jboss-log4j.xml
  +15:55:12,404 INFO  [TransactionManagerService] JBossTS Transaction Service (JTA version) - JBoss Inc.
  +15:55:12,404 INFO  [TransactionManagerService] Setting up property manager MBean and JMX layer
  +15:55:12,640 INFO  [TransactionManagerService] Starting recovery manager
  +15:55:13,196 INFO  [TransactionManagerService] Recovery manager started
  +15:55:13,197 INFO  [TransactionManagerService] Binding TransactionManager JNDI Reference
  +15:55:21,607 INFO  [ServiceEndpointManager] jbossws-1.2.0.CR2 (date=200701061621)
  +15:55:24,157 INFO  [Embedded] Catalina naming disabled
  +15:55:24,275 INFO  [ClusterRuleSetFactory] Unable to find a cluster rule set in the classpath. Will load the default rule set.
  +15:55:24,278 INFO  [ClusterRuleSetFactory] Unable to find a cluster rule set in the classpath. Will load the default rule set.
  +15:55:24,781 INFO  [AprLifecycleListener] The Apache Tomcat Native library which allows optimal performance in production environments was not found on the java.library.path: .:/Library/Java/Extensions:/System/Library/Java/Extensions:/usr/lib/java
  +15:55:25,099 INFO  [Http11Protocol] Initializing Coyote HTTP/1.1 on http-8080
  +15:55:25,101 INFO  [AjpProtocol] Initializing Coyote AJP/1.3 on ajp-8009
  +15:55:25,102 INFO  [Catalina] Initialization processed in 820 ms
  +15:55:25,102 INFO  [StandardService] Starting service jboss.web
  +15:55:25,109 INFO  [StandardEngine] Starting Servlet Engine: JBossWeb/2.0.0.snapshot
  +15:55:25,255 INFO  [StandardHost] XML validation disabled
  +15:55:25,287 INFO  [Catalina] Server startup in 185 ms
  +15:55:25,665 INFO  [TomcatDeployer] deploy, ctxPath=/invoker, warUrl=.../deploy/http-invoker.sar/invoker.war/
  +15:55:27,358 INFO  [WebappLoader] Dual registration of jndi stream handler: factory already defined
  +15:55:28,189 INFO  [TomcatDeployer] deploy, ctxPath=/, warUrl=.../deploy/jboss-web.sar/ROOT.war/
  +15:55:28,498 INFO  [TomcatDeployer] deploy, ctxPath=/jbossws, warUrl=.../tmp/deploy/tmp3387jbossws-context-exp.war/
  +15:55:28,842 INFO  [TomcatDeployer] deploy, ctxPath=/jbossmq-httpil, warUrl=.../deploy/jms/jbossmq-httpil.sar/jbossmq-httpil.war/
  +15:55:29,282 WARN  [DeployerInterceptorJSE] Cannot load servlet class: org.jboss.web.tomcat.tc5.StatusServlet
  +15:55:31,180 INFO  [TomcatDeployer] deploy, ctxPath=/web-console, warUrl=.../deploy/management/console-mgr.sar/web-console.war/
  +15:55:32,379 INFO  [MailService] Mail Service bound to java:/Mail
  +15:55:32,931 INFO  [RARDeployment] Required license terms exist, view META-INF/ra.xml in .../deploy/jboss-ha-local-jdbc.rar
  +15:55:33,096 INFO  [RARDeployment] Required license terms exist, view META-INF/ra.xml in .../deploy/jboss-ha-xa-jdbc.rar
  +15:55:33,161 INFO  [RARDeployment] Required license terms exist, view META-INF/ra.xml in .../deploy/jboss-local-jdbc.rar
  +15:55:33,316 INFO  [RARDeployment] Required license terms exist, view META-INF/ra.xml in .../deploy/jboss-xa-jdbc.rar
  +15:55:33,490 INFO  [RARDeployment] Required license terms exist, view META-INF/ra.xml in .../deploy/jms/jms-ra.rar
  +15:55:33,547 INFO  [RARDeployment] Required license terms exist, view META-INF/ra.xml in .../deploy/mail-ra.rar
  +15:55:34,322 INFO  [ConnectionFactoryBindingService] Bound ConnectionManager 'jboss.jca:service=ConnectionFactoryBinding,name=JmsXA' to JNDI name 'java:JmsXA'
  +15:55:34,990 INFO  [WrapperDataSourceService] Bound ConnectionManager 'jboss.jca:service=DataSourceBinding,name=DefaultDS' to JNDI name 'java:DefaultDS'
  +15:55:38,116 INFO  [A] Bound to JNDI name: queue/A
  +15:55:38,123 INFO  [B] Bound to JNDI name: queue/B
  +15:55:38,129 INFO  [C] Bound to JNDI name: queue/C
  +15:55:38,141 INFO  [D] Bound to JNDI name: queue/D
  +15:55:38,153 INFO  [ex] Bound to JNDI name: queue/ex
  +15:55:38,283 INFO  [testTopic] Bound to JNDI name: topic/testTopic
  +15:55:38,291 INFO  [securedTopic] Bound to JNDI name: topic/securedTopic
  +15:55:38,298 INFO  [testDurableTopic] Bound to JNDI name: topic/testDurableTopic
  +15:55:38,307 INFO  [testQueue] Bound to JNDI name: queue/testQueue
  +15:55:38,488 INFO  [UILServerILService] JBossMQ UIL service available at : /0.0.0.0:8093
  +15:55:38,562 INFO  [DLQ] Bound to JNDI name: queue/DLQ
  +15:55:38,743 INFO  [TomcatDeployer] deploy, ctxPath=/jmx-console, warUrl=.../deploy/jmx-console.war/
  +15:55:39,245 INFO  [Http11Protocol] Starting Coyote HTTP/1.1 on http-8080
  +15:55:39,376 INFO  [AjpProtocol] Starting Coyote AJP/1.3 on ajp-8009
  +15:55:39,480 INFO  [Server] JBoss (MX MicroKernel) [4.2.0.CR1 (build: SVNTag=JBoss_4_2_0_CR1 date=200701180935)] Started in 36s:405ms
  +		</programlisting>
  +		Now we have JBoss using MySQL as it's default datasource and starting up with no errors.
   		</para>
   	</section>
   	
  
  
  



More information about the jboss-cvs-commits mailing list