cancel
Showing results for 
Search instead for 
Did you mean: 

Keyword search - format=xml returns error

shikarishambu
Champ in-the-making
Champ in-the-making
I am trying to get keyword search to return results as XML. I get the following error

<message>10030011 Wrapped Exception (with status template): 10030010 IO Error during processing of the template 'org/alfresco/repository/search/keywordsearch.get.xml.ftl'. Please contact your system administrator.</message> 
  <exception>org.alfresco.web.scripts.WebScriptException - 10030011 Wrapped Exception (with status template): 10030010 IO Error during processing of the template 'org/alfresco/repository/search/keywordsearch.get.xml.ftl'. Please contact your system administrator.</exception>
  <callstack>java.io.FileNotFoundException: Template org/alfresco/repository/search/keywordsearch.get.xml.ftl not found.


Is XML a valid return format ? If yes, how do I rectify this error.
http://myalfrescoserver:8080/alfresco/service/api/search/keyword?q=claims&guest=alf:guest&format=xml
6 REPLIES 6

tonyc
Champ in-the-making
Champ in-the-making
XML is not a default valid return type…

The output response can either be in HTML, ATOM or RSS.  The default output format is HTML

Although if you take a look at keywordsearch.get.rss.ftl,  you could easily take that template and create an XML one 'keywordsearch.get.xml.ftl'..  XML and RSS are very similar.

shikarishambu
Champ in-the-making
Champ in-the-making
Thank you very much. I looked at the rss.ftl and a different xml.ftl to try create keywordsearch.xml.ftl.

Here is what I have
<?xml version="1.0" encoding="UTF-8"?>
<keywordsearch xmlns:opensearch="http://a9.com/-/spec/opensearch/1.1/" xmlns:atom="http://www.w3.org/2005/Atom">
  <title>Alfresco Keyword Search: ${search.searchTerms}</title>
  <link>${absurl(scripturl("?q=${search.searchTerms?url}&p=${search.startPage}&c=${search.itemsPerPage}&l=${search.localeId}")?xml)}"</link>
  <description>Alfresco Keyword Search: ${search.searchTerms}</description>
  <language>${search.localeId}</language>
  <lastBuildDate>${xmldate(date)}</lastBuildDate>
  <pubDate>${xmldate(date)}</pubDate>
  <generator>Alfresco ${server.edition} v${server.version}</generator>
  <opensearch:totalResults>${search.totalResults}</opensearch:totalResults>
  <opensearch:startIndex>${search.startIndex}</opensearch:startIndex>
  <opensearch:itemsPerPage>${search.itemsPerPage}</opensearch:itemsPerPage>
  <opensearch:Query role="request" searchTerms="${search.searchTerms}" startPage="${search.startPage}" count="${search.itemsPerPage}" language="${search.localeId}"/>
  <atom:link rel="self" href="${absurl(scripturl("?q=${search.searchTerms?url}&p=${search.startPage}&c=${search.itemsPerPage}&l=${search.localeId}")?xml)}" type="application/atom+xml"/>
<#if search.startPage &gt; 1>
  <atom:link rel="first" href="${absurl(scripturl("?q=${search.searchTerms?url}&p=1&c=${search.itemsPerPage}&l=${search.localeId}")?xml)}" type="application/atom+xml"/>
  <atom:link rel="previous" href="${absurl(scripturl("?q=${search.searchTerms?url}&p=${search.startPage - 1}&c=${search.itemsPerPage}&l=${search.localeId}")?xml)}" type="application/atom+xml"/>
</#if>
<#if search.startPage &lt; search.totalPages>
  <atom:link rel="next" href="${absurl(scripturl("?q=${search.searchTerms?url}&p=${search.startPage + 1}&c=${search.itemsPerPage}&l=${search.localeId}")?xml)}" type="application/atom+xml"/>
  <atom:link rel="last" href="${absurl(scripturl("?q=${search.searchTerms?url}&p=${search.totalPages}&c=${search.itemsPerPage}&l=${search.localeId}")?xml)}" type="application/atom+xml"/>
</#if>
  <atom:link rel="search" type="application/opensearchdescription+xml" href="${absurl(url.serviceContext)}/api/search/keyword/description.xml"/>
<#list search.results as row>           
  <item>
    <title>${row.name}</title>
    <link>${absurl(url.serviceContext)}${row.url}</link>
    <description>${row.properties.description!""}</description>
    <pubDate>${xmldate(row.properties.modified)}</pubDate>
    <guid isPermaLink="false">${row.id}</guid>
  </item>
</#list>
</keywordsearch>

