简体   繁体   English

Liferay:尚未设置Bean定位器

[英]Liferay : Bean Locator has not been set

I have a existing table in database. 我在数据库中已有一个表。 I have modified service.xml as follows :- Service.xml :- 我修改了service.xml如下:-Service.xml:-

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE service-builder PUBLIC "-//Liferay//DTD Service Builder 6.0.0//EN" "http://www.liferay.com/dtd/liferay-service-builder_6_0_0.dtd">
<service-builder package-path="net.test"> 
    <author>pfeffeg</author>
    <namespace>dataaccess</namespace>
 <entity name="test" remote-service="true" local-service="true">
    <column name="PID" type="long"></column>
    <column name="PName" type="String"></column>
    <column name="IID" type="long" primary="true"></column>
    <column name="iName" type="String"></column>
    </entity>
</service-builder>

Create table query:- 创建表查询:

CREATE TABLE [dbo].[dataaccess_test](
 [PID] [bigint] NULL,
 [PName] [varchar](max) NULL,
 [IID] [bigint] NOT NULL,
 [iName] [varchar](max) NULL,
 CONSTRAINT [pk_IdetailidTest] PRIMARY KEY CLUSTERED 
(
 [IID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF,             ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]

I have built the service builder. 我已经建立了服务构建器。 All classes have apparently been built correctly. 所有类显然都正确构建。 but when i try to run the portlet I am getting a Bean Locator exception. 但是,当我尝试运行Portlet时,出现了Bean Locator异常。

BeanLocator has not been set
com.liferay.portal.kernel.bean.BeanLocatorException: BeanLocator has not been set
    at com.liferay.portal.kernel.bean.PortletBeanLocatorUtil.locate(PortletBeanLocatorUtil.java:40)

What liferay version are you are you working with? 您正在使用哪个liferay版本?

And please post the whole service.xml file. 并请发布整个service.xml文件。 This error is usually derivated from errors in service.xml file. 此错误通常是源于service.xml文件中的错误。

Thanks aritzg, I am now able to execute the portlet without errors. 感谢aritzg,我现在能够执行portlet而不会出错。 The solution - column name attribute in service.xml should start with a capital letter. 解决方案-service.xml中的列名属性应以大写字母开头。 Looks strange but it worked for me. 看起来很奇怪,但对我有用。

service.xml service.xml

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE service-builder PUBLIC "-//Liferay//DTD Service Builder 6.0.0//EN" "http://www.liferay.com/dtd/liferay-service-builder_6_0_0.dtd">
<service-builder package-path="net.test"> 
    <author>pfeffeg</author>
    <namespace>dataaccess</namespace>
 <entity name="test" remote-service="true" local-service="true">
    <column name="PID" type="long"></column>
    <column name="PName" type="String"></column>
    <column name="IID" type="long" primary="true"></column>
    <column name="IName" type="String"></column>
    </entity>
</service-builder>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM