'The type com.liferay.petra.sql.dsl.query.DSLQuery cannot be resolved. It is indirectly referenced from required .class files

I am following a beginner's tutorial from here in order to create a service and then consume it from another module (eg. a Portlet)

Everything goes well until I try to deploy it - there is an error in the generated classes: The type com.liferay.petra.sql.dsl.query.DSLQuery cannot be resolved. It is indirectly referenced from required .class files



Solution 1:[1]

I prefer using a more generic way that will organize all Liferay related imports for you with just a single line:

compileOnly group: "com.liferay.portal", name: "release.portal.api", version: "7.3.5-ga6"

Solution 2:[2]

My workspace was working fine and next day when I started my system I faced problem that workspace is invalid, don't know what happened. I took new liferay workspace and then copy pasted my service builder then on deployment I faced this issue. The type com.liferay.petra.sql.dsl.query.DSLQuery cannot be resolved. It is indirectly referenced from required .class files I tried to add

compileOnly group: "com.liferay", name: "com.liferay.petra.sql.dsl.api"

but then facing new issue. I don't think so this import would help, that is something else problem Luckily I had my current workspace in zip format last week as a backup now again I m imported that zip and retried to build service again, now it is working fine. thanks

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Jan Verweij
Solution 2 asifaftab87