SURF Part 3 – Alfresco WCM Content

March 9, 2009

**NOTE: This articles uses features found in HEAD which are considered to be work-in-progress.  This article is for demo purposes only.**

In this article I will look at deploying and consuming WCM content from a SURF web application.  To make this very simple, we have created a standalone Tomcat 6 bundle which has an example SURF web application pre-configured (thanks to Michael Uzquiano for all the assistance!).  This is the same web app as used in the previous articles, so all previous material is still relevant.

Once the Tomcat bundle is deployed and your WCM instance configured, you will have working examples of:

  • An AVM layout separating Surf content (components, templates etc) and Web content (XML content, CSS, images etc).
  • Deployment configuration allowing the Surf and/or Web content to be deployed to a local file system directory.
  • An FSR – configured for the deployment as above
  • A Surf website example of including static content e.g. an HTML file from the local file system.
  • A surf website example of dispatching dynamic content from the remote Alfresco repository.
  • Web form examples for the creation of example content.

Initially I will describe the steps required to get up and running, and then I will dissect the configuration so that we fully understand how it is working.

Prerequisites

  • It is expected that you are familiar with Alfresco concepts such as CIFS, Web Scripts, Web Forms etc.  This is not a beginners tutorial to Alfresco WCM!
  • Alfresco v3.x installed with WCM configured and running at http://localhost:8080.  If this address is different, you will need to re-configure the Alfresco endpoint.  This is detailed below within the “Dynamic Content Example”, so do not be alarmed if your “Products” section does not work after the install.
  • This article is based on the Surf Deployment Configurations wiki article which I would highly recommend reading.

Download

Download the surf-sample Tomcat bundle and extract to your local file system e.g. c:\surf-sample.

Installation

Download the Surf demo Tomcat bundle and extract to your local file system.  Have a browse through the files and you will see that the following is included:

  • surf-sample\sample – The Tomcat 6 bundle directory
  • surf-sample\setup\AVM – An example directory structure to be loaded into the AVM
  • surf-sample\setup\FSR – An example FSR
  • surf-sample\setup\web forms – Example web forms for creating news and product items
  • surf-sample\setup\web scripts – Example web scripts for the products section

Alfresco Setup

  • Create a new web project with the DNS name – “demo”. If you do not use this name, you will have to make a small change to the “Product” web script. See the “Web Scripts” section below.
  • Connect via CIFS to the AVM as the “admin” user.
  • Copy the contents of the AVM structure dir from the surf-sample\setup\AVM\ROOT to the admin user sandbox via CIFS. (You could also zip up and bulk import if you prefer)
  • Submit this content to the Staging sandbox.

The AVM directory structure should look like the following:

Web Forms

I have included two example web forms with the files so that you can quickly create some example content to be used with deployment, and for testing the example functionality.  There are two web forms which need to be installed, one for the news articles and one for products.

Article Web Form

  • Create a new article web form using the C:\surf-sample\setup\web forms\article\article.xsd file.  Add the output path pattern of /${webapp}/content/news/source/${name}.xml
  • Add C:\surf-sample\setup\web forms\article\latestNews.html.ftl as a rendition with the output path pattern /${webapp}/content/news/latestNews.html

Products Web Form

The product XML items are read dynamically by the Surf webapp.

  • Create a new product web form using the C:\surf-sample\setup\web forms\product\product.xsd. Add the output path pattern of /${webapp}/content/products/source/${name}.xml

Note there is also a article.html.ftl file, however at present this is not used.  Once the web forms are installed, you can test creating some content.  Verify that the output is being populated to the correct locations as listed above.

Web Scripts

The Products section uses a web script which must be installed.

  • Copy the C:\surf-sample\setup\web scripts\products folder in to the Alfresco Data Dictionary\web scripts folder and refresh the web scripts. If your site name is not “demo”, you will need to edit the site reference within C:\surf-sample\setup\web scripts\products\products.get.js i.e.


var storeid = ("demo");

Deployment Setup

