Solr Tika XPath Exception - xpath

I'm trying to index an HTML document using Apache Solr and the TikaEntityProcessor, with the idea being that I can use XPath to select specific elements from the HTML.
I have followed the advanced example shown at the bottom of the TikaEntityProcessor Solr Wiki page.
When I try to complete a data import command, I receive the following error message(s):
03-Oct-2012 16:39:48 org.apache.solr.handler.dataimport.DataImporter doFullImport
INFO: Starting Full Import
03-Oct-2012 16:39:48 org.apache.solr.core.SolrCore execute
INFO: [htmlTest] webapp=/apache-solr-3.6.1 path=/dataimport params={command=full-import} status=0 QTime=31
03-Oct-2012 16:39:48 org.apache.solr.handler.dataimport.SimplePropertiesWriter readIndexerProperties
INFO: Read dataimport.properties
03-Oct-2012 16:39:48 org.apache.solr.update.DirectUpdateHandler2 deleteAll
INFO: [htmlTest] REMOVING ALL DOCUMENTS FROM INDEX
03-Oct-2012 16:39:48 org.apache.solr.core.SolrDeletionPolicy onInit
INFO: SolrDeletionPolicy.onInit: commits:num=1
commit{dir=C:\Program Files\Apache Tomcat\conf\apache-solr-3.5.0\htmlTest\data\index,segFN=segments_1e,version=1349187077567,generation=50,filenames=[_u.fnm, _u.nrm, _u.tis, _u.prx, _u.frq, _u.fdx, _u.fdt, _u.tii, segments_1e]
03-Oct-2012 16:39:48 org.apache.solr.core.SolrDeletionPolicy updateCommits
INFO: newest commit = 1349187077567
03-Oct-2012 16:39:48 org.apache.solr.handler.dataimport.SqlEntityProcessor initQuery
SEVERE: The query failed 'null'
java.lang.NullPointerException
at java.io.File.<init>(File.java:222)
at org.apache.solr.handler.dataimport.FileDataSource.getFile(FileDataSource.java:96)
at org.apache.solr.handler.dataimport.BinFileDataSource.getData(BinFileDataSource.java:53)
at org.apache.solr.handler.dataimport.BinFileDataSource.getData(BinFileDataSource.java:44)
at org.apache.solr.handler.dataimport.SqlEntityProcessor.initQuery(SqlEntityProcessor.java:59)
at org.apache.solr.handler.dataimport.SqlEntityProcessor.nextRow(SqlEntityProcessor.java:73)
at org.apache.solr.handler.dataimport.EntityProcessorWrapper.pullRow(EntityProcessorWrapper.java:330)
at org.apache.solr.handler.dataimport.EntityProcessorWrapper.nextRow(EntityProcessorWrapper.java:296)
at org.apache.solr.handler.dataimport.DocBuilder.buildDocument(DocBuilder.java:683)
at org.apache.solr.handler.dataimport.DocBuilder.buildDocument(DocBuilder.java:709)
at org.apache.solr.handler.dataimport.DocBuilder.buildDocument(DocBuilder.java:619)
at org.apache.solr.handler.dataimport.DocBuilder.doFullDump(DocBuilder.java:327)
at org.apache.solr.handler.dataimport.DocBuilder.execute(DocBuilder.java:225)
at org.apache.solr.handler.dataimport.DataImporter.doFullImport(DataImporter.java:375)
at org.apache.solr.handler.dataimport.DataImporter.runCmd(DataImporter.java:445)
at org.apache.solr.handler.dataimport.DataImporter$1.run(DataImporter.java:426)
03-Oct-2012 16:39:48 org.apache.solr.common.SolrException log
SEVERE: Exception while processing: tika-test document : SolrInputDocument[{text=text(1.0)={<html>
<meta name="Content-Encoding" content="ISO-8859-1">
<meta name="Content-Type" content="text/html">
<title></title>
<body>
<h1>This is my first heading</h1>
This is some content
<h1>This is my second heading</h1>
This is some more content
</body></html>}}]:org.apache.solr.handler.dataimport.DataImportHandlerException: java.lang.NullPointerException
at org.apache.solr.handler.dataimport.SqlEntityProcessor.initQuery(SqlEntityProcessor.java:65)
at org.apache.solr.handler.dataimport.SqlEntityProcessor.nextRow(SqlEntityProcessor.java:73)
at org.apache.solr.handler.dataimport.EntityProcessorWrapper.pullRow(EntityProcessorWrapper.java:330)
at org.apache.solr.handler.dataimport.EntityProcessorWrapper.nextRow(EntityProcessorWrapper.java:296)
at org.apache.solr.handler.dataimport.DocBuilder.buildDocument(DocBuilder.java:683)
at org.apache.solr.handler.dataimport.DocBuilder.buildDocument(DocBuilder.java:709)
at org.apache.solr.handler.dataimport.DocBuilder.buildDocument(DocBuilder.java:619)
at org.apache.solr.handler.dataimport.DocBuilder.doFullDump(DocBuilder.java:327)
at org.apache.solr.handler.dataimport.DocBuilder.execute(DocBuilder.java:225)
at org.apache.solr.handler.dataimport.DataImporter.doFullImport(DataImporter.java:375)
at org.apache.solr.handler.dataimport.DataImporter.runCmd(DataImporter.java:445)
at org.apache.solr.handler.dataimport.DataImporter$1.run(DataImporter.java:426)
Caused by: java.lang.NullPointerException
at java.io.File.<init>(File.java:222)
at org.apache.solr.handler.dataimport.FileDataSource.getFile(FileDataSource.java:96)
at org.apache.solr.handler.dataimport.BinFileDataSource.getData(BinFileDataSource.java:53)
at org.apache.solr.handler.dataimport.BinFileDataSource.getData(BinFileDataSource.java:44)
at org.apache.solr.handler.dataimport.SqlEntityProcessor.initQuery(SqlEntityProcessor.java:59)
... 11 more
03-Oct-2012 16:39:48 org.apache.solr.update.processor.LogUpdateProcessor finish
INFO: {deleteByQuery=*:*} 0 31
03-Oct-2012 16:39:48 org.apache.solr.common.SolrException log
SEVERE: Full Import failed:java.lang.RuntimeException: java.lang.RuntimeException: org.apache.solr.handler.dataimport.DataImportHandlerException: java.lang.NullPointerException
at org.apache.solr.handler.dataimport.DocBuilder.execute(DocBuilder.java:264)
at org.apache.solr.handler.dataimport.DataImporter.doFullImport(DataImporter.java:375)
at org.apache.solr.handler.dataimport.DataImporter.runCmd(DataImporter.java:445)
at org.apache.solr.handler.dataimport.DataImporter$1.run(DataImporter.java:426)
Caused by: java.lang.RuntimeException: org.apache.solr.handler.dataimport.DataImportHandlerException: java.lang.NullPointerException
at org.apache.solr.handler.dataimport.DocBuilder.buildDocument(DocBuilder.java:621)
at org.apache.solr.handler.dataimport.DocBuilder.doFullDump(DocBuilder.java:327)
at org.apache.solr.handler.dataimport.DocBuilder.execute(DocBuilder.java:225)
... 3 more
Caused by: org.apache.solr.handler.dataimport.DataImportHandlerException: java.lang.NullPointerException
at org.apache.solr.handler.dataimport.SqlEntityProcessor.initQuery(SqlEntityProcessor.java:65)
at org.apache.solr.handler.dataimport.SqlEntityProcessor.nextRow(SqlEntityProcessor.java:73)
at org.apache.solr.handler.dataimport.EntityProcessorWrapper.pullRow(EntityProcessorWrapper.java:330)
at org.apache.solr.handler.dataimport.EntityProcessorWrapper.nextRow(EntityProcessorWrapper.java:296)
at org.apache.solr.handler.dataimport.DocBuilder.buildDocument(DocBuilder.java:683)
at org.apache.solr.handler.dataimport.DocBuilder.buildDocument(DocBuilder.java:709)
at org.apache.solr.handler.dataimport.DocBuilder.buildDocument(DocBuilder.java:619)
... 5 more
Caused by: java.lang.NullPointerException
at java.io.File.<init>(File.java:222)
at org.apache.solr.handler.dataimport.FileDataSource.getFile(FileDataSource.java:96)
at org.apache.solr.handler.dataimport.BinFileDataSource.getData(BinFileDataSource.java:53)
at org.apache.solr.handler.dataimport.BinFileDataSource.getData(BinFileDataSource.java:44)
at org.apache.solr.handler.dataimport.SqlEntityProcessor.initQuery(SqlEntityProcessor.java:59)
... 11 more
03-Oct-2012 16:39:48 org.apache.solr.update.DirectUpdateHandler2 rollback
INFO: start rollback
03-Oct-2012 16:39:48 org.apache.solr.update.DirectUpdateHandler2 rollback
INFO: end_rollback
My data import configuration is:
<dataConfig>
<dataSource type="BinFileDataSource"/>
<dataSource type="FieldReaderDataSource" name="fld"/>
<document>
<entity name="tika-test" processor="TikaEntityProcessor"
url="C:/Program Files/Apache Tomcat/conf/apache-solr-3.5.0/htmlTest/data/html_basic.html" format="html">
<field column="text"/>
<entity type="XPathEntityProcessor" forEach="/html" dataField="text">
<field xpath="//h1" column="date" />
</entity>
</entity>
</document>
</dataConfig>
And the HTML document Solr is indexing is:
<html>
<head>
</head>
<body>
<h1>This is my first heading</h1>
<div>
This is some content
</div>
<h1>This is my second heading</h1>
<div>
This is some more content
</div>
</body>

You seem to be missing a reference to the right data source. It needs to be an attribute on entity called dateSource which matches attribute name on the datasource definition itself. You seem to have defined the name fld but did not reference it.
I recommend doing this explicitly for both data sources and the corresponding entities to avoid confusion.

Related

sharing variables across freemarker files

I have 2 ftl files ( helloworld2.ftl and helloworld4.ftl ). I am trying to understand the variables sharing between ftl files. In helloworld4.ftl i have declared SharedVar and i am trying to access that varible in included file ie helloworld2.ftl. Am able to access. But at the end one set of extra error message im getting. why is it so?
I have used global instead of assign still same behaviour.
Contents of them follows
helloworld2.ftl :
<html>
<head>
<title>new file
</head>
<body>
<h1>${sharedVar}</h1>
</body>
</html>
helloworld4.ftl
<#assign sharedVar="sharedVar">
**********************
<#include "t2">
**********************
${sharedVar}*
ftl loading part,
Map<String, String> m = new HashMap<>();
m.put("t2", readFile("E://workspace//example//src//main//resources//templates//helloworld2.ftl"));
m.put("t4", readFile("E://workspace//example//src//main//resources//templates//helloworld4.ftl"));
for (Map.Entry<String, String> n : m.entrySet()) {
stringLoader.putTemplate(n.getKey(), n.getValue());
}
Output follows,
**********************
<html>
<head>
<title>new file
</head>
<body>
<h1>sharedVar</h1>
</body>
</html>
**********************
sharedVar*Aug 07, 2022 3:08:56 PM freemarker.log._JULLoggerFactory$JULLogger error
SEVERE: Error executing FreeMarker template
FreeMarker template error:
The following has evaluated to null or missing:
==> sharedVar [in template "t2" at line 7, column 17]

thymeleaf - passing a Selection Variable Expression *{foo} to an Expression Utility Object

I have a spring backed form with a model object Foo that contains Bar
<form action="#" th:action="#{/some/action}" th:object="${foo}" method="post">
now, I would like to do something like this:
<input type="text" id="bar.createdAt" name="bar.createdAt" th:value="*{bar.createdAt} ? ${#dates.format(bar.createdAt, #messages.msg('app.dateformat.datetime'))}"/>
but the following parsing exeption is thrown:
org.springframework.web.util.NestedServletException: Request processing failed; nested exception is org.thymeleaf.exceptions.TemplateProcessingException: Exception evaluating SpringEL expression: "#dates.format(bar.createdAt, #messages.msg('app.dateformat.datetime'))" (registration:93)
org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:973)
org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:852)
javax.servlet.http.HttpServlet.service(HttpServlet.java:622)
org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:837)
javax.servlet.http.HttpServlet.service(HttpServlet.java:729)
root cause
org.thymeleaf.exceptions.TemplateProcessingException: Exception evaluating SpringEL expression: "#dates.format(bar.createdAt, #messages.msg('app.dateformat.datetime'))" (registration:93)
org.thymeleaf.spring4.expression.SpelVariableExpressionEvaluator.evaluate(SpelVariableExpressionEvaluator.java:161)
org.thymeleaf.standard.expression.VariableExpression.executeVariable(VariableExpression.java:154)
org.thymeleaf.standard.expression.SimpleExpression.executeSimple(SimpleExpression.java:59)
root cause
org.springframework.expression.spel.SpelEvaluationException: EL1007E:(pos 7): Property or field 'createdAt' cannot be found on null
org.springframework.expression.spel.ast.PropertyOrFieldReference.readProperty(PropertyOrFieldReference.java:211)
org.springframework.expression.spel.ast.PropertyOrFieldReference.getValueInternal(PropertyOrFieldReference.java:85)
org.springframework.expression.spel.ast.PropertyOrFieldReference.access$000(PropertyOrFieldReference.java:43)
org.springframework.expression.spel.ast.PropertyOrFieldReference$AccessorLValue.getValue(PropertyOrFieldReference.java:341)
I've already tried:
...#dates.format(*{bar.createdAt}..., ...#dates.format(__*{bar.createdAt}__...but none has worked out.
the same without the form (directly accessing view model object) works fine.
Any idea what would be the right construct?
Thanks in advance!!!
Instead of :
${#dates.format(bar.createdAt, #messages.msg('app.dateformat.datetime'))}
Change it to :
*{#dates.format(bar.createdAt, #messages.msg('app.dateformat.datetime'))}
So that the utility object will work on the bar property of the last selected object which is the form backing object, ${foo}, in your case.
I think the clue is in the line:
Property or field 'createdAt' cannot be found on null
Are you sure that bar is not null?

G Render is null in integration tests

I am getting the error below when I am running an integration test, and attempting to render a template. The unique part of this is the template is rendering a template inside it on line 93. The reason I am doing this is to have a template that I am rendering to convert it to a PDF, it contains a styling template that calls the view template. Then the same view template I am using to set in a gsp page with styling for preview within the browser
The template containing the nested template is below minus the styling
<html>
<head>
<style type="text/css" media="print"></style>
</head>
<body>
<g:render template="depositStatement"/>
</body>
</html>
This works when running the application, but does not work when running integration tests.
Failure: |
Print Deposit Request(com.srm.billing.BillingPaymentRequestControllerIntegrationSpec)
|
org.codehaus.groovy.grails.web.taglib.exceptions.GrailsTagException: Error executing tag <g:render>: null
at org.codehaus.groovy.grails.web.pages.GroovyPage.throwRootCause(GroovyPage.java:527)
at org.codehaus.groovy.grails.web.pages.GroovyPage.invokeTag(GroovyPage.java:470)
at org.springsource.loaded.ri.ReflectiveInterceptor.jlrMethodInvoke(ReflectiveInterceptor.java:1270)
at C__Development_Grails36_sales_revenue_webapp_grails_app_views_billingPaymentRequest__printDepositStatement_gsp.run_closure1(_printDepositStatement.gsp:93)
at org.springsource.loaded.ri.ReflectiveInterceptor.jlrMethodInvoke(ReflectiveInterceptor.java:1270)
at groovy.lang.Closure.call(Closure.java:423)
at groovy.lang.Closure.call(Closure.java:417)
at org.codehaus.groovy.grails.web.taglib.GroovyPageTagBody.executeClosure(GroovyPageTagBody.java:206)
at org.codehaus.groovy.grails.web.taglib.GroovyPageTagBody.captureClosureOutput(GroovyPageTagBody.java:108)
at org.codehaus.groovy.grails.web.taglib.GroovyPageTagBody.call(GroovyPageTagBody.java:219)
at org.codehaus.groovy.grails.plugins.web.taglib.SitemeshTagLib.captureTagContent(SitemeshTagLib.groovy:49)
at org.codehaus.groovy.grails.plugins.web.taglib.SitemeshTagLib$_closure3.doCall(SitemeshTagLib.groovy:157)
at org.springsource.loaded.ri.ReflectiveInterceptor.jlrMethodInvoke(ReflectiveInterceptor.java:1270)
at groovy.lang.Closure.call(Closure.java:423)
at org.codehaus.groovy.grails.web.pages.GroovyPage.invokeTagLibClosure(GroovyPage.java:501)
at org.codehaus.groovy.grails.web.pages.GroovyPage.invokeTag(GroovyPage.java:419)
at C__Development_Grails36_sales_revenue_webapp_grails_app_views_billingPaymentRequest__printDepositStatement_gsp.run(_printDepositStatement.gsp:94)
at org.codehaus.groovy.grails.web.pages.GroovyPageWritable.doWriteTo(GroovyPageWritable.java:217)
at org.codehaus.groovy.grails.web.pages.GroovyPageWritable.writeTo(GroovyPageWritable.java:128)
at org.codehaus.groovy.grails.web.pages.GroovyPagesTemplateRenderer.makeTemplate(GroovyPagesTemplateRenderer.java:219)
at org.codehaus.groovy.grails.web.pages.GroovyPagesTemplateRenderer.render(GroovyPagesTemplateRenderer.java:105)
at org.codehaus.groovy.grails.plugins.web.taglib.RenderTagLib$_closure7.doCall(RenderTagLib.groovy:364)
at org.springsource.loaded.ri.ReflectiveInterceptor.jlrMethodInvoke(ReflectiveInterceptor.java:1270)
at groovy.lang.Closure.call(Closure.java:423)
at org.codehaus.groovy.grails.web.pages.GroovyPage.captureTagOutput(GroovyPage.java:586)
at org.codehaus.groovy.grails.web.util.TagLibraryMetaUtils.registerMethodMissingForTags_closure3(TagLibraryMetaUtils.groovy:55)
at org.springsource.loaded.ri.ReflectiveInterceptor.jlrMethodInvoke(ReflectiveInterceptor.java:1270)
at com.srm.billing.BillingPaymentRequestService.renderOutput(BillingPaymentRequestService.groovy:656)
at com.srm.billing.BillingPaymentRequestService.getOrCreateBillingDepositRequest(BillingPaymentRequestService.groovy:94)
at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:204)
at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.invokeJoinpoint(CglibAopProxy.java:708)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:157)
at org.springframework.transaction.interceptor.TransactionInterceptor$1.proceedWithInvocation(TransactionInterceptor.java:98)
at org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:262)
at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:95)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:644)
at com.srm.billing.BillingPaymentRequestControllerIntegrationSpec.Print Deposit Request(BillingPaymentRequestControllerIntegrationSpec.groovy:73)
Caused by: java.lang.NullPointerException
at java.util.concurrent.ConcurrentHashMap.hash(ConcurrentHashMap.java:333)
at java.util.concurrent.ConcurrentHashMap.get(ConcurrentHashMap.java:988)
at org.codehaus.groovy.grails.web.pages.GroovyPagesTemplateRenderer.generateScaffoldedTemplate(GroovyPagesTemplateRenderer.java:248)
at org.codehaus.groovy.grails.web.pages.GroovyPagesTemplateRenderer.access$300(GroovyPagesTemplateRenderer.java:64)
at org.codehaus.groovy.grails.web.pages.GroovyPagesTemplateRenderer$1$1.updateValue(GroovyPagesTemplateRenderer.java:164)
at org.codehaus.groovy.grails.web.pages.GroovyPagesTemplateRenderer$1$1.updateValue(GroovyPagesTemplateRenderer.java:135)
at grails.util.CacheEntry.getValue(CacheEntry.java:141)
at grails.util.CacheEntry.getValue(CacheEntry.java:81)
at org.codehaus.groovy.grails.web.pages.GroovyPagesTemplateRenderer.findAndCacheTemplate(GroovyPagesTemplateRenderer.java:132)
at org.codehaus.groovy.grails.web.pages.GroovyPagesTemplateRenderer.render(GroovyPagesTemplateRenderer.java:100)
at org.codehaus.groovy.grails.plugins.web.taglib.RenderTagLib$_closure7.doCall(RenderTagLib.groovy:364)
at org.springsource.loaded.ri.ReflectiveInterceptor.jlrMethodInvoke(ReflectiveInterceptor.java:1270)
at groovy.lang.Closure.call(Closure.java:423)
at org.codehaus.groovy.grails.web.pages.GroovyPage.invokeTagLibClosure(GroovyPage.java:501)
at org.codehaus.groovy.grails.web.pages.GroovyPage.invokeTag(GroovyPage.java:419)
... 36 more
|Completed 3 integration tests, 1 failed in 0m 3s
It doesn't mean render tag is null, your gsp has null pointer exception, so check your second gsp for possible NPE. Just to verify its not render tag issue, you can remove every thing from your second gsp and that should fix it, which will prove render is not an issue, and then find out the cause of NPE

