Ask Questions and Find Answers
Important:
Ask is now read-only. You can review any existing questions and answers, but not add anything new.
But - don't panic! While ask is no more, we've replaced it with discuss - the new Liferay Discussion Forum! Read more here here or just visit the site here:
discuss.liferay.com
RE: Service-builder mod stop working when adding @ServiceReference to Custo
Hi all,
I'm trying to add custom SQL to a service-builder module managing a sample customer entity. The service is working well without custom-sql and I'm following this tutorial plus some other sources. The problem is that, as soon as I add this lines of code to CustomerFinderImpl.java...
@ServiceReference(type=CustomSQL.class)<br> private CustomSQL _customSQL;
... the service stops working (meaning it's no longer available to a portlet using it and is no longer available on the JSONWS API page).
It's strange because both modules (-api and -service) are shown as starting on the server log (I have to force "refresh of the -api bundle on gogo shell) and are also listed as Active on the gogo shell console.
554|Active | 1|Example13service-api (1.0.0)<br>
555|Active | 1|Example13service-service (1.0.0)<br>
559|Active | 1|Example13 (1.0.0)
Even the portlet using the service starts, but if I do a scr:info on it's class it will show an unsatisfied reference:
*** Bundle: com.test.example13 (559)<br> Component
Description:<br> Name:
com.test.example13.portlet.Example13Portlet<br> Implementation
Class: com.test.example13.portlet.Example13Portlet<br> Default
State: enabled<br> Activation: immediate<br> Configuration
Policy: optional<br> Activate Method: insertDummyData<br>
Deactivate Method: deactivate<br> Modified Method: -<br>
Configuration Pid:
[com.test.example13.portlet.Example13Portlet]<br>
Services: <br> javax.portlet.Portlet<br> Service Scope:
singleton<br> Reference: customerService<br> Interface
Name: com.test.example13.sb.service.CustomerService<br>
Cardinality: 1..1<br> Policy: static<br> Policy option:
reluctant<br> Reference Scope: bundle<br> Component
Description Properties:<br>
com.liferay.portlet.display-category = category.sample<br>
com.liferay.portlet.instanceable = true<br>
javax.portlet.init-param.template-path = /<br>
javax.portlet.init-param.view-template = /view.jsp<br>
javax.portlet.name = example13<br>
javax.portlet.resource-bundle = content.Language<br>
javax.portlet.security-role-ref = power-user,user<br> Component
Configuration:<br> ComponentId: 2571<br> State:
unsatisfied reference<br> UnsatisfiedReference:
customerService<br> Target: null<br> (no target
services)<br> Component Configuration Properties:<br>
com.liferay.portlet.display-category = category.sample<br>
com.liferay.portlet.instanceable = true<br> component.id
= 2571<br> component.name =
com.test.example13.portlet.Example13Portlet<br>
javax.portlet.init-param.template-path = /<br>
javax.portlet.init-param.view-template = /view.jsp<br>
javax.portlet.name = example13<br>
javax.portlet.resource-bundle = content.Language<br>
javax.portlet.security-role-ref = power-user,user
Previuosly it didn't compile, but adding "compile "com.liferay:com.liferay.portal.dao.orm.custom.sql:1.0.3" to build.gradle solved the building problem.
I'm doing this with Liferay 7.0 CE GA7 and IDE 3.4 (with blade and Liferay Workspace up-to-date).
Any ideas?
TIA
Fernando
Hi David,
Sorry, I'm not sure I'm following... I tried three ways:
g! scr:info com.test.example13.sb.service.CustomerService<br>
No Component with name or configuration with ID matching
com.test.example13.sb.service.CustomerService<br> g! scr:info
com.test.example13.sb.service <br> No Component
with name or configuration with ID matching
com.test.example13.sb.service<br> g! scr:info
Example13service-service<br> No Component with name or
configuration with ID matching Example13service-service
Still, I have both modules of the service as STARTED...
g! lb 13service<br> START LEVEL 20<br> ID|State
|Level|Name<br> 554|Active | 1|Example13service-api
(1.0.0)<br> 555|Active | 1|Example13service-service (1.0.0)
... and the *-service module is declaring:
g! headers 555
Example13service-service (555)<br>
------------------------------<br> Manifest-Version = 1.0<br>
Bnd-LastModified = 1541758479786<br> Bundle-ManifestVersion =
2<br> Bundle-Name = Example13service-service<br>
Bundle-SymbolicName = com.test.example13.sb.service<br>
Bundle-Version = 1.0.0<br> Created-By = 1.8.0_191 (Oracle
Corporation)<br> Export-Package =
com.test.example13.sb.exception;version="1.0.0";uses:="com.liferay.portal.kernel.exception",com.test.example13.sb.model;version="1.0.0";uses:="com.liferay.expando.kernel.model,com.liferay.exportimport.kernel.lar,com.liferay.portal.kernel.annotation,com.liferay.portal.kernel.bean,com.liferay.portal.kernel.model,com.liferay.portal.kernel.service,com.liferay.portal.kernel.util",com.test.example13.sb.model.impl;uses:="com.liferay.expando.kernel.model,com.liferay.exportimport.kernel.lar,com.liferay.portal.kernel.json,com.liferay.portal.kernel.model,com.liferay.portal.kernel.model.impl,com.liferay.portal.kernel.service,com.test.example13.sb.model";version="1.0.0",com.test.example13.sb.service;version="1.0.0";uses:="com.liferay.exportimport.kernel.lar,com.liferay.portal.kernel.dao.orm,com.liferay.portal.kernel.exception,com.liferay.portal.kernel.jsonwebservice,com.liferay.portal.kernel.model,com.liferay.portal.kernel.search,com.liferay.portal.kernel.security.access.control,com.liferay.portal.kernel.service,com.liferay.portal.kernel.spring.osgi,com.liferay.portal.kernel.transaction,com.liferay.portal.kernel.util,com.test.example13.sb.model",com.test.example13.sb.service.base;uses:="com.liferay.counter.kernel.service,com.liferay.exportimport.kernel.lar,com.liferay.portal.kernel.bean,com.liferay.portal.kernel.dao.orm,com.liferay.portal.kernel.exception,com.liferay.portal.kernel.model,com.liferay.portal.kernel.module.framework.service,com.liferay.portal.kernel.search,com.liferay.portal.kernel.service,com.liferay.portal.kernel.service.persistence,com.liferay.portal.kernel.transaction,com.liferay.portal.kernel.util,com.liferay.portal.spring.extender.service,com.test.example13.sb.model,com.test.example13.sb.service,com.test.example13.sb.service.persistence";version="1.0.0",com.test.example13.sb.service.http;uses:="com.liferay.portal.kernel.exception,com.liferay.portal.kernel.security.auth,com.test.example13.sb.model";version="1.0.0",com.test.example13.sb.service.impl;uses:="com.liferay.portal.kernel.exception,com.test.example13.sb.model,com.test.example13.sb.service.base";version="1.0.0",com.test.example13.sb.service.persistence;version="1.0.0";uses:="com.liferay.portal.kernel.dao.orm,com.liferay.portal.kernel.service,com.liferay.portal.kernel.service.persistence,com.liferay.portal.kernel.util,com.test.example13.sb.exception,com.test.example13.sb.model",com.test.example13.sb.service.persistence.impl;uses:="com.liferay.portal.kernel.bean,com.liferay.portal.kernel.dao.orm,com.liferay.portal.kernel.exception,com.liferay.portal.kernel.model,com.liferay.portal.kernel.service.persistence,com.liferay.portal.kernel.service.persistence.impl,com.liferay.portal.kernel.util,com.liferay.portal.spring.extender.service,com.test.example13.sb.exception,com.test.example13.sb.model,com.test.example13.sb.model.impl,com.test.example13.sb.service.persistence";version="1.0.0",com.test.example13.sb.service.util;uses:="com.liferay.portal.kernel.configuration";version="1.0.0"<br>
Import-Package =
com.liferay.counter.kernel.service;version="[1.0,2)",com.liferay.expando.kernel.model;version="[1.0,2)",com.liferay.expando.kernel.util;version="[1.0,2)",com.liferay.exportimport.kernel.lar;version="[1.1,2)",com.liferay.portal.dao.orm.custom.sql;version="[1.0,2)",com.liferay.portal.kernel.annotation;version="[6.3,7)",com.liferay.portal.kernel.bean;version="[7.0,8)",com.liferay.portal.kernel.configuration;version="[6.2,7)",com.liferay.portal.kernel.dao.db;version="[7.1,8)",com.liferay.portal.kernel.dao.jdbc;version="[7.1,8)",com.liferay.portal.kernel.dao.orm;version="[7.0,8)",com.liferay.portal.kernel.exception;version="[7.0,8)",com.liferay.portal.kernel.json;version="[7.0,8)",com.liferay.portal.kernel.jsonwebservice;version="[7.0,8)",com.liferay.portal.kernel.log;version="[7.0,8)",com.liferay.portal.kernel.model;version="[1.0,1.1)",com.liferay.portal.kernel.model.impl;version="[1.0,2)",com.liferay.portal.kernel.module.framework.service;version="[1.0,2)",com.liferay.portal.kernel.search;version="[7.2,8)",com.liferay.portal.kernel.security.access.control;version="[1.0,2)",com.liferay.portal.kernel.security.auth;version="[1.0,2)",com.liferay.portal.kernel.service;version="[1.3,2)",com.liferay.portal.kernel.service.http;version="[1.0,2)",com.liferay.portal.kernel.service.persistence;version="[1.1,2)",com.liferay.portal.kernel.service.persistence.impl;version="[1.2,2)",com.liferay.portal.kernel.spring.osgi;version="[1.0,2)",com.liferay.portal.kernel.transaction;version="[7.0,8)",com.liferay.portal.kernel.util;version="[7.3,8)",com.liferay.portal.kernel.uuid;version="[6.2,7)",com.liferay.portal.spring.extender.service;version="[1.0,2)",com.test.example13.sb.exception;version="[1.0,2)",com.test.example13.sb.model;version="[1.0,1.1)",com.test.example13.sb.model.impl,com.test.example13.sb.service;version="[1.0,1.1)",com.test.example13.sb.service.base,com.test.example13.sb.service.persistence;version="[1.0,1.1)",com.test.example13.sb.service.util,javax.sql,org.osgi.framework,org.osgi.util.tracker<br>
Javac-Debug = on<br> Javac-Deprecation = off<br> Javac-Encoding
= Cp1252<br> Liferay-Require-SchemaVersion = 1.0.0<br>
Liferay-Service = true<br> Liferay-Spring-Context =
META-INF/spring<br> Provide-Capability =
osgi.service;objectClass:List<String>="com.test.example13.sb.service.CustomerLocalService",osgi.service;objectClass:List<String>="com.test.example13.sb.service.CustomerService"<br>
Require-Capability =
liferay.extender;filter:="(&(liferay.extender=spring.extender)(version>=2.0)(!(version>=3.0)))",osgi.ee;filter:="(&(osgi.ee=JavaSE)(version=1.8))"<br>
Tool = Bnd-3.5.0.201709291849
Any ideas?
TIA
Fernando
So from your lb output command above, normally I get the list of components like:
scr:list 555
That gives the list of components in a bundle and should show general state for them. Each one will be listed with a component id, so I use that with the scr:info command argument to get the details on each component.
I've never been successful w/ the search by name option; I'm sure there's a trick for it, but since I have a working path I haven't looked into it further.
Hi David,
In this situation, the scr:list 555 comes up empty.
Also, the ds:unsatisfied command only lists the portlet
as missing one dependency: the service itself.
I found out that I just need to comment
the @ServiceReference(type=CustomSQL.class) line and
use CustomSQLUtil instead of the @referenced variable so that it
starts working.
I'd really like to understand what's happening but now that it's working I think I'll move forward.
Thanks
Fernando
Hi David,
I used ServiceReference since it's mentioned on this tutorial.
Just tried @Reference (all 3 of them) and none worked (2 were disallowed on that location).
Unless you tell me that using CustomSQLUtil has a very bad side effect, I'll stick to it, since it's working. :-)
Thanks
Fernando