Ask Questions and Find Answers
Important:
Ask is now read-only. You can review any existing questions and answers, but not add anything new.
But - don't panic! While ask is no more, we've replaced it with discuss - the new Liferay Discussion Forum! Read more here here or just visit the site here:
discuss.liferay.com
RE: build_service problems in deploying: table not created
Hi all,
seems that in LR 7 developing with Liferay IDE there are problems in deploying what was created by build_service.
Seems that the table defined in service.xml is only created the first time that xxx-service and xxx-api are deployed.
Then if you change anything and use again build_service you receive an error "table already exist".
If you delete the table from the database, the deploy works without errors but the table is never created.
What is the method to correctly use build_service in LR 7?
TL;DR what I have done:
I'm using Liferay IDE bundled with Eclipse Neon
The Liferay bundle is liferay-ce-portal-tomcat-7.0-ga7-20180507111753223.zip
The operating System is MS Windows 10
Database MySQL 5.6
The jdk is jdk1.8.0_171
Documentation consulted:
https://dev.liferay.com/develop/tutorials/-/knowledge_base/7-0/generating-the-back-end https://dev.liferay.com/develop/tutorials/-/knowledge_base/7-0/service-builder
Sequence tried without obtaining the table creation (after the first deploy):
1) refresh xxx-service; refresh xxx-service gradle project; launch gradle task buildService; do the same for xxx-api; deploy xxx-service and xxx-api. Receive error: table already exist.
2) remove table from MySql; repeat the step in 1). There is no error in deploy baut the table is not created.
3) delete xxx-service and xxx-api from the running server; stop Eclipse; restart Eclipse; Deploy xxx-service and xxx-api (drag and drop the modules on the running server). Deployment seems correct (modules are indicated as Started, Syncronized) but there is no table in MySQL
Add "include-and-override=portal-developer.properties" to your portal-ext.properties file.
This will restore the legacy way of recreating the tables.
You don't want to do this for production. In production, your module should include an UpgradeProcess that incorporates all of the details for making DDL changes to the database. The Liferay source provides examples for how to do this correctly.
Thanks; but I had no luck.
Mybe I'm particularly dumb in this period.
Now, starting from the "bundle" directory, the "liferay-ce-portal-7.0-ga7\portal-setup-wizard.properties" contains:
admin.email.from.address=test@liferay.com admin.email.from.name=Test Test company.default.locale=en_US company.default.web.id=liferay.com default.admin.email.address.prefix=test jdbc.default.driverClassName=com.mysql.jdbc.Driver jdbc.default.password=malerba jdbc.default.url=jdbc:mysql://localhost/msb3?characterEncoding=UTF-8&dontTrackOpenResources=true&holdResultsOpenOverStatementClose=true&useFastDateParsing=false&useUnicode=true jdbc.default.username=lruser liferay.home=C:/appoggio/liferay/bundle/liferay-ce-portal-7.0-ga7 setup.wizard.enabled=false include-and-override=portal-developer.properties
The "liferay-ce-portal-7.0-ga7\tomcat-8.0.32\webapps\ROOT\WEB-INF\classes\portal-developer.properties" contains
schema.module.build.auto.upgrade=true theme.css.fast.load=false theme.css.fast.load.check.request.parameter=true theme.images.fast.load=false theme.images.fast.load.check.request.parameter=true javascript.fast.load=true javascript.log.enabled=false layout.template.cache.enabled=false browser.launcher.url= combo.check.timestamp=true minifier.enabled=false openoffice.cache.enabled=false com.liferay.portal.servlet.filters.cache.CacheFilter=false com.liferay.portal.servlet.filters.etag.ETagFilter=false com.liferay.portal.servlet.filters.header.HeaderFilter=false com.liferay.portal.servlet.filters.themepreview.ThemePreviewFilter=true
Still no table is created and I tried all the methods in my first post.
About UpgradeProcess I'll try to implement it when I will be able to release in production for the first time.
BTW the Liferay source code is huge; where can I find an example of UpgradeProcess?
There is any documentation about UpgradeProcess?
Again thanks for your time
You might need to build services and deploy an update if it thinks the previous version was already deployed. Also check your version in the bnd.bnd file and update as well.
You can find UpgradeProcess doco on dev.liferay.com: https://dev.liferay.com/develop/tutorials/-/knowledge_base/7-0/creating-an-upgrade-process-for-your-app
Well, seems that the UpgradeProcess is more complex than I expected.
But, reading documentation, I found this (in https://dev.liferay.com/develop/tutorials/-/knowledge_base/7-0/creating-an-upgrade-process-for-your-app ):
Before continuing with upgrade step registrators, if your application was modularized from a former traditional Liferay plugin application (application WAR) and it uses Service Builder, it requires a Bundle Activator to register itself in <strong>Liferay Portal’s Release_ table</strong>. If this is the case for your application, <a href="https://dev.liferay.com/develop/tutorials/-/knowledge_base/7-0/upgrade-processes-for-former-service-builder-plugins">create and register a Bundle Activator</a> and then return here to write your upgrade step registrator.
So I discovered that deleting the row of my service from the release_ table, deleting ad deploying again my service in the server correctly creates the table.
Regarding documentation, I looked at the previous link; but it was not clear for me where the .java files have to be inserted in the project tree.
Looking at https://github.com/liferay/liferay-plugins/tree/6.2.x/portlets/knowledge-base-portlet/docroot/WEB-INF/src/com/liferay/knowledgebase/hook/upgrade I discovered that the upgrade directory is inside the hook directory that seems is inside a module directory.
It means that in a "x" Liferay workspace project, "y" build service Lifreay module project I have to create the upgrade folder at the same level of "y-service" and "y-api"?
I mean:
x + + modules + + y + + y-service + y-api + upgrade
Is this correct?
No, not really.
You're using Liferay 7, you can't look at the liferay plugins project for 6.2 and derive something like that from it.
In Liferay 7, you can build your upgrade process java sources right in your service building impl project, use the @Component to register and OSGi will take care of the rest.
Powered by Liferay™