Skip to main content

GlassFish and MySQL bundle

Posted by arungupta on August 11, 2008 at 10:50 AM PDT



GlassFish and href="http://mysql.org">MySQL bundle was href="http://blogs.sun.com/theaquarium/entry/new_netbeans_glassfish_and_mysql">released
a while ago and I finally got a chance to try it out. Here
are simple instructions to get you started:

  1. Download GlassFish and MySQL co-bundle zip from href="http://java.sun.com/javaee/downloads/index.jsp">here.
  2. Install the bundle ( href="http://docs.sun.com/app/docs/doc/820-3797">detailed
    docs)
    1. Create a temp directory and unzip the contents of bundle
      there. The contents are:


      style="text-align: left; background-color: rgb(204, 204, 255); width: 100%;"
      cellpadding="2" cellspacing="2">

      -rw-r--r--   1 arungupta 
      arungupta   239703 Mar 19 02:57 3RD-PARTY-LICENSE.txt
      style="font-family: monospace;">
      -rw-r--r--  
      1 arungupta 
      arungupta      709 Mar 19
      02:57 LICENSE.txt


      -rw-r--r--  
      1 arungupta  arungupta  1560195 Mar 19 02:57
      appserv.class


      drwxr-xr-x 
      18 arungupta 
      arungupta      612 Mar 19
      02:57 package


      -rwxr-xr-x  
      1 arungupta  arungupta    
      5577 Mar 19 02:57 setup
    2. Invoke "setup" script that brings up the installer. Take
      the default value, click "Next", accept the license, click "Next" and
      specify the install directory location as shown below:



      src="http://blogs.sun.com/arungupta/resource/images/gam-install-directory.png">
    3. If the directory is not created, then click on "Create
      Directory" button. Enter the administrator password and click on "Don't
      Prompt for Admin User Name and Password" as shown below:



      src="http://blogs.sun.com/arungupta/resource/images/gam-install-admin-configuration.png">



      These are not the typical values used in a production system.
    4. Take the default values for MySQL as shown below:



      src="http://blogs.sun.com/arungupta/resource/images/gam-install-mysql-config.png">



      and click on "Next".
    5. Once the final options are shown, click on "Install Now"
      button to start the install process:



      src="http://blogs.sun.com/arungupta/resource/images/gam-install-now.png">



      and see the install in progress as shown below:



      src="http://blogs.sun.com/arungupta/resource/images/gam-installing.png">
    6. It's recommended to Regiser the recently installed copy
      of Application Server, the benefits are highlighted href="http://blogs.sun.com/arungupta/entry/3_steps_for_successful_glassfish">here.
      After registration, click on "Next" and then on "Finish" to complete
      the installation process.
    7. The directory structure after completed installation
      looks like:


      style="text-align: left; background-color: rgb(204, 204, 255); width: 100%;"
      cellpadding="2" cellspacing="2">
      drwxr-xr-x 
      22 arungupta 
      arungupta      
      748 Aug 10 16:23 .


      drwxr-xr-x  
      5 arungupta 
      arungupta      
      170 Aug 10 16:22 ..


      -rw-r--r--  
      1 arungupta  arungupta    239703
      Aug 10 16:23 3RD-PARTY-LICENSE.txt
      style="font-family: monospace;">
      -rw-r--r--  
      1 arungupta 
      arungupta      4149 Aug 10
      16:23 COPYRIGHT


      -rw-r--r--  
      1 arungupta 
      arungupta      2126 Aug 10
      16:23 Install_Application_Server_9PE_200808101622.log
      style="font-family: monospace;">
      -rw-r--r--  
      1 arungupta 
      arungupta      
      709 Aug 10 16:23 LICENSE.txt
      style="font-family: monospace;">
      -rw-r--r--  
      1 arungupta  arungupta  20025392 Aug 10 16:23
      License_Notice_Translated.pdf
      style="font-family: monospace;">
      -rw-r--r--  
      1 arungupta 
      arungupta      
      186 Aug 10 16:23 Sun_Java_System_Application_Server_install.A08100423
      style="font-family: monospace;">
      -rw-r--r--  
      1 arungupta  arungupta    191191
      Aug 10 16:23 Sun_Java_System_Application_Server_install.B08100423
      style="font-family: monospace;">
      -rw-r--r--  
      1 arungupta  arungupta   1569911 Aug 10
      16:23 appserv_uninstall.class
      style="font-family: monospace;">
      drwxr-xr-x 
      17 arungupta 
      arungupta      
      578 Aug 10 16:23 bin


      drwxr-xr-x  
      4 arungupta 
      arungupta      
      136 Aug 10 16:23 config
      style="font-family: monospace;">
      drwxr-xr-x  
      9 arungupta 
      arungupta      
      306 Aug 10 16:23 docs


      drwxr-xr-x  
      3 arungupta 
      arungupta      
      102 Aug 10 16:23 domains
      style="font-family: monospace;">
      drwxr-xr-x 
      11 arungupta 
      arungupta      
      374 Aug 10 16:23 imq


      drwxr-xr-x  
      9 arungupta 
      arungupta      
      306 Aug 10 16:23 javadb
      style="font-family: monospace;">
      drwxr-xr-x 
      14 arungupta 
      arungupta      
      476 Aug 10 16:23 jbi


      drwxr-xr-x 
      65 arungupta 
      arungupta      2210 Aug 10
      16:23 lib


      drwxr-xr-x 
      19 arungupta 
      arungupta      
      646 Aug 10 16:23 mysql
      style="font-family: monospace;">
      drwxr-xr-x  
      6 arungupta 
      arungupta      
      204 Aug 10 16:23 samples
      style="font-family: monospace;">
      -rwxr-xr-x  
      1 arungupta 
      arungupta      4717 Aug 10
      16:23 uninstall


      drwxr-xr-x 
      14 arungupta 
      arungupta      
      476 Aug 10 16:23 updatecenter
  3. Configure MySQL
    1. In "mysql" directory, change the permissions of
      "configure" and "scripts/mysql_install_db" script by invoking


      style="text-align: left; background-color: rgb(204, 204, 255); width: 100%;"
      cellpadding="2" cellspacing="2">
      chmod +x configure scripts/mysql_install_db
    2. Then invoke "configure" script to see the output as:


      style="text-align: left; background-color: rgb(204, 204, 255); width: 100%;"
      cellpadding="2" cellspacing="2">
      ~/tools/glassfish/v2/SUNWappserver/mysql > style="font-weight: bold;">./configure

      NOTE: This is a MySQL binary distribution. It's ready to run, you don't

      need to configure it!



      To help you a bit, I am now going to create the needed MySQL databases

      and start the MySQL server for you.  If you run into any
      trouble, please

      consult the MySQL manual, that you can find in the Docs directory.



      Installing MySQL system tables...

      080810 16:39:16 [Warning] Setting lower_case_table_names=2 because file
      system for
      /Users/arungupta/tools/glassfish/v2/SUNWappserver/mysql/data/ is case
      insensitive

      OK

      Filling help tables...

      080810 16:39:16 [Warning] Setting lower_case_table_names=2 because file
      system for
      /Users/arungupta/tools/glassfish/v2/SUNWappserver/mysql/data/ is case
      insensitive

      OK



      To start mysqld at boot time you have to copy

      support-files/mysql.server to the right place for your system



      PLEASE REMEMBER TO SET A PASSWORD FOR THE MySQL root USER !

      To do so, start the server, then issue the following commands:

      ./bin/mysqladmin -u root password 'new-password'

      ./bin/mysqladmin -u root -h Macintosh-187.local password 'new-password'



      Alternatively you can run:

      ./bin/mysql_secure_installation



      which will also give you the option of removing the test

      databases and anonymous user created by default.  This is

      strongly recommended for production servers.



      See the manual for more instructions.



      You can start the MySQL daemon with:

      cd . ; ./bin/mysqld_safe &



      You can test the MySQL daemon with mysql-test-run.pl

      cd mysql-test ; perl mysql-test-run.pl



      Please report any problems with the ./bin/mysqlbug script!



      The latest information about MySQL is available on the web at

      http://www.mysql.com

      Support MySQL by buying support/licenses at http://shop.mysql.com

      Starting the mysqld server.  You can test that it is up and
      running

      with the command:

      ./bin/mysqladmin version

      ~/tools/glassfish/v2/SUNWappserver/mysql >chown:
      /Users/arungupta/tools/glassfish/v2/SUNWappserver/mysql/data/Macintosh-187.local.err:
      Operation not permitted

      Starting mysqld daemon with databases from
      /Users/arungupta/tools/glassfish/v2/SUNWappserver/mysql/data



      This configures and starts MySQL process as well. As mentioned in the
      command output, MySQL server running can be cofirmed by giving the
      command "./bin/mysqladmin version". It shows the following output on my
      machine:


      style="text-align: left; background-color: rgb(204, 204, 255); width: 100%;"
      cellpadding="2" cellspacing="2">
      ~/tools/glassfish/v2/SUNWappserver/mysql
      >./bin/mysqladmin version

      ./bin/mysqladmin  Ver 8.41 Distrib 5.0.51a, for
      apple-darwin8.6.0 on powerpc

      Copyright (C) 2000-2006 MySQL AB

      This software comes with ABSOLUTELY NO WARRANTY. This is free software,

      and you are welcome to modify and redistribute it under the GPL license



      Server
      version         
      5.0.51a


      Protocol
      version       
      10


      Connection             
      Localhost via UNIX socket
      style="font-family: monospace;">
      UNIX
      socket            
      /tmp/mysql.sock


      Uptime:                
      2 min 22 sec




      Threads: 1  Questions: 1  Slow queries: 0 
      Opens: 12  Flush tables: 1  Open tables: 6 
      Queries per second avg: 0.007



      MySQL daemon can always be restarted as:


      style="text-align: left; background-color: rgb(204, 204, 255); width: 100%;"
      cellpadding="2" cellspacing="2">
      ~/tools/glassfish/v2/SUNWappserver/mysql > style="font-weight: bold;">./bin/mysqld_safe

      Starting mysqld daemon with databases from
      /Users/arungupta/tools/glassfish/v2/SUNWappserver/mysql/data
  4. Register GlassFish and MySQL with NetBeans
    1. Installing GlassFish is straight-forward - Just go to
      NetBeans IDE, "Services" tab, "Services" tree, right-click and select
      "Add Server..." as shown:



      src="http://blogs.sun.com/arungupta/resource/images/gam-nb-gf-register.png">



      and then follow the directions.
    2. To configure MySQL, right-click on "Databases" tree and
      select "Register MySQL Server ..." as shown ( href="http://www.netbeans.org/kb/61/ide/mysql.html">official
      docs):



      src="http://blogs.sun.com/arungupta/resource/images/gam-nb-register-mysql.png">
    3. Take the default values in "Basic Properties" and specify
      the properties in "Admin Properties" tab as:



      src="http://blogs.sun.com/arungupta/resource/images/gam-nb-mysql-configure.png">
    4. Starting MySQL server from the command gives "Permission
      Denied" access. So I started MySQL server from command-line as shown
      above and then could see all the databases as shown below:



      src="http://blogs.sun.com/arungupta/resource/images/gam-nb-mysql-expanded.png">



      Alternatively, you can also download href="http://download.netbeans.org/netbeans/6.1/mysql_bundle/">NetBeans
      6.1 with GlassFish and MySQL Bundle where both GlassFish and
      MySQL are pre-configured for you.

Now you can leverage this deadly combination of href="http://netbeans.org">NetBeans, href="http://glassfish.org">GlassFish and href="http://mysql.org">MySQL to create any
enterprise application.



There are many related blog entries on this topic as well:

  • href="http://blogs.sun.com/sathyan/entry/glassfish_bundle_with_mysql_community">GlassFish
    bundle with MySQL Community Server
  • href="http://blogs.sun.com/branajam/entry/new_netbeans_6_1_glassfish">New
    NetBeans 6.1, GlassFish, & MySQL Bundle
  • href="http://www.bytebot.net/blog/archives/2008/05/02/netbeans-61-with-glassfish-mysql-bundle">NetBeans
    6.1 with GlassFish, MySQL bundle
  • href="http://blogs.sun.com/alexismp/entry/sun_appserver_glassfish_mysql_bundle">Sun AppServer (GlassFish) / MySQL bundle now available



Technorati: href="http://technorati.com/tag/glassfish">glassfish
mysql href="http://technorati.com/tag/netbeans">netbeans

Related Topics >>

Comments

rubemazenha, good question. The GlassFish + MySQL bundle is a developer convenience bundle. MySQL Community Server is included, and for enterprise applications we recommend MySQL Enterprise Server. Arun, I've created a staroffice prezo for America's Sales Meeting that also details this in prezo format (and step-by-step cluster demo instructions). I'll post to the wiki and let you know.

Enterprise applications with both database and AS in the same machine? :)