Uploaded image for project: 'PUBLIC - Liferay Portal Community Edition'
  1. PUBLIC - Liferay Portal Community Edition
  2. LPS-60809

AssetLocalServiceImpl.mergeCategories throws ClassCastException

    Details

      Description

      This issue is not reproducible from the UI, as the faulty method is not invoked.
      Master is not affected.

      REPRODUCTION STEPS

      1. start a new 6.2 SP13 portal
      2. create two categories:
        site administration -> content -> categories -> add category
      3. in your database check the categoryId for those categories from assetcategory table
        OR
        run the following Groovy script:
        import com.liferay.portlet.asset.service.AssetCategoryLocalServiceUtil;
        categories = AssetCategoryLocalServiceUtil.getCategories();
        out.println(categories);
        
      4. merge the categories: run the following Groovy script from control panel -> server administration -> script
        import com.liferay.portal.kernel.exception.PortalException;
        import com.liferay.portal.kernel.exception.SystemException;
        import com.liferay.portal.kernel.log.Log;
        import com.liferay.portal.kernel.log.LogFactoryUtil;
        import com.liferay.portlet.asset.service.AssetCategoryLocalServiceUtil;
        
        import java.io.IOException;
         System.out.println("testing starts");
                
                long first = <ADD HERE THE FIRST CATEGORYID>;
                long sec = <ADD HERE THE SECOND CATEGORYID>;
                try {
           AssetCategoryLocalServiceUtil.mergeCategories(first, sec);
          } catch (PortalException e) {
           e.printStackTrace();
          } catch (SystemException e) {
           e.printStackTrace();
          }
        

        expected result the two categories are merged now and there is only one category
        actual result it didn't merge the categories and there is an exception in the log:

        com.liferay.portal.kernel.search.SearchException: java.lang.ClassCastException: java.lang.Long cannot be cast to com.liferay.portlet.asset.model.Asset
        Category
                at com.liferay.portal.kernel.search.BaseIndexer.reindex(BaseIndexer.java:453)
                at com.liferay.portlet.asset.service.impl.AssetCategoryLocalServiceImpl.mergeCategories(AssetCategoryLocalServiceImpl.java:439)
                at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
                at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
                at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
                at java.lang.reflect.Method.invoke(Method.java:606)
                at com.liferay.portal.spring.aop.ServiceBeanMethodInvocation.proceed(ServiceBeanMethodInvocation.java:115)
                at com.liferay.portal.spring.transaction.DefaultTransactionExecutor.execute(DefaultTransactionExecutor.java:62)
                at com.liferay.portal.spring.transaction.TransactionInterceptor.invoke(TransactionInterceptor.java:51)
                at com.liferay.portal.spring.aop.ServiceBeanMethodInvocation.proceed(ServiceBeanMethodInvocation.java:111)
                at com.liferay.portal.spring.aop.ServiceBeanAopProxy.invoke(ServiceBeanAopProxy.java:175)
                at com.sun.proxy.$Proxy140.mergeCategories(Unknown Source)
                at com.liferay.portlet.asset.service.AssetCategoryLocalServiceUtil.mergeCategories(AssetCategoryLocalServiceUtil.java:664)
                at com.liferay.portlet.asset.service.AssetCategoryLocalServiceUtil$mergeCategories.call(Unknown Source)
                at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:40)
                at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:116)
                at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:128)
                at Script12.run(Script12.groovy:13)
                at com.liferay.portal.scripting.groovy.GroovyExecutor.eval(GroovyExecutor.java:58)
                at com.liferay.portal.scripting.ScriptingImpl.eval(ScriptingImpl.java:86)
                at com.liferay.portal.scripting.ScriptingImpl.exec(ScriptingImpl.java:107)
                at com.liferay.portal.kernel.scripting.ScriptingUtil.exec(ScriptingUtil.java:79)
                at com.liferay.portlet.admin.action.EditServerAction.runScript(EditServerAction.java:508)
                at com.liferay.portlet.admin.action.EditServerAction.processAction(EditServerAction.java:207)
                at com.liferay.portal.struts.PortletRequestProcessor.process(PortletRequestProcessor.java:166)
                at com.liferay.portlet.StrutsPortlet.processAction(StrutsPortlet.java:218)
                at com.liferay.portlet.FilterChainImpl.doFilter(FilterChainImpl.java:71)
                at com.liferay.portal.kernel.portlet.PortletFilterUtil.doFilter(PortletFilterUtil.java:48)
                at com.liferay.portlet.InvokerPortletImpl.invoke(InvokerPortletImpl.java:597)
                at com.liferay.portlet.InvokerPortletImpl.invokeAction(InvokerPortletImpl.java:628)
                at com.liferay.portlet.InvokerPortletImpl.processAction(InvokerPortletImpl.java:308)
                at com.liferay.portlet.PortletContainerImpl._doProcessAction(PortletContainerImpl.java:389)
                at com.liferay.portlet.PortletContainerImpl.processAction(PortletContainerImpl.java:107)
                at com.liferay.portlet.SecurityPortletContainerWrapper.processAction(SecurityPortletContainerWrapper.java:109)
                at com.liferay.portlet.RestrictPortletContainerWrapper.processAction(RestrictPortletContainerWrapper.java:75)
                at com.liferay.portal.kernel.portlet.PortletContainerUtil.processAction(PortletContainerUtil.java:115)
                at com.liferay.portal.action.LayoutAction.processLayout(LayoutAction.java:386)
                at com.liferay.portal.action.LayoutAction.doExecute(LayoutAction.java:200)
                at com.liferay.portal.action.LayoutAction.execute(LayoutAction.java:95)
                at org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:431)
                at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:236)
                at com.liferay.portal.struts.PortalRequestProcessor.process(PortalRequestProcessor.java:168)
                at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1196)
                at org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:432)
                at javax.servlet.http.HttpServlet.service(HttpServlet.java:650)
                at com.liferay.portal.servlet.MainServlet.callParentService(MainServlet.java:574)
                at com.liferay.portal.servlet.MainServlet.service(MainServlet.java:551)
                at javax.servlet.http.HttpServlet.service(HttpServlet.java:731)
                at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:303)
                at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
                at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
                at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
                at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
                at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.doFilter(InvokerFilterChain.java:116)
                at com.liferay.portal.kernel.servlet.BaseFilter.processFilter(BaseFilter.java:169)
                at com.liferay.portal.servlet.filters.secure.SecureFilter.processFilter(SecureFilter.java:308)
                at com.liferay.portal.kernel.servlet.BaseFilter.doFilter(BaseFilter.java:59)
                at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.processDoFilter(InvokerFilterChain.java:204)
                at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.doFilter(InvokerFilterChain.java:109)
                at com.liferay.portal.kernel.servlet.BaseFilter.processFilter(BaseFilter.java:169)
                at com.liferay.portal.servlet.filters.jsoncontenttype.JSONContentTypeFilter.processFilter(JSONContentTypeFilter.java:42)
                at com.liferay.portal.kernel.servlet.BaseFilter.doFilter(BaseFilter.java:59)
                at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.processDoFilter(InvokerFilterChain.java:204)
                at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.doFilter(InvokerFilterChain.java:109)
                at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilter.doFilter(InvokerFilter.java:119)
                at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
                at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
                at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:748)
                at org.apache.catalina.core.ApplicationDispatcher.processRequest(ApplicationDispatcher.java:486)
                at org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:411)
                at org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:338)
                at com.liferay.portal.servlet.FriendlyURLServlet.service(FriendlyURLServlet.java:161)
                at javax.servlet.http.HttpServlet.service(HttpServlet.java:731)
                at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:303)
                at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
                at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
                at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
                at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
                at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.doFilter(InvokerFilterChain.java:116)
                at com.liferay.portal.kernel.servlet.BaseFilter.processFilter(BaseFilter.java:169)
                at com.liferay.portal.servlet.filters.uploadservletrequest.UploadServletRequestFilter.processFilter(UploadServletRequestFilter.java:93)
                at com.liferay.portal.kernel.servlet.BaseFilter.doFilter(BaseFilter.java:59)
                at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.processDoFilter(InvokerFilterChain.java:204)
                at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.doFilter(InvokerFilterChain.java:109)
                at com.liferay.portal.kernel.servlet.BaseFilter.processFilter(BaseFilter.java:169)
                at com.liferay.portal.servlet.filters.strip.StripFilter.processFilter(StripFilter.java:361)
                at com.liferay.portal.kernel.servlet.BaseFilter.doFilter(BaseFilter.java:59)
                at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.processDoFilter(InvokerFilterChain.java:204)
                at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.doFilter(InvokerFilterChain.java:109)
                at com.liferay.portal.kernel.servlet.BaseFilter.processFilter(BaseFilter.java:169)
                at com.liferay.portal.servlet.filters.gzip.GZipFilter.processFilter(GZipFilter.java:123)
                at com.liferay.portal.kernel.servlet.BaseFilter.doFilter(BaseFilter.java:59)
                at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.processDoFilter(InvokerFilterChain.java:204)
                at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.doFilter(InvokerFilterChain.java:109)
                at com.liferay.portal.kernel.servlet.BaseFilter.processFilter(BaseFilter.java:169)
                at com.liferay.portal.servlet.filters.secure.SecureFilter.processFilter(SecureFilter.java:308)
                at com.liferay.portal.kernel.servlet.BaseFilter.doFilter(BaseFilter.java:59)
                at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.processDoFilter(InvokerFilterChain.java:204)
                at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.doFilter(InvokerFilterChain.java:109)
                at com.liferay.portal.kernel.servlet.BaseFilter.processFilter(BaseFilter.java:169)
                at com.liferay.portal.servlet.filters.i18n.I18nFilter.processFilter(I18nFilter.java:254)
                at com.liferay.portal.kernel.servlet.BaseFilter.doFilter(BaseFilter.java:59)
                at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.processDoFilter(InvokerFilterChain.java:204)
                at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.doFilter(InvokerFilterChain.java:109)
                at com.liferay.portal.kernel.servlet.BaseFilter.processFilter(BaseFilter.java:169)
                at com.liferay.portal.servlet.filters.etag.ETagFilter.processFilter(ETagFilter.java:86)
                at com.liferay.portal.kernel.servlet.BaseFilter.doFilter(BaseFilter.java:59)
                at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.processDoFilter(InvokerFilterChain.java:204)
                at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.doFilter(InvokerFilterChain.java:109)
                at com.liferay.portal.kernel.servlet.BaseFilter.processFilter(BaseFilter.java:169)
                at com.liferay.portal.servlet.filters.jsoncontenttype.JSONContentTypeFilter.processFilter(JSONContentTypeFilter.java:42)
                at com.liferay.portal.kernel.servlet.BaseFilter.doFilter(BaseFilter.java:59)
                at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.processDoFilter(InvokerFilterChain.java:204)
                at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.doFilter(InvokerFilterChain.java:109)
                at com.liferay.portal.kernel.servlet.BaseFilter.processFilter(BaseFilter.java:169)
                at com.liferay.portal.servlet.filters.autologin.AutoLoginFilter.processFilter(AutoLoginFilter.java:268)
                at com.liferay.portal.kernel.servlet.BaseFilter.doFilter(BaseFilter.java:59)
                at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.processDoFilter(InvokerFilterChain.java:204)
                at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.doFilter(InvokerFilterChain.java:109)
                at com.liferay.portal.kernel.servlet.BaseFilter.processFilter(BaseFilter.java:169)
                at com.liferay.portal.servlet.filters.sso.ntlm.NtlmPostFilter.processFilter(NtlmPostFilter.java:83)
                at com.liferay.portal.kernel.servlet.BaseFilter.doFilter(BaseFilter.java:59)
                at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.processDoFilter(InvokerFilterChain.java:204)
                at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.doFilter(InvokerFilterChain.java:109)
                at com.liferay.portal.kernel.servlet.BaseFilter.processFilter(BaseFilter.java:169)
                at com.liferay.portal.sharepoint.SharepointFilter.processFilter(SharepointFilter.java:88)
                at com.liferay.portal.kernel.servlet.BaseFilter.doFilter(BaseFilter.java:59)
                at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.processDoFilter(InvokerFilterChain.java:204)
                at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.doFilter(InvokerFilterChain.java:109)
                at com.liferay.portal.kernel.servlet.BaseFilter.processFilter(BaseFilter.java:169)
                at com.liferay.portal.servlet.filters.virtualhost.VirtualHostFilter.processFilter(VirtualHostFilter.java:226)
                at com.liferay.portal.kernel.servlet.BaseFilter.doFilter(BaseFilter.java:59)
                at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.processDoFilter(InvokerFilterChain.java:204)
                at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.doFilter(InvokerFilterChain.java:109)
                at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.processDirectCallFilter(InvokerFilterChain.java:185)
                at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.doFilter(InvokerFilterChain.java:96)
                at org.tuckey.web.filters.urlrewrite.UrlRewriteFilter.doFilter(UrlRewriteFilter.java:738)
                at com.liferay.portal.servlet.filters.urlrewrite.UrlRewriteFilter.processFilter(UrlRewriteFilter.java:57)
                at com.liferay.portal.kernel.servlet.BaseFilter.doFilter(BaseFilter.java:59)
                at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.processDoFilter(InvokerFilterChain.java:204)
                at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.doFilter(InvokerFilterChain.java:109)
                at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.processDirectCallFilter(InvokerFilterChain.java:165)
                at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.doFilter(InvokerFilterChain.java:96)
                at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.processDirectCallFilter(InvokerFilterChain.java:165)
                at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.doFilter(InvokerFilterChain.java:96)
                at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.processDirectCallFilter(InvokerFilterChain.java:185)
                at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.doFilter(InvokerFilterChain.java:96)
                at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilter.doFilter(InvokerFilter.java:119)
                at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
                at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
                at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:220)
                at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:122)
                at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:505)
                at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:170)
                at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:103)
                at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:957)
                at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:116)
                at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:423)
                at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1079)
                at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:620)
                at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:318)
                at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
                at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
                at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
                at java.lang.Thread.run(Thread.java:745)
        Caused by: java.lang.ClassCastException: java.lang.Long cannot be cast to com.liferay.portlet.asset.model.AssetCategory
                at com.liferay.portlet.asset.util.AssetCategoryIndexer.doReindex(AssetCategoryIndexer.java:187)
                at com.liferay.portal.kernel.search.BaseIndexer.reindex(BaseIndexer.java:446)
                ... 164 more
        

        Attachments

        1. Fixed.PNG
          Fixed.PNG
          190 kB
        2. Reproduced.PNG
          Reproduced.PNG
          212 kB

          Issue Links

            Activity

              People

              • Assignee:
                harry.chai Harry Chai
                Reporter:
                tamas.molnar Tamas Molnar
                Participants of an Issue:
                Recent user:
                Esther Sanz
              • Votes:
                0 Vote for this issue
                Watchers:
                1 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:
                  Days since last comment:
                  3 years, 50 weeks, 3 days ago

                  Packages

                  Version Package
                  6.2.X EE