RE: ServiceBuilder is Importing petra StringBundler instead of kernel.Strin

David Ilechukwu, modified 7 Years ago. Regular Member Posts: 154 Join Date: 6/7/10 Recent Posts
Hello folks!
The -ServicePersistenceImpl classes generated by ServiceBuilder all import the com.liferay.petra.string.StringBundler class instead of the com.liferay.portal.kernel.util.StringBundler class. This causes an compile error in the 
appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
                    orderByComparator)
method which is expecting a query argument of type com.liferay.portal.kernel.util.StringBundler.

The following error is thrown
C:\Software\Devel\Src\Web\Component\hrm_core\hrm_core-service\src\main\java\com\tpl\pmedics\hrm_core\service\persistence\impl\JobVacancyPersistenceImpl.java:231: error: incompatible types: com.liferay.petra.string.StringBundler cannot be converted to com.liferay.portal.kernel.util.StringBundler
                                appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
                                                        ^
C:\Software\Devel\Src\Web\Component\hrm_core\hrm_core-service\src\main\java\com\tpl\pmedics\hrm_core\service\persistence\impl\JobVacancyPersistenceImpl.java:734: error: incompatible types: com.liferay.petra.string.StringBundler cannot be converted to com.liferay.portal.kernel.util.StringBundler
                                appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,

I'm using ServiceBuilder plugin declared as follows in my build.gradle
buildscript {
    dependencies {
        classpath group: "com.liferay", name: "com.liferay.gradle.plugins.service.builder", version: "2.1.61"
    }
    repositories {
        maven {
            url "https://repository-cdn.liferay.com/nexus/content/groups/public"
        }
    }
}    
apply plugin: "com.liferay.portal.tools.service.builder"

Also, I noticed that servicebuilder started importing the petra package StringBundler after I changed the dtd declaration in my service.xml file from 

to
​​​​​​​

It imports the com.liferay.portal.kernel.util.StringBundler class when the dtd is 7.0.0 rather than 7.1.0

However, the blogs-service module source code shows that the service builder uses the 7.1.0 servicebuilder and yet the generated -ServiceImplPersistence classes import the com.liferay.portal.kernel.util.StringBundler class rather than com.liferay.petra.string.StringBundler - wondering how that works.

Any helps, please? Searched around without any mention of this kind of occurence.
thumbnail
Michel Schmidt, modified 7 Years ago. New Member Posts: 21 Join Date: 2/27/17 Recent Posts
However, the blogs-service module source code shows that the service builder uses the 7.1.0 servicebuilder and yet the generated -ServiceImplPersistence classes import the com.liferay.portal.kernel.util.StringBundler class rather than com.liferay.petra.string.StringBundler - wondering how that works.

From what I can see, the dependency changed in most modules from com.liferay.portal.kernel.util.StringBundler to com.liferay.petra.string.StringBundler (both in the 7.1-branch and also in the master-branch).

Some examples: Here, here, here, here and here.

I also have ported a customized liferay core app to 7.1 and remember having done the same.
David Ilechukwu, modified 7 Years ago. Regular Member Posts: 154 Join Date: 6/7/10 Recent Posts
Michel Schmidt
However, the blogs-service module source code shows that the service builder uses the 7.1.0 servicebuilder and yet the generated -ServiceImplPersistence classes import the com.liferay.portal.kernel.util.StringBundler class rather than com.liferay.petra.string.StringBundler - wondering how that works.

From what I can see, the dependency changed in most modules from com.liferay.portal.kernel.util.StringBundler to com.liferay.petra.string.StringBundler (both in the 7.1-branch and also in the master-branch).

Some examples: Here, here, here, here and here.

I also have ported a customized liferay core app to 7.1 and remember having done the same.
Many thanks Michel - for your quick reply! Yes, you're right. There's been a change in dependency from kernel StringBundler to petra package StringBundler (I've even included those same petra package dependencies in my own build.gradle). See here...
buildscript {
    dependencies {
        classpath group: "com.liferay", name: "com.liferay.gradle.plugins.service.builder", version: "2.1.61"
    }
    repositories {
        maven {
            url "https://repository-cdn.liferay.com/nexus/content/groups/public"
        }
    }
}    
apply plugin: "com.liferay.portal.tools.service.builder"
dependencies {
    compileOnly group: "biz.aQute.bnd", name: "biz.aQute.bndlib", version: "3.1.0"
    compileOnly group: "com.liferay", name: "com.liferay.portal.spring.extender.api", version: "3.0.0"
    compileOnly group: "com.liferay.portal", name: "com.liferay.portal.kernel", version: "3.0.0"
    compileOnly group: "com.liferay", name: "com.liferay.petra.function", version: "2.0.0"
    compileOnly group: "com.liferay", name: "com.liferay.petra.model.adapter", version: "2.0.0"
    compileOnly group: "com.liferay", name: "com.liferay.petra.reflect", version: "2.0.0"
    compileOnly group: "com.liferay", name: "com.liferay.petra.string", version: "2.0.0"    
    compileOnly group: "com.liferay", name: "com.liferay.portal.dao.orm.custom.sql.api", version: "1.0.0"
    compileOnly group: "javax.portlet", name: "portlet-api", version: "3.0.0"
    compileOnly group: "javax.servlet", name: "javax.servlet-api", version: "3.0.1"
    compileOnly group: "org.osgi", name: "org.osgi.core", version: "5.0.0"
    compileOnly group: "org.osgi", name: "org.osgi.service.component.annotations", version: "1.3.0"    
    compileOnly project(":hrm_core-api")
}

But why then does the code generated by ServiceBuilder in my -ServicePersistenceImpl classes throw compile errors like this...
C:\Software\Devel\Src\Web\Component\hrm_core\hrm_core-service\src\main\java\com\tpl\pmedics\hrm_core\service\persistence\impl\JobVacancyPersistenceImpl.java:734: error: incompatible types: com.liferay.petra.string.StringBundler cannot be converted to com.liferay.portal.kernel.util.StringBundler
                                appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,

Apparently, the generated code is expecting the "query" object to be an instance of com.liferay.portal.kernel.util.StringBundler rather than com.liferay.petra.string.StringBundler in this method...
​​​​​​​            if (orderByComparator != null) {
                appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
                    orderByComparator);
            }

How do I resolve this please? Is this a servicebuilder issue?

​​​​​​​Thanks.
thumbnail
Minhchau Dang, modified 7 Years ago. Liferay Master Posts: 598 Join Date: 10/22/07 Recent Posts
David Ilechukwu

How do I resolve this please? Is this a servicebuilder issue?

Yes, it's a service builder issue. I'm not exactly sure why this thread was forked from your other thread, but you can read the reply there for ways to resolve the issue.
thumbnail
Satyanarayana kolliboyin, modified 6 Years ago. Junior Member Posts: 26 Join Date: 6/23/10 Recent Posts
After updated dependency as below issue is resolved.Before : compileOnly group: "com.liferay.portal", name: "com.liferay.portal.kernel", version: "3.64.1" After (working) : compileOnly group: "com.liferay.portal", name: "com.liferay.portal.kernel", version: "3.0.0"