AtlasOfLivingAustralia / logger-service

Atlas event logging
https://logger.ala.org.au
1 stars 8 forks source link

logger POSTs not working - ReadOnlyPropertyException #7

Closed djtfmartin closed 9 years ago

djtfmartin commented 9 years ago

The logging is currently broken and there havent been any log events since April. Im not sure whats caused this as the software hasnt been updated since March.

This is the exception in the logs:

2015-05-20 00:14:46,182 ERROR [GrailsExceptionResolver] ReadOnlyPropertyException occurred when processing request: [POST] /service/logger/
Cannot set readonly property: class for class: org.ala.client.model.LogEventVO. Stacktrace follows:
groovy.lang.ReadOnlyPropertyException: Cannot set readonly property: class for class: org.ala.client.model.LogEventVO
    at au.org.ala.logger.LoggerController.save(LoggerController.groovy:34)
    at grails.plugin.cache.web.filter.PageFragmentCachingFilter.doFilter(PageFragmentCachingFilter.java:198)
    at grails.plugin.cache.web.filter.AbstractFilter.doFilter(AbstractFilter.java:63)
    at au.org.ala.cas.client.UriFilter.doFilter(UriFilter.java:200)
    at au.org.ala.cas.client.UriFilter.doFilter(UriFilter.java:200)
    at au.org.ala.cas.client.UriFilter.doFilter(UriFilter.java:200)
    at org.jasig.cas.client.session.SingleSignOutFilter.doFilter(SingleSignOutFilter.java:65)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
    at java.lang.Thread.run(Thread.java:745)

cc @nickdos

m-r-c commented 9 years ago

The problem is this line: LogEventVO incomingLog = new LogEventVO(request.getJSON());

The incoming JSON must have a 'class' attribute in it. That would explain why it suddenly stopped working: the client changed what is being sent.

I have put in a simple check to ignore a 'class' attribute in the incoming JSON.

djtfmartin commented 9 years ago

This is odd. The biocache webservices (the client) havent been updated since November 2014. Similarly, the logger services hadnt changed since March.

m-r-c commented 9 years ago

Hmm, that's very odd.

I have deployed the updated version, and it's still failing at the same point but with a different error:

No such property: lastUpdated for class: org.ala.client.model.LogEventVO. Stacktrace follows: groovy.lang.MissingPropertyException: No such property: lastUpdated for class: org.ala.client.model.LogEventVO

I'll keep digging.

m-r-c commented 9 years ago

OK, it looks like the invalid requests are coming from ala-downloads, which is using an old version of the logger client jar (1.0-SNAPSHOT, 1.2 is the current) and is just dumping its LogEvent entity into the log as JSON instead of constructing the logger client's LogEventVO object. There are requests from the biocache service which are correctly formatted (it's using logger client 1.2 and constructs the LogEventVO).

This is from downloads:

{
  "class": "au.org.ala.downloads.LogEvent",
  "id": 137,
  "comment": "",
  "dateCreated": "2015-05-20T09:47:23Z",
  "eventTypeId": 1002,
  "lastUpdated": "2015-05-20T09:47:23Z",
  "month": null,
  "reasonTypeId": 0,
  "recordCounts": {
    ...
    "dr570": "696511",
    "dr571": "2520423",
    "dr473": "462",
    "dr1984": "566"
  },
  "sourceTypeId": 0,
  "sourceUrl": "http://biocache.ala.org.au/archives/exports/aves_brief/aves.zip",
  "userEmail": "...",
  "userIP": "..."
}

This is from biocache:

{
  "recordCounts": {
    "dp36": 1,
    "in21": 1,
    "co55": 1
  },
  "userIP": "...",
  "eventTypeId": 1000,
  "userEmail": "",
  "comment": "Viewing Occurrence Record e64bae33-7e32-4cd7-b15c-e4e72239bbe2",
  "month": ""
}

I have updated the logger service to ignore any attribute that is not a property of the LogEventVO class. We should probably also change downloads to construct the correct object like biocache-service does.