Mail Server: OFBiz with Mysql Setup

Mohit Sethi
Appliedcode
Published in
4 min readAug 8, 2015

Apache OFBiz™ is an open source product for the automation of enterprise processes that includes framework components and business applications for ERP (Enterprise Resource Planning), CRM (Customer Relationship Management), E-Business / E-Commerce, SCM (Supply Chain Management), MRP (Manufacturing Resource Planning), MMS/EAM (Maintenance Management System/Enterprise Asset Management), POS (Point Of Sale).

Apache OFBiz is licensed under the Apache License Version 2.0 and is part of The Apache Software Foundation.

Step 1: Install JAVA

Java is the primary requirement for installing Apache OFBiz. It required minimum Java 1.6 to installed on your system. Make sure you have Java installed with proper version on your system.

# java -version

If you do not Java installed, Use below tutorial to install java else ignore it.

For Ubuntu, Debian and LinuxMint Users — Install JAVA 7 or Install JAVA 8

Step 2: Install Mysql and Setup for OFBiz

MySQL is a powerful database management system used for organizing and retrieving data

To install MySQL, open terminal and type in these commands:

sudo apt-get install mysql-server libapache2-mod-auth-mysql php5-mysql

During the installation, MySQL will ask you to set a root password. If you miss the chance to set the password while the program is installing, it is very easy to set the password later from within the MySQL shell.

Once you have installed MySQL, we should activate it with this command:

sudo mysql_install_db

Creating Databases and user access for OFBiz

We will be creating databases and user access which will be used with ofbiz to store the data. Below are the commands:

mysql>create database ofbiz;  
mysql>create database ofbizolap;
mysql>create database ofbiztenant;
mysql>use mysql;
mysql>select database();
mysql>create user ofbiz@localhost;
mysql>create user ofbizolap@localhost;
mysql>create user ofbiztenant@localhost;
mysql>update user set password=PASSWORD("ofbiz") where User='ofbiz';
mysql>update user set password=PASSWORD("ofbizolap") where User='ofbizolap';
mysql>update user set password=PASSWORD("ofbiztenant") where User='ofbiztenant';
mysql>grant all privileges on *.* to 'ofbiz'@localhost identified by 'ofbiz';
mysql>grant all privileges on *.* to 'ofbizolap'@localhost identified by 'ofbizolap';
mysql>grant all privileges on *.* to 'ofbiztenant'@localhost identified by 'ofbiztenant';

Step 3: Download Apache OFBiz from SVN

We will be using SVN download latest Apache OFBiz files. first make sure you have svn client installed on system after that checkout the latest build from the subversion repository of OFBiz.

# cd /opt/  
# yum install subversion
# svn co http://svn.apache.org/repos/asf/ofbiz/trunk apache-ofbiz

Step 4: Integrating Apache OFBiz with Mysql

Before we build Apache OFBiz, we will be integrating it with Mysql
1. Firstly, will be needing the JDBC connector: mysql-connector-java-5.1.14-bin.jar — to be placed in <ofbiz-dir>/framework/entity/lib/jdbc
2. Create a backup of apache-ofbiz/framework/entity/config/entityengine.xml
3. Edit entityengine.xml as follows:
a. Add the following datasources below the datasource ‘localmysql’

