Part 6: Glassfish V3 Pet Catalog sample DEMO in VM Template - SW Installation

OpenSolaris 200906 JeOS Prototype was designed as PURE CLI enviroment providing main building stone for creation of Virtual Appliances or VM Templates

In this example I will DEMOnstrate creation of Evaluation type Virtual Appliance / VM Template which will leveradge OpenSolaris 200906 JeOS prototype and just in Dec/09 released Glassfish v3, Java EE 6 and Netbeans 6.8 with simple Java EE 6 demo. This entry is part of Virtual Appliances & OVF workshop.

New Glassfish V3 introduce an unique network repository based modular structure, so we can more easily create really simple initial DEMO setup which user can extend by installation more samples right from Glassfish V3 repository or from Netbeans GUI.


Step 2: Add layered software

Step 2g: Install Java EE 6 Pet Catalog sample from NetBeans 6.8 IDE (Video)

This Pet Catalog app explains a web application that uses JSF 2.0, Java EE 6, GlassFish and MySQL.

1. Get on Java EE 6 Pet Catalog sample

Java EE 6 Pet Catalog sample:

Carol McDonald blog TechDays sample Java EE 6 Pet Catalog with GlassFish v3 preview and MySQL

Java EE 5 Pet Catalog sample:

Ed Ort's and Carol McDonald tech tip in GlassFish and MySQL, Part 2: Building a CRUD Web Application With Data Persistence

Backup is on ~/unbundled/PetSample in case then links will not be avaiable in future

osol@osol-jeos:~/unbundled$ find ./PetCatalogSample -name \*.html
  ./PetCatalogSample/JavaEE5/GlassFish and MySQL, Part 2: Building a CRUD Web Application With Data Persistence.html
  ./PetCatalogSample/JavaEE6/Java EE 6 Pet Catalog with GlassFish v3 preview and MySQL.html
  ./PetCatalogSample/datasrource/LAB-4923: Spring Framework and JPA.html

2. Install MySQL Connector / J

Sample use MySQL database, so we need to install latest MySQL Connector-J

Using MySQL With Java

MySQL Connector-J for MySqQL 5.1

osol@osol-jeos:~/unbundled/glassfishv3$ cd /tmp
osol@osol-jeos:/tmp$  wget http://dev.mysql.com/get/Downloads/Connector-J/mysql-connector-java-5.1.10.zip/from/http://mirror.csclub.uwaterloo.ca/mysql/
Length: 3,871,044 (3.7M) [application/zip]

osol@osol-jeos:/tmp$ unzip mysql-connector-java-5.1.10.zip

osol@osol-jeos:/tmp$ pfexec cp  ./mysql-connector-java-5.1.10/\*.jar  /usr/java/jre/lib/ext

osol@osol-jeos:/tmp$ pfexec chown root:bin /usr/java/jre/lib/ext/mysql-connector-java-5.1.10-bin.jar

osol@osol-jeos:/tmp$ rm -r ./mysql-connector-java-5.1.10
osol@osol-jeos:/tmp$ rm mysql-connector-java-5.1.10.zip

3. Start Glassfish and MySQL servers

osol@osol-jeos:~$ cd ~/unbundled/webstack16/
osol@osol-jeos:~/unbundled/webstack16$  ./bin/sun-mysql51 start
Starting mysql51                   OK

osol@osol-jeos:~$ cd ~/unbundled/glassfishv3/
osol@osol-jeos:~/unbundled/glassfishv3$ ./bin/asadmin start-domain
Waiting for DAS to start ......
Started domain: domain1
Domain location: /export/home/osol/unbundled/glassfishv3/glassfish/domains/domain1
Log file: /export/home/osol/unbundled/glassfishv3/glassfish/domains/domain1/logs/server.log
Admin port for the domain: 4848
Command start-domain executed successfully.

4. Allow use OSOL to login into MySQL from localhost with password

By default MySQL 5.1 in WebStack configuration we can login from localhost wihout password,
because in VM Ttemplate we use a IP address from DHCP, we need to allow also connections from LOCALHOST with password too.

osol@osol-jeos:~$ cd ~/unbundled/webstack16/
osol@osol-jeos:~/unbundled/webstack16$

osol@osol-jeos:~/unbundled/webstack16$ ./bin/mysql -u root -p
Enter password:

Type 'help;' or '\\h' for help. Type '\\c' to clear the current input statement.

mysql> grant all privileges on \*.\* to osol@localhost  identified by 'justone1';
Query OK, 0 rows affected (0.01 sec)

