cancel
Showing results for 
Search instead for 
Did you mean: 

WebForm (Edit Web Content Wizard) ERROR on Alfresco 3.4.b

ronnybse
Champ in-the-making
Champ in-the-making
I was working with Alfresco Community Edition 3.2r2 without problems.
But now I just installed Alfresco Community Edition 3.4.b (win x64 .exe) and now i got this problem:

If I try to make a content change using a webForm I get the following error(in the Edit Web Content Wizard):
   
Error  Please correct the errors below then click Finish.

    * error regenerating rendition using phone.ftl: null
and the log:

18:31:54,686 User:admin ERROR [ui.common.Utils] error regenerating rendition using phone.ftl: null
java.lang.NullPointerException
   at org.alfresco.web.forms.FormInstanceDataImpl.regenerateRenditions(FormInstanceDataImpl.java:284)
   at org.alfresco.web.bean.wcm.EditWebContentWizard.saveContent(EditWebContentWizard.java:195)
   at org.alfresco.web.bean.wcm.CreateWebContentWizard$2.execute(CreateWebContentWizard.java:276)
   at org.alfresco.web.bean.wcm.CreateWebContentWizard$2.execute(CreateWebContentWizard.java:272)
   at org.alfresco.repo.transaction.RetryingTransactionHelper.doInTransaction(RetryingTransactionHelper.java:377)
   at org.alfresco.repo.transaction.RetryingTransactionHelper.doInTransaction(RetryingTransactionHelper.java:251)
   at org.alfresco.web.bean.wcm.CreateWebContentWizard.next(CreateWebContentWizard.java:284)
   at org.alfresco.web.bean.wizard.WizardManager.next(WizardManager.java:554)
   at sun.reflect.GeneratedMethodAccessor2861.invoke(Unknown Source)
   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.java: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(InvokeApplicationExecutor.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(ApplicationFilterChain.java:290)
   at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
   at org.alfresco.web.app.servlet.AuthenticationFilter.doFilter(AuthenticationFilter.java:104)
   at sun.reflect.GeneratedMethodAccessor635.invoke(Unknown Source)
   at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
   at java.lang.reflect.Method.invoke(Method.java:597)
   at org.alfresco.repo.management.subsystems.ChainingSubsystemProxyFactory$1.invoke(ChainingSubsystemProxyFactory.java:116)
   at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
   at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:202)
   at $Proxy214.doFilter(Unknown Source)
   at org.alfresco.repo.web.filter.beans.BeanProxyFilter.doFilter(BeanProxyFilter.java:82)
   at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
   at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
   at org.alfresco.repo.web.filter.beans.NullFilter.doFilter(NullFilter.java:68)
   at sun.reflect.GeneratedMethodAccessor635.invoke(Unknown Source)
   at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
   at java.lang.reflect.Method.invoke(Method.java:597)
   at org.alfresco.repo.management.subsystems.ChainingSubsystemProxyFactory$1.invoke(ChainingSubsystemProxyFactory.java:116)
   at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
   at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:202)
   at $Proxy214.doFilter(Unknown Source)
   at org.alfresco.repo.web.filter.beans.BeanProxyFilter.doFilter(BeanProxyFilter.java:82)
   at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
   at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
   at org.alfresco.web.app.servlet.GlobalLocalizationFilter.doFilter(GlobalLocalizationFilter.java:58)
   at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.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:127)
   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:298)
   at org.apache.coyote.http11.Http11AprProcessor.process(Http11AprProcessor.java:859)
   at org.apache.coyote.http11.Http11AprProtocol$Http11ConnectionHandler.process(Http11AprProtocol.java:579)
   at org.apache.tomcat.util.net.AprEndpoint$Worker.run(AprEndpoint.java:1555)
   at java.lang.Thread.run(Thread.java:619)

These are the steps that I followed:
1. Create a webForm
(phone.xsd)

<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
      targetNamespace="http://www.example.org/side"
      xmlns:si="http://www.example.org/side"
      elementFormDefault="qualified">
      
  <xs:element name="sideBar">
    <xs:complexType>
      <xs:sequence>
        <xs:element name="phoneNumber" type="xs:normalizedString" />
      </xs:sequence>
    </xs:complexType>
  </xs:element>
 
</xs:schema>
(phone.ftl)

<#ftl ns_prefixes={"D", "http://www.example.org/side"}>

<h2>Contact Number:</h2>
<p>${sideBar.phoneNumber}</p>
<p><a href="contact.html" target="blank">Contact us</a></p>

2. Create a new web project using the wizard, and configure the webForm.

3. In user sandbox, create new content using the webForm 'Create Web Content Wizard' (.html and .xml).

4. Submit changes to the staging sandbox.

5. In the user sandbox, in the webForm section, use the option 'browse content', and use the option 'edit' to modify the content using the webform.

6. In the 'Edit Web Content Wizard' when go to next step, the error is showed.


As I mentioned, this was working fine in the other version.
Someone could help me?
1 REPLY 1

ronnybse
Champ in-the-making
Champ in-the-making
Well, as looks all the steps that I followed are correct, and the webform definition are correct too. I consider this as a bug of alfresco 3.4.b and 3.4.c.

As I needed this functionality working, I had to modify the class FormInstanceDataImpl.java on alfresco Web-Client project to avoid the NPE.

So, the first change that I made was on line 283 (FormInstanceDataImpl.java)
To avoid the NPE, I moved the code to obtain the lockData inside the conditional if exist a lockOwner

            lockOwner = avmLockService.getLockOwner(storeId, storePath);
            /*bse: to avoid NPE when there is not locked data. Moved inside the conditional*/
           
            if (lockOwner != null)
            {
               Map<String, String> lockData = avmLockService.getLockData(storeId, storePath);
               currentLockStore = lockData.get(WCMUtil.LOCK_KEY_STORE_NAME);
               if (logger.isDebugEnabled())
               …
Actually the class RegenerateResult.java require a not null lockOwner in the constructor method, so we must add an 'else' sentence in the above conditional where if not exist a lockOwner, we assign the current user as lockOwner.

            else
            {
               /*bse: to have a lockOwner, as this is required*/
               lockOwner = username;
            }
           
            result.add(new RegenerateResult(ret, path, ret.render(this, path), lockOwner));
With the change mentioned above, we avoid the NPE, but now there is other error.
In the class EditWebContentWizard.java once we made a modification, the code lock the file with the user, but dont update the lockOwner variable and is still null.

So, the second chage that I made was on line 190 (EditWebContentWizard.java), to update the lockOwner

      final ContentWriter writer = this.getAvmService().getContentWriter(this.createdPath, true);
     
      /*bse: to update the lockOwner, as this is required*/
      lockOwner = this.getAvmLockingService().getLockOwner(storeId, storePath);
     
      this.content = XMLUtil.toString(this.getInstanceDataDocument(), false);
      writer.putContent(this.content);
With these two changes, the edit webForm content works.
But there is other error: If we cancel the edit, we will see that the files are still locked.
This occurs because in the class EditWebContentWizard.java the code add the renditions path to the variable(existingLocks) reponsible to show lock files. And in 'cancel' method, if the path is registered in this variable(existingLocks), dont remove the lock.

So in this case, In line 234 (EditWebContentWizard.java) I only commented the code where the renditions path are added to the variable(existingLocks)

            /*bse: to unlock the files when user click 'cancel'*/
//            if (rr.getLockOwner() != null)
//            {
//                this.existingLocks.add(path);
//            }

With these changes this functionality is working well.
There are other bugs, but not related to this change.