HTMLUnit HtmlPage.getBody() returns null even though the response contains a <body> tag

I'm using HTMLUnit in Java to extract information from website.
Ran into a strange phenom where the page is not fully parsed into the DOM tree.
After the following:
HtmlPage lineHours = (HtmlPage) _webClient.getTopLevelWindows().get(1).getEnclosedPage();
Watching the expression lineHours.asXml() results in the following (... marks ommitted sensitive data)
<?xml version="1.0" encoding="UTF-8"?>
<html>
<head>
<script ...>
</script>
</head>
</html>
While printing lineHours.getWebResponse().getContentAsString() results in the following:
<html>
<head>
<script ...>
</script>
</head>
</html>
<body>
<div> ...
In short, the body tag is not parsed into the DOM tree. and therefore all XPath queries and helper methods such as HtmlPage.getBody() fail. In a regular browser the page renders well.
Any ideas?
Thanks
Tomer
This was eventually solved by parsing the DOM tree using a Xerces parser and retrieving the result from it.

Thymeleaf v2.0.15 SaxParse Exception - Scanner state not 24

I am trying to use Thymeleaf template engine for generating Emails in my Spring Web Application.
I have followed the documentation on their website, but I keep getting a SaxParseException no matter how simple my HTML5 template is.
I am using a HTML 5 template as shown below.
<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
<title th:remove="all">Account confirmation HTML email</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
</head>
<body>
<h3 th:utext="#{mail.template.confirmation.greeting(${user.firstName}, ${user.lastName})}"></h3>
<p th:utext="#{mail.template.confirmation.introduction(${createdDate})}">
</p>
</body>
</html>
My Spring config.
#Bean
public ClassLoaderTemplateResolver emailTemplateResolver() {
ClassLoaderTemplateResolver cltr = new ClassLoaderTemplateResolver();
cltr.setPrefix("/dk/rfit/orderit/web/mail/");
cltr.setSuffix(".html");
cltr.setTemplateMode("HTML5");
cltr.setCharacterEncoding("UTF-8");
cltr.setOrder(3);
cltr.setCacheable(true);
return cltr;
}
#Bean
public TemplateEngine mailTemplateEngine() {
SpringTemplateEngine ste = new SpringTemplateEngine();
ste.setTemplateResolver(emailTemplateResolver());
return ste;
}
StackTrace..
2013-01-31 08:01:33,431 [org.thymeleaf.TemplateEngine] [http-bio-8080-exec-10] (TemplateEngine.java:829) INFO org.thymeleaf.TemplateEngine - [THYMELEAF] INITIALIZING TEMPLATE ENGINE
2013-01-31 08:01:33,496 [org.thymeleaf.templateresolver.AbstractTemplateResolver] [http-bio-8080-exec-10] (AbstractTemplateResolver.java:99) INFO org.thymeleaf.templateresolver.AbstractTemplateResolver - [THYMELEAF] INITIALIZING TEMPLATE RESOLVER: org.thymeleaf.templateresolver.ClassLoaderTemplateResolver
2013-01-31 08:01:33,496 [org.thymeleaf.templateresolver.AbstractTemplateResolver] [http-bio-8080-exec-10] (AbstractTemplateResolver.java:110) INFO org.thymeleaf.templateresolver.AbstractTemplateResolver - [THYMELEAF] TEMPLATE RESOLVER INITIALIZED OK
2013-01-31 08:01:33,498 [org.thymeleaf.messageresolver.AbstractMessageResolver] [http-bio-8080-exec-10] (AbstractMessageResolver.java:72) INFO org.thymeleaf.messageresolver.AbstractMessageResolver - [THYMELEAF] INITIALIZING MESSAGE RESOLVER: org.thymeleaf.spring3.messageresolver.SpringMessageResolver
2013-01-31 08:01:33,499 [org.thymeleaf.messageresolver.AbstractMessageResolver] [http-bio-8080-exec-10] (AbstractMessageResolver.java:78) INFO org.thymeleaf.messageresolver.AbstractMessageResolver - [THYMELEAF] MESSAGE RESOLVER INITIALIZED OK
2013-01-31 08:01:33,506 [org.thymeleaf.TemplateEngine.CONFIG] [http-bio-8080-exec-10] (ConfigurationPrinterHelper.java:130) INFO org.thymeleaf.TemplateEngine.CONFIG - [THYMELEAF] TEMPLATE ENGINE CONFIGURATION:
[THYMELEAF] * Cache Factory implementation: org.thymeleaf.cache.StandardCacheManager
[THYMELEAF] * Template modes:
[THYMELEAF] * LEGACYHTML5
[THYMELEAF] * VALIDXHTML
[THYMELEAF] * HTML5
[THYMELEAF] * XHTML
[THYMELEAF] * XML
[THYMELEAF] * VALIDXML
[THYMELEAF] * Template resolvers (in order):
[THYMELEAF] * [3] org.thymeleaf.templateresolver.ClassLoaderTemplateResolver
[THYMELEAF] * Message resolvers (in order):
[THYMELEAF] * org.thymeleaf.spring3.messageresolver.SpringMessageResolver
[THYMELEAF] * Dialect: org.thymeleaf.spring3.dialect.SpringStandardDialect
[THYMELEAF] * Prefix: "th"
[THYMELEAF] TEMPLATE ENGINE CONFIGURED OK
2013-01-31 08:01:33,507 [org.thymeleaf.TemplateEngine] [http-bio-8080-exec-10] (TemplateEngine.java:842) INFO org.thymeleaf.TemplateEngine - [THYMELEAF] TEMPLATE ENGINE INITIALIZED
2013-01-31 08:09:52,146 [org.thymeleaf.TemplateEngine] [http-bio-8080-exec-10] (TemplateEngine.java:1173) ERROR org.thymeleaf.TemplateEngine - [THYMELEAF][http-bio-8080-exec-10] Exception processing template "account-confirmation": Exception parsing document
2013-01-31 08:09:52,149 [dk.rfit.orderit.web.controller.AccountController] [http-bio-8080- exec-10] (AccountController.java:213) ERROR dk.rfit.orderit.web.controller.AccountController org.thymeleaf.templateparser.xmlsax.AbstractNonValidatingSAXTemplateParser.parseTemplateUsingP ool(AbstractNonValidatingSAXTemplateParser.java:167) org.thymeleaf.templateparser.xmlsax.AbstractNonValidatingSAXTemplateParser.parseTemplate(Abstr actNonValidatingSAXTemplateParser.java:115)
at org.thymeleaf.TemplateRepository.getTemplate(TemplateRepository.java:276)
at org.thymeleaf.TemplateEngine.process(TemplateEngine.java:1192)
at org.thymeleaf.TemplateEngine.process(TemplateEngine.java:1148)
at org.thymeleaf.TemplateEngine.process(TemplateEngine.java:1095)
at org.thymeleaf.TemplateEngine.process(TemplateEngine.java:1008)
at org.thymeleaf.TemplateEngine.process(TemplateEngine.java:982)
dk.rfit.orderit.web.service.EmailServiceThymeLeafImpl$1.prepare(EmailServiceThymeLeafImpl.java:65)
at org.springframework.mail.javamail.JavaMailSenderImpl.send(JavaMailSenderImpl.java:352)
... 73 more
Caused by: org.xml.sax.SAXException: Scanner State 24 not Recognized
at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.parse(AbstractSAXParser.java:1245 )
at com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl$JAXPSAXParser.parse(SAXParserImpl.java:5 22)
at javax.xml.parsers.SAXParser.parse(SAXParser.java:395)
at org.thymeleaf.templateparser.xmlsax.AbstractNonValidatingSAXTemplateParser.doParse(AbstractNon ValidatingSAXTemplateParser.java:208)
at org.thymeleaf.templateparser.xmlsax.AbstractNonValidatingSAXTemplateParser.parseTemplateUsingP ool(AbstractNonValidatingSAXTemplateParser.java:132)
... 82 more
Hope that somebody can tell me what to do to solve this problem..
In addition to Vel's answer: if you need to insert invalid XHTML via utext, which could be perfectly fine for HTML5 (like unclosed <br> tags), you need to use template mode LEGACYHTML5:
cltr.setTemplateMode("LEGACYHTML5");
This error is usually raised by the parser when the parsed markup is not well-formed XML.
The html5 template file becomes not a valid html file after parsing. This means some end-tag (/>)or something extra tag which does not meet the validation of XHTML.
Another option is to specify property in application.properties:
spring.thymeleaf.mode=LEGACYHTML5
Having nekohtml dependency in your project, e.g. in a pom.xml
<dependency>
<groupId>net.sourceforge.nekohtml</groupId>
<artifactId>nekohtml</artifactId>
</dependency>
is mandatory.

Resources