mysql> quit

osol@osol-jeos:~/unbundled/webstack16$ ./bin/mysql -u osol -p
Enter password:

mysql> quit
osol@osol-jeos:~/unbundled/webstack16$             

5. Install Netbeans 6.8 platform with Java EE 6 support

Unfortunately for Netbeans 6.8 remotes usage of Glassfish V3 / Java EE 6 you need a to donwload vreison withintegrtaed GlassfishV3,
local instance of same version is needed to be able to compile/build jar's which will be after deployed later

On Windows host you get 210MB download size, you don't need any MySQL files, JDBC driver is already part of IDE.

6. Load a Pet Catalog sample and follow up Videos

You need a actual PUBLIC IP address of JeOS instance fro remote deployment, in samples I use 129.157.18.49, I get it like this:

osol@osol-jeos:~/unbundled$ dladm show-ether
LINK            PTYPE    STATE    AUTO  SPEED-DUPLEX                    PAUSE
e1000g0         current  up       yes   1G-f                            bi

osol@osol-jeos:~/unbundled$ ifconfig e1000g0
e1000g0: flags=1004843<UP,BROADCAST,RUNNING,MULTICAST,DHCP,IPv4> mtu 1500 index 2
        inet 129.157.18.49 netmask fffffe00 broadcast 129.157.19.255

In Netbeans 6.8 IDE

  • Open pet catalog catalog project
  • Register MySQL Server
  • Create petcatalog MySQL databe
  • Open JDBC/petcatalog (created automatically)
  • Load SQL data to petcatalog database.

In Glassfish admin

  • Create a petcatalog MySQL connection pool (local connection using localhost)
  • Create a JDBC/petcatalog MySQL

In Netbeans IDE

  • Build, Deploy and Test petcatalog application

Videos of setup:

PetCatalog in NetBeans68 on Remote GFv3 MySQL51 Res: 1024x768 (27MB)
PetCatalog in NetBeans68 on Remote GFv3 MySQL51 Res: 640x480 (15MB)

7. Stop Glassfish and MySQL servers

osol@osol-jeos:~$ cd ~/unbundled/glassfishv3/
osol@osol-jeos:~/unbundled/glassfishv3$ ./bin/asadmin stop-domain
Waiting for the domain to stop ....
Command stop-domain executed successfully.

osol@osol-jeos:~$ cd ~/unbundled/webstack16/
osol@osol-jeos:~/unbundled/webstack16$  ./bin/sun-mysql51 stop
Stopping mysql51                   OK

6. Check used space after Pet Catalog Sample installation

6a. Check ZFS used space after Pet Catalog Sample installation

osol@osol-jeos:~$ zfs list
NAME                               USED  AVAIL  REFER  MOUNTPOINT
rpool                             2.25G  5.56G  83.5K  /rpool
rpool/ROOT                         862M  5.56G    19K  legacy
rpool/ROOT/opensolaris             862M  5.56G   862M  /
rpool/dump                         384M  5.56G   384M  -
rpool/export                       545M  5.56G    20K  /export
rpool/export/home                  545M  5.56G    20K  /export/home
rpool/export/home/osol             545M  5.56G  57.5K  /export/home/osol
rpool/export/home/osol/unbundled   545M  5.56G   545M  /export/home/osol/unbundled
rpool/swap                         512M  6.06G    20K  -

osol@osol-jeos:~$ df -h
Filesystem                                       Size  Used Avail Use% Mounted on
rpool                                               5.6G   84K  5.6G   1% /rpool
rpool/ROOT/opensolaris
                                                       6.5G  862M  5.6G  14% /
rpool/export                                     5.6G   20K  5.6G   1% /export
rpool/export/home                            5.6G   20K  5.6G   1% /export/home
rpool/export/home/osol
                                                       5.6G   58K  5.6G   1% /export/home/osol
rpool/export/home/osol/unbundled
                                                       6.1G  546M  5.6G   9% /export/home/osol/unbundled

6b. Check Virtual Disk and Archive sizes after Pet Catalog Sample installation

osol@osol-jeos:~/unbundled/webstack16$  pfexec init 0

Virtual Disk size grow to 1611MB and with 7Z ultra compression size is now 378MB
Comments:

Post a Comment:
  • HTML Syntax: NOT allowed
About

Hands-on experience with Virtualization

Search

Categories
Archives
« April 2014
SunMonTueWedThuFriSat
  
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
   
       
Today