audit4j-db config failure for external db (needs dataSource, but can't read it from config)

52 views
Skip to first unread message

River Hume

unread,
Jan 11, 2019, 6:34:57 PM1/11/19
to Audit4j
Hello,

I am trying to use the DatabaseAuditHandler and hoping to use a postgres dataSource but am having difficulty getting the config to work.
I am specifying embedded=false (w/ type, driver, url, user, pass) in my conf, which seems to properly disable the embedded db, invoking hikari.HikariConfig.validate, which fails as follows:

Exception... Caused by: java.lang.IllegalArgumentException: either dataSource or dataSourceClassName is required
    at com.zaxxer.hikari.HikariConfig.validate

Note: documentation makes no mention of this parameter that I can find. Also note, docs still specify the parameter as 'embeded' instead of 'embedded'.


So I tried adding this to config:
  dataSource: org.postgres.ds.PGPoolingDataSource

...but then it fails like this:
  Unable to find property 'dataSource' on class: org.audit4j.handler.db.DatabaseAuditHandler       

If I am inferring correctly, this should be the correct parameter, as the setter method in DatabaseAuditHandler.java is defined as 'setDataSource(...)'


I also tried the following parameters in config in place of 'dataSource' with the same results (Unable to find property '...' on class: org.audit4j.handler.db.DatabaseAuditHandler)
   db_datasourceClass (matches setDb_datasourceClass method in DatabaseAuditHandler.java), dataSourceClassName, db_dataSource, db_dataSourceClass, etc...

  
I DID notice that there are no GET methods defined for either dataSource or db_datasourceClass... OR for the 'separate' parameter for that matter, so I tried setting 'separate: true' in cfg (a feature I had hoped to use anyway, and WOW I get the same error as for trying to set the datasource:

  Unable to find property 'separate' on class: org.audit4j.handler.db.DatabaseAuditHandler

... leading me to suspect that the config loader needs these getters defined to see the params as setable (all other configurable params appear to have setters)? Does this sound right? Any other leads?

Note: using both audit4j-core & audit4j-db version 2.5.0 (same results when using 2.4.1 for both) with no other plugins, no aspectj or annotations. I have successfully integrated audit4j otherwise, and have working console & file handlers, but will need db handler for production.

Thanks In Advance!
River Hume

River Hume

unread,
Jan 22, 2019, 9:40:01 PM1/22/19
to Audit4j
SOLVED:

Problem was wrong config parameter - the docs fail to specify how to correctly set the datasource. Correct parameter is:
  db_datasourceClass: org.postgresql.ds.PGSimpleDataSource

Works great now! :)

Please update the docs, Thanks!
Reply all
Reply to author
Forward
0 new messages