'Error during trigger prepare'

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view

'Error during trigger prepare'

Tony Graham
I have two eXist-db 3.0 instances on two different machines. I develop
on one and test the .xar on the other just in case my thrashing around
while getting things to work allowed something to work that won't work
from a straight install of the .xar file. As it turns out...

I have a main 'digest_vs_reports.xml' XML file with 17,000 summaries of
test results in it. In an effort to speed-up producing HTML from this, I
pre-compute some per-test values that are used in generating the HTML
and update the per-test element with additional attributes. The update
happens in a trigger function. This works fine on the development
machine but produces a stack trace on the test machine.

Is it possible to get a dump of the triggers that are configured for a
collection so that I can see what the differences are between the two
machines? They are supposed to have identical configurations, but it
seems like they don't.

There's nothing about triggers in the 'exist.log' on the development
machine, but on the test machine, storing a new 'digest_vs_reports.xml'

2017-03-20 22:26:03,147 [qtp46760312-54] INFO  (NativeBroker.java
[removeXMLResource]:2707) - Removing document digest_vs_reports.xml
(36277) ...

2017-03-20 22:26:03,191 [qtp46760312-54] WARN  (TransactionManager.java
[close]:186) - Transaction was not committed or aborted, auto aborting!

2017-03-20 22:26:03,192 [qtp46760312-54] ERROR (DocumentTriggers.java
[afterUpdateDocument]:256) - Error during trigger prepare

org.exist.collections.triggers.TriggerException: Error during trigger

The <triggers> section of 'collection.xconf' for '/db/ahrts-data' (where
the 'collection.xconf' is copied to '/db/system/config/db/ahrts-data' in
the 'post-install.xql' of the 'ahrts' package) is:

         <trigger class="org.exist.collections.triggers.XQueryTrigger">
             <parameter name="url"

where 'triggers.xqm' is based on the example in the docs and contains:

xquery version "3.1";

     A simple XQuery for an XQueryTrigger that
     logs all trigger events for which it is executed
     in the file /db/triggers-log.xml
module namespace trigger="http://exist-db.org/xquery/trigger";
import module namespace common = "elided/common"
     at "common.xqm";
declare namespace xmldb="http://exist-db.org/xquery/xmldb";

declare function trigger:after-create-document($uri as xs:anyURI) {
     if (ends-with($uri, '/digest_vs_reports.xml'))
         then (local:log-event("after", "create", "document", $uri),
     else ()

declare function trigger:after-update-document($uri as xs:anyURI) {
     if (ends-with($uri, '/digest_vs_reports.xml'))
         then (local:log-event("after", "update", "document", $uri),
     else ()

declare function local:log-event($type as xs:string, $event as
xs:string, $object-type as xs:string, $uri as xs:string) {
     let $log-collection := "/db"
     let $log := "triggers-log.xml"
     let $log-uri := concat($log-collection, "/", $log)
         (: create the log file if it does not exist :)
         if (not(doc-available($log-uri))) then
             xmldb:store($log-collection, $log, <triggers/>)
         else ()
         (: log the trigger details to the log file :)
         update insert <trigger event="{string-join(($type, $event,
$object-type), "-")}" uri="{$uri}" timestamp="{current-dateTime()}"/>
into doc($log-uri)/triggers

There is no <trigger> log element for the trigger that produces the
stack trace.

'common:add-error-class()' does the actual work.

If I edit a 'digest_vs_reports.xml' document on the test machine using
eXide (e.g., add and remove a space just so eXide thinks it's changed
and will save it), then the trigger runs on the test machine. It's
seemingly only storing the document that has problems.


Tony Graham.
Senior Architect
XML Division
Antenna House, Inc.
Skerries, Ireland
[hidden email]

Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
Exist-open mailing list
[hidden email]