All content is deployed to the C:\surf-sample\sample\deploy directory. This represents a stand alone directory which is configured to deliver the Alfresco content.  This directory is separated into two sections as follows:

  • Web Content – e.g. HTML renditions, JS, CSS etc – deployed to C:\surf-sample\sample\deploy\webroot\ROOT
  • Surf Content – surf items such as templates, components etc – deployed to C:\surf-sample\sample\deploy\alfresco

Configure two deployment targets:

  • Edit your Web Project and add two File System Receivers using the details below.

Name: Content Production
Excludes: [A-Za-z0-9:/_]*ROOT/WEB-INF/*
Target Name: content

Name: Surf Production
Source Path: /ROOT/WEB-INF/classes/alfresco
Target Name: alfresco

FSR

There is an example FSR located within C:\surf-sample\setup\FSR.  You can copy this directory to another location if required e.g. c:\FSR.  The C:\surf-sample\setup\FSR\application-context.xml file has an example configuration which will need to be edited to match your file system locations depending upon where the surf-sample app is located.  See the dir locations in bold below:


<!-- Target Configuration. Modify for your site. -->
<property name="targetData">
<map>
<entry key="alfresco">
<map>
<entry key="root"><value>C:\surf-sample\sample\deploy\alfresco</value></entry>
<entry key="user"><value>admin</value></entry>
<entry key="password"><value>admin</value></entry>
</map>
</entry>
<entry key="content">
<map>
<entry key="root"><value>C:\surf-sample\sample\deploy\webroot</value></entry>
<entry key="user"><value>admin</value></entry>
<entry key="password"><value>admin</value></entry>
</map>
</entry>
</map>
</property>

Once complete, you should be able to start the surf-sample Tomcat and give the site a test.  Create some content using the web forms and deploy it to the surf-sample app.  Start the Tomcat using C:\surf-sample\sample\bin\startup.bat and hit http://localhost/surf/page?p=index

Static Content Example

The Home Page of the site includes a static HTML file that is created using the article.xsd web form.  This creates the latestNews.html file within the repository to ROOT\content\news which is then deployed to the C:\surf-sample\sample\deploy\webroot\ROOT\content\news.  The Surf web application then includes the latestNews.html at request time.

The HTML include import is done by the Surf component, however before this will function, we need to configure Surf (using Spring) to look into the C:\surf-sample\sample\deploy directory for the static content and web scripts.  If you open C:\surf-sample\sample\shared\classes\alfresco\web-extension\custom-web-framework-application-context.xml you will see the example configuration:


<!-- Local Store Abstract  -->
<bean id="webframework.localstore" class="org.alfresco.web.scripts.LocalFileSystemStore" abstract="true" init-method="init">
<property name="root">
<value>/surf-sample/sample/deploy</value>
</property>
</bean>
<!-- Web Scripts: Local Store -->
<bean id="webframework.localstore.webscripts" parent="webframework.localstore">
<property name="path">
<value>alfresco/site-webscripts</value></property>
</bean>

Once this is configured, components can access this static content.  The component that is used on the Home Page is C:\surf-sample\sample\deploy\alfresco\site-data\components\page.main.index.xml and looks like:

<?xml version='1.0' encoding='UTF-8'?>
<component>
<scope>page</scope>
<region-id>main</region-id>
<source-id>index</source-id>
<component-type-id>/component/common/include</component-type-id>
<properties>
<container>div</container>
</properties>
<resources>
<resource id="source" type="webapp">/content/news/latestNews.html</resource>
</resources>
</component>

You can see that we are using one of the web scripts that comes bundled with Surf which is referenced by  /component/common/include.  The resource id is then passed in i.e. the html fragment.

Finally, it is also worth noting at this point that we have mapped a Tomcat alias to point to the “deploy” directory also.  This allows us to reference files such as CSS and images if required, using the “/files” alias.  Here is the server.xml extract:

<Context path="/files" docBase="${catalina.home}/deploy/webroot/ROOT" reloadable="true" crossContext="true"/>

Dynamic Content Example

The second example is the Products page which dynamically loads content from the Alfresco repository.  A list of products is dynamically generated using a web script connecting top the remote Alfresco repository.  When a link is clicked, the relevant content item is dispatched and loaded from the local file system.

The first part of this is a web script that is called to list all of the product items.  This web script is actually located on the remote Alfresco server and therefore we have to configure Surf to search this location for web scripts.

Like configuring the local file store, there is a custom Spring file located in C:\surf-sample\sample\shared\classes\alfresco\web-extension.  Open the web-framework-config-custom.xml file and if you scroll to the bottom, you will see the following extract:


<config evaluator="string-compare" condition="Remote">
<remote>
<endpoint>
<id>alfresco-system</id>
<name>Alfresco - System access</name>
<description>System account access to Alfresco</description>
<connector-id>alfresco</connector-id>
<endpoint-url>http://localhost:8080/alfresco/s</endpoint-url>
<identity>declared</identity>
<username>admin</username>
<password>admin</password>
<unsecure>true</unsecure>
</endpoint>
<!-- The default endpoint -->
<default-endpoint-id>alfresco-system</default-endpoint-id>
</remote>
</config>

This extract configures the remote Alfresco repository as an end-point.  You may also notice just above this that there is another entrance as follows:

<!-- Webapp Resource Resolver -->
<resource-resolver>
<id>webapp</id>
<name>Alfresco Web Application Resource Resolver</name>
<description>Resolves data access for web application assets</description>
<class>org.alfresco.web.framework.resource.AlfrescoWebProjectResourceResolver</class>
<alias-uri>/files</alias-uri>
<store-id>demo</store-id>
</resource-resolver>

This lets Surf bind to web application resources, like static files, in this case, the actual product XML item we wish to view.

With the end-point and resource resolver in place we can call the remote web script.  So the process is fairly straight forward – the Surf component calls the remote web script that returns a list of products via JSON.  We then need a way to load an appropriate template to display each product, and that is done by a page-association item.  This tells Surf that there is an association between the content that is being loaded and the template we would like to use to display it.  Take a look at C:\surf-sample\sample\deploy\alfresco\site-data\page-associations\products.xml:

<?xml version="1.0" encoding="UTF-8"?>
<content-association>
<source-id>{http://www.alfresco.org/model/wcmmodel/1.0}avmplaincontent</source-id>
<dest-id>products</dest-id>
<assoc-type>content-type</assoc-type>
<format-id>default</format-id>
</content-association>

You can see here that the source-id is “{http://www.alfresco.org/model/wcmmodel/1.0}avmplaincontent” and that the dest-id is “products” meaning that all content of the type avmplaincontent would be rendered via the “products” template.

Summary

Hopefully this provides a preview of how nicely WCM content will integrate with Surf powered websites, and Web Studio is also on the horizon to complete the suite.  As noted previously, this Surf configuration and setup is based on the Surf Deployment Configurations wiki article which I would highly recommend reading.  This provides a really good and detailed overview of other possible Surf configurations.

Thanks to Michael Uzquiano for all the assistance!

{ 2 trackbacks }

SURF Part 1 - Getting Started
03.10.09 at 10:30 am
SURF Part 2 - Pages and Navigation
03.10.09 at 10:32 am

{ 17 comments… read them below or add one }

joseba 03.11.09 at 12:08 pm

Hello:

I am try to configure this part, and when I go to the dynamic content page, i don´t see the page, I see the following error:

Alfresco Web Script Status 500 – Internal Error

The Web Script /surf/service/products/left has responded with a status of 500 – Internal Error.

500 Description: An error inside the HTTP server which prevented it from fulfilling the request.

Message: Failed to load script ‘org.alfresco.web.scripts.LocalFileSystemStore$LocalFileSystemStoreScriptContent@e7b1c3′: TypeError: Cannot read property “length” from undefined (/surf-sample/sample/deploy/alfresco/site-webscripts/products.left.get.js#23)

Exception: org.mozilla.javascript.EcmaError – TypeError: Cannot read property “length” from undefined (/surf-sample/sample/deploy/alfresco/site-webscripts/products.left.get.js#23)

org.mozilla.javascript.ScriptRuntime.constructError(ScriptRuntime.java:3350)
org.mozilla.javascript.ScriptRuntime.constructError(ScriptRuntime.java:3340)
org.mozilla.javascript.ScriptRuntime.typeError(ScriptRuntime.java:3356)
org.mozilla.javascript.ScriptRuntime.typeError2(ScriptRuntime.java:3375)
org.mozilla.javascript.ScriptRuntime.undefReadError(ScriptRuntime.java:3388)
org.mozilla.javascript.ScriptRuntime.getObjectProp(ScriptRuntime.java:1362)
org.mozilla.javascript.gen.c3._c0(/surf-sample/sample/deploy/alfresco/site-webscripts/products.left.get.js:23)
org.mozilla.javascript.gen.c3.call(/surf-sample/sample/deploy/alfresco/site-webscripts/products.left.get.js)
org.mozilla.javascript.ContextFactory.doTopCall(ContextFactory.java:393)
org.mozilla.javascript.ScriptRuntime.doTopCall(ScriptRuntime.java:2834)
org.mozilla.javascript.gen.c3.call(/surf-sample/sample/deploy/alfresco/site-webscripts/products.left.get.js)
org.mozilla.javascript.gen.c3.exec(/surf-sample/sample/deploy/alfresco/site-webscripts/products.left.get.js)
org.alfresco.web.scripts.PresentationScriptProcessor.executeScriptImpl(PresentationScriptProcessor.java:256)
org.alfresco.web.scripts.PresentationScriptProcessor.executeScript(PresentationScriptProcessor.java:148)
org.alfresco.web.scripts.AbstractWebScript.executeScript(AbstractWebScript.java:800)
org.alfresco.web.scripts.DeclarativeWebScript.execute(DeclarativeWebScript.java:90)
org.alfresco.web.scripts.PresentationContainer.executeScript(PresentationContainer.java:60)
org.alfresco.web.scripts.LocalWebScriptRuntimeContainer.executeScript(LocalWebScriptRuntimeContainer.java:169)
org.alfresco.web.scripts.AbstractRuntime.executeScript(AbstractRuntime.java:261)
org.alfresco.web.scripts.AbstractRuntime.executeScript(AbstractRuntime.java:139)
org.alfresco.web.scripts.WebScriptProcessor.executeBody(WebScriptProcessor.java:329)
org.alfresco.web.framework.render.AbstractProcessor.execute(AbstractProcessor.java:85)
org.alfresco.web.framework.render.RenderHelper.processComponent(RenderHelper.java:332)
org.alfresco.web.framework.render.RenderUtil.renderRawComponent(RenderUtil.java:451)
org.alfresco.web.framework.render.RenderUtil.renderRawComponent(RenderUtil.java:434)
org.alfresco.web.site.taglib.ComponentIncludeTag.doStartTag(ComponentIncludeTag.java:46)
org.alfresco.tools.TagUtil.execute(TagUtil.java:142)
org.alfresco.tools.TagUtil.execute(TagUtil.java:78)
org.alfresco.web.scripts.FreemarkerTagSupportDirective.executeTag(FreemarkerTagSupportDirective.java:89)
org.alfresco.web.scripts.GenericFreemarkerTagDirective.execute(GenericFreemarkerTagDirective.java:127)
freemarker.core.Environment.visit(Environment.java:261)
freemarker.core.UnifiedCall.accept(UnifiedCall.java:126)
freemarker.core.Environment.visit(Environment.java:208)
freemarker.core.Environment.process(Environment.java:188)
freemarker.template.Template.process(Template.java:237)
org.alfresco.web.scripts.PresentationTemplateProcessor.process(PresentationTemplateProcessor.java:146)
org.alfresco.web.scripts.FreemarkerProcessor.executeBody(FreemarkerProcessor.java:240)
org.alfresco.web.framework.render.AbstractProcessor.execute(AbstractProcessor.java:85)
org.alfresco.web.framework.render.RenderHelper.processRenderable(RenderHelper.java:276)
org.alfresco.web.framework.render.bean.ChromeRenderer.body(ChromeRenderer.java:60)
org.alfresco.web.framework.render.AbstractRenderer.render(AbstractRenderer.java:105)
org.alfresco.web.framework.render.bean.ComponentRenderer.body(ComponentRenderer.java:129)
org.alfresco.web.framework.render.RenderUtil.renderRegionComponents(RenderUtil.java:328)
org.alfresco.web.site.taglib.RegionIncludeTag.doStartTag(RegionIncludeTag.java:43)
org.alfresco.tools.TagUtil.execute(TagUtil.java:142)
org.alfresco.tools.TagUtil.execute(TagUtil.java:78)
org.alfresco.web.scripts.FreemarkerTagSupportDirective.executeTag(FreemarkerTagSupportDirective.java:89)
org.alfresco.web.scripts.GenericFreemarkerTagDirective.execute(GenericFreemarkerTagDirective.java:127)
freemarker.core.Environment.visit(Environment.java:261)
freemarker.core.UnifiedCall.accept(UnifiedCall.java:126)
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.web.scripts.PresentationTemplateProcessor.process(PresentationTemplateProcessor.java:146)
org.alfresco.web.scripts.FreemarkerProcessor.executeBody(FreemarkerProcessor.java:240)
org.alfresco.web.framework.render.AbstractProcessor.execute(AbstractProcessor.java:85)
org.alfresco.web.framework.render.RenderHelper.processRenderable(RenderHelper.java:276)
org.alfresco.web.framework.render.bean.ChromeRenderer.body(ChromeRenderer.java:60)
org.alfresco.web.framework.render.AbstractRenderer.render(AbstractRenderer.java:105)
org.alfresco.web.framework.render.bean.RegionRenderer.body(RegionRenderer.java:134)
org.alfresco.web.framework.render.AbstractRenderer.render(AbstractRenderer.java:105)
org.alfresco.web.framework.render.RenderUtil.startRegionRenderer(RenderUtil.java:273)
org.alfresco.web.framework.render.RenderUtil.renderRegion(RenderUtil.java:213)
org.alfresco.web.framework.render.PresentationUtil.renderRegion(PresentationUtil.java:124)
org.alfresco.web.site.taglib.RegionTag.doStartTag(RegionTag.java:109)
org.alfresco.tools.TagUtil.execute(TagUtil.java:142)
org.alfresco.tools.TagUtil.execute(TagUtil.java:78)
org.alfresco.web.scripts.FreemarkerTagSupportDirective.executeTag(FreemarkerTagSupportDirective.java:89)
org.alfresco.web.scripts.RegionFreemarkerTagDirective.execute(RegionFreemarkerTagDirective.java:128)
freemarker.core.Environment.visit(Environment.java:261)
freemarker.core.UnifiedCall.accept(UnifiedCall.java:126)
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.web.scripts.PresentationTemplateProcessor.process(PresentationTemplateProcessor.java:146)
org.alfresco.web.scripts.FreemarkerProcessor.executeBody(FreemarkerProcessor.java:240)
org.alfresco.web.framework.render.AbstractProcessor.execute(AbstractProcessor.java:85)
org.alfresco.web.framework.render.RenderHelper.processTemplate(RenderHelper.java:376)
org.alfresco.web.framework.render.bean.TemplateInstanceRenderer.body(TemplateInstanceRenderer.java:135)
org.alfresco.web.framework.render.AbstractRenderer.render(AbstractRenderer.java:105)
org.alfresco.web.framework.render.bean.PageRenderer.body(PageRenderer.java:81)
org.alfresco.web.framework.render.AbstractRenderer.render(AbstractRenderer.java:105)
org.alfresco.web.framework.render.RenderUtil.startPageRenderer(RenderUtil.java:144)
org.alfresco.web.framework.render.RenderUtil.renderPage(RenderUtil.java:117)
org.alfresco.web.framework.render.PresentationUtil.renderPage(PresentationUtil.java:85)
org.alfresco.web.site.servlet.DispatcherServlet.dispatchPage(DispatcherServlet.java:459)
org.alfresco.web.site.servlet.DispatcherServlet.dispatch(DispatcherServlet.java:336)
org.alfresco.web.site.servlet.DispatcherServlet.service(DispatcherServlet.java:153)
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.tuckey.web.filters.urlrewrite.RuleChain.handleRewrite(RuleChain.java:176)
org.tuckey.web.filters.urlrewrite.RuleChain.doRules(RuleChain.java:145)
org.tuckey.web.filters.urlrewrite.UrlRewriter.processRequest(UrlRewriter.java:92)
org.tuckey.web.filters.urlrewrite.UrlRewriteFilter.doFilter(UrlRewriteFilter.java:381)
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
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.web.scripts.WebScriptException – TypeError: Cannot read property “length” from undefined (/surf-sample/sample/deploy/alfresco/site-webscripts/products.left.get.js#23)

org.alfresco.web.scripts.PresentationScriptProcessor.executeScriptImpl(PresentationScriptProcessor.java:261)

Exception: org.alfresco.web.scripts.WebScriptException – Failed to load script ‘org.alfresco.web.scripts.LocalFileSystemStore$LocalFileSystemStoreScriptContent@e7b1c3′: TypeError: Cannot read property “length” from undefined (/surf-sample/sample/deploy/alfresco/site-webscripts/products.left.get.js#23)

org.alfresco.web.scripts.PresentationScriptProcessor.executeScript(PresentationScriptProcessor.java:152)

Server: Alfresco Labs v3.0.0 (Stable r13140) schema 2.000
Time: 11-mar-2009 12:04:12

Can you help me?, please

admin 03.11.09 at 3:40 pm

Hi,
Is the Products web script installed and working correctly on your Alfresco repo? You can check by browsing to the Web Scripts Home i,e, http://localhost:8080/alfresco/service/, select “Browse by web script package”, scroll down and select “/products”. You can then click on the GET link i.e. GET / alfresco/service/products/get and this will run the web script. If it is working it will return a JSON response listing some example products. If it fails to return any products, check your AVM dir structure. It loads the products from the /content/products/source dir.

Other things to check:
1) is your repo running at http://localhost:8080 as I mentioned within the prerequisites?
2) Is the username/pass admin/admin? If not edit in the web-framework-config-custom.xml.

Ben.

joseba 03.11.09 at 5:18 pm

Hi ben,

I click on the GET link i.e. GET /alfresco/service/products/get and I see the following error:

HTTP 404 page not found…

Thank you very much

joseba 03.12.09 at 1:27 pm

I resolve the problem, I copy bad the products.get.html.ftl

thank you

Seb 03.19.09 at 1:22 pm

The link to the “Surf Tomcat bundle” is broken :-s

admin 03.19.09 at 1:37 pm

Thanks for letting me know Seb. Now fixed.

Regards, Ben.

Marie 03.20.09 at 4:40 pm

Hi Ben,

Thank you for the tutorial. I try the part 3.
I work with Alfresco 3d Tomcat 6.
I add a article via the Web content wizard and I have the error :

Please correct the errors below then click Finish.
Error generating rendition using latestNews.html.ftl: node avm://demo–admin–preview/-1;www;avm_w … latestNews.html does not have aspect {http://www.alfresco.org/model/wcmappmodel/1.0}rendition

On tomcat

05:02:16,734 User:admin ERROR [ui.common.Utils] Error generating rendition using latestNews.htm
l.ftl: node avm://demo–admin–preview/-1;www;avm_webapps;ROOT;content;news;latestNews.html doe
s not have aspect {http://www.alfresco.org/model/wcmappmodel/1.0}rendition
java.lang.IllegalArgumentException: node avm://demo–admin–preview/-1;www;avm_webapps;ROOT;con
tent;news;latestNews.html does not have aspect {http://www.alfresco.org/model/wcmappmodel/1.0}r
endition
at org.alfresco.web.forms.RenditionImpl.(RenditionImpl.java:84)
at org.alfresco.web.forms.RenditionImpl.(RenditionImpl.java:95)
at org.alfresco.web.forms.RenderingEngineTemplateImpl.render(RenderingEngineTemplateImp
l.java:302)
at org.alfresco.web.bean.wcm.CreateWebContentWizard.saveContent(CreateWebContentWizard.
java:595)
at org.alfresco.web.bean.wcm.CreateWebContentWizard$2.execute(CreateWebContentWizard.ja
va:285)
at org.alfresco.web.bean.wcm.CreateWebContentWizard$2.execute(CreateWebContentWizard.ja
va:282)
at org.alfresco.repo.transaction.RetryingTransactionHelper.doInTransaction(RetryingTran
sactionHelper.java:320)
at org.alfresco.repo.transaction.RetryingTransactionHelper.doInTransaction(RetryingTran
sactionHelper.java:227)
at org.alfresco.web.bean.wcm.CreateWebContentWizard.next(CreateWebContentWizard.java:29
3)
at org.alfresco.web.bean.wizard.WizardManager.next(WizardManager.java:541)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25
)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.apache.myfaces.el.MethodBindingImpl.invoke(MethodBindingImpl.java:132)
at org.apache.myfaces.application.ActionListenerImpl.processAction(ActionListenerImpl.j
ava:61)
at javax.faces.component.UICommand.broadcast(UICommand.java:109)
at javax.faces.component.UIViewRoot._broadcastForPhase(UIViewRoot.java:97)
at javax.faces.component.UIViewRoot.processApplication(UIViewRoot.java:171)
at org.apache.myfaces.lifecycle.InvokeApplicationExecutor.execute(InvokeApplicationExec
utor.java:32)
at org.apache.myfaces.lifecycle.LifecycleImpl.executePhase(LifecycleImpl.java:95)
at org.apache.myfaces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:70)
at javax.faces.webapp.FacesServlet.service(FacesServlet.java:139)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterCh
ain.java:290)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java
:206)
at org.alfresco.web.app.servlet.AuthenticationFilter.doFilter(AuthenticationFilter.java
:81)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterCh
ain.java:235)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java
:206)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:286)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:845)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protoc
ol.java:583)
at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
at java.lang.Thread.run(Thread.java:619)

Can you help me?, please

admin 03.23.09 at 11:07 am

Hi Marie,
When I have seen this error in the past it has been due to the meta data being broken i.e. the rendition is not associated with the xml as it should be.

Try Will’s repair script to fix the association – http://wabson.wordpress.com/2008/08/04/web-script-repair-web-project/
Regards, Ben.

Peter 03.25.09 at 2:22 pm

Hi Ben, hope you can help explain this a bit more, specifically how to base an entire surf website out of a WCM project, instead of only pulling out content or the odd web script? Surf is great on its own but being able to use CIFS to dump stuff in using AVM instead of putting everything in the classpath would be brilliant. Both the classpath and possible localstore locations are in this case on a remote development server to which I only have command-line access, and SCPing everything kind of sucks!
I understand that what I want to do should require the modification of the beans for model objects as well as the search paths to use the remotestore (wherever you have used localstore), but I am having a difficult time making this work, and I think I’m missing something fairly obvious. I have AVM and Surf working perfectly in isolation, but can’t get them to talk.

So, I’ve got as far as defining an (abstract) remote store with the end point pointing to http://server/alfresco/s, api is /avmstore as per the Surf deployment configurations wiki page, and also have set the storeId to “test03–admin” (which is a web project in my Alfresco install).

Looking over my own config I seem to have covered everything – remote store set up with right endpoint, search paths and model objects have the remotestore in the relevant place (it’s the first item in the searchpaths), web project exists with the surf structire in /WEB-INF/classes/alfresco, in the admin’s sandbox. Can’t get it to work though :( Either it starts up fine but wont work, or it sits forever at deployment when starting Tomcat – presumably while something times out again and again.
I’m using the URL structure from the “Surf as a Preview Server” section of the wiki, where you specify storeId, user and page on the URL. Even with just http://server/alfwf/page?p=test it won’t work either, though.

The wiki is woeful at explaining around the subject, so being a non-expert I’m rather at a dead end., and hope you can shed some light on the matter.

Best,
Peter.

admin 04.08.09 at 2:47 pm

Hi Peter,

If i understand you correctly, you are trying to store the SURF files within the AVM, and then deploy them to your surf application? If this is the case, this is exactly what the example above demonstrates. It seperates the two different types of content i.e. the Surf files (web scripts, templates etc) and also the typical content produced via web forms and anything else uploaded via CIFS (e.g. xml, html etc). All of these files are then deployed to the target surf app, placing the relavent files in their correct locations e..g overwriting the surf framework files and adding to the xml, html etc into the required folders.

There are two example config files located in C:\surf-sample\sample\shared\classes\alfresco\web-extension. These are:

1) custom-web-framework-application-context.xml – This sets the local store i.e. where the static files are, and also the web scripts local store.

2) web-framework-config-custom.xml – this sets the alfresco repo end point however this is only required for the “products” example that connects back to the repo and loads content dynamically.

Let me know if i have mis-understood!

Regards, Ben.

buckwheat219 04.15.09 at 5:25 am

Hello Loseba ,please say much more about how you solve the bug so
Thanks alot

Alfresco Web Script Status 500 – Internal Error

The Web Script /surf/service/products/left has responded with a status of 500 – Internal Error.

500 Description: An error inside the HTTP server which prevented it from fulfilling the request.

Message: Failed to load script ‘org.alfresco.web.scripts.LocalFileSystemStore$LocalFileSystemStoreScriptContent@e7b1c3′: TypeError: Cannot read property “length” from undefined (/surf-sample/sample/deploy/alfresco/site-webscripts/products.left.get.js#23)

Exception: org.mozilla.javascript.EcmaError – TypeError: Cannot read property “length” from undefined (/surf-sample/sample/deploy/alfresco/site-webscripts/products.left.get.js#23)

ric 05.06.09 at 5:58 pm

I’m getting the same problem as buckweat.

I’ve checked the source code for products.get.js and the path is:

var path = (“/www/avm_webapps/surf/content/products/source”);

which doesn’t exist (at least in our case). I don’t have the CIFS well configured so I did a bulk import for the admin staging area (that could be the problem). The other stuff works so I assume that the problem could be that path.

ric 05.07.09 at 11:31 am

I figured it out. The path was wrong. The way I did things the path was actually var path = (”/www/avm_webapps/ROOT/content/products/source”);. Notice ROOT instead of SURF.

Here’s how I found out. There are some sample scripts in http://localhost:8080/alfresco/service/index/package/org/alfresco/sample and one of them lists AVM stores http://localhost:8080/alfresco/service/sample/avm/stores

Browse through the demo store (if you’re using the default values for this example) and you’ll see the correct path.

volek 05.13.09 at 1:07 pm

Thanks, ric!
I had wrong path too.
/www/avm_webapps/ROOT/content/products/source is valid path to me.

Mark 05.22.09 at 7:09 pm

Hi Ben,

Thanks for the article. I am still struggling with this. A few questions:
1. Are there any configs that need to be done to the Alfresco DM to allow Surf to grab webscripts?
2. Is there a good way to test if Alfresco is releasing webscripts: e.g. going to a link lik ehttp://localhost:8585/alfresco/s…… something?
3. I just pulled a new Surf and it has a config file called, web-framework-config-remote.xml. It is here, in the war file, that I am setting the remote endpoint. Do you see any problem here?
4. Is there a special way to refer to remote webscripts from the tags in the Surf templates?

Any advise is appreciated.

Thanks, Mark

Jorge Elizondo 08.12.10 at 6:53 pm

Hi Ben,

When I click on this link, http://www.benh.co.uk/wp-content/uploads/2009/03/surf-sample.zip
I get the “You 404’d it. Gnarly, dude” message

thanks in advance

admin 08.13.10 at 8:37 am

Thanks for letting me know Jorge. I migrated hosts some time back and it looks like the permissions were not set correctly. Should be OK now. If you are interested in using Spring Surf with OpenCMIS, we will be releasing the WCM Quick Start in a few weeks (http://wiki.alfresco.com/wiki/Roadmap#WCM_Quick_Start).

Regards, Ben.

Leave a Comment

You can use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>