简体   繁体   中英

Liferay : Bean Locator has not been set

I have a existing table in database. I have modified service.xml as follows :- 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.

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?

And please post the whole service.xml file. This error is usually derivated from errors in service.xml file.

Thanks aritzg, I am now able to execute the portlet without errors. The solution - column name attribute in service.xml should start with a capital letter. Looks strange but it worked for me.

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>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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