cancel
Showing results for 
Search instead for 
Did you mean: 

Repository Corruption when modifying content properties

laurents
Champ in-the-making
Champ in-the-making
Hi all,
from a new Alfresco installation v3.4 (latest check out from yesterday) have re-compiled and re-deployed alfresco.war into Tomcat. All went fine, startup fine, no errors in catalina.out logs, a fresh new repository is created and a new alfresco DB setup with tables and content, no MySQL error reported. I have no custom code, no custom extensions.

Problem Description : when creating or adding a new content, simple Plain Text file, "Modify all properties when this wizard closes" unchecked. Then I try to edit it online, just add some dummy text, then "Done Editing" works fine.
But, as soon as I change the properties of this file (View Details), and say modify its Description attribute, save… it becomes impossible to edit the file on line, finishing with a "Done Editing" generates this error on the web UI :

"Unable to check in Content Node due to system errorSmiley Surprisedrg.alfresco.service.cmr.repository.ContentData cannot be cast to org.alfresco.repo.domain.node.ContentDataWithId"

and further check-out check-in operations also fail on this document. Looks like the repository is corrupted at this point.

I am not sure if I did something wrong during the installation, or if this is a known problem or if I misunderstood the point in how to use the product. It sounds so big that I am sure that I must have done something wrong or use a wrong snapshot, but I would need some help how to find a work around.

Is this current latest snapshot already usable (see version.properties) ?

Any help appreciated. Thanks,
Laurent



version.properties :
version.major=3
version.minor=4
version.revision=0
version.label=dev

# Edition label

version.edition=Community

# Build number

version.build=@build-number@

# Schema number

version.schema=4107


Trace log :

