You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Run XML through a linter before passing it to Solr #433
Solr has absolutely no tolerance for XML errors. So we need a method of linting all of the XML and creating a blacklist of files with errors. We already have the functionality in ParserController::index_laws() to apply a blacklist, and it works fine, we just need to generate that blacklist.
I'm thinking xmllint. Specifically, xmllint --noout *. Its output isn't totally pure, but I think we can use a regex to extract all of the XML filenames from that list, unique it, and then use that as our blacklist. But I think we'll need to see how common xmllint is. It looks like it's easily installed (e.g., sudo apt-get install libxml2-utils on Ubuntu), but that's going to require more research.
Its a big one. I think it has to do with what I named my core in solr.xml
552 [coreLoadExecutor-3-thread-1] ERROR org.apache.solr.core.CoreContainer ? Unable to create core: statedecoded
org.apache.solr.common.SolrException: Plugin init failure for [schema.xml] fieldType "statedec_facet_hierarchical": Plugin init failure for [schema.xml] analyzer/tokenizer: Error instantiating class: 'org.apache.lucene.analysis.core.KeywordTokenizerFactory'
at org.apache.solr.util.plugin.AbstractPluginLoader.load(AbstractPluginLoader.java:177)
at org.apache.solr.schema.IndexSchema.readSchema(IndexSchema.java:467)
at org.apache.solr.schema.IndexSchema.(IndexSchema.java:164)
at org.apache.solr.schema.IndexSchemaFactory.create(IndexSchemaFactory.java:55)
at org.apache.solr.schema.IndexSchemaFactory.buildIndexSchema(IndexSchemaFactory.java:69)
at org.apache.solr.core.CoreContainer.createFromLocal(CoreContainer.java:619)
at org.apache.solr.core.CoreContainer.create(CoreContainer.java:657)
at org.apache.solr.core.CoreContainer$1.call(CoreContainer.java:364)
at org.apache.solr.core.CoreContainer$1.call(CoreContainer.java:356)
at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:334)
at java.util.concurrent.FutureTask.run(FutureTask.java:166)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)
at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:334)
at java.util.concurrent.FutureTask.run(FutureTask.java:166)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1146)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:679)
Caused by: org.apache.solr.common.SolrException: Plugin init failure for [schema.xml] analyzer/tokenizer: Error instantiating class: 'org.apache.lucene.analysis.core.KeywordTokenizerFactory'
at org.apache.solr.util.plugin.AbstractPluginLoader.load(AbstractPluginLoader.java:177)
at org.apache.solr.schema.FieldTypePluginLoader.readAnalyzer(FieldTypePluginLoader.java:362)
at org.apache.solr.schema.FieldTypePluginLoader.create(FieldTypePluginLoader.java:86)
at org.apache.solr.schema.FieldTypePluginLoader.create(FieldTypePluginLoader.java:43)
at org.apache.solr.util.plugin.AbstractPluginLoader.load(AbstractPluginLoader.java:151)
... 16 more
Caused by: org.apache.solr.common.SolrException: Error instantiating class: 'org.apache.lucene.analysis.core.KeywordTokenizerFactory'
at org.apache.solr.core.SolrResourceLoader.newInstance(SolrResourceLoader.java:556)
at org.apache.solr.schema.FieldTypePluginLoader$2.create(FieldTypePluginLoader.java:342)
at org.apache.solr.schema.FieldTypePluginLoader$2.create(FieldTypePluginLoader.java:335)
at org.apache.solr.util.plugin.AbstractPluginLoader.load(AbstractPluginLoader.java:151)
... 20 more
Caused by: java.lang.reflect.InvocationTargetException
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:532)
at org.apache.solr.core.SolrResourceLoader.newInstance(SolrResourceLoader.java:553)
... 23 more
Caused by: java.lang.IllegalArgumentException: Unknown parameters: {delimiter=~}
at org.apache.lucene.analysis.core.KeywordTokenizerFactory.(KeywordTokenizerFactory.java:41)
... 28 more
I've definitely done something wrong. I've seen this error, when we were working on this the other day. I'll have this solved in a few minutes—I have to look at my notes.
Got it! I never committed three crucial directories. I'm on a train, with an increasingly bad 3G connection, but let's see if I can commit these changes.
Still uploading! If it doesn't work in the next few minutes, If you don't see a commit soon, then it'll be a couple of hours, until I can get home and back to an internet connection. :-/ Once you can sync those changes, though, everything will work great. Thanks for pointing this out!
It kept returning a non-zero status, and I had no idea why. It was really frustrating. It turns out that was wholly accurate—xmllint was reporting that it had found some errors within XML, which is, in fact, a non-zero result. :-/
OK, problem solved. Unfortunately, this requires libxml2-utils, which is yet another prerequisite. I've create a new issue to add a test for it in v1.0, and I'll add that requirement to the documentation now.
Ah, got it. I forgot about the subfolders. I wasn't having any luck using find to generate that list, which would of course have searched recursively, for reasons I never did figure out. But I'll try again—now that I'm directing output to a file, that might work OK.
None of them piped any data to xmllint.txt, but instead sent it right to display. I have no idea of why. Will revisit this for v1.0. In the meantime, the linter runs only if LAW_LONG_URLS is disabled. If it's enabled, then an error is thrown, to alert the user that the XML is being trusted.
After an hour banging away at this, I've figured out the problem. It turns out that this is very much the fault of xmllint. It's writing to stderr, not stdout. xmllint finding errors in XML is not an error, it's a feature. It should be writing to stderr if there's an error with xmllint, not with XML. Anyway, that's why nothing can ever be captured.
The standard solutions to this are ghastly (involving proc_open() and stream_get_contents()), so I'm inclined to just append 2>&1 >/dev/null to the end of the command (redirecting stderr to stdout), and capture that output.
It's too late for me to start adding that code in just now. So, Future Me, here's what you need:
exec('cd downloads/current/code-xml/; find . -type f -exec xmllint --noout '{}' + 2>&1 >/dev/null', $output);
$output = implode("\n", $output);
—
Reply to this email directly or view it on GitHub.
We're no longer feeding XML into Solr so this doesn't matter anyway. I'll keep this open if we want to post-process our XML generation (in which case we should rename the ticket), but otherwise this is no longer an issue.
Well, since Solr is still an option for folks, and since Solr seizes up and dies if there's a single XML error, I think it's best to retain. After I put hours and hours into work into this damned problem, I'll just add in those two lines, test it, and be done with it. :)
Well, since Solr is still an option for folks, and since Solr seizes up and dies if there's a single XML error, I think it's best to retain. After I put hours and hours into work into this damned problem, I'll just add in those two lines, test it, and be done with it. :)
—
Reply to this email directly or view it on GitHub.
Activity
NSkelsey commentedon Oct 4, 2013
Have you committed your local changes of OSC solr_home into UI? I am running into XML errors when I use it as the solr_home.
waldoj commentedon Oct 4, 2013
I sure have. Are the XML errors when you're importing Virginia's XML files?
NSkelsey commentedon Oct 4, 2013
Ah, no. Just on startup
waldoj commentedon Oct 4, 2013
Whoa. Mind pasting in the error you're getting?
NSkelsey commentedon Oct 4, 2013
Its a big one. I think it has to do with what I named my core in solr.xml
552 [coreLoadExecutor-3-thread-1] ERROR org.apache.solr.core.CoreContainer ? Unable to create core: statedecoded
org.apache.solr.common.SolrException: Plugin init failure for [schema.xml] fieldType "statedec_facet_hierarchical": Plugin init failure for [schema.xml] analyzer/tokenizer: Error instantiating class: 'org.apache.lucene.analysis.core.KeywordTokenizerFactory'
at org.apache.solr.util.plugin.AbstractPluginLoader.load(AbstractPluginLoader.java:177)
at org.apache.solr.schema.IndexSchema.readSchema(IndexSchema.java:467)
at org.apache.solr.schema.IndexSchema.(IndexSchema.java:164)
at org.apache.solr.schema.IndexSchemaFactory.create(IndexSchemaFactory.java:55)
at org.apache.solr.schema.IndexSchemaFactory.buildIndexSchema(IndexSchemaFactory.java:69)
at org.apache.solr.core.CoreContainer.createFromLocal(CoreContainer.java:619)
at org.apache.solr.core.CoreContainer.create(CoreContainer.java:657)
at org.apache.solr.core.CoreContainer$1.call(CoreContainer.java:364)
at org.apache.solr.core.CoreContainer$1.call(CoreContainer.java:356)
at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:334)
at java.util.concurrent.FutureTask.run(FutureTask.java:166)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)
at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:334)
at java.util.concurrent.FutureTask.run(FutureTask.java:166)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1146)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:679)
Caused by: org.apache.solr.common.SolrException: Plugin init failure for [schema.xml] analyzer/tokenizer: Error instantiating class: 'org.apache.lucene.analysis.core.KeywordTokenizerFactory'
at org.apache.solr.util.plugin.AbstractPluginLoader.load(AbstractPluginLoader.java:177)
at org.apache.solr.schema.FieldTypePluginLoader.readAnalyzer(FieldTypePluginLoader.java:362)
at org.apache.solr.schema.FieldTypePluginLoader.create(FieldTypePluginLoader.java:86)
at org.apache.solr.schema.FieldTypePluginLoader.create(FieldTypePluginLoader.java:43)
at org.apache.solr.util.plugin.AbstractPluginLoader.load(AbstractPluginLoader.java:151)
... 16 more
Caused by: org.apache.solr.common.SolrException: Error instantiating class: 'org.apache.lucene.analysis.core.KeywordTokenizerFactory'
at org.apache.solr.core.SolrResourceLoader.newInstance(SolrResourceLoader.java:556)
at org.apache.solr.schema.FieldTypePluginLoader$2.create(FieldTypePluginLoader.java:342)
at org.apache.solr.schema.FieldTypePluginLoader$2.create(FieldTypePluginLoader.java:335)
at org.apache.solr.util.plugin.AbstractPluginLoader.load(AbstractPluginLoader.java:151)
... 20 more
Caused by: java.lang.reflect.InvocationTargetException
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:532)
at org.apache.solr.core.SolrResourceLoader.newInstance(SolrResourceLoader.java:553)
... 23 more
Caused by: java.lang.IllegalArgumentException: Unknown parameters: {delimiter=~}
at org.apache.lucene.analysis.core.KeywordTokenizerFactory.(KeywordTokenizerFactory.java:41)
... 28 more
waldoj commentedon Oct 4, 2013
I've definitely done something wrong. I've seen this error, when we were working on this the other day. I'll have this solved in a few minutes—I have to look at my notes.
waldoj commentedon Oct 4, 2013
Got it! I never committed three crucial directories. I'm on a train, with an increasingly bad 3G connection, but let's see if I can commit these changes.
waldoj commentedon Oct 4, 2013
Still uploading! If it doesn't work in the next few minutes, If you don't see a commit soon, then it'll be a couple of hours, until I can get home and back to an internet connection. :-/ Once you can sync those changes, though, everything will work great. Thanks for pointing this out!
waldoj commentedon Oct 5, 2013
Good Lord, that took forever. All set.
NSkelsey commentedon Oct 5, 2013
The commit solved my issue, thanks!
waldoj commentedon Nov 1, 2013
Returning to the issue, I think we'll want to use this:
Replace thin space entities with Unicode thin spaces
waldoj commentedon Nov 5, 2013
I fought and fought with this:
It kept returning a non-zero status, and I had no idea why. It was really frustrating. It turns out that was wholly accurate—
xmllintwas reporting that it had found some errors within XML, which is, in fact, a non-zero result. :-/Run all XML through a linter, and omit invalid XML from Solr
waldoj commentedon Nov 5, 2013
OK, problem solved. Unfortunately, this requires libxml2-utils, which is yet another prerequisite. I've create a new issue to add a test for it in v1.0, and I'll add that requirement to the documentation now.
16 remaining items
waldoj commentedon Nov 8, 2013
Ah, got it. I forgot about the subfolders. I wasn't having any luck using
findto generate that list, which would of course have searched recursively, for reasons I never did figure out. But I'll try again—now that I'm directing output to a file, that might work OK.waldoj commentedon Nov 11, 2013
I'm going to pipe this through
findandxargsand see if that fixes things. If so, I'll include this fix in today's v0.8 release.waldoj commentedon Nov 11, 2013
Nope. I tried all of these:
None of them piped any data to
xmllint.txt, but instead sent it right to display. I have no idea of why. Will revisit this for v1.0. In the meantime, the linter runs only if LAW_LONG_URLS is disabled. If it's enabled, then an error is thrown, to alert the user that the XML is being trusted.Only validate XML if LAW_LONG_URLS is disabled
Remove old invalid XML handler
Count XML errors more gracefully
waldoj commentedon Apr 18, 2014
This is infuriating and mystifying. Even this doesn't work:
The data is sent directly to the browser, rather than being intercepted and stored within
$output. How? I don't know. Witchcraft?It's appalling how much time I've spent on this.
waldoj commentedon Dec 22, 2014
After an hour banging away at this, I've figured out the problem. It turns out that this is very much the fault of xmllint. It's writing to
stderr, notstdout. xmllint finding errors in XML is not an error, it's a feature. It should be writing tostderrif there's an error withxmllint, not with XML. Anyway, that's why nothing can ever be captured.The standard solutions to this are ghastly (involving
proc_open()andstream_get_contents()), so I'm inclined to just append2>&1 >/dev/nullto the end of the command (redirectingstderrtostdout), and capture that output.waldoj commentedon Dec 22, 2014
It's too late for me to start adding that code in just now. So, Future Me, here's what you need:
krusynth commentedon Dec 22, 2014
Oh I also figured out how to handle nested folders with XML lint; I'll post that when I get back.
krusynth commentedon May 2, 2015
We're no longer feeding XML into Solr so this doesn't matter anyway. I'll keep this open if we want to post-process our XML generation (in which case we should rename the ticket), but otherwise this is no longer an issue.
waldoj commentedon May 2, 2015
Well, since Solr is still an option for folks, and since Solr seizes up and dies if there's a single XML error, I think it's best to retain. After I put hours and hours into work into this damned problem, I'll just add in those two lines, test it, and be done with it. :)
krusynth commentedon May 2, 2015
Nono, we're using Solarium, not ingesting XML. So this isn't relevant anymore.
waldoj commentedon May 3, 2015
I missed this memo. Huzzah!