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

Log scenario of UUID enabled with no columns for service.xml

    Details

      Description

      Description

      There is a feature on the ServiceBuilder module that allows you the ability to generate a service layer for an entity with no persistence layer. This is currently broken since you cannot generate a service for an entity with no columns. The customer has found a workaround by removing uuid="true"

      Steps to reproduce

      NOTE: Used blade version "2.1.0.201704130650"

      1. Generate service-builder modules using blade with the following code

      blade create -t service-builder -p com.nps.simple simple
      

      2. Modify the generated simple/simple-service/service.xml so the only entity has no columns.

      <service-builder package-path="com.nps.simple">
      	<namespace>NPS_SIMPLE</namespace>
      	<entity local-service="true" name="BasicEntry" remote-service="true" uuid="true"/>
      </service-builder>
      

      3. Run "gradlew buildService" in the simple directory

      Results of Testing

      Expected: The service API and impl classes are created for BasicEntry but with no persistence classes/SQL included

      Execution still fails but log the scenario with uuid is improperly set

      Actual: The execution fails

      Errors/Logs

      10:04:32,714 ERROR [runtime:60] Error executing FreeMarker template
      FreeMarker template error:
      Java method "com.liferay.portal.tools.service.builder.Entity.isHierarchicalTree()" threw an exception when invoked on com.liferay.portal.tools.service.builder.Entity object "[email protected]"; see cause exception in the Java stack trace.
      
      ----
      FTL stack trace ("~" means nesting-related):
              - Failed at: #if entity.isHierarchicalTree()  [in template "com/liferay/portal/tools/service/builder/dependencies/persistence_impl.ftl" at line 1, column 1]
      ----
      
      Java stack trace (for programmers):
      ----
      freemarker.core._TemplateModelException: [... Exception message was already printed; see it above ...]
              at freemarker.ext.beans._MethodUtil.newInvocationTemplateModelException(_MethodUtil.java:311)
              at freemarker.ext.beans._MethodUtil.newInvocationTemplateModelException(_MethodUtil.java:275)
              at freemarker.ext.beans.SimpleMethodModel.exec(SimpleMethodModel.java:80)
              at freemarker.core.MethodCall._eval(MethodCall.java:62)
              at freemarker.core.Expression.eval(Expression.java:78)
              at freemarker.core.Expression.evalToBoolean(Expression.java:124)
              at freemarker.core.Expression.evalToBoolean(Expression.java:110)
              at freemarker.core.ConditionalBlock.accept(ConditionalBlock.java:46)
              at freemarker.core.Environment.visit(Environment.java:324)
              at freemarker.core.MixedContent.accept(MixedContent.java:54)
              at freemarker.core.Environment.visit(Environment.java:324)
              at freemarker.core.Environment.process(Environment.java:302)
              at freemarker.template.Template.process(Template.java:325)
              at com.liferay.portal.freemarker.FreeMarkerUtil.process(FreeMarkerUtil.java:47)
              at com.liferay.portal.freemarker.FreeMarkerUtil.process(FreeMarkerUtil.java:37)
              at com.liferay.portal.tools.service.builder.ServiceBuilder._processTemplate(ServiceBuilder.java:5461)
              at com.liferay.portal.tools.service.builder.ServiceBuilder._createPersistenceImpl(ServiceBuilder.java:2825)
              at com.liferay.portal.tools.service.builder.ServiceBuilder.<init>(ServiceBuilder.java:749)
              at com.liferay.portal.tools.service.builder.ServiceBuilder.main(ServiceBuilder.java:219)
      Caused by: java.lang.RuntimeException: There is no primary key for entity BasicEntry
              at com.liferay.portal.tools.service.builder.Entity._getPKColumn(Entity.java:889)
      Exception in thread "main"      at com.liferay.portal.tools.service.builder.Entity.hasPrimitivePK(Entity.java:577)
              at com.liferay.portal.tools.service.builder.Entity.hasPrimitivePK(Entity.java:569)
              at com.liferay.portal.tools.service.builder.Entity.isHierarchicalTree(Entity.java:685)
      FreeMarker template error:      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      
              at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
      Java method "com.liferay.portal.tools.service.builder.Entity.isHierarchicalTree()" threw an exception when invoked on com.liferay.portal.tools.service.builder.Entity object "[email protected]"; see cause exception in the Java stack trace.
              at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
      
              at java.lang.reflect.Method.invoke(Method.java:498)
      

      Master

      cbceb0521e587e12a2bea7333901b99a900709ab

      To Quote Nathan:

      [...] A bit of logging to warn the developer that you can't set uuid=true if you have no primary key would do the trick. Beyond that this is working correctly, up to and including the transactional semantics.

        Attachments

          Activity

            People

            Assignee:
            joyce.wang Joyce Wang
            Reporter:
            shanon.mathai Shanon Mathai
            Participants of an Issue:
            Recent user:
            Csaba Turcsan
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved:
              Days since last comment:
              4 years, 23 weeks, 2 days ago

                Packages

                Version Package
                7.0.0 DXP FP19
                7.0.3 CE GA4
                7.0.0 DXP SP4
                7.0.X EE
                7.1.X
                Master