<datasource name="localmysqlolap"  
helper-class="org.ofbiz.entity.datasource.GenericHelperDAO"
field-type-name="mysql"
check-on-start="true"
add-missing-on-start="true"
check-pks-on-start="false"
use-foreign-keys="true"
join-style="ansi-no-parenthesis"
alias-view-columns="false"
drop-fk-use-foreign-key-keyword="true"
table-type="InnoDB"
character-set="latin1"
collate="latin1_general_cs">
<read-data reader-name="seed"/>
<read-data reader-name="seed-initial"/>
<read-data reader-name="demo"/>
<read-data reader-name="ext"/>
<inline-jdbc
jdbc-driver="com.mysql.jdbc.Driver"
jdbc-uri="jdbc:mysql://127.0.0.1/ofbiz?autoReconnect=true"
jdbc-username="ofbizolap"
jdbc-password="ofbizolap"
isolation-level="ReadCommitted"
pool-minsize="2"
pool-maxsize="250"
time-between-eviction-runs-millis="600000"/>
</datasource>
<datasource name="localmysqltenant"
helper-class="org.ofbiz.entity.datasource.GenericHelperDAO"
field-type-name="mysql"
check-on-start="true"
add-missing-on-start="true"
check-pks-on-start="false"
use-foreign-keys="true"
join-style="ansi-no-parenthesis"
alias-view-columns="false"
drop-fk-use-foreign-key-keyword="true"
table-type="InnoDB"
character-set="latin1"
collate="latin1_general_cs">
<read-data reader-name="seed"/>
<read-data reader-name="seed-initial"/>
<read-data reader-name="demo"/>
<read-data reader-name="ext"/>
<inline-jdbc
jdbc-driver="com.mysql.jdbc.Driver"
jdbc-uri="jdbc:mysql://127.0.0.1/ofbiz?autoReconnect=true"
jdbc-username="ofbiztenant"
jdbc-password="ofbiztenant"
isolation-level="ReadCommitted"
pool-minsize="2"
pool-maxsize="250"
time-between-eviction-runs-millis="600000"/>
</datasource>

b. Replace derby with mysql in default, default-no-eca and test delegators as follows:

<delegator name="default" entity-model-reader="main" entity-group-reader="main" entity-eca-reader="main" distributed-cache-clear-enabled="false">  
<group-map group-name="org.ofbiz" datasource-name="localmysql"/>
<group-map group-name="org.ofbiz.olap" datasource-name="localmysqlolap"/>
<group-map group-name="org.ofbiz.tenant" datasource-name="localmysqltenant"/>
</delegator>
<delegator name="default-no-eca" entity-model-reader="main" entity-group-reader="main" entity-eca-reader="main" entity-eca-enabled="false" distributed-cache-clear-enabled="false">
<group-map group-name="org.ofbiz" datasource-name="localmysql"/>
<group-map group-name="org.ofbiz.olap" datasource-name="localmysqlolap"/>
<group-map group-name="org.ofbiz.tenant" datasource-name="localmysqltenant"/>
</delegator>
<delegator name="test" entity-model-reader="main" entity-group-reader="main" entity-eca-reader="main">
<group-map group-name="org.ofbiz" datasource-name="localmysql"/>
<group-map group-name="org.ofbiz.olap" datasource-name="localmysqlolap"/>
<group-map group-name="org.ofbiz.tenant" datasource-name="localmysqltenant"/>
</delegator>

Save the file.

Step 5: Installing Apache OFBiz

# cd /opt/apache-ofbiz/  
# ./ant

Step 6: Install Dataset, Load Demo and Seed Data

Apache OFBiz provides dataset, demo data and seed data, this data is useful for experiment. This data is unuseful for production setup.

# ./ant load-demo  
# ./ant load-extseed

Step 7: Start Apache OFBiz Service

After installing Apache OFBiz, Use following command to start Apache OFBiz service on system.

# ./ant start

Access Apache OFBiz in Browser

Access Apache OFBiz in browser on port 8443 as below given url and login credentials.

URL: https://svr10.tecadmin.net:8443/myportal/control/main  
Admin Username: admin
Admin Password: ofbiz

References:

http://ofbiz.apache.org/

Congratulation’s! You have successfully install apache OFBiz with Mysql integration on your Linux system.

--

--

Mohit Sethi
Appliedcode

OpenSource | DevSecOps | DataScience | Machine Learning | ChatBots | Robotic Process Automation(RPA) | Coffee lover | Codes for a better world | Opinions = Mine