Tuesday, 8 March 2016

Install and Configure Hybris 5.7 suite in Ubuntu or windows

HYBRIS 5.7 BUILD & INSTALLATION STEPS (LINUX)

 Step 1)      Unzip the downloaded hybris 5.x suite to the destination folder.
       (To unzip:  Unzip hybris-commerce-suite-5.5.0.0.zip –d  /var/www/html/Hybris E-Commerce)

Note: Scroll below for troubleshooting issues- For solving errors regarding ANT, JAVA Path etc.

Step 2) Install the Recipe.
         
             Syntax (in linux): install.sh –r recipeName
              
             Recipes are used to install B2C accelerators,B2B accelerators ,Telco accelerator...
         
             Before installing the recipes, we will find only the bin folder inside the hybris folder.

             To install the recipe, navigate to the installer path in command,

             for Linux:        hybris_test/installer$   install.sh –r b2c_acc_plus
             for windows:   hybris_test/installer$   install.bat –r b2c_acc_plus

                    
             This will add all the required extensions to localextensions.xml as per the recipeName                   we have give in the command.

             We have to get Build Successful message in the cmd prompt.

              Now check the hybris folder, we get
             
 

   
             Here is my localextensions.xml after installing the recipe:  

             <hybrisconfig xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' xsi:noNamespaceSchemaLocation='../bin/platform/resources/schemas/extensions.xsd'>
  <extensions>
    <path dir='${HYBRIS_BIN_DIR}' autoload='false' />
    <extension name='mcc' />
    <extension name='backoffice' />
    <extension name='commercesearchbackoffice' />
    <extension name='commerceservicesbackoffice' />
    <extension name='solrfacetsearchbackoffice' />
    <extension name='solrserver' />
    <extension dir="${HYBRIS_BIN_DIR}/custom/training/trainingcore"/>
    <extension dir="${HYBRIS_BIN_DIR}/custom/training/trainingfacades"/>
    <extension dir="${HYBRIS_BIN_DIR}/custom/training/trainingtest"/>
    <extension dir="${HYBRIS_BIN_DIR}/custom/training/trainingstorefront"/>
    <extension dir="${HYBRIS_BIN_DIR}/custom/training/trainingfulfilmentprocess"/>
    <extension dir="${HYBRIS_BIN_DIR}/custom/training/traininginitialdata"/>
    <extension dir="${HYBRIS_BIN_DIR}/custom/training/trainingcockpits"/>
    <extension name='yaddon' />
    <extension name='ycommercewebservices' />
    <extension name='electronicsstore' />
    <extension name='apparelstore' />
    <extension name='captchaaddon' />
    <extension name='liveeditaddon' />
    <extension name='acceleratorwebservicesaddon' />
  </extensions>
</hybrisconfig>

Step 3) Installing the modulegen
  
             Navigate to bin/platform folder in cmd.  (/var/www/html/hybris_test/hybris/bin/platform)
            
             In linux:         . ./setantenv.sh    (. <space> ./setantenv.sh)  
             In windows:  . ./setantenv.bat
      
             NOTE : If windows you can refer the link : http://hybrisdiary.com/2015/09/26/installing-hybris-in-local-system/

            Run the modulegen command as follows: 
           
            ant modulegen -Dinput.module=accelerator -Dinput.name=training -Dinput.package=com.hybris.training -Dinput.template=develop

            Explanation of the command :
    
            Dinput.module=accelerator    => we are installing B2C module 
            Dinput.name= training (can be given any name)   => name of the module
            Dinput.package= com.hybris.training   (can be given any name) 
            Dinput.template= specifies whether configuration is for development or production.

           We have to get Build Successful message in the cmd prompt. 

      (Follow the 1st 2 steps specified in the command prompt). Refer above for my localextensions.xml file after following the steps from the command prompt. 

   Step 4)  Run ant clean all in the same folder path (bin/platform) . Build should be successful.

                

   Step 5) Start the Hybris server: 
       
                in Linux:  ./hybrisserver.sh run
                in Win:     hybrisserver.bat debug

  Step 6) Initialize the Hybris server.
               Can be done in 2 ways: 

                     1) Through HAC(Hybris Admininstration Console) ---  Make sure Toggle all checkbox   is selected.                                     or
                     2) Through command :  ant initialize

              Wait until Hybris starts and until the command shows:
              Dec 12, 2014 3:39:08 PM org.apache.catalina.startup.Catalina start

              INFO: Server startup in 163949 ms

     Hybris is now ready to use: 

     Default port :  http://localhost:9001
            or           http://<IP>:9001
                        

 Step 7) Enter below URL mappings in Host file in the below path:
              in linux:    /etc/hosts
              in win:     C:\Windows\System32\drivers\etc 

             
      127.0.0.1   apparel.local
      127.0.0.1   electronics.local
      <IP>        ... 

            If you encounter DNS lookup failed when accessing the URL, refer the below link:

             https://hybrisdiary.com/2015/08/07/the-server-at-electronics-local-cant-be-found-because-the-dns-look-up-failed/
 
 
 Step 8)  Access sample site shipped with Hybris:

              Apparel UK site
             http://apparel.local:9001/trainingstorefront/?site=apparel-uk
             
            

      Similarly 
  
            Apparel-DE site
           http://localhost:9001/ trainingstorefront/?site=apparel-de


           Electronics site
           http://localhost:9001/ trainingstorefront/?site=electronics


           TroubleShoot during configuration:
                 

         1)  If you encounter the following ERROR: ant build : unable to locate tools.jar. Expected find it in C:\Program Files\Java\jre7\lib\tools.jar)

you can just copy the tools.jar from "C:\ProgramFiles\Java\jdk1.7.0\lib" directly into "C:\Program Files\Java\jre7\lib\".You will successfully recover the problems.


        NOTE: For above issue In Ubuntu: Install JDK :  sudo apt-get install default-jdk


