RE: Liferay 7.0 CustomSQL Gives an error- Null is not a valid include

Amos Fong, modified 6 Years ago. New Member Post: 1 Join Date: 4/29/19 Recent Posts
When I put
@ServiceReference (type = CustomSQL.class)
private CustomSQL _customSQL;
in my * FinderImpl.java of my service module, I get an error in the web module:
ERROR [http-nio-8080-exec-5][MVCPortlet:589] null is not a valid include
even without actually using it.

I have the default.xml in the custom-sql folder within resources / META-INF and in my build.gradle
compile group: "com.liferay", name: "com.liferay.portal.dao.orm.custom.sql", version: "1.0.4"
The import com.liferay.portal.dao.orm.custom.sql.CustomSQL is done correctly .
​​​​​​​
I am doing something wrong?
thumbnail
Andrew Jardine, modified 6 Years ago. Liferay Legend Posts: 2416 Join Date: 12/22/10 Recent Posts
Hi Cesar,

I am pretty sure I had the same problem around this time last year. Just looking back at that project I ended up just using --

import com.liferay.portal.dao.orm.custom.sql.CustomSQLUtil;
and for my gradle reference I have
compileOnly group: "com.liferay", name: "com.liferay.portal.dao.orm.custom.sql", version: "1.0.4"

I don't have an @ServiceReference at all. Now I know that in the case of the *LocalService classes, it's bad form to use the Util version as you don't reap the benefits of OSGI dependency management etc, but it looks like in the end I just stuck with a straight call.

String sql = CustomSQLUtil.get(getClass(), FIND_RECIPIENTS);
FWIWT, normally when I am using an @ServiceReference I include the full canonical name -- so in this case it would be
@ServiceReference(type=com.liferay.portal.dao.orm.custom.sql.CustomSQL.class)
private CustomSQL _customSQL;
Not sure if that will make a difference, but it'd be an easy test.