14:55:53,194 User:admin ERROR [ui.common.Utils] Unable to check in Content Node due to system errorSmiley Surprisedrg.alfresco.service.cmr.repository.ContentData cannot be cast to org.alfresco.repo.domain.node.ContentDataWithId
java.lang.ClassCastException: org.alfresco.service.cmr.repository.ContentData cannot be cast to org.alfresco.repo.domain.node.ContentDataWithId
   at org.alfresco.repo.domain.node.AbstractNodeDAOImpl.setNodePropertiesImpl(AbstractNodeDAOImpl.java:1701)
   at org.alfresco.repo.domain.node.AbstractNodeDAOImpl.addNodeProperties(AbstractNodeDAOImpl.java:1808)
   at org.alfresco.repo.node.db.DbNodeServiceImpl.addAspectsAndProperties(DbNodeServiceImpl.java:501)
   at org.alfresco.repo.node.db.DbNodeServiceImpl.addAspectsAndProperties(DbNodeServiceImpl.java:422)
   at org.alfresco.repo.node.db.DbNodeServiceImpl.addProperties(DbNodeServiceImpl.java:1417)
   at sun.reflect.GeneratedMethodAccessor748.invoke(Unknown Source)
   at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
   at java.lang.reflect.Method.invoke(Method.java:597)
   at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:307)
   at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:183)
   at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:150)
   at org.alfresco.repo.tenant.MultiTNodeServiceInterceptor.invoke(MultiTNodeServiceInterceptor.java:104)
   at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
   at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:202)
   at $Proxy7.addProperties(Unknown Source)
   at sun.reflect.GeneratedMethodAccessor748.invoke(Unknown Source)
   at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
   at java.lang.reflect.Method.invoke(Method.java:597)
   at org.alfresco.repo.service.StoreRedirectorProxyFactory$RedirectorInvocationHandler.invoke(StoreRedirectorProxyFactory.java:215)
   at $Proxy8.addProperties(Unknown Source)
   at org.alfresco.repo.node.MLPropertyInterceptor.invoke(MLPropertyInterceptor.java:233)
   at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
   at org.alfresco.repo.node.NodeRefPropertyMethodInterceptor.invoke(NodeRefPropertyMethodInterceptor.java:269)
   at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
   at org.alfresco.repo.node.NodeRefPropertyMethodInterceptor.invoke(NodeRefPropertyMethodInterceptor.java:269)
   at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
   at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:202)
   at $Proxy7.addProperties(Unknown Source)
   at org.alfresco.repo.copy.CopyServiceImpl.copyProperties(CopyServiceImpl.java:871)
   at org.alfresco.repo.copy.CopyServiceImpl.copy(CopyServiceImpl.java:352)
   at sun.reflect.GeneratedMethodAccessor857.invoke(Unknown Source)
   at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
   at java.lang.reflect.Method.invoke(Method.java:597)
   at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:307)
   at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:183)
   at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:150)
   at org.alfresco.repo.security.permissions.impl.AlwaysProceedMethodInterceptor.invoke(AlwaysProceedMethodInterceptor.java:34)
   at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
   at org.alfresco.repo.security.permissions.impl.ExceptionTranslatorMethodInterceptor.invoke(ExceptionTranslatorMethodInterceptor.java:44)
   at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
   at org.alfresco.repo.audit.AuditMethodInterceptor.invoke(AuditMethodInterceptor.java:132)
   at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
   at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:107)
   at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
   at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:202)
   at $Proxy49.copy(Unknown Source)
   at org.alfresco.repo.coci.CheckOutCheckInServiceImpl.checkin(CheckOutCheckInServiceImpl.java:552)
   at sun.reflect.GeneratedMethodAccessor856.invoke(Unknown Source)
   at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
   at java.lang.reflect.Method.invoke(Method.java:597)
   at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:307)
   at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:183)
   at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:150)
   at net.sf.acegisecurity.intercept.method.aopalliance.MethodSecurityInterceptor.invoke(MethodSecurityInterceptor.java:80)
   at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
   at org.alfresco.repo.security.permissions.impl.ExceptionTranslatorMethodInterceptor.invoke(ExceptionTranslatorMethodInterceptor.java:44)
   at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
   at org.alfresco.repo.audit.AuditMethodInterceptor.invoke(AuditMethodInterceptor.java:132)
   at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
   at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:107)
   at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
   at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:202)
   at $Proxy108.checkin(Unknown Source)
   at org.alfresco.web.bean.coci.CheckinCheckoutDialog$1.execute(CheckinCheckoutDialog.java:522)
   at org.alfresco.repo.transaction.RetryingTransactionHelper.doInTransaction(RetryingTransactionHelper.java:325)
   at org.alfresco.repo.transaction.RetryingTransactionHelper.doInTransaction(RetryingTransactionHelper.java:232)
   at org.alfresco.web.bean.coci.CheckinCheckoutDialog.checkinFileOK(CheckinCheckoutDialog.java:527)
   at org.alfresco.web.bean.coci.DoneEditingDialog.handle(DoneEditingDialog.java:116)
   at sun.reflect.GeneratedMethodAccessor855.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 javax.faces.component.UICommand.broadcast(UICommand.java:89)
   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.GeneratedMethodAccessor490.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 $Proxy212.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.GeneratedMethodAccessor490.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 $Proxy212.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.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)
1 REPLY 1

laurents
Champ in-the-making
Champ in-the-making
guys at Alfresco,

I found a work around but I am not sure if it is orthodox ! It is a simple hack and an explanation how to prevent the above error to happen. The Java class concerned is :

projects/repository/source/java/org/alfresco/repo/domain/node/AbstractNodeDAOImpl.java

method : setNodePropertiesImpl

The problem is that at line 1701 in the original class where the exception is raised we have this :
ContentDataWithId contentDataWithId = (ContentDataWithId) valueToDelete.getValue(DataTypeDefinition.CONTENT);

here, there is a casting done on a serialized object which "sometimes" is NOT ContentDataWithId. In general it is common practice in Java to perform a test on a serialized object's type before using it in order to make sure there is no error at run-time. So I have changed the code as below in red, the error does not occur anymore. However I am not sure about possible side effects.

- What to do with objects which are not of type ContentDataWithId ?
- Are there other coding errors like these across the sources, if yes we are all running on a mine field on the community edition…

