52North / OpenSensorSearch

Open Sensor Search is a platform for sensor discovery across all sensor web supporting major specifications (OGC SWE) and popular IoT websites (Xively, Thingspeak, ...).
Apache License 2.0
13 stars 12 forks source link

Failed to compile stylesheet. 1 error detected #30

Open nuest opened 10 years ago

nuest commented 10 years ago

java.util.concurrent.ExecutionException: javax.xml.transform.TransformerConfigurationException: Failed to compile stylesheet. 1 error detected.

Reported here: http://sensorweb.forum.52north.org/SIR-Servlet-tp4026964p4027098.html

Approach: Catch the full Saxon error output message (if not done already).

Ideas:

nuest commented 10 years ago

The method doing the validation is already synchronized

private synchronized ValidationResult actualValidate(SensorMLDocument smlDoc) throws IOException {

nuest commented 10 years ago

Report by John

One of the links you sent was someone having problems related to their Windows file path containing a space. I've simplified my tomcat path which had dots and dashes in it to /srv/tomcat but this hasn't fixed the problem.

I've also checked the file permissions: -rw-r--r--. 1 tomcat tomcat 44804 Mar 13 20:45 /srv/tomcat/temp/SensorML_Profile_for_Discovery.sch.xsl

Was a long shot anyway > spaces in path and rights are not an issue.

nuest commented 10 years ago

You mentioned concurrency in a previous message. The service appears to be generating the .sch.xsl file multiple times and at the same time. It seems to run into some corruption such as finding a non-closed XML tag but this varies. After the capture below, I looked in the process list and found that a Java process was still running for the old Tomcat path (despite me running shutdown.sh before moving it). So I shut Tomcat down and made sure no processes were left over and ran another test.

First capture:

20:45:33.746 [pool-4-thread-1] INFO  SensorML4DiscoveryValidatorImpl -
Created XSL file for validation:
/srv/tomcat/temp/SensorML_Profile_for_Discovery.sch.xsl
20:45:33.747 [pool-4-thread-1] DEBUG SensorML4DiscoveryValidatorImpl -
Creating transformer...
20:45:34.062 [pool-5-thread-1] INFO  SensorML4DiscoveryValidatorImpl -
Created XSL file for validation:
/srv/tomcat/temp/SensorML_Profile_for_Discovery.sch.xsl
20:45:34.062 [pool-5-thread-1] DEBUG SensorML4DiscoveryValidatorImpl -
Creating transformer...
Error on line 555 column 15 of SensorML_Profile_for_Discovery.sch.xsl:
  SXXP0003: Error reported by XML parser: The element type
"svrl:failed-assert" must be
  terminated by the matching end-tag "</svrl:failed-assert>".
20:45:34.189 [pool-4-thread-1] DEBUG SensorML4DiscoveryValidatorImpl -
Created net.sf.saxon.Controller@5b4ad2e2
20:45:34.272 [pool-6-thread-1] INFO  SensorML4DiscoveryValidatorImpl -
Created XSL file for validation:
/srv/tomcat/temp/SensorML_Profile_for_Discovery.sch.xsl
20:45:34.272 [pool-6-thread-1] DEBUG SensorML4DiscoveryValidatorImpl -
Creating transformer...
20:45:34.298 [pool-7-thread-1] INFO  SensorML4DiscoveryValidatorImpl -
Created XSL file for validation:
/srv/tomcat/temp/SensorML_Profile_for_Discovery.sch.xsl
20:45:34.298 [pool-7-thread-1] DEBUG SensorML4DiscoveryValidatorImpl -
Creating transformer...
20:45:34.303 [pool-9-thread-1] INFO  SensorML4DiscoveryValidatorImpl -
Created XSL file for validation:
/srv/tomcat/temp/SensorML_Profile_for_Discovery.sch.xsl
20:45:34.303 [pool-9-thread-1] DEBUG SensorML4DiscoveryValidatorImpl -
Creating transformer...
20:45:34.304 [pool-10-thread-1] INFO  SensorML4DiscoveryValidatorImpl -
Created XSL file for validation:
/srv/tomcat/temp/SensorML_Profile_for_Discovery.sch.xsl
20:45:34.304 [pool-10-thread-1] DEBUG SensorML4DiscoveryValidatorImpl -
Creating transformer...
20:45:34.680 [pool-10-thread-1] DEBUG SensorML4DiscoveryValidatorImpl -
Created net.sf.saxon.Controller@e139e3e
20:45:34.724 [pool-9-thread-1] DEBUG SensorML4DiscoveryValidatorImpl -
Created net.sf.saxon.Controller@29f9ffaa
20:45:34.725 [pool-6-thread-1] DEBUG SensorML4DiscoveryValidatorImpl -
Created net.sf.saxon.Controller@2eedaaf4
20:45:34.750 [pool-7-thread-1] DEBUG SensorML4DiscoveryValidatorImpl -
Created net.sf.saxon.Controller@7206eb38

After starting Tomcat again, I see a similar thing but get a different random XML error:

21:48:52.913 [http-bio-8080-exec-7] DEBUG HarvestServiceListener - Start
harvest SOS: http://192.168.140.20:8080/52nSOSv3.5.0/sos
Warning: at xsl:stylesheet on line 150 column 2 of iso_svrl_for_xslt2.xsl:
  Running an XSLT 1 stylesheet with an XSLT 2 processor
21:48:52.922 [pool-8-thread-1] DEBUG SOSServiceHarvester - Call()!
Warning: at xsl:stylesheet on line 150 column 2 of iso_svrl_for_xslt2.xsl:
  Running an XSLT 1 stylesheet with an XSLT 2 processor
21:48:53.063 [pool-8-thread-1] DEBUG Client - GetCapabilities to be send to
SOS @ http://192.168.140.20:8080/52nSOSv3.5.0/sos : <ns:GetCapabilities
service="SOS" xmlns:ns="http://www.opengi
s.net/sos/1.0"><ns1:AcceptVersions
xmlns:ns1="http://www.opengis.net/ows/1.1"><ns1:Version>1.0.0</ns1:Version></ns1:AcceptVersions></ns:GetCapabilities>
21:48:53.064 [pool-8-thread-1] DEBUG Client - Sending request (first 100
characters): <ns:GetCapabilities service="SOS"
xmlns:ns="http://www.opengis.net/sos/1.0"><ns1:AcceptVersions xmln
21:48:53.170 [pool-8-thread-1] DEBUG Client - Client connecting via POST to
http://192.168.140.20:8080/52nSOSv3.5.0/sos
21:48:53.328 [pool-4-thread-1] INFO  SensorML4DiscoveryValidatorImpl -
Created XSL file for validation:
/srv/tomcat/temp/SensorML_Profile_for_Discovery.sch.xsl
21:48:53.328 [pool-4-thread-1] DEBUG SensorML4DiscoveryValidatorImpl -
Creating transformer...
21:48:53.699 [pool-6-thread-1] INFO  SensorML4DiscoveryValidatorImpl -
Created XSL file for validation:
/srv/tomcat/temp/SensorML_Profile_for_Discovery.sch.xsl
21:48:53.699 [pool-6-thread-1] DEBUG SensorML4DiscoveryValidatorImpl -
Creating transformer...
21:48:53.787 [pool-5-thread-1] INFO  SensorML4DiscoveryValidatorImpl -
Created XSL file for validation:
/srv/tomcat/temp/SensorML_Profile_for_Discovery.sch.xsl
21:48:53.788 [pool-5-thread-1] DEBUG SensorML4DiscoveryValidatorImpl -
Creating transformer...
21:48:53.798 [pool-4-thread-1] DEBUG SensorML4DiscoveryValidatorImpl -
Created net.sf.saxon.Controller@1454e9a7
Error on line 95 column 21 of SensorML_Profile_for_Discovery.sch.xsl:
  SXXP0003: Error reported by XML parser: An invalid XML character (Unicode:
0x0) was found
  in the value of attribute &quot;test&quot; and element is
&quot;xsl:if&quot;.
21:48:53.885 [pool-9-thread-1] INFO  SensorML4DiscoveryValidatorImpl -
Created XSL file for validation:
/srv/tomcat/temp/SensorML_Profile_for_Discovery.sch.xsl
21:48:53.885 [pool-9-thread-1] DEBUG SensorML4DiscoveryValidatorImpl -
Creating transformer...
21:48:53.971 [pool-10-thread-1] INFO  SensorML4DiscoveryValidatorImpl -
Created XSL file for validation:
/srv/tomcat/temp/SensorML_Profile_for_Discovery.sch.xsl
21:48:53.971 [pool-10-thread-1] DEBUG SensorML4DiscoveryValidatorImpl -
Creating transformer...
21:48:53.996 [pool-7-thread-1] INFO  SensorML4DiscoveryValidatorImpl -
Created XSL file for validation:
/srv/tomcat/temp/SensorML_Profile_for_Discovery.sch.xsl
21:48:53.996 [pool-7-thread-1] DEBUG SensorML4DiscoveryValidatorImpl -
Creating transformer...
21:48:54.042 [pool-6-thread-1] DEBUG SensorML4DiscoveryValidatorImpl -
Created net.sf.saxon.Controller@1da7cb5d
21:48:54.049 [pool-8-thread-1] DEBUG PGSQLHarvestServiceDAO - >>>Database
Query: INSERT INTO service (service_url,service_type) SELECT
'http://192.168.140.20:8080/52nSOSv3.5.0/sos','SOS' WH
E

I suspect the poor file system performance of my virtual machine is flushing out this race condition type problem, which would fit with your experience of seeing it intermittently.

Sounds like a very reasonable explanation to me!

Is this file intended to be generated for every sensor being harvested? If so, what measures are supposed to be in place to prevent collisions. Would creating it with a random name such as a uuid help?

The file should only be created once, adding a random component to the name could be a workaround.

nuest commented 10 years ago

This problem might have been introduced when injecting the validator instead of having my own singleton.

Idea: while the initialize method in SensorML4DiscoveryValidatorImpl is only called in the constructor, the actual class might be injected several times (it is not a singleton). Approaches

nuest commented 10 years ago

random component in filename implement in https://github.com/nuest/OpenSensorSearch/commit/ace64a019321cf40f43e960f9d03654f18da0338

However, this now creates the file for every validation, which is a performance issue (and clutters the temp directory) and if this fixed the problem the XSL file generation should be encapsulated in a provider.