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

VerifyDynamicDataMapping process fails if you have a DDLRecord with a repeatable Documents and Media field filled out

    Details

      Description

      Description
      If you have a Data Definition with a repeatable Documents and Media field, it can cause problems in the VerifyDynamicDataMapping process. This happens because each DDMContent entry associated with that Data Definition will have StorageEngineUtil.getFields called on it during the VerifyDynamicDataMapping process, and the value for each of its Documents and Media fields will be returned. The Verify process then calls String.valueOf() on this value and attempts to convert the result to a JSONObject.

      The problem is, if the field is repeatable, then StorageEngineUtil.getFields will create an array of Strings for the field. So when we call String.valueOf() on it, it results in the Object.toString method being called on an array (e.g. ""[Ljava.lang.String;@459e1bdc"). So when we try to parse it as JSON, it results in a JSONException. This ultimately results in the database being stuck in an unusable state since it failed the Verify process.

      Steps to Reproduce
      1. Start up Liferay 6.2 and log in as the admin user.
      2. Navigate to Control Panel > Site Administration > Content > Documents and Media.
      3. Add some documents (you should add at least one).
      4. Navigate to Control Panel > Site Administration > Content > Dynamic Data Lists.
      5. Add a Data Definition with a repeatable Documents and Media field.
      6. Add a Dynamic Data List, selecting the Data Definition that you added in step 5.
      7. Add an entry to this list. Fill out the Documents and Media field with a document that you added in step 3 (you can reproduce this error with any nonzero number of filled-out instances of this field).
      8. Shut down Liferay 6.2
      9. Add the following lines to your portal-ext.properties file:

      verify.frequency=-1
      verify.processes=com.liferay.portal.verify.VerifyDynamicDataMapping
      

      10. Restart the portal and observe the logs as the VerifyDynamicDataMapping process is running.

      Expected Result: The VerifyDynamicDataMapping process completes successfully and the portal starts up.
      Actual Result: The VerifyDynamicDataMapping process throws the following error and the database ends up in an unusable state:

      15:35:05,909 ERROR [localhost-startStop-1][DBUpgrader:247] Unable to execute verify process: com.liferay.portal.kernel.json.JSONException: org.json.JSONException: A JSONObject text must begin with '{' at 1 [character 2 line 1]
      com.liferay.portal.verify.VerifyException: com.liferay.portal.kernel.json.JSONException: org.json.JSONException: A JSONObject text must begin with '{' at 1 [character 2 line 1]
              at com.liferay.portal.verify.VerifyProcess.verify(VerifyProcess.java:71)
              at com.liferay.portal.verify.VerifyProcessUtil._verifyProcess(VerifyProcessUtil.java:111)
              at com.liferay.portal.verify.VerifyProcessUtil._verifyProcess(VerifyProcessUtil.java:76)
              at com.liferay.portal.verify.VerifyProcessUtil.verifyProcess(VerifyProcessUtil.java:46)
              at com.liferay.portal.events.StartupHelper.verifyProcess(StartupHelper.java:140)
              at com.liferay.portal.events.StartupHelperUtil.verifyProcess(StartupHelperUtil.java:67)
              at com.liferay.portal.tools.DBUpgrader.verify(DBUpgrader.java:240)
              at com.liferay.portal.events.StartupAction.doRun(StartupAction.java:239)
              at com.liferay.portal.events.StartupAction.run(StartupAction.java:77)
              at com.liferay.portal.servlet.MainServlet.processStartupEvents(MainServlet.java:1300)
              at com.liferay.portal.servlet.MainServlet.init(MainServlet.java:264)
              at javax.servlet.GenericServlet.init(GenericServlet.java:160)
              at org.apache.catalina.core.StandardWrapper.initServlet(StandardWrapper.java:1280)
              at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1193)
              at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:1088)
              at org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:5176)
              at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5460)
              at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
              at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:901)
              at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:877)
              at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:633)
              at org.apache.catalina.startup.HostConfig.deployDescriptor(HostConfig.java:656)
              at org.apache.catalina.startup.HostConfig$DeployDescriptor.run(HostConfig.java:1635)
              at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)
              at java.util.concurrent.FutureTask.run(FutureTask.java:262)
              at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
              at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
              at java.lang.Thread.run(Thread.java:745)
      Caused by: com.liferay.portal.kernel.json.JSONException: org.json.JSONException: A JSONObject text must begin with '{' at 1 [character 2 line 1]
              at com.liferay.portal.json.JSONObjectImpl.<init>(JSONObjectImpl.java:82)
              at com.liferay.portal.json.JSONFactoryImpl.createJSONObject(JSONFactoryImpl.java:161)
              at com.liferay.portal.kernel.json.JSONFactoryUtil.createJSONObject(JSONFactoryUtil.java:68)
              at com.liferay.portal.verify.VerifyDynamicDataMapping.updateFileUploadReferences(VerifyDynamicDataMapping.java:601)
              at com.liferay.portal.verify.VerifyDynamicDataMapping.updateDDLFileUploadReferences(VerifyDynamicDataMapping.java:497)
              at com.liferay.portal.verify.VerifyDynamicDataMapping.updateFileUploadReferences(VerifyDynamicDataMapping.java:570)
              at com.liferay.portal.verify.VerifyDynamicDataMapping.updateFileUploadReferences(VerifyDynamicDataMapping.java:551)
              at com.liferay.portal.verify.VerifyDynamicDataMapping.verifyStructure(VerifyDynamicDataMapping.java:843)
              at com.liferay.portal.verify.VerifyDynamicDataMapping.doVerify(VerifyDynamicDataMapping.java:303)
              at com.liferay.portal.verify.VerifyProcess.verify(VerifyProcess.java:68)
              ... 27 more
      Caused by: org.json.JSONException: A JSONObject text must begin with '{' at 1 [character 2 line 1]
              at org.json.JSONTokener.syntaxError(JSONTokener.java:433)
              at org.json.JSONObject.<init>(JSONObject.java:188)
              at org.json.JSONObject.<init>(JSONObject.java:314)
              at com.liferay.portal.json.JSONObjectImpl.<init>(JSONObjectImpl.java:79)
              ... 36 more
      

      Not reproduced in master or ee-7.0.x
      In master and ee-7.0.x, the VerifyDynamicDataMapping process was renamed to DDMServiceVerifyProcess and was heavily modified/refactored. Therefore, this bug does not exist there.
      Reproduced in ee-6.2.x (968a11ae29c4813c452d2f49dee2e384a9451f27)

        Attachments

          Issue Links

            Activity

              People

              • Votes:
                0 Vote for this issue
                Watchers:
                1 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:
                  Days since last comment:
                  2 years, 15 weeks, 1 day ago

                  Packages

                  Version Package
                  6.2.X EE