2)  To install Java on Ubuntu using  apt-get

       sudo apt-get update

 Then, check if Java is not already installed:

         java -version
 
       If it returns "The program java can be found in the following packages", Java     hasn't been installed yet, so execute the following command:

         sudo apt-get install default-jre 
      This will install the Java Runtime Environment (JRE). If you instead need the Java Development Kit (JDK), which is usually needed to compile Java applications (for example Apache Ant, Apache Maven, Eclipse and IntelliJ IDEA execute the following command:

       sudo apt-get install default-jdk
  
 3)  Setting the "JAVA_HOME" environment variable

i) First find out the path of your Java installation:

  sudo update-alternatives --config java
 
ii) The path of the installation is for each:
  1. /usr/lib/jvm/java-7-oracle
  2. /usr/lib/jvm/java-6-openjdk-amd64
  3. /usr/lib/jvm/java-7-oracle
 iii) Copy the path from your preferred installation and then edit the file 
      /etc/environment:
 
           sudo nano /etc/environment 
 iv) In this file, add the following line (replacing YOUR_PATH by the just copied path): 
 
    JAVA_HOME="YOUR_PATH"
 
    Don't forget to remove bin/java from the end of the path while putting it into JAVA_HOME 
 
 v) Now reload this file:
 
    source /etc/environment
 
 vi) Test it by executing:
 
         echo $JAVA_HOME 




  





CONFIGURE HYBRIS AS A SERVICE – To auto start hybris on boot

1)      Stop the server:                ./hybrisserver stop       (or ctrl –c   exit)

2)      Create a hybris service startup file:    vi /etc/init.d/hybris  
a.       Setting the base path in the file to your hybris installation:

                        HYBRIS_HOME="/var/www/html/Hybris E-Commerce/hybris" and save the file.

b.    If error is thrown in this line:
accepted
# Source function library
. /etc/init.d/functions

Replace with:                            # Source function library
                        . /lib/lsb/init-functions

c.       Set permission for the file to be executed:
  chmod 755 /etc/init.d/hybris

3)      Add the file to the server startup list:

chkconfig --add hybris
chkconfig hybris on


4)      To rebuild hybris :
cd /home/hybris/hybris/bin/platform
                                                         . ./setantenv.sh
ant clean all          # command to rebuild

NOTE: To upgrade higher ANT version:
i)                    Download “apache-ant-1.9.6.zip” and extract to /usr/local
ii)                   Under hybris/bin/platform: 


iii)                 To check version of ant:  ant -version

5)      Start Hybris server:             ./hybrisserver.sh run

Hurray HYBRIS is now ready to RUN!!!

    Default localhost:              http://<localhost>:9001

    Default Factory password:
                                                User:         admin   
Password: nimda




http://<localhost>:9001/mcc




http://<localhost>:9001/admincockpit






To install/save Custom extensions in a separate directory.


If the above cockpits are not loaded, we need to add the extensions in the 
hybris\config\localextensions.xml




In localextensions.xml

<extension>
    <!--
    There should be a path dir defined within the config like below
  -->
    <path dir="${HYBRIS_BIN_DIR}" />
    <!--
    Navigate to where your extensions are defined, you can create your 
    own path variable above if you want too, this is just an example for you  -->
  
    <!-- ext-template -->
    <extension name="yempty" />
 
    <!--Begin Custom extensions -->
    <extension name="admincockpit" /> 
    <extension name="backoffice" />
    <extension name="cockpit" />
    <extension name="hmc" />    <!--Hybris management console -->
    <extension name="mcc" />
    <extension name="platformhmc" /> 
    <!--End Custom extensions -->
 
 
  <extension name="${HYBRIS_BIN_DIR}/../../myExtensionsFolder/extension1" />
  <extension name="${HYBRIS_BIN_DIR}/../../myExtensionsFolder/extension2" />  
</extension>
 

To configure Hybris to use MYSQL

    As we know that hybris suite by default provides HSQL database,
    so if we want to connect to MySQL database we need to do the following modifications:

   1) Under  \hybris\bin\platform\project.properties
  
       Under DATABASE SETTINGS (apprx line 191)
    
       Comment-  "Database settings for HSQLDB"
       and Uncomment the "Database settings for MySQL 5.1"

  2) This is my configuration for MYSQL:
   
     db.url=jdbc:mysql://localhost/hsqldb?useConfigs=maxPerformance&characterEncoding=utf8&useSSL=false
     db.driver=com.mysql.jdbc.Driver
     db.username=root
     db.password=<ur DB password>
     db.tableprefix=
     db.customsessionsql=SET SESSION TRANSACTION ISOLATION LEVEL READ COMMITTED;
     mysql.optional.tabledefs=CHARSET=utf8 COLLATE=utf8_bin
     mysql.tabletype=InnoDB
     mysql.allow.fractional.seconds=true     

     Create a DB (say as in above config: 'hsqldb') in MYSQL.

3) Since hybris Commerce Suite version 5.0.2, MySQL connector is not shipped with the hybris   Commerce Suite,
Hence download the below mysql java connector and place it in hybris/bin/platform/lib/dbdriver
MYSQL java connector link :
NOTE:  With MySQL 5.6.4 (or later) the mysql.allow.fractional.seconds property must be defined.
Before 5.6.4 you must either omit the mysql.allow.fractional.seconds property or
set it for false! In project.properties file.

4) reload/build ant:  ant clean all

5) Initialize the system in HAC or use :  ant initialize
    (ant clean all initialize can also be used)

6) Say:    
    mysql -u root -p 
    show databases;
    use hsqldb;
    show tables;
    We can now check that our DB ('hsqldb') has loaded with Hybris default tables.