I get the following error - Read-write transaction started within read-only transaction.
<?xml version="1.0" encoding="UTF-8" ?> 
- <response>
- <status>
  500
  <name>Internal Error</name>
  <description>An error inside the HTTP server which prevented it from fulfilling the request.</description>
  </status>
  <message>10040013 Wrapped Exception (with status template): 10040012 Read-Write transaction started within read-only transaction</message>
  <exception>org.alfresco.web.scripts.WebScriptException - 10040013 Wrapped Exception (with status template): 10040012 Read-Write transaction started within read-only transaction</exception>
  <callstack>org.alfresco.error.AlfrescoRuntimeException: 10040012 Read-Write transaction started within read-only transaction org.alfresco.repo.transaction.RetryingTransactionHelper.doInTransaction(RetryingTransactionHelper.java:298) org.alfresco.repo.transaction.RetryingTransactionHelper.doInTransaction(RetryingTransactionHelper.java:233) org.alfresco.repo.web.scripts.RepoStore$RepoTemplateSource$1.doWork(RepoStore.java:805) org.alfresco.repo.web.scripts.RepoStore$RepoTemplateSource$1.doWork(RepoStore.java:803) org.alfresco.repo.security.authentication.AuthenticationUtil.runAs(AuthenticationUtil.java:489) org.alfresco.repo.web.scripts.RepoStore$RepoTemplateSource.lastModified(RepoStore.java:801) org.alfresco.repo.web.scripts.RepoStore$RepoTemplateLoader.getLastModified(RepoStore.java:725) freemarker.cache.MultiTemplateLoader$MultiSource.getLastModified(MultiTemplateLoader.java:172) freemarker.cache.MultiTemplateLoader.getLastModified(MultiTemplateLoader.java:126) freemarker.cache.TemplateCache.getTemplate(TemplateCache.java:306) freemarker.cache.TemplateCache.getTemplate(TemplateCache.java:235) freemarker.template.Configuration.getTemplate(Configuration.java:487) freemarker.template.Configuration.getTemplate(Configuration.java:452) org.alfresco.repo.template.FreeMarkerProcessor.process(FreeMarkerProcessor.java:195) org.alfresco.web.scripts.AbstractWebScript.renderTemplate(AbstractWebScript.java:523) org.alfresco.web.scripts.DeclarativeWebScript.renderFormatTemplate(DeclarativeWebScript.java:241) org.alfresco.web.scripts.DeclarativeWebScript.execute(DeclarativeWebScript.java:147) org.alfresco.repo.web.scripts.RepositoryContainer$2.execute(RepositoryContainer.java:357) org.alfresco.repo.transaction.RetryingTransactionHelper.doInTransaction(RetryingTransactionHelper.java:326) org.alfresco.repo.web.scripts.RepositoryContainer.transactionedExecute(RepositoryContainer.java:407) org.alfresco.repo.web.scripts.RepositoryContainer.transactionedExecuteAs(RepositoryContainer.java:424) org.alfresco.repo.web.scripts.RepositoryContainer.executeScript(RepositoryContainer.java:288) org.alfresco.web.scripts.AbstractRuntime.executeScript(AbstractRuntime.java:262) org.alfresco.web.scripts.AbstractRuntime.executeScript(AbstractRuntime.java:139) org.alfresco.web.scripts.servlet.WebScriptServlet.service(WebScriptServlet.java:122) javax.servlet.http.HttpServlet.service(HttpServlet.java:717) org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290) org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233) org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191) org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128) org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102) org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109) org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:286) org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:845) org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583) org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447) java.lang.Thread.run(Thread.java:619) org.alfresco.web.scripts.WebScriptException: 10040013 Wrapped Exception (with status template): 10040012 Read-Write transaction started within read-only transaction org.alfresco.web.scripts.AbstractWebScript.createStatusException(AbstractWebScript.java:613)</callstack>
  <server>Alfresco Community v3.2.0 (2039) schema 2,019</server>
  <time>Nov 4, 2009 4:39:47 PM</time>
  </response>

Any ideas why this error occurs or how to fix it.

TIA

tonyc
Champ in-the-making
Champ in-the-making
Try replacing..
<keywordsearch xmlnsSmiley Surprisedpensearch="http://a9.com/-/spec/opensearch/1.1/" xmlns:atom="http://www.w3.org/2005/Atom">
with..
<keywordsearch>

And also add…

<url>/api/search/keyword.xml?q={searchTerms}&amp;p={startPage?}&amp;c={count?}&amp;l={language?}</url>
<url>/search/keyword.xml?q={searchTerms}&amp;p={startPage?}&amp;c={count?}&amp;l={language?}</url>
to keywordsearch.get.desc.xml

Also make sure your xml template is named keywordsearch.get.xml.ftl

shikarishambu
Champ in-the-making
Champ in-the-making
thanks. I did all that. My keywordsearch.get.desc.xml and keywordsearch.get.xml.ftl are located in  Data Dictionary > Web Scripts Extensions > org > alfresco > repository > search

