Message Boards

Service Builder Custom SQL Issue

thumbnail
Neil Francese, modified 4 Years ago.

Service Builder Custom SQL Issue

New Member Posts: 22 Join Date: 4/3/12 Recent Posts
I'm upgraded a 6.2 Service Builder Entity to be a module in a fixpack DXP,-5-7110 bundle.   I was able to deploy the -service and -api fine.  Things seem to work for most of my basic entities but I encountered a problem when adding a bit of custom SQL.   Everything compiles fine but when I deploy the -api continues to load properly but the -service module encounters the following error 

org.osgi.framework.BundleException: Could not resolve module: xxx.xxx.core.service [1012]_  Unresolved requirement: Import-Package: com.liferay.util.dao.orm; version="[7.0.0,8.0.0)"_ [Sanitized]
    at org.eclipse.osgi.container.Module.start(Module.java:444)
    at org.eclipse.osgi.internal.framework.EquinoxBundle.start(EquinoxBundle.java:428)
    at org.apache.felix.fileinstall.internal.DirectoryWatcher.startBundle(DirectoryWatcher.java:1258)
    at org.apache.felix.fileinstall.internal.DirectoryWatcher.startBundles(DirectoryWatcher.java:1230)
    at org.apache.felix.fileinstall.internal.DirectoryWatcher.startAllBundles(DirectoryWatcher.java:1218)
    at org.apache.felix.fileinstall.internal.DirectoryWatcher.doProcess(DirectoryWatcher.java:507)
    at org.apache.felix.fileinstall.internal.DirectoryWatcher.process(DirectoryWatcher.java:361)
    at org.apache.felix.fileinstall.internal.DirectoryWatcher.run(DirectoryWatcher.java:312)

It seems to be related to one of my finders that uses:  "import com.liferay.util.dao.orm.CustomSQL;" for the @ServiceReference annotation as described in liferay documentation (https://portal.liferay.dev/docs/7-1/tutorials/-/knowledge_base/t/custom-sql)

 @ServiceReference(type = CustomSQL.class)
    private CustomSQL _customSQL;

I see 'com.liferay.util.dao.orm.CustomSQL' should be provided by util-java.jar   I have the following dependency declared in my pom which resolves for compilation but doesn't seem to be satisfied by the server at run time.  
        <dependency>
            <groupId>com.liferay.portal</groupId>
            <artifactId>com.liferay.util.java</artifactId>
            <version>3.0.17</version>
            <scope>provided</scope>
        </dependency>

If I add com.liferay.util.java-3.0.17.jar directly to my osgi/modules folder it resolves and the -service module deploys but I suspect that this functionality should already be on the classpath somewhere and perhaps I have a configuration issue? .  Any ideas?
thumbnail
Neil Francese, modified 4 Years ago.

RE: Service Builder Custom SQL Issue

New Member Posts: 22 Join Date: 4/3/12 Recent Posts
The more I read the more I'm assuming that com.liferay.util.java is an optional include and therefore can be embedded in my module using compileInclude for gradle users or in my case, as I'm using maven,  using bnd.bnd -includeresource directive.
If anyone thinks this is not the preferred way let me know as I suspect this will work but not sure if it's the Liferay way ;)
thumbnail
Sergio Sánchez, modified 3 Years ago.

RE: Service Builder Custom SQL Issue

Regular Member Posts: 143 Join Date: 7/6/11 Recent Posts
Hi,
just in case anyone finds this problem in their Custom Finder developments for Liferay 7.x
You will need:
1. A dependency in Gradle or Maven like the following:
compileOnly group: "com.liferay", name: "com.liferay.portal.dao.orm.custom.sql.api"

2. Make sure that your FinderImpl class in registered as an OSGi component and you import the correct CustomSQL class:
import com.liferay.portal.dao.orm.custom.sql.CustomSQL;
​​​​​​​[...]
@Component(service = ExtUserFinder.class)
public class ExtUserFinderImpl extends ExtUserFinderBaseImpl implements ExtUserFinder{

Hope it helps if someone runs into this problem