How to get metrics using jolokia module?


I want to get some metrics from an application that is run using tomcat. I've configured jolokia module as follows:

- module: jolokia
  metricsets: ["jmx"]
  enabled: true
  period: 5s
    app: jmx
  hosts: [""]
  namespace: "databaseconnectionpool"
  path: "/jolokia/?ignoreErrors=true&canonicalNaming=false"
#    - mbean: 'com.jolbox.bonecp:type=BoneCP'
    - mbean: 'com.jolbox.bonecp:name=BoneCP'
        - attr: TotalCreatedConnections
          field: TotalCreatedConnections
        - attr: TotalFree
          field: TotalFree
        - attr: TotalLeased
          field: TotalLeased

but in error.message field I get this error:

error making http request: Post dial tcp connect: connection refused

I can see the BoneCP mbean using jvisualvm without setting any port for jmx neither in application nor in jvisualvm to connect to the application. As far as I know jolokia is a tool for jmx over http but don't know if it is for export or for import or for both. If it exports jmx over http I think I should add it to the classpath of the application and specify a port for it. If so, why the port was not specified in example configuration of the elastic guide docs?

How can I get it working?