RE: Servicebuilder does not add dependency for OrderByInfo

Michael Green, modified 5 Years ago. New Member Posts: 21 Join Date: 3/5/20 Recent Posts
I am working through the guestbook tutorial. https://help.liferay.com/hc/en-us/articles/360032887552-Introduction-to-Developing-a-Web-ApplicationI am using 7.3.1ga2, clean install of IDE and workspace. I have added the service.xml changes and the Service Impl for Guestbook Entry and Guestbook.
When I build the modules I am getting an error:
Task :modules:guestbook:guestbook-service:compileJava
.../gb/modules/guestbook/guestbook-service/src/main/java/com/liferay/docs/guestbook/service/persistence/impl/GuestbookPersistenceImpl.java:208: error: cannot access OrderByInfo
                    3 + (orderByComparator.getOrderByFields().length * 2));
                                          ^
  class file for com.liferay.petra.sql.dsl.query.sort.OrderByInfo not found
Note: Some input files use unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
1 error

I had to fix it with adding a 
   compileOnly 'com.liferay:com.liferay.petra.sql.dsl.api'
line to the build.gradle file of the guestbook-service:
dependencies {
    compileOnly group: "com.liferay", name: "com.liferay.petra.io"
    compileOnly group: "com.liferay", name: "com.liferay.petra.lang"
    compileOnly group: "com.liferay", name: "com.liferay.petra.string"
    compileOnly group: "com.liferay", name: "com.liferay.portal.aop.api"
    compileOnly group: "com.liferay.portal", name: "com.liferay.portal.kernel"
    compileOnly group: "org.osgi", name: "org.osgi.annotation.versioning"
    compileOnly group: "org.osgi", name: "org.osgi.core"
    compileOnly group: "org.osgi", name: "org.osgi.service.component.annotations"
    compileOnly project(":modules:guestbook:guestbook-api") 
    compileOnly 'com.liferay:com.liferay.petra.sql.dsl.api'    
}
buildService {
    apiDir = "../guestbook-api/src/main/java"
}
​​​​​​​group = "com.liferay.docs.guestbook"

Is this right  or am I missing something else?
thumbnail
Jan van der Kaaden, modified 5 Years ago. Junior Member Posts: 28 Join Date: 3/20/11 Recent Posts
Thanks Michael,I had the same problem and fixed it the same way. Cheers,Jan
thumbnail
mehdi tilab, modified 5 Years ago. New Member Posts: 4 Join Date: 5/20/20 Recent Posts
Hi friends, i have same problem and i get following error:
Could not find com.liferay:com.liferay.petra.sql.dsl.api
https://liferay.dev/documents/portlet_file_entry/14/Capture.jpg/b5014ed3-07af-4f5c-f065-0f943fae37de?status=0&download=true


Do you have any idea?
thumbnail
mehdi tilab, modified 5 Years ago. New Member Posts: 4 Join Date: 5/20/20 Recent Posts
my problem resolved by adding version as bellow:

compileOnly group: "com.liferay", name: "com.liferay.petra.sql.dsl.api", version: "1.0.2"
thumbnail
Shalinee Tawar, modified 5 Years ago. New Member Posts: 5 Join Date: 2/6/15 Recent Posts
I am facing the same issue for literary 7.3.1 ga2.
First of all I was not able to activate my service and api modules.
When tried to activate, it gave me the following error
  Unresolved requirement: Import-Package: com.liferay.portal.kernel.model; version="[4.1.0,5.0.0)"

Then tried to add the version to "7.3.0"
compileOnly group: "com.liferay.portal", name: "com.liferay.portal.kernel", version: "7.3.0"
and it gives the same error as Michael.
  
I have fixed the issue by replacing
compileOnly group: "com.liferay.portal", name: "com.liferay.portal.kernel"
to 
compileOnly group: "com.liferay.portal", name: "release.portal.api", version: "7.3.1-ga2-3"
in the build.gradle file and it worked.
I hope this helps.
Michael Green, modified 5 Years ago. New Member Posts: 21 Join Date: 3/5/20 Recent Posts
I think you are also running up against another issue I was having.

Have a look at the end of this thread. It has a github link to other fixes which at this time I think all relate to the target version config. What you have done is "fixed" the version of the library used in the build. Which overrides the BOM from the top level. It would be better in the long run to try to not have versions in the build files like this if you can.

https://liferay.dev/forums/-/message_boards/message/119021716#_com_liferay_message_boards_web_portlet_MBPortlet_message_119021716
thumbnail
Shalinee Tawar, modified 5 Years ago. New Member Posts: 5 Join Date: 2/6/15 Recent Posts
I tried to change the version of Liferay as 7.3.2 in the eclipse > Liferay workspace manually but it didn't work. May be there is no IDE support for eclipse for liferay version 7.3.2 as when I try to create the "Liferay workspace" in eclipse it only provides me the option till Liferay version 7.3.0.

So for now it is working with following by adding version:
compileOnly group: "com.liferay.portal", name: "release.portal.api", version: "7.3.1-ga2-3"