Quick fix coded in red :

// Add or remove properties as we go
        ContentDataWithId cdwi;
        for (Map.Entry<NodePropertyKey, MapValueComparison> entry : persistableDiff.entrySet())
        {
            NodePropertyKey key = entry.getKey();

            QName qname = qnameDAO.getQName(key.getQnameId()).getSecond();

            PropertyDefinition removePropDef = dictionaryService.getProperty(qname);
            boolean isContent = (removePropDef != null &&
                    removePropDef.getDataType().getName().equals(DataTypeDefinition.CONTENT));

            switch (entry.getValue())
            {
            case NULL:
            case EQUAL:
                // The entries are the same
                propsToDelete.remove(key);
                propsToAdd.remove(key);
                continue;
            case RIGHT_ONLY:
                // Only in new props: add
                propsToDelete.remove(key);
                // Handle new content
                if (isContent)
                {
                    // The new value needs conversion to the ID-based ContentData reference
                    NodePropertyValue newPropValue = propsToAdd.get(key);
                    ContentData newContentData = (ContentData) newPropValue.getValue(DataTypeDefinition.CONTENT);
                    if (newContentData != null)
                    {
                        Long newContentDataId = contentDataDAO.createContentData(newContentData).getFirst();
                        cdwi = new ContentDataWithId(newContentData, newContentDataId);
                        newPropValue = new NodePropertyValue(DataTypeDefinition.CONTENT, new ContentDataId(newContentDataId));
                        propsToAdd.put(key, newPropValue);
                        newPropsRaw.put(key, new NodePropertyValue(DataTypeDefinition.CONTENT, cdwi));
                    }
                }
                continue;
            case LEFT_ONLY:
                // Only present in old props: must not be added
                propsToAdd.remove(key);
                // Handle deleted content
                if (isContent)
                {
                    // The old values will be an ID-based ContentData reference
                    NodePropertyValue valueToDelete = propsToDelete.get(key);
                    if (valueToDelete.getValue(DataTypeDefinition.CONTENT) instanceof ContentDataWithId) {
                        cdwi = (ContentDataWithId) valueToDelete.getValue(DataTypeDefinition.CONTENT);
                        if (cdwi != null) {
                            Long contentDataId = cdwi.getId();
                            contentDataDAO.deleteContentData(contentDataId);
                        }
                    } else {
                    // What needs to be done here, when the object is not the type expected ?
                    }

                }
                continue;
            case NOT_EQUAL:
                // Value has changed: remove and add
                if (isContent)
                {
                    // The old values will be an ID-based ContentData reference
                    NodePropertyValue valueToDelete = propsToDelete.get(key);
                    if (valueToDelete.getValue(DataTypeDefinition.CONTENT) instanceof ContentDataWithId) {
                        cdwi = (ContentDataWithId) valueToDelete.getValue(DataTypeDefinition.CONTENT);
                        if (cdwi != null) {
                            Long contentDataId = cdwi.getId();
                            contentDataDAO.deleteContentData(contentDataId);
                        }
                    } else {
                    // What needs to be done here, when the object is not the type expected ?
                    }


                    // The new value needs conversion to the ID-based ContentData reference
                    NodePropertyValue newPropValue = propsToAdd.get(key);
                    ContentData newContentData = (ContentData) newPropValue.getValue(DataTypeDefinition.CONTENT);
                    if (newContentData != null)
                    {
                        Long newContentDataId = contentDataDAO.createContentData(newContentData).getFirst();
                        cdwi = new ContentDataWithId(newContentData, newContentDataId);
                        newPropValue = new NodePropertyValue(DataTypeDefinition.CONTENT, new ContentDataId(newContentDataId));
                        propsToAdd.put(key, newPropValue);
                        newPropsRaw.put(key, new NodePropertyValue(DataTypeDefinition.CONTENT, cdwi));
                    }
                }
                continue;
            default:
                throw new IllegalStateException("Unknown MapValueComparison: " + entry.getValue());
            }
        }