RE: Not getting the services of Service Builder in a module portlet

Ganesh Puli, modified 5 Years ago. New Member Posts: 19 Join Date: 2/27/18 Recent Posts
Service Build A is there which is using the Services of another service Builder B, but am not able to access the services of service Builder Aand am getting NoClassDefinitionFoundError  of EntityLocalServiceUtil  at runtime, or some times it is showing like could not Initial the EntityLocalServiceUtil class
example error [status_jsp:950] com.liferay.portal.kernel.portlet.PortletContainerException: com.liferay.portal.kernel.portlet.PortletContainerException: javax.servlet.ServletException: java.lang.NoClassDefFoundError: com/vy/payment/gateway/service/VYPGProviderDetailsLocalServiceUtilEven thorugh I mentioned the corresponding service module depency in the build.grald, am getting the above error                                       please suggest me , how can i proceed in calling the services
thumbnail
David H Nebinger, modified 5 Years ago. Liferay Legend Posts: 14933 Join Date: 9/2/06 Recent Posts
Well, I'm not sure what you're doing, but I can offer the following...

Never use the LocalServiceUtil classes. They exist for legacy code support and for places where it is not possible to inject a service through OSGi's @Reference annotation. If you are using a LocalServiceUtil, you are likely on a wrong path.

"NoClassDefinitionFound" happens when the class is not found. This could be because the module is not deployed, the module is not exporting the package that contains the class, ...  It points to a general dependency issue.

For Liferay ServiceBuilder modules, you'll never depend upon the service module, only on the API module. That's where the interfaces are all defined.

It is fine for Service A to invoke Service B. A's implementation would have an @Reference to the B service (as exposed by B's API module), so as long as it can be resolved, Service A will start and be injected wherever it is used.
Ganesh Puli, modified 5 Years ago. New Member Posts: 19 Join Date: 2/27/18 Recent Posts
thanks David H Nebinger, can you please give an example on it
In mycase my planning     
 A is a service module                 
B is another service module
C is another service module
D is normal module portlet
E is also a normal module portlet

here  A is integrating with other third party API (example stripe paymentgateway)B is integrating with other third party API (example authorize.net or razorpay)C is the generic module
in this we have to call the services of A or B (Based on the request)D and E or the normal modules which are going to use the services of A & B through C
please suggest me , how can we achieve my  above plan of action in liferay 7.0.1 GA2thanks & Regards
thumbnail
David H Nebinger, modified 5 Years ago. Liferay Legend Posts: 14933 Join Date: 9/2/06 Recent Posts
Build it out just the way you explain it. There's no rocket science involved, you are just describing having some services and some portlets and the need to reference those services in the portlets in order to invoke them.