当我尝试使用servicebuilder构建liferay服务时出现空指针异常
我有一个“ECLocalDataService.java”类。我正在尝试将其构建为 liferay 本地服务,以便我可以使用 ServiceLocator.findService() 从所有 portlet 和速度模板访问它。
我的 ECLocalDataService 有点像这样:
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);
}
它的实现类是这样的:
import com.rosettastone.service.base.ECDataLocalServiceBaseImpl;
public class ECDataLocalServiceImpl extends ECDataLocalServiceBaseImpl {
public float getPriceBySKU(String sku) {
float price = 125.99f;
return price;
}
}
我已经在我的 service.xml 中注册了我的 ECDataLocalService
<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>
现在,当我单击 Liferay Dev Studio 中的“BuildServices”图标时,它会抛出 NullPointer 异常。它甚至不显示它为哪个对象找到了 NullPointer,没有错误消息或日志消息,只是简单地显示 NullPointerException 并且不会构建服务。
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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
此时,只有一个。代码示例中的元素。它没有列,也没有定义主键列。在这些情况下代码生成不可能工作。
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.
build-services ant 任务旨在从定义一个或多个表的 service.xml 构建服务。然后它会为您生成所有 Java 代码。没有必要先创建 Java 文件,事实上我认为这行不通。
我会阅读这篇 Liferay wiki 文章,这应该会让您上路。
http://www.liferay.com/community/wiki/- /wiki/Main/Service+Builder
一旦您获得由此生成的服务 jar,请将其放在 tomcat 类路径中,以便其他 portlet 可以访问该服务。
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.