Service builder generates invalid code

I’m currently trying to upgrade some code to build against DXP 2026.q2.5 (which happened to be the latest version when I started the process a few weeks ago) from 7.4.3.

Using version 17.1.8 of com.liferay.gradle.plugins.workspace, when I run the buildService task, it generates code that doesn’t compile against the DXP API. Specifically, it adds calls to getPersistence().cacheResult(…) - a method that is apparently supposed to be defined on BasePersistence, but does not exist in any currently-released version of DXP, although it’s present on master of liferay-portal and has been since May 5.

Does anyone have an explanation for (a) why that method doesn’t exist in the several releases of DXP that have happened since it was added and (b) what version of com.liferay.gradle.plugins.workspace is supposed to work with the latest releases of DXP (and how you’re supposed to know, given that the online documentation simply recommends always using the latest one)?

3 Answers

3

Hey Chris, thanks for raising this, I can help answer your questions:

  • Why is BasePersistence.cacheResult on master but not in 2026.Q2?
    • 2026.Q2 was branched off an older portal-kernel that predates the method’s inclusion so it won’t exist on that quarterly version unfortunately.
  • Which workspace version works with the latest DXP, and how do I find out?
    • So this isn’t an problem with Workspace per se but rather an issue of what version of Service Builder is being used. Newer versions of Workspace will pull in newer versions of Service Builder which may not be compatible with your version of DXP. For example, Workspace 17.1.8 will pull in Service Builder 1.0.550 which isn’t compatible with 2026.Q2, 1.0.532 should be used instead. I don’t recommend rolling back to an older version of Workspace to resolve this. Instead, the recommended solution is to pin Service Builder to a compatible version in gradle.properties like so:
      • com.liferay.portal.tools.service.builder.version=1.0.532
    • We’re working on creating a reference page that maps the recommended Service Builder version for a given DXP release with instructions on how to pin it. Hopefully that’ll address your concerns and make it easier to identify what version of Service Builder to use in the future.

Thanks. That's really helpful. I ended up finding a version of the workspace plugin that pulled a compatible version of service builder, but I'll have a go at just overriding the service builder version instead.

That seems to have worked. Thanks (both) for your help.

I’m sorry.
To get the ServiceBuilder working again, you need to downgrade to Workspace version 16.0.6. I apologize for the incorrect information.

That said, I agree with Tim_Pak that it’s better to set the ServiceBuilder to version 1.0.532 and not downgrade the Workspace.

Thanks. I'll give it a go.

We have rolled back to version 17.1.5. In that version, the cacheResult() method is available in the PersistenceImpl class.