I have refreshed the web scripts. I still get the Read-Write error

<?xml version="1.0" encoding="UTF-8" ?> 
- <response>
- <status>
  500
  <name>Internal Error</name>
  <description>An error inside the HTTP server which prevented it from fulfilling the request.</description>
  </status>
  <message>10050017 Wrapped Exception (with status template): 10050016 Read-Write transaction started within read-only transaction</message>
  <exception>org.alfresco.web.scripts.WebScriptException - 10050017 Wrapped Exception (with status template): 10050016 Read-Write transaction started within read-only transaction</exception>
  <callstack>org.alfresco.error.AlfrescoRuntimeException: 10050016 Read-Write transaction started within read-only transaction org.alfresco.repo.transaction.RetryingTransactionHelper.doInTransaction(RetryingTransactionHelper.java:298) org.alfresco.repo.transaction.RetryingTransactionHelper.doInTransaction(RetryingTransactionHelper.java:233) org.alfresco.repo.web.scripts.RepoStore$RepoTemplateSource$1.doWork(RepoStore.java:805) org.alfresco.repo.web.scripts.RepoStore$RepoTemplateSource$1.doWork(RepoStore.java:803) org.alfresco.repo.security.authentication.AuthenticationUtil.runAs(AuthenticationUtil.java:489) org.alfresco.repo.web.scripts.RepoStore$RepoTemplateSource.lastModified(RepoStore.java:801) org.alfresco.repo.web.scripts.RepoStore$RepoTemplateLoader.getLastModified(RepoStore.java:725) freemarker.cache.MultiTemplateLoader$MultiSource.getLastModified(MultiTemplateLoader.java:172) freemarker.cache.MultiTemplateLoader.getLastModified(MultiTemplateLoader.java:126) freemarker.cache.TemplateCache.getTemplate(TemplateCache.java:306) freemarker.cache.TemplateCache.getTemplate(TemplateCache.java:235) freemarker.template.Configuration.getTemplate(Configuration.java:487) freemarker.template.Configuration.getTemplate(Configuration.java:452) org.alfresco.repo.template.FreeMarkerProcessor.process(FreeMarkerProcessor.java:195) org.alfresco.web.scripts.AbstractWebScript.renderTemplate(AbstractWebScript.java:523) org.alfresco.web.scripts.DeclarativeWebScript.renderFormatTemplate(DeclarativeWebScript.java:241) org.alfresco.web.scripts.DeclarativeWebScript.execute(DeclarativeWebScript.java:147) org.alfresco.repo.web.scripts.RepositoryContainer$2.execute(RepositoryContainer.java:357) org.alfresco.repo.transaction.RetryingTransactionHelper.doInTransaction(RetryingTransactionHelper.java:326) org.alfresco.repo.web.scripts.RepositoryContainer.transactionedExecute(RepositoryContainer.java:407) org.alfresco.repo.web.scripts.RepositoryContainer.transactionedExecuteAs(RepositoryContainer.java:424) org.alfresco.repo.web.scripts.RepositoryContainer.executeScript(RepositoryContainer.java:288) org.alfresco.web.scripts.AbstractRuntime.executeScript(AbstractRuntime.java:262) org.alfresco.web.scripts.AbstractRuntime.executeScript(AbstractRuntime.java:139) org.alfresco.web.scripts.servlet.WebScriptServlet.service(WebScriptServlet.java:122) javax.servlet.http.HttpServlet.service(HttpServlet.java:717) org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290) org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233) org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191) org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128) org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102) org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109) org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:286) org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:845) org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583) org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447) java.lang.Thread.run(Thread.java:619) org.alfresco.web.scripts.WebScriptException: 10050017 Wrapped Exception (with status template): 10050016 Read-Write transaction started within read-only transaction org.alfresco.web.scripts.AbstractWebScript.createStatusException(AbstractWebScript.java:613)</callstack>
  <server>Alfresco Community v3.2.0 (2039) schema 2,019</server>
  <time>Nov 5, 2009 10:30:39 AM</time>
  </response>

tonyc
Champ in-the-making
Champ in-the-making
They shouldn't be there… put them where the rest of the webscript resides. 

<TOMCAT_HOME>/webapps/alfresco/WEB-INF/classes/alfresco/templates/webscripts/org/alfresco/repository/search/

shikarishambu
Champ in-the-making
Champ in-the-making
Thanks. That seem to have solved that issue, though I sure don't understand why I have to put these files here. Per Alfresco documentation, it seems to me that Web Scripts Extension is the place to put modifications to webscripts/ new webscripts.

I now get a different error when I try to get the xml on the browser

The operation completed successfully. Error processing resource 'http://localhost:8080/alfresco/service/api/search/keyword?…

  <opensearch:totalResults>3</opensearch:totalResults>
—————————^