SQL table not created when deploying WAR file in Liferay

I created the JSR-268 portlet for Liferay, which uses services to interact with the database. I can deploy the portlet without problems or errors, but the table defined by the services has not been created!

When checking the portlet, I do not get the "table not found" error. I have no mistakes! The tables are simply not in the database. I found other things on the Internet saying that I have to use the generated "create.sql" file that Lilderay Service Builder created, but I don't see it anywhere.

Can someone help me?

+6
sql portlet liferay
source share
4 answers

Are tables created? I had a similar problem when I deleted tables manually. I thought they would be created again when the portlet was deployed, but this did not happen.

After examining the source code, I found that Liferay stores portlet information in the servicecomponent table and checks 2 things before it executes (pseudo) SQL in META-INF/tables.sql :

  • build.number in service.properties should be higher than in servicecomponent ,
  • tables.sql must be different from the value stored in the servicecomponent .

Only then tables.sql is executed.

An easy way to achieve this is to delete all entries in the servicecomponent addressed to your portlet.

+10
source share

Try removing the entry from the servicecomponent table. And reinstall the portlet.

 delete FROM servicecomponent where buildNamespace="<your table namespace>" 
+2
source share

I ran into the same problem and below this solution works for me.

Steps

  • I changed build.number in service.properties higher than in servicecomponent.
  • Removed all xml files from the META-INF folder.
  • Removed all sql files from the webapp / WEB-INF / sql folder.

Then build-service and deployment will create user tables that are defined in the service.xml file.

+1
source share

If you use serviceBuilder in Liferay 6.2, when you define a new object in the Liferay schema in the service.xml file, the first time any portlet tries to access the table, it will be created if it does not exist.

When using a different scheme, there are several problems, because sometimes Liferay does not automatically create tables. Then you need to execute the Creation SQL statement and create it manually, and then access it through LocalServiceUtil.

0
source share

All Articles