cancel
Showing results for 
Search instead for 
Did you mean: 

Exception when trying to create a new calendar event

emp_tyres
Champ in-the-making
Champ in-the-making
Hullo,
  while trying to create a calendar event by using a small java-developed HTTP client, I am getting the following exception:


Message: Wrapped Exception (with status template): Error during processing of the template 'Expression result is undefined on line 3, column 6 in org/alfresco/slingshot/calendar/event.post.html.ftl.'. Please contact your system administrator.Exception: freemarker.core.InvalidReferenceException - Expression result is undefined on line 3, column 6 in org/alfresco/slingshot/calendar/event.post.html.ftl.         freemarker.core.TemplateObject.assertNonNull(TemplateObject.java:124)         freemarker.core.TemplateObject.invalidTypeException(TemplateObject.java:134)         freemarker.core.Dot._getAsTemplateModel(Dot.java:78)         freemarker.core.Expression.getAsTemplateModel(Expression.java:89)         freemarker.core.BuiltIn$existsBI._getAsTemplateModel(BuiltIn.java:639)         freemarker.core.BuiltIn$existsBI.isTrue(BuiltIn.java:650)         freemarker.core.IfBlock.accept(IfBlock.java:80)         freemarker.core.Environment.visit(Environment.java:208)         freemarker.core.MixedContent.accept(MixedContent.java:92)         freemarker.core.Environment.visit(Environment.java:208)         freemarker.core.EscapeBlock.accept(EscapeBlock.java:84)         freemarker.core.Environment.visit(Environment.java:208)         freemarker.core.MixedContent.accept(MixedContent.java:92)         freemarker.core.Environment.visit(Environment.java:208)         freemarker.core.Environment.process(Environment.java:188)         freemarker.template.Template.process(Template.java:237)         org.alfresco.repo.template.FreeMarkerProcessor.process(FreeMarkerProcessor.java:201)         org.alfresco.web.scripts.AbstractWebScript.renderTemplate(AbstractWebScript.java:505)         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:319)         org.alfresco.repo.transaction.RetryingTransactionHelper.doInTransaction(RetryingTransactionHelper.java:320)         org.alfresco.repo.transaction.RetryingTransactionHelper.doInTransaction(RetryingTransactionHelper.java:227)         org.alfresco.repo.web.scripts.RepositoryContainer.transactionedExecute(RepositoryContainer.java:368)         org.alfresco.repo.web.scripts.RepositoryContainer.transactionedExecuteAs(RepositoryContainer.java:390)         org.alfresco.repo.web.scripts.RepositoryContainer.executeScript(RepositoryContainer.java:273)         org.alfresco.web.scripts.AbstractRuntime.executeScript(AbstractRuntime.java:261)         org.alfresco.web.scripts.AbstractRuntime.executeScript(AbstractRuntime.java:139)         org.alfresco.web.scripts.servlet.WebScriptServlet.service(WebScriptServlet.java:116)         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:595)Exception: org.alfresco.service.cmr.repository.TemplateException - Error during processing of the template 'Expression result is undefined on line 3, column 6 in org/alfresco/slingshot/calendar/event.post.html.ftl.'. Please contact your system administrator.      org.alfresco.repo.template.FreeMarkerProcessor.process(FreeMarkerProcessor.java:205)Exception: org.alfresco.web.scripts.WebScriptException - Wrapped Exception (with status template): Error during processing of the template 'Expression result is undefined on line 3, column 6 in org/alfresco/slingshot/calendar/event.post.html.ftl.'. Please contact your system administrator.      org.alfresco.web.scripts.AbstractWebScript.createStatusException(AbstractWebScript.java:595)      Alfresco Labs v3.0.0 (Stable 1526) schema 1,002      Sep 24, 2009 11:37:16 AMDiagnostics Inspect Web Script (org/alfresco/slingshot/calendar/event.post)‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍

I am using 3.0.0, and was wondering

  • if this can depend on the way I am doing my request

  • if this has happened to anyone else (and maybe is fixed in a later release)
My client code is pretty plain so I am not sure it is really useful to debug this, but here is the relevant method (might be useful to toher people too…):

   public static void test2() {      HttpClient client = new HttpClient();      client.getParams().setParameter("http.useragent", "Test Client");      client.getState().setCredentials(AuthScope.ANY,            new UsernamePasswordCredentials("user", "pass"));      BufferedReader br = null;      PostMethod method = new PostMethod("http://<alfresco-url>/alfresco/service/calendar/create");      List<NameValuePair> nvps = new ArrayList<NameValuePair>();      nvps.add(new NameValuePair("username", "username"));      nvps.add(new NameValuePair("password", "password"));      nvps.add(new NameValuePair("what", "CICCIO"));      nvps.add(new NameValuePair("where", "IRCC"));      nvps.add(new NameValuePair("desc", "DESC"));      nvps.add(new NameValuePair("from", "2009-09-24"));      nvps.add(new NameValuePair("start", "12:00"));      nvps.add(new NameValuePair("to", "2009-09-24"));      nvps.add(new NameValuePair("end", "13:00"));      nvps.add(new NameValuePair("site", "SP2"));      NameValuePair[] array = new NameValuePair[nvps.size()];      method.setRequestBody(nvps.toArray(array));      method.setDoAuthentication(true);      try {         int returnCode = client.executeMethod(method);         if (returnCode == HttpStatus.SC_NOT_IMPLEMENTED) {            System.err.println("The Post method is not implemented by this URI");            // still consume the response body            method.getResponseBodyAsString();         } else {            br = new BufferedReader(new InputStreamReader(method.getResponseBodyAsStream()));            String readLine;            while (((readLine = br.readLine()) != null)) {               System.err.println(readLine);            }         }      } catch (Exception e) {         System.err.println(e);      } finally {         method.releaseConnection();         if (br != null)            try {               br.close();            } catch (Exception fe) {            }      }   }‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍

TIA,

Emp
3 REPLIES 3

emp_tyres
Champ in-the-making
Champ in-the-making
It appears I am the only person experiencing this issue, so I am wondering if someone could kindly copy-paste my java client code on a quick project of theirs and see if they manage to make it work…

I am getting a little bit desperate around here and would like to be sure I have to upgrade before embarking on the adventure.

TIA,

Emp

steffen
Champ in-the-making
Champ in-the-making
Hi

it seems to me that you are using the worng format for the request. You are sending url style parameters in the http request body:

username=user&password=password&what=CICCIO&where=IRCC&desc=DESC&from=2009-09-24&start=12%3A00&to=2009-09-24&end=13%3A00&site=SP2

but the web script is expecting JSON, like:

{"desc":"description","end":"13:00","from":"2009/09/30","page":"calendar","site":"test2","start":"12:00","template_x002e_view_x002e_calendarContainer-addEvent-cancel-button":"","template_x002e_view_x002e_calendarContainer-addEvent-ok-button":"","to":"2009/09/30","what":"what","where":"where"}

greetings

steffen

emp_tyres
Champ in-the-making
Champ in-the-making
THANKS! - I read thousands of posts and made thousands of tests, and yet I was still doing my JSON wrong - your hint was all that was needed to let me have another go - I will be posting the compelte working code tomorrow for anyone in need to benefit!!! 🙂

TIA,
Emp