Can’t wait to get started?
Pre-configured JBilling + My SQL Virtual Appliance for VMWare Server 2.0
Although setting up Jbilling with MySQL is documented, it is not very clear.
Prerequisites
- MySQL Server
- MySQL Client
- Java Development Kit
- MySQL JDBC Driver
- Jbilling Deployment Package (jbilling-1_1_2.zip)
- zip and unzip
- Download and unzip Jbilling
Go to your /opt/ folder where will be installing jbilling.
Download Jbilling Binary Package
This will take a while to download depending on your connection speed. The Download file is about 46MB.
Alternatively if you have already downloaded Jbilling Version 1.1.2, you can just copy it to your /opt/ directory and move to the next step.
Jbilling is packaged as Zip file. We need to unzip this binary package.
Now we should have a “jbilling” folder inside “/opt”
total 46M
drwxr-xr-x 8 root root 4.0K 2008-01-15 14:09 jbilling
-rwxr-xr-x 1 root root 46M 2009-02-23 12:28 jbilling-1_1_2.zip
Lets take a look inside the jbilling folder.
total 324K
drwxr-xr-x 2 root root 4.0K 2008-03-13 16:26 bin
drwxr-xr-x 2 root root 4.0K 2008-01-15 14:09 client
-rw-r–r– 1 root root 35K 2008-01-15 14:09 COPYING
drwxr-xr-x 4 root root 4.0K 2008-01-15 14:09 docs
-rw-r–r– 1 root root 62K 2008-01-15 14:09 jbilling_installation_instructions.pdf
drwxr-xr-x 2 root root 4.0K 2008-01-15 14:09 lib
-rw-r–r– 1 root root 189K 2008-11-20 15:41 release_notes.pdf
drwxr-xr-x 8 root root 4.0K 2008-01-15 14:09 resources
drwxr-xr-x 3 root root 4.0K 2008-01-15 14:09 server
Setting up MySQL Server
Logging into MySQL Server
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 83
Server version: 5.0.67-0ubuntu6 (Ubuntu)
Type ‘help;’ or ‘\h’ for help. Type ‘\c’ to clear the buffer.
Create Jbilling Database
Query OK, 1 row affected (0.03 sec)
Create Jbilling User
Query OK, 0 rows affected (0.00 sec)
Quit and exit out of MySQL
Bye
Import MySQL Schema
Import Initial Data
Checking imported data and schema
Now we check to see if all tables are created
+——————————–+
| Tables_in_jbilling |
+——————————–+
| ach |
| ageing_entity_step |
| base_user |
| billing_process |
| billing_process_configuration |
| blacklist |
| contact |
| contact_field |
| contact_field_type |
| contact_map |
| contact_type |
| country |
| credit_card |
| currency |
| currency_entity_map |
| currency_exchange |
| customer |
| entity |
| entity_delivery_method_map |
| entity_payment_method_map |
| event_log |
| event_log_message |
| event_log_module |
| international_description |
| invoice |
| invoice_delivery_method |
| invoice_line |
| invoice_line_type |
| item |
| item_price |
| item_type |
| item_type_map |
| item_user_price |
| jbilling_table |
| jbilling_table_column |
| language |
| list |
| list_entity |
| list_field |
| list_field_entity |
| mediation_cfg |
| mediation_order_map |
| mediation_process |
| mediation_record |
| menu_option |
| notification_message |
| notification_message_arch |
| notification_message_arch_line |
| notification_message_line |
| notification_message_section |
| notification_message_type |
| order_billing_type |
| order_line |
| order_line_type |
| order_period |
| order_process |
| order_status |
| paper_invoice_batch |
| partner |
| partner_payout |
| partner_range |
| payment |
| payment_authorization |
| payment_info_cheque |
| payment_invoice |
| payment_method |
| payment_result |
| period_unit |
| permission |
| permission_role_map |
| permission_type |
| permission_user |
| pluggable_task |
| pluggable_task_parameter |
| pluggable_task_type |
| pluggable_task_type_category |
| preference |
| preference_type |
| process_run |
| process_run_total |
| process_run_total_pm |
| promotion |
| promotion_user_map |
| purchase_order |
| report |
| report_entity_map |
| report_field |
| report_type |
| report_type_map |
| report_user |
| role |
| subscriber_status |
| user_credit_card_map |
| user_role_map |
| user_status |
+——————————–+
and we check if initial data was imported:
+—-+———–+
| id | can_login |
+—-+———–+
| 1 | 1 |
| 2 | 1 |
| 3 | 1 |
| 4 | 1 |
| 5 | 0 |
| 6 | 0 |
| 7 | 0 |
| 8 | 0 |
+—-+———–+
Setting up Jbilling
jbilling.properties
root@exotix:/opt/jbilling/server/default/conf# ls -lh
total 300K
-rw-r–r– 1 root root 14K 2008-11-26 14:09 ehcache.xml
-rw-r–r– 1 root root 15K 2008-01-15 14:09 jacorb.properties
-rw-r–r– 1 root root 3.1K 2008-01-15 14:09 jbilling.properties
-rw-r–r– 1 root root 6.5K 2008-01-15 14:09 jboss-minimal.xml
-rw-r–r– 1 root root 897 2008-01-15 14:09 jbossmq-state.xml
-rw-r–r– 1 root root 23K 2008-01-15 14:09 jboss-service.xml
drwxr-xr-x 3 root root 4.0K 2008-01-15 14:09 jboss.web
-rw-r–r– 1 root root 194 2008-01-15 14:09 jndi.properties
-rw-r–r– 1 root root 2.8K 2008-03-13 16:57 log4j.xml
-rw-r–r– 1 root root 6.9K 2008-01-15 14:09 login-config.xml
-rw-r–r– 1 root root 543 2008-01-15 14:09 server.policy
-rw-r–r– 1 root root 35K 2008-01-15 14:09 standardjaws.xml
-rw-r–r– 1 root root 100K 2008-01-15 14:09 standardjbosscmp-jdbc.xml
-rw-r–r– 1 root root 53K 2008-01-15 14:09 standardjboss.xml
drwxr-xr-x 2 root root 4.0K 2008-01-15 14:09 xmdesc
now we need to edit jbilling.properties and set required parameters
use your favorite editor to modify this file. I use “vim” editor.
Look at these lines
2 # will be created. Also other files, like logos, will be put here
3 base_dir=c:/jbilling/resources/
4 # email server parameters for emails
5 # sent to the entities and as a default
Change them to
2 # will be created. Also other files, like logos, will be put here
3 base_dir=/opt/jbilling/resources/
4 # email server parameters for emails
5 # sent to the entities and as a default
standardjbosscmp-jdbc.xml
Next we need to edit “standardjbosscmp-jdbc.xml”
Again use your favorite editor to edit this file:
17 <datasource>java:/ApplicationDS</datasource>
18 <datasource-mapping>Hypersonic SQL</datasource-mapping>
19
20 <create-table>true</create-table>
To
17 <datasource>java:/ApplicationDS</datasource>
18 <datasource-mapping>mySQL</datasource-mapping>
19
20 <create-table>true</create-table>
We need to modify few files in the deployment director
root@exotix:/opt/jbilling/server/default/deploy# ls -lh
total 6.6M
-rw-r–r– 1 root root 1.5K 2008-11-27 13:24 betty.wsr
-rw-r–r– 1 root root 5.2M 2008-11-27 13:24 billing.war
-rw-r–r– 1 root root 2.0K 2008-01-15 14:09 cache-invalidation-service.xml
-rw-r–r– 1 root root 1.5K 2008-01-15 14:09 client-deployer-service.xml
drwxr-xr-x 2 root root 4.0K 2008-01-15 14:09 deploy.last
drwxr-xr-x 4 root root 4.0K 2008-01-15 14:09 http-invoker.sar
-rw-r–r– 1 root root 4.8K 2008-01-15 14:09 hypersonic-ds.xml
-rw-r–r– 1 root root 3.7K 2008-01-15 14:09 iiop-service.xml
-rw-r–r– 1 root root 1.2M 2008-11-27 13:24 jbilling.jar
-rw-r–r– 1 root root 121K 2008-01-15 14:09 jboss-jca.sar
-rw-r–r– 1 root root 6.6K 2008-01-15 14:09 jboss-local-jdbc.rar
drwxr-xr-x 5 root root 4.0K 2008-01-15 14:09 jboss-net.sar
drwxr-xr-x 5 root root 4.0K 2008-01-15 14:09 jbossweb-tomcat50.sar
-rw-r–r– 1 root root 13K 2008-01-15 14:09 jboss-xa-jdbc.rar
drwxr-xr-x 3 root root 4.0K 2008-01-15 14:09 jms
drwxr-xr-x 3 root root 4.0K 2008-01-15 14:09 jmx-invoker-adaptor-server.sar
-rw-r–r– 1 root root 1.6K 2008-01-15 14:09 mail-service.xml
-rw-r–r– 1 root root 4.0K 2008-01-15 14:09 monitoring-service.xml
drwxr-xr-x 2 root root 4.0K 2008-01-15 14:09 online_doc.war
-rw-r–r– 1 root root 1.8K 2008-01-15 14:09 properties-service.xml
drwxr-xr-x 2 root root 4.0K 2008-01-15 14:09 resources
-rw-r–r– 1 root root 3.9K 2008-01-15 14:09 schedule-manager-service.xml
-rw-r–r– 1 root root 1.8K 2008-01-15 14:09 scheduler-service.xml
drwxr-xr-x 3 root root 4.0K 2008-01-15 14:09 snmp-adaptor.sar
-rw-r–r– 1 root root 198 2008-01-15 14:09 sqlexception-service.xml
-rw-r–r– 1 root root 1.4K 2008-01-15 14:09 transaction-service.xml
-rw-r–r– 1 root root 1.1K 2008-01-15 14:09 user-service.xml
hypersonic-ds.xml
First we need ro remove “hypersonic-ds.xml” file
And copy MySQL data source to the deployment folder.
Use your favorite editor to edit “mysql-ds.xml” file.
Change The content from:
13 <local-tx-datasource>
14 <jndi-name>ApplicationDS</jndi-name>
15 <connection-url>jdbc:mysql://mysql-hostname:3306/jbossdb</connection-url>
16 <driver-class>com.mysql.jdbc.Driver</driver-class>
17 <user-name>x</user-name>
18 <password>y</password>
19 <min-pool-size>5</min-pool-size>
20 <max-pool-size>50</max-pool-size>
21 </local-tx-datasource>
22
23 </datasources>
To
13 <local-tx-datasource>
14 <jndi-name>ApplicationDS</jndi-name>
15 <connection-url>jdbc:mysql://localhost:3306/jbilling?zeroDateTimeBehavior=convertToNull</connection-url>
16 <driver-class>com.mysql.jdbc.Driver</driver-class>
17 <user-name>jbilling</user-name>
18 <password>jbilling</password>
19 <min-pool-size>5</min-pool-size>
20 <max-pool-size>50</max-pool-size>
21 </local-tx-datasource>
22
23 </datasources>
Note: make sure the “?zeroDateTimeBehavior=convertToNull” is added to the end of the url. This flag tells the driver to convert mysql date “0000-00-00 00:00:00” to Null. Jbilling will throw crazy exceptions if this flag is not set.
hsqldb-jdbc2-service.xml
Now we are going to setup JMS database.
root@exotix:/opt/jbilling/server/default/deploy/jms# ls -lh
total 76K
-rw-r–r– 1 root root 4.7K 2008-01-15 14:09 hsqldb-jdbc2-service.xml
-rw-r–r– 1 root root 2.5K 2008-01-15 14:09 hsqldb-jdbc-state-service.xml
-rw-r–r– 1 root root 856 2008-01-15 14:09 jbossmq-destinations-service.xml
drwxr-xr-x 4 root root 4.0K 2008-01-15 14:09 jbossmq-httpil.sar
-rw-r–r– 1 root root 3.5K 2008-01-15 14:09 jbossmq-service.xml
-rw-r–r– 1 root root 2.2K 2008-01-15 14:09 jms-ds.xml
-rw-r–r– 1 root root 40K 2008-01-15 14:09 jms-ra.rar
-rw-r–r– 1 root root 599 2008-01-15 14:09 jvm-il-service.xml
-rw-r–r– 1 root root 1.7K 2008-01-15 14:09 uil2-service.xml
Remove “hsqldb-jdbc2-service.xml” file.
Copy MySQL Data Source for JMS.
Setting JPA (NOT NEEDED FOR JBILLING 1.1.3)
as of jbilling 1.1 jbilling is using JPA for some parts of it.
To set Jbilling to work with MySQL you need to change one line inside jbilling.jar file.
Go to deployment directory
create a “tmp” folder and move the jbilling.jar file to the tmp directory
root@exotix:/opt/jbilling/server/default/deploy# mv jbilling.jar tmp/
Jar files are essentially Zip files with .jar extension. So we are going to unzip the jar file
we are going to have these files and folders now.
total 1.2M
drwxr-xr-x 3 root root 4.0K 2008-10-23 10:28 com
-rw-r–r– 1 root root 7.2K 2008-10-17 18:30 entityNotifications.properties
-rw-r–r– 1 root root 1.2M 2008-11-27 13:24 jbilling.jar
drwxr-xr-x 2 root root 4.0K 2008-11-27 10:08 META-INF
remove the jar file itself
inside META-INF is the “persistence.xml” file we need to modify
total 348K
-rw-r–r– 1 root root 160K 2008-11-27 10:08 ejb-jar.xml
-rw-r–r– 1 root root 67K 2008-11-27 10:08 jbosscmp-jdbc.xml
-rw-r–r– 1 root root 51K 2008-11-27 10:08 jboss.xml
-rw-r–r– 1 root root 202 2008-11-27 10:08 MANIFEST.MF
-rw-r–r– 1 root root 1.9K 2008-11-27 10:08 persistence.xml
-rw-r–r– 1 root root 40K 2008-11-27 10:08 validator-rules.xml
-rw-r–r– 1 root root 4.7K 2008-11-27 10:08 ws-validation.xml
use your favorite editor to edit this file.
we need to modify this section:
15 <!– Scan for annotated classes and Hibernate mapping XML files –>
16 <property name=”hibernate.archive.autodetection” value=”class”/>
17 <property name=”hibernate.dialect” value=”org.hibernate.dialect.HSQLDialect”/>
18 <!–
19 <property name=”hibernate.dialect” value=”org.hibernate.dialect.PostgreSQLDialect”/>
20 –>
To
15 <!– Scan for annotated classes and Hibernate mapping XML files –>
16 <property name=”hibernate.archive.autodetection” value=”class”/>
17 <property name=”hibernate.dialect” value=”org.hibernate.dialect.MySQL5Dialect”/>
18 <!–
19 <property name=”hibernate.dialect” value=”org.hibernate.dialect.PostgreSQLDialect”/>
20 –>
Now we need to recreate the jar file
move back to deploy directory and remove the tmp directory
root@exotix:/opt/jbilling/server/default/deploy# rm -fr tmp
make sure the jbilling.jar file is created
total 8.4M
-rw-r–r– 1 root root 1.5K 2008-11-27 13:24 betty.wsr
-rw-r–r– 1 root root 5.2M 2008-11-27 13:24 billing.war
-rw-r–r– 1 root root 2.0K 2008-01-15 14:09 cache-invalidation-service.xml
-rw-r–r– 1 root root 1.5K 2008-01-15 14:09 client-deployer-service.xml
drwxr-xr-x 2 root root 4.0K 2008-01-15 14:09 deploy.last
drwxr-xr-x 4 root root 4.0K 2008-01-15 14:09 http-invoker.sar
-rw-r–r– 1 root root 3.7K 2008-01-15 14:09 iiop-service.xml
-rw-r–r– 1 root root 3.0M 2009-02-23 14:19 jbilling.jar
-rw-r–r– 1 root root 121K 2008-01-15 14:09 jboss-jca.sar
-rw-r–r– 1 root root 6.6K 2008-01-15 14:09 jboss-local-jdbc.rar
drwxr-xr-x 5 root root 4.0K 2008-01-15 14:09 jboss-net.sar
drwxr-xr-x 5 root root 4.0K 2008-01-15 14:09 jbossweb-tomcat50.sar
-rw-r–r– 1 root root 13K 2008-01-15 14:09 jboss-xa-jdbc.rar
drwxr-xr-x 3 root root 4.0K 2009-02-23 13:22 jms
drwxr-xr-x 3 root root 4.0K 2008-01-15 14:09 jmx-invoker-adaptor-server.sar
-rw-r–r– 1 root root 1.6K 2008-01-15 14:09 mail-service.xml
-rw-r–r– 1 root root 4.0K 2008-01-15 14:09 monitoring-service.xml
-rw-r–r– 1 root root 947 2009-02-23 13:16 mysql-ds.xml
drwxr-xr-x 2 root root 4.0K 2008-01-15 14:09 online_doc.war
-rw-r–r– 1 root root 1.8K 2008-01-15 14:09 properties-service.xml
drwxr-xr-x 2 root root 4.0K 2008-01-15 14:09 resources
-rw-r–r– 1 root root 3.9K 2008-01-15 14:09 schedule-manager-service.xml
-rw-r–r– 1 root root 1.8K 2008-01-15 14:09 scheduler-service.xml
drwxr-xr-x 3 root root 4.0K 2008-01-15 14:09 snmp-adaptor.sar
-rw-r–r– 1 root root 198 2008-01-15 14:09 sqlexception-service.xml
-rw-r–r– 1 root root 1.4K 2008-01-15 14:09 transaction-service.xml
-rw-r–r– 1 root root 1.1K 2008-01-15 14:09 user-service.xml
SETTING UP SPRING (FOR JBILLING 1.1.3)
As of version 1.1.3, jbilling is using spring for database connections and JPA settings.
Just like configuration for jbilling 1.1.2, you need to change jbilling-database.xml in server/default/conf directory.
make sure you change values for database connectivity.
<bean id=”dataSource” class=”org.apache.commons.dbcp.BasicDataSource” destroy-method=”close”>
<property name=”driverClassName” value=”com.mysql.jdbc.Driver”/>
<property name=”url” value=”jdbc:mysql://localhost:3306/jbilling?zeroDateTimeBehavior=convertToNull”/>
<property name=”username” value=”jbilling” />
<property name=”password” value=”jbilling” />
<property name=”initialSize” value=”5″/>
<property name=”maxWait” value=”-1″ />
</bean>
Setting up MySQL JDBC Driver
change directory to “/opt/”
Download MySQL JDBC Driver
extract the driver
Copy driver jar file to jbilling server lib director
Running Jbilling
lets look at the files inside the bin directory
total 176K
-rw-r–r– 1 root root 28K 2008-01-15 14:09 appLog.txt
-rw-r–r– 1 root root 110 2008-01-15 14:09 appLog.txt.0
-rw-r–r– 1 root root 0 2008-01-15 14:09 appLog.txt.0.lck
-rw-r–r– 1 root root 1.7K 2008-01-15 14:09 deployer.bat
-rw-r–r– 1 root root 2.6K 2008-01-15 14:09 deployer.sh
-rw-r–r– 1 root root 1.4K 2008-01-15 14:09 dirname.exe.stackdump
-rw-r–r– 1 root root 2.5K 2008-01-15 14:09 jboss_init_redhat.sh
-rw-r–r– 1 root root 3.7K 2008-01-15 14:09 jboss_init_suse.sh
-rw-r–r– 1 root root 3.0K 2008-01-15 14:09 run.bat
-rw-r–r– 1 root root 1.4K 2008-01-15 14:09 run.conf
-rw-r–r– 1 root root 31K 2008-01-15 14:09 run.jar
-rw-r–r– 1 root root 4.6K 2008-01-15 14:09 run.sh
-rw-r–r– 1 root root 1.8K 2008-01-15 14:09 shutdown.bat
-rw-r–r– 1 root root 17K 2008-01-15 14:09 shutdown.jar
-rw-r–r– 1 root root 2.0K 2008-01-15 14:09 shutdown.sh
-rw-r–r– 1 root root 2.1K 2008-01-15 14:09 twiddle.bat
-rw-r–r– 1 root root 39K 2008-01-15 14:09 twiddle.jar
-rw-r–r– 1 root root 2.3K 2008-01-15 14:09 twiddle.sh
as you see .sh files are not executable. We need to make these files executable
Check to make sure they are executable now.
total 176K
-rw-r–r– 1 root root 28K 2008-01-15 14:09 appLog.txt
-rw-r–r– 1 root root 110 2008-01-15 14:09 appLog.txt.0
-rw-r–r– 1 root root 0 2008-01-15 14:09 appLog.txt.0.lck
-rw-r–r– 1 root root 1.7K 2008-01-15 14:09 deployer.bat
-rwxr-xr-x 1 root root 2.6K 2008-01-15 14:09 deployer.sh
-rw-r–r– 1 root root 1.4K 2008-01-15 14:09 dirname.exe.stackdump
-rwxr-xr-x 1 root root 2.5K 2008-01-15 14:09 jboss_init_redhat.sh
-rwxr-xr-x 1 root root 3.7K 2008-01-15 14:09 jboss_init_suse.sh
-rw-r–r– 1 root root 3.0K 2008-01-15 14:09 run.bat
-rw-r–r– 1 root root 1.4K 2008-01-15 14:09 run.conf
-rw-r–r– 1 root root 31K 2008-01-15 14:09 run.jar
-rwxr-xr-x 1 root root 4.6K 2008-01-15 14:09 run.sh
-rw-r–r– 1 root root 1.8K 2008-01-15 14:09 shutdown.bat
-rw-r–r– 1 root root 17K 2008-01-15 14:09 shutdown.jar
-rwxr-xr-x 1 root root 2.0K 2008-01-15 14:09 shutdown.sh
-rw-r–r– 1 root root 2.1K 2008-01-15 14:09 twiddle.bat
-rw-r–r– 1 root root 39K 2008-01-15 14:09 twiddle.jar
-rwxr-xr-x 1 root root 2.3K 2008-01-15 14:09 twiddle.sh
all set, we will run jbilling for the first time.
if everything goes smoothly you should end up with jbilling server running
Note: make sure you are not running any other application like apache on port 80
14:27:08,537 INFO [ChannelSocket] JK2: ajp13 listening on /0.0.0.0:8009
14:27:08,541 INFO [JkMain] Jk running ID=0 time=1/21 config=null
14:27:08,560 INFO [Server] JBoss (MX MicroKernel) [3.2.6 (build: CVSTag=JBoss_3_2_6 date=200410140106)] Started in 39s:448ms
check the web application “http://localhost/billing/” and make sure you see the jbilling page.
Congratulations! You got jbilling running!


Thank you for this great tutorial ! It’s just working fine.
However, I’m in front of the http://localhost/billing/ screen, and I don’t know how to login, as no username/password/company-ID combination was available.
All the best
dear carpediem,
this documented in jbillings installation document.
I know it is a bit confusing, you have to create a new company.
you can have jbilling setup with few companies, the login page will ask you fore three fields, username,password and entity id which is the company id.
go to this page http://localhost/billing/signupEntity.do?action=setup and setup your company and admin user and password.
hope this helps.
parham
Parham,
1st I would would like to thank you for and excellent howto!. Hats off to you. I am trying to get this installed on solaris 10 sparc and was wondering if you would be able to do a howto on that platform. Sparc and x86. could also use opensolaris.
Romske
Dear Romske,
I think these instructions should work on solaris or any other *nix systems.
Please try these instructions on solaris and let me know if you had any problems, I’ll try to run on open solaris my self.
Parham
This is a great tutorial as I have found jbilling docs to be sparse and confusing - works fine - only comment I have is change from port 80 to another port unless you are deploying on it’s own server. Edit
/opt/jbilling/server/default/deploy/jbossweb-tomcat50.sar/server.xml
Excellent notes. Thanks for taking time put these together and post these. Work great.
BTW — do you know if JBilling also works with servlet container like Tomcat (rather than EE container like JBOSS)
Thanks.
Just wanted to say thanks for the howto. I searched forever for a good howto on getting jbilling up and running. There is NO WAY I would have been able to do this on my own. Thanks so much! I now have jbilling working on ubuntu 9.04! Oh…and thanks to Hotelguy for posting the note about changing the port. I changed my port from 80 to a different one and everything works great! Much love!
Thanks for good post
Thanks, this is very helpful. In the section on setting up spring, you mention that it’s necessary to edit jbilling-database.xml, but I have never installed jbilling 1.1.2 so I don’t know what to do here. Could you point me in the right direction? Many thanks.
any luck with answer on jbilling-database.xml
I just modified the blog,
You need to change the driver, the url and username and passwords.
Cheers,