Reputation: 10241
I have a "ECLocalDataService.java" class. I am trying to build it as liferay local service, so that I can access it from all portlets and velocity templates using ServiceLocator.findService().
My ECLocalDataService is somewhat like this:
public interface ECDataLocalService {
public java.lang.String getBeanIdentifier();
public void setBeanIdentifier(java.lang.String beanIdentifier);
@Transactional(propagation = Propagation.SUPPORTS, readOnly = true)
public float getPriceBySKU(java.lang.String sku);
}
and its implementation class is like this:
import com.rosettastone.service.base.ECDataLocalServiceBaseImpl;
public class ECDataLocalServiceImpl extends ECDataLocalServiceBaseImpl {
public float getPriceBySKU(String sku) {
float price = 125.99f;
return price;
}
}
I have registered my ECDataLocalService in my service.xml
<service-builder package-path="com.rosettastone">
<author>rajeshp</author>
<namespace>mycompany</namespace>
<entity name="ECDataLocalService" local-service="true" remote-service="false" human-name="ECDataLocalService"></entity>
</service-builder>
Now after this, when I click the "BuildServices" icon in Liferay Dev Studio, it throws NullPointer exception. It doesn't even show for what object that it found a NullPointer for, no error message or log messages, just simply display NullPointerException and the service doesn't get built.
Upvotes: 0
Views: 3625
Reputation: 9295
<entity name="ECDataLocalService" local-service="true" remote-service="false" human-name="ECDataLocalService"></entity>
At this time, there's only one <entity> element in your code sample. It has no columns, and no primary key columns defined. Code generation cannot possibly work under these circumstances.
Upvotes: 1
Reputation: 2683
build-services ant task is meant for building a service from a service.xml that defines a table or tables. It then generates all Java code for you. There's no need to create Java files first, in fact I don't think that will work.
I would read this Liferay wiki article, and that should get you on your way.
http://www.liferay.com/community/wiki/-/wiki/Main/Service+Builder
Once you have your resulting service jar from this put that on your tomcat classpath so other portlets can access the service.
Upvotes: 0