Why is service builder in liferay throwing parser errors? - liferay

I'm trying to build a service with ant in LiferayIDE, so far without any luck, the console keeps showing errors that say there was a parser errors at multiple lines of the Service Builder.
Errors are like the following:
[echo] 18:50:41,514 ERROR [main][java:355] PARSER_ERROR
[echo] C:\lportal\plugins\portlets\caja-en-linea-portlet\ServiceBuilder.temp:497:16: unexpected token: String
[echo] at de.hunsicker.jalopy.language.antlr.InternalJavaParser.typeDefinitionInternal(InternalJavaParser.java:660)
[echo] at de.hunsicker.jalopy.language.antlr.InternalJavaParser.typeDefinition(InternalJavaParser.java:465)
[echo] at de.hunsicker.jalopy.language.antlr.InternalJavaParser.parse(InternalJavaParser.java:296)
[echo] at de.hunsicker.jalopy.language.JavaRecognizer.parse(JavaRecognizer.java:588)
[echo] at de.hunsicker.jalopy.Jalopy.parse(Jalopy.java:1212)
[echo] at de.hunsicker.jalopy.Jalopy.format(Jalopy.java:1044)
[echo] at de.hunsicker.jalopy.Jalopy.format(Jalopy.java:1017)
[echo] at com.liferay.portal.tools.servicebuilder.ServiceBuilder.writeFile(ServiceBuilder.java:449)
[echo] at com.liferay.portal.tools.servicebuilder.ServiceBuilder.writeFile(ServiceBuilder.java:365)
[echo] at com.liferay.portal.tools.servicebuilder.ServiceBuilder._createModel(ServiceBuilder.java:2194)
[echo] at com.liferay.portal.tools.servicebuilder.ServiceBuilder.<init>(ServiceBuilder.java:758)
[echo] at com.liferay.portal.tools.servicebuilder.ServiceBuilder.main(ServiceBuilder.java:228)
[echo] 18:50:41,623 ERROR [main][java:355] PARSER_ERROR
[echo] C:\lportal\plugins\portlets\caja-en-linea-portlet\ServiceBuilder.temp:506:16: unexpected token: void
[echo] at de.hunsicker.jalopy.language.antlr.InternalJavaParser.typeDefinitionInternal(InternalJavaParser.java:660)
[echo] at de.hunsicker.jalopy.language.antlr.InternalJavaParser.typeDefinition(InternalJavaParser.java:465)
[echo] at de.hunsicker.jalopy.language.antlr.InternalJavaParser.parse(InternalJavaParser.java:296)
[echo] at de.hunsicker.jalopy.language.JavaRecognizer.parse(JavaRecognizer.java:588)
[echo] at de.hunsicker.jalopy.Jalopy.parse(Jalopy.java:1212)
[echo] at de.hunsicker.jalopy.Jalopy.format(Jalopy.java:1044)
[echo] at de.hunsicker.jalopy.Jalopy.format(Jalopy.java:1017)
[echo] at com.liferay.portal.tools.servicebuilder.ServiceBuilder.writeFile(ServiceBuilder.java:449)
[echo] at com.liferay.portal.tools.servicebuilder.ServiceBuilder.writeFile(ServiceBuilder.java:365)
[echo] at com.liferay.portal.tools.servicebuilder.ServiceBuilder._createModel(ServiceBuilder.java:2194)
[echo] at com.liferay.portal.tools.servicebuilder.ServiceBuilder.<init>(ServiceBuilder.java:758)
[echo] at com.liferay.portal.tools.servicebuilder.ServiceBuilder.main(ServiceBuilder.java:228)
[echo] 18:50:41,623 ERROR [main][java:355] PARSER_ERROR
[echo] C:\lportal\plugins\portlets\caja-en-linea-portlet\ServiceBuilder.temp:522:16: unexpected token: String
[echo] at de.hunsicker.jalopy.language.antlr.InternalJavaParser.typeDefinitionInternal(InternalJavaParser.java:660)
[echo] at de.hunsicker.jalopy.language.antlr.InternalJavaParser.typeDefinition(InternalJavaParser.java:465)
[echo] at de.hunsicker.jalopy.language.antlr.InternalJavaParser.parse(InternalJavaParser.java:296)
[echo] at de.hunsicker.jalopy.language.JavaRecognizer.parse(JavaRecognizer.java:588)
[echo] at de.hunsicker.jalopy.Jalopy.parse(Jalopy.java:1212)
[echo] at de.hunsicker.jalopy.Jalopy.format(Jalopy.java:1044)
[echo] at de.hunsicker.jalopy.Jalopy.format(Jalopy.java:1017)
[echo] at com.liferay.portal.tools.servicebuilder.ServiceBuilder.writeFile(ServiceBuilder.java:449)
[echo] at com.liferay.portal.tools.servicebuilder.ServiceBuilder.writeFile(ServiceBuilder.java:365)
[echo] at com.liferay.portal.tools.servicebuilder.ServiceBuilder._createModel(ServiceBuilder.java:2194)
[echo] at com.liferay.portal.tools.servicebuilder.ServiceBuilder.<init>(ServiceBuilder.java:758)
[echo] at com.liferay.portal.tools.servicebuilder.ServiceBuilder.main(ServiceBuilder.java:228)
[echo] 18:50:41,623 ERROR [main][java:355] PARSER_ERROR
[echo] C:\lportal\plugins\portlets\caja-en-linea-portlet\ServiceBuilder.temp:531:16: unexpected token: void
[echo] at de.hunsicker.jalopy.language.antlr.InternalJavaParser.typeDefinitionInternal(InternalJavaParser.java:660)
[echo] at de.hunsicker.jalopy.language.antlr.InternalJavaParser.typeDefinition(InternalJavaParser.java:465)
[echo] at de.hunsicker.jalopy.language.antlr.InternalJavaParser.parse(InternalJavaParser.java:296)
[echo] at de.hunsicker.jalopy.language.JavaRecognizer.parse(JavaRecognizer.java:588)
[echo] at de.hunsicker.jalopy.Jalopy.parse(Jalopy.java:1212)
[echo] at de.hunsicker.jalopy.Jalopy.format(Jalopy.java:1044)
[echo] at de.hunsicker.jalopy.Jalopy.format(Jalopy.java:1017)
[echo] at com.liferay.portal.tools.servicebuilder.ServiceBuilder.writeFile(ServiceBuilder.java:449)
[echo] at com.liferay.portal.tools.servicebuilder.ServiceBuilder.writeFile(ServiceBuilder.java:365)
[echo] at com.liferay.portal.tools.servicebuilder.ServiceBuilder._createModel(ServiceBuilder.java:2194)
[echo] at com.liferay.portal.tools.servicebuilder.ServiceBuilder.<init>(ServiceBuilder.java:758)
[echo] at com.liferay.portal.tools.servicebuilder.ServiceBuilder.main(ServiceBuilder.java:228)
[echo] 18:50:41,623 ERROR [main][java:355] PARSER_ERROR
[echo] C:\lportal\plugins\portlets\caja-en-linea-portlet\ServiceBuilder.temp:546:16: unexpected token: int
[echo] at de.hunsicker.jalopy.language.antlr.InternalJavaParser.typeDefinitionInternal(InternalJavaParser.java:660)
[echo] at de.hunsicker.jalopy.language.antlr.InternalJavaParser.typeDefinition(InternalJavaParser.java:465)
[echo] at de.hunsicker.jalopy.language.antlr.InternalJavaParser.parse(InternalJavaParser.java:296)
[echo] at de.hunsicker.jalopy.language.JavaRecognizer.parse(JavaRecognizer.java:588)
[echo] at de.hunsicker.jalopy.Jalopy.parse(Jalopy.java:1212)
[echo] at de.hunsicker.jalopy.Jalopy.format(Jalopy.java:1044)
[echo] at de.hunsicker.jalopy.Jalopy.format(Jalopy.java:1017)
[echo] at com.liferay.portal.tools.servicebuilder.ServiceBuilder.writeFile(ServiceBuilder.java:449)
[echo] at com.liferay.portal.tools.servicebuilder.ServiceBuilder.writeFile(ServiceBuilder.java:365)
[echo] at com.liferay.portal.tools.servicebuilder.ServiceBuilder._createModel(ServiceBuilder.java:2194)
[echo] at com.liferay.portal.tools.servicebuilder.ServiceBuilder.<init>(ServiceBuilder.java:758)
[echo] at com.liferay.portal.tools.servicebuilder.ServiceBuilder.main(ServiceBuilder.java:228)
[echo] 18:50:41,623 ERROR [main][java:355] PARSER_ERROR
[echo] C:\lportal\plugins\portlets\caja-en-linea-portlet\ServiceBuilder.temp:555:16: unexpected token: void
[echo] at de.hunsicker.jalopy.language.antlr.InternalJavaParser.typeDefinitionInternal(InternalJavaParser.java:660)
[echo] at de.hunsicker.jalopy.language.antlr.InternalJavaParser.typeDefinition(InternalJavaParser.java:465)
[echo] at de.hunsicker.jalopy.language.antlr.InternalJavaParser.parse(InternalJavaParser.java:296)
[echo] at de.hunsicker.jalopy.language.JavaRecognizer.parse(JavaRecognizer.java:588)
[echo] at de.hunsicker.jalopy.Jalopy.parse(Jalopy.java:1212)
[echo] at de.hunsicker.jalopy.Jalopy.format(Jalopy.java:1044)
[echo] at de.hunsicker.jalopy.Jalopy.format(Jalopy.java:1017)
[echo] at com.liferay.portal.tools.servicebuilder.ServiceBuilder.writeFile(ServiceBuilder.java:449)
[echo] at com.liferay.portal.tools.servicebuilder.ServiceBuilder.writeFile(ServiceBuilder.java:365)
[echo] at com.liferay.portal.tools.servicebuilder.ServiceBuilder._createModel(ServiceBuilder.java:2194)
[echo] at com.liferay.portal.tools.servicebuilder.ServiceBuilder.<init>(ServiceBuilder.java:758)
[echo] at com.liferay.portal.tools.servicebuilder.ServiceBuilder.main(ServiceBuilder.java:228)
[echo] 18:50:41,733 ERROR [main][java:355] PARSER_ERROR
[echo] C:\lportal\plugins\portlets\caja-en-linea-portlet\ServiceBuilder.temp:571:16: unexpected token: String
[echo] at de.hunsicker.jalopy.language.antlr.InternalJavaParser.typeDefinitionInternal(InternalJavaParser.java:660)
[echo] at de.hunsicker.jalopy.language.antlr.InternalJavaParser.typeDefinition(InternalJavaParser.java:465)
[echo] at de.hunsicker.jalopy.language.antlr.InternalJavaParser.parse(InternalJavaParser.java:296)
[echo] at de.hunsicker.jalopy.language.JavaRecognizer.parse(JavaRecognizer.java:588)
[echo] at de.hunsicker.jalopy.Jalopy.parse(Jalopy.java:1212)
[echo] at de.hunsicker.jalopy.Jalopy.format(Jalopy.java:1044)
[echo] at de.hunsicker.jalopy.Jalopy.format(Jalopy.java:1017)
[echo] at com.liferay.portal.tools.servicebuilder.ServiceBuilder.writeFile(ServiceBuilder.java:449)
[echo] at com.liferay.portal.tools.servicebuilder.ServiceBuilder.writeFile(ServiceBuilder.java:365)
[echo] at com.liferay.portal.tools.servicebuilder.ServiceBuilder._createModel(ServiceBuilder.java:2194)
[echo] at com.liferay.portal.tools.servicebuilder.ServiceBuilder.<init>(ServiceBuilder.java:758)
[echo] at com.liferay.portal.tools.servicebuilder.ServiceBuilder.main(ServiceBuilder.java:228)
[echo] 18:50:41,733 ERROR [main][java:355] PARSER_ERROR
[echo] C:\lportal\plugins\portlets\caja-en-linea-portlet\ServiceBuilder.temp:580:16: unexpected token: void
[echo] at de.hunsicker.jalopy.language.antlr.InternalJavaParser.typeDefinitionInternal(InternalJavaParser.java:660)
[echo] at de.hunsicker.jalopy.language.antlr.InternalJavaParser.typeDefinition(InternalJavaParser.java:465)
[echo] at de.hunsicker.jalopy.language.antlr.InternalJavaParser.parse(InternalJavaParser.java:296)
[echo] at de.hunsicker.jalopy.language.JavaRecognizer.parse(JavaRecognizer.java:588)
[echo] at de.hunsicker.jalopy.Jalopy.parse(Jalopy.java:1212)
[echo] at de.hunsicker.jalopy.Jalopy.format(Jalopy.java:1044)
[echo] at de.hunsicker.jalopy.Jalopy.format(Jalopy.java:1017)
[echo] at com.liferay.portal.tools.servicebuilder.ServiceBuilder.writeFile(ServiceBuilder.java:449)
[echo] at com.liferay.portal.tools.servicebuilder.ServiceBuilder.writeFile(ServiceBuilder.java:365)
[echo] at com.liferay.portal.tools.servicebuilder.ServiceBuilder._createModel(ServiceBuilder.java:2194)
[echo] at com.liferay.portal.tools.servicebuilder.ServiceBuilder.<init>(ServiceBuilder.java:758)
[echo] at com.liferay.portal.tools.servicebuilder.ServiceBuilder.main(ServiceBuilder.java:228)
[echo] 18:50:41,733 ERROR [main][java:355] PARSER_ERROR
[echo] C:\lportal\plugins\portlets\caja-en-linea-portlet\ServiceBuilder.temp:590:12: unexpected token: boolean
Which means I have something wrong in my service.xml, but I can't find out what mistake.
My service.xml is like follows:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE service-builder PUBLIC "-//Liferay//DTD Service Builder 6.2.0//EN" "http://www.liferay.com/dtd/liferay-service-builder_6_2_0.dtd">
<service-builder package-path="com.cide.cajaenlinea.econtinua">
<author>Gerardo</author>
<namespace>ECcaja</namespace>
<entity name="MovimientosTesoreria" local-service="true" data-source="catalogosEvolution" remote-service="false" table="TTesoreriaMovimientos"
session-factory="EvolutionSessionFactory">
<column name="IdMovimiento" type="int" primary="true"></column>
<column name="IdTipoMovimiento" type="int"></column>
<column name="IdCatCuentaBancaria" type="int"></column>
<column name="IdUsuario" type="int"></column>
<column name="IdDivisaTipoCambio" type="int"></column>
<column name="IdPoliza" type="int"></column>
<column name="IdTipoIngreso" type="int"></column>
<column name="IdAFavorDePersona" type="int"></column>
<column name="IdAFavorDeTipo" type="int"></column>
<column name="FolioMovimiento" type="int"></column>
<column name="NumeroCheque" type="String"></column>
<column name="Concepto" type="String"></column>
<column name="FechaRegistro" type="Date"></column>
<column name="Debe" type="double"></column>
<column name="Haber" type="double"></column>
<column name="FechaExpedicion" type="Date"></column>
<column name="FechaDeposito" type="Date"></column>
<column name="Pagado" type="boolean"></column>
<column name="EjercicioAnt" type="boolean"></column>
<column name="FechaEntrega" type="Date"></column>
<column name="CFDSerie" type="String"></column>
<column name="CFDFolio" type="int"></column>
<column name="CFDMetodoPago" type="String"></column>
<column name="CFDFormaPago" type="String"></column>
<column name="IdDatosFacturacion" type="int"></column>
<column name="IdDatosFacturacionAFavorDe" type="int"></column>
<column name="IdTipoPago" type="int"></column>
<column name="NaturalezaMovimiento" type="String"></column>
<column name="Inhabilitado" type="boolean"></column>
<column name="Cantidad" type="int"></column>
<column name="FoliosRequerimiento" type="String"></column>
<column name="IdCaja" type="int"></column>
<column name="TipoFolio" type="int"></column>
<column name="IdInformacionBancaria" type="int"></column>
<finder return-type="Collection" name="MovimientosIdMovimiento">
<finder-column name="IdMovimiento"></finder-column>
</finder>
<finder return-type="Collection" name="MovimientosFolios">
<finder-column name="FolioMovimiento"></finder-column>
</finder>
<finder return-type="Collection" name="MovimientosAFavorDe">
<finder-column name="IdAFavorDePersona"></finder-column>
<finder-column name="IdAFavorDeTipo"></finder-column>
</finder>
</entity>
<entity name="Empleados" local-service="true" data-source="catalogosEvolution" remote-service="false" table="Empleado"
session-factory="EvolutionSessionFactory">
<column name="claveempleado" type="int"></column>
<column name="Id" type="int" primary="true"></column>
<column name="Nombre" type="String"></column>
<column name="Paterno" type="String"></column>
<column name="Materno" type="String"></column>
<column name="Nombres" type="String"></column>
<column name="Fecha Nacimiento" type="Date"></column>
<column name="Lugar Nacimiento" type="String"></column>
<column name="Sexo" type="int"></column>
<column name="Estado Civil" type="int"></column>
<column name="Calle" type="String"></column>
<column name="Colonia" type="String"></column>
<column name="Cp" type="String"></column>
<column name="Delegacion" type="String"></column>
<column name="Estado" type="String"></column>
<column name="Tel1" type="String"></column>
<column name="Email" type="String"></column>
<column name="CURP" type="String"></column>
<column name="RFC" type="String"></column>
<column name="Id_Adscripcion" type="int"></column>
<column name="EmailCia" type="String"></column>
<finder return-type="Collection" name="EmpleadoPClave">
<finder-column name="claveempleado"></finder-column>
</finder>
<finder return-type="Collection" name="EmpleadoPNombre">
<finder-column name="Nombre"></finder-column>
<finder-column name="Paterno"></finder-column>
<finder-column name="Materno"></finder-column>
<finder-column name="Nombres"></finder-column>
</finder>
<finder return-type="Collection" name="EmpleadoPEmail">
<finder-column name="Email"></finder-column>
<finder-column name="EmailCia"></finder-column>
</finder>
</entity>
<entity name="NumerosOrden" local-service="true" data-source="catalogosEvolution" remote-service="false" table="TNumsOrdenAFoliosMovimiento"
session-factory="EvolutionSessionFactory">
<column name="idOrden" type="int" primary="true"></column>
<column name="numOrden" type="int"></column>
<column name="FolioMovimiento" type="String"></column>
<column name="RFCCliente" type="String"></column>
<column name="NombreCliente" type="String"></column>
<column name="Calle" type="String"></column>
<column name="Colonia" type="String"></column>
<column name="Pais" type="String"></column>
<column name="CodigoPostal" type="String"></column>
<column name="Delegacion" type="String"></column>
<column name="Digest" type="String"></column>
<column name="Respuesta" type="String"></column>
<column name="Total" type="double"></column>
<column name="Afiliacion" type="String"></column>
<column name="Store" type="String"></column>
<column name="Terminal" type="String"></column>
<column name="NumReferencia" type="String"></column>
<column name="NumAutorizacion" type="String"></column>
<column name="Verificado" type="boolean"></column>
<finder return-type="Collection" name="CompraPNumDeOrden">
<finder-column name="numOrden"></finder-column>
<finder-column name="FolioMovimiento"></finder-column>
</finder>
<finder return-type="Collection" name="CompraPorRFCCliente">
<finder-column name="RFCCliente"></finder-column>
</finder>
</entity>
<entity name="Alumnos" local-service="true" data-source="catalogosEvolution" remote-service="false" table="Alumnos"
session-factory="EvolutionSessionFactory">
<column name="MatriculaId" type="int"></column>
<column name="Matricula" type="String" primary="true"></column>
<column name="ApellidoPaterno" type="String"></column>
<column name="ApellidoMaterno" type="String"></column>
<column name="Nombre" type="String"></column>
<column name="EdoCivil" type="String"></column>
<column name="RFC" type="String"></column>
<column name="CURP" type="String"></column>
<column name="Sexo" type="String"></column>
<column name="Pais" type="String"></column>
<column name="Entidad" type="String"></column>
<column name="Municipio" type="String"></column>
<column name="Calle" type="String"></column>
<column name="Colonia" type="String"></column>
<column name="CodigoPostal" type="String"></column>
<column name="Telefono" type="String"></column>
<column name="Email" type="String"></column>
<finder return-type="Collection" name="AlumnoPMatricula">
<finder-column name="Matricula"></finder-column>
</finder>
<finder return-type="Collection" name="AlumnoPRFC">
<finder-column name="RFC"></finder-column>
<finder-column name="CURP"></finder-column>
</finder>
</entity>
<entity name="Generales" local-service="true" data-source="catalogosEvolution" remote-service="false" table="CatGenerales"
session-factory="EvolutionSessionFactory">
<column name="IdGeneral" type="int" primary="true"></column>
<column name="RFC" type="String"></column>
<column name="GralDescripcion" type="String"></column>
<column name="Inhabilitado" type="boolean"></column>
<column name="IdUsuario" type="int"></column>
<column name="FechaUltimoCambio" type="Date"></column>
<finder return-type="Collection" name="GeneralPRFC">
<finder-column name="RFC"></finder-column>
</finder>
<finder name="GeneralPNombre" return-type="Collection">
<finder-column name="GralDescripcion"></finder-column>
</finder>
</entity>
</service-builder>
After trying to build the service again I found out that the problem must be in my entity "Empleados", because if I include it the service builder throws errors, all the other entities seem to be fine. But I still can't find what the error may be in the way I'm writing that entity. Folowing is the entity Empleados:
<entity name="Empleados" local-service="true" data-source="catalogosEvolution" remote-service="false" table="Empleado" session-factory="EvolutionSessionFactory">
2 <column name="claveempleado" type="int"></column>
3 <column name="Id" type="int" primary="true"></column>
4 <column name="Nombre" type="String"></column>
5 <column name="Paterno" type="String"></column>
6 <column name="Materno" type="String"></column>
7 <column name="Nombres" type="String"></column>
8 <column name="Fecha Nacimiento" type="Date"></column>
9 <column name="Lugar Nacimiento" type="String"></column>
10 <column name="Sexo" type="int"></column>
11 <column name="Estado Civil" type="int"></column>
12 <column name="Calle" type="String"></column>
13 <column name="Colonia" type="String"></column>
14 <column name="Cp" type="String"></column>
15 <column name="Delegacion" type="String"></column>
16 <column name="Estado" type="String"></column>
17 <column name="Tel1" type="String"></column>
18 <column name="Email" type="String"></column>
19 <column name="CURP" type="String"></column>
20 <column name="RFC" type="String"></column>
21 <column name="Id_Adscripcion" type="int"></column>
22 <column name="EmailCia" type="String"></column>
23 <finder return-type="Collection" name="EmpleadoPClave">
24 <finder-column name="claveempleado"></finder-column>
25 </finder>
26 <finder return-type="Collection" name="EmpleadoPNombre">
27 <finder-column name="Nombre"></finder-column>
28 <finder-column name="Paterno"></finder-column>
29 <finder-column name="Materno"></finder-column>
30 <finder-column name="Nombres"></finder-column>
31 </finder>
32 <finder return-type="Collection" name="EmpleadoPEmail">
33 <finder-column name="Email"></finder-column>
34 <finder-column name="EmailCia"></finder-column>
35 </finder>
36 </entity>
But I still can't figure out what's wrong with this last entity. Could it be the blank spaces in some column names? Cause if it's so, there's a problem as this column names are defined with spaces in them in the DB. And I also forgot to mention that this, as also the entity "Para Identificacion" is a view, not a table.

ServiceBuilder uses the name attribute to generate things like method names for each entities model. For example Fecha Nacimiento would generate getFecha Nacimiento in each of the generated Empleados classes.
Unfortunately, this is what is causing the parse errors since getFecha Nacimiento is not a valid method name due to the white space.

Related

JHipster:Relation "datcat_attribute_metadata" does not exist

JHipster is not creating the table DatcatAttributeMetadata to the database. This is a child table with a foreign key relationship manyToOne with parent table DatcatAttributeMetadata.
Parent table was created earlier but when adding DatcatAttributeMetadata using Jhipster entity module this table is not being added to PostgresSql and throwing an error ERROR: relation "datcat_attribute_metadata" does not exist
Have tried --force-entity and mvn liquidbase:diff multiple times but still the table is not being created in DB
Below is the code snippet to
master.xml
20170612191949_added_entity_constraints_DatcatAttributeMetadata.xml
20170612191949_added_entity_DatcatAttributeMetadata.xml
http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-3.4.xsd">
<include file="classpath:config/liquibase/changelog/00000000000000_initial_schema.xml" relativeToChangelogFile="false"/>
<include file="classpath:config/liquibase/changelog/20170612161115_added_entity_DatcatDatasetMetadata.xml" relativeToChangelogFile="false"/>
<include file="classpath:config/liquibase/changelog/20170612191949_added_entity_DatcatAttributeMetadata.xml" relativeToChangelogFile="false"/>
<!-- jhipster-needle-liquibase-add-changelog - JHipster will add liquibase changelogs here -->
<include file="classpath:config/liquibase/changelog/20170612191949_added_entity_constraints_DatcatAttributeMetadata.xml" relativeToChangelogFile="false"/>
<!-- jhipster-needle-liquibase-add-constraints-changelog - JHipster will add liquibase constraints changelogs here -->
<?xml version="1.0" encoding="utf-8"?>
<databaseChangeLog
xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-3.4.xsd">
<!--
Added the constraints for entity DatcatAttributeMetadata.
-->
<changeSet id="20170612191949-2" author="jhipster">
<addForeignKeyConstraint baseColumnNames="dataset_id_id"
baseTableName="datcat_attribute_metadata"
constraintName="fk_datcat_attribute_metadata_dataset_id_id"
referencedColumnNames="dataset_id"
referencedTableName="datcat_dataset_metadata"/>
</changeSet>
</databaseChangeLog>
http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-3.4.xsd
http://www.liquibase.org/xml/ns/dbchangelog-ext http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-ext.xsd">
<property name="now" value="now()" dbms="h2"/>
<property name="now" value="current_timestamp" dbms="postgresql"/>
<property name="floatType" value="float4" dbms="postgresql, h2"/>
<property name="floatType" value="float" dbms="mysql, oracle, mssql"/>
<changeSet id="20170612191949-1" author="jhipster">
<createTable tableName="datcat_attribute_metadata">
<column name="attribute_id" type="bigint" autoIncrement="${autoIncrement}">
<constraints primaryKey="true" nullable="false"/>
</column>
<column name="attribute_def" type="varchar(255)">
<constraints nullable="false" />
</column>
<column name="primary_key" type="boolean">
<constraints nullable="false" />
</column>
<column name="foreign_key" type="varchar(255)">
<constraints nullable="true" />
</column>
<column name="attribute_datatype" type="varchar(255)">
<constraints nullable="false" />
</column>
<column name="attribute_lenght" type="integer">
<constraints nullable="true" />
</column>
<column name="dataset_id_id" type="bigint">
<constraints nullable="false" />
</column>
<!-- jhipster-needle-liquibase-add-column - JHipster will add columns here, do not remove-->
</createTable>
</changeSet>
Logs
2017-06-12 16:15:01.198 DEBUG 44521 --- [ XNIO-2 task-3] c.e.p.d.apis.aop.logging.LoggingAspect : Enter: com.exelon.predix.datacatalog.apis.web.rest.DatcatAttributeMetadataResource.getAllDatcatAttributeMetadata() with argument[s] = [Page request [number: 0, size 20, sort: id: ASC]]
2017-06-12 16:15:01.207 DEBUG 44521 --- [ XNIO-2 task-3] .d.a.w.r.DatcatAttributeMetadataResource : REST request to get a page of DatcatAttributeMetadata
2017-06-12 16:15:01.210 DEBUG 44521 --- [ XNIO-2 task-3] c.e.p.d.apis.aop.logging.LoggingAspect : Enter: com.exelon.predix.datacatalog.apis.service.DatcatAttributeMetadataService.findAll() with argument[s] = [Page request [number: 0, size 20, sort: id: ASC]]
2017-06-12 16:15:01.210 DEBUG 44521 --- [ XNIO-2 task-3] a.s.i.DatcatAttributeMetadataServiceImpl : Request to get all DatcatAttributeMetadata
Hibernate: select datcatattr0_.attribute_id as attribut1_0_, datcatattr0_.attribute_datatype as attribut2_0_, datcatattr0_.attribute_def as attribut3_0_, datcatattr0_.attribute_lenght as attribut4_0_, datcatattr0_.dataset_id_dataset_id as dataset_7_0_, datcatattr0_.foreign_key as foreign_5_0_, datcatattr0_.primary_key as primary_6_0_ from datcat_attribute_metadata datcatattr0_ order by datcatattr0_.attribute_id asc limit ?
2017-06-12 16:15:01.223 WARN 44521 --- [ XNIO-2 task-3] o.h.engine.jdbc.spi.SqlExceptionHelper : SQL Error: 0, SQLState: 42P01
2017-06-12 16:15:01.223 ERROR 44521 --- [ XNIO-2 task-3] o.h.engine.jdbc.spi.SqlExceptionHelper : ERROR: relation "datcat_attribute_metadata" does not exist
Position: 331
2017-06-12 16:15:01.237 ERROR 44521 --- [ XNIO-2 task-3] c.e.p.d.apis.aop.logging.LoggingAspect : Exception in com.exelon.predix.datacatalog.apis.service.DatcatAttributeMetadataService.findAll() with cause = 'org.hibernate.exception.SQLGrammarException: could not extract ResultSet' and exception = 'could not extract ResultSet; SQL [n/a]; nested exception is org.hibernate.exception.SQLGrammarException: could not extract ResultSet'
Please not I have updated the column names of the primary key in both parent and child table as dataset_id and attribute_id respectively by making changes in liquidbase file and using #Column annotation in domain class.

Liferay JSF service builder configuration error

Am newbie to Liferay. I have created one JSF portlet and added the service builder to it. Using this link Generate a Persistence Framework. After configure a service builder i have generated the source using service builder. But am getting following exception when build service of project.
Exception in thread "main" java.lang.IllegalArgumentException: No entity column exist with column database name guestbookId for entity Guestbook
[echo] at com.liferay.portal.tools.service.builder.ServiceBuilder._getEntityColumnByColumnDBName(ServiceBuilder.java:4242)
[echo] at com.liferay.portal.tools.service.builder.ServiceBuilder._getColumnLengths(ServiceBuilder.java:3857)
[echo] at com.liferay.portal.tools.service.builder.ServiceBuilder._createSQLIndexes(ServiceBuilder.java:3355)
[echo] at com.liferay.portal.tools.service.builder.ServiceBuilder.<init>(ServiceBuilder.java:796)
[echo] at com.liferay.portal.tools.service.builder.ServiceBuilder.main(ServiceBuilder.java:216)
[echo] -Dservice.tpl.spring_xml_session=com/liferay/portal/tools/service/builder/dependencies/spring_xml_session.ftl
[echo] Java HotSpot(TM) 64-Bit Server VM warning: ignoring option MaxPermSize=512m; support was removed in 8.0
[mkdir] Created dir: D:\liferay\liferay-plugins-sdk-7.0\portlets\jsfguestbook-portlet\docroot\WEB-INF\service-classes
[copy] Copied 9 empty directories to 9 empty directories under D:\liferay\liferay-plugins-sdk-7.0\portlets\jsfguestbook-portlet\docroot\WEB-INF\service-classes
[javac] Compiling 38 source files to D:\liferay\liferay-plugins-sdk-7.0\portlets\jsfguestbook-portlet\docroot\WEB-INF\service-classes
[javac] Note: Some input files use or override a deprecated API.
[javac] Note: Recompile with -Xlint:deprecation for details.
[javac] Note: Some input files use unchecked or unsafe operations.
[javac] Note: Recompile with -Xlint:unchecked for details.
[jar] Building jar: D:\liferay\liferay-plugins-sdk-7.0\portlets\jsfguestbook-portlet\docroot\WEB-INF\lib\jsfguestbook-portlet-service.jar
[delete] Deleting directory D:\liferay\liferay-plugins-sdk-7.0\portlets\jsfguestbook-portlet\docroot\WEB-INF\service-classes
BUILD SUCCESSFUL
Total time: 8 seconds
Also after built the service i have added the code as per article. I got no method is configured for following code.
public Guestbook getFirstGuestbookByName(long groupId, String name) throws SystemException {
Guestbook guestbook = null;
List<Guestbook> guestbooks = guestbookPersistence.findByName(groupId, name); // This method is not exist.
if (guestbooks != null && guestbooks.size() > 0) {
guestbook = guestbooks.get(0);
}
return guestbook;
}
My service.xml configuration is follows
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE service-builder PUBLIC "-//Liferay//DTD Service Builder 7.0.0//EN" "http://www.liferay.com/dtd/liferay-service-builder_7_0_0.dtd">
<service-builder package-path="com.liferay.docs.guestbook">
<author>muthuvignesh.k</author>
<namespace>GB</namespace>
<entity name="Guestbook" local-service="true" uuid="true">
<!-- PK fields -->
<column name="guestbookId" type="long" primary="true"></column>
<!-- Group instance -->
<column name="groupId" type="long"></column>
<!-- Audit fields -->
<column name="companyId" type="long"></column>
<column name="userId" type="long"></column>
<column name="userName" type="String"></column>
<column name="createDate" type="Date"></column>
<column name="modifiedDate" type="Date"></column>
<column name="name" type="String"></column>
<finder name="GroupId" return-type="Collection">
<finder-column name="groupId"></finder-column>
</finder>
</entity>
<entity name="Entry" local-service="true" uuid="true">
<!-- PK fields -->
<column name="entryId" type="long" primary="true"></column>
<!-- Group instance -->
<column name="groupId" type="long"></column>
<!-- Audit fields -->
<column name="companyId" type="long"></column>
<column name="userId" type="long"></column>
<column name="userName" type="String"></column>
<column name="createDate" type="Date"></column>
<column name="modifiedDate" type="Date"></column>
<column name="name" type="String"></column>
<column name="email" type="String"></column>
<column name="message" type="String"></column>
<column name="guestbookId" type="long"></column>
<finder name="G_G" return-type="Collection">
<finder-column name="groupId"></finder-column>
<finder-column name="guestbookId"></finder-column>
</finder>
</entity>
<exceptions>
<exception>GuestbookName</exception>
<exception>EntryName</exception>
<exception>EntryMessage</exception>
<exception>EntryEmail</exception>
</exceptions>
Since i have using Liferay 7.0 for this. How to overcome this.
I had a same error in 6.2. It seems that the error was in the WEB-INF/sql/indexes.sql file. An index entry was using the field that the service builder could not find (but existed in the service.xml).
I think (but I couldn't verify it) the problem was occurred by an older version of liferay maven plugin (6.2.0-ga1). By deleting the file and upgrading to version 6.2.5, service builder generated a different indexes.sql and the build was successful.
Service Builder
The issue appears to be in your service builder.
1.What stands out the most is your malformed XML. You need to close the tag.
2.Secondly in your Java code you are trying to access a finder that doesn't exist. The only finder you have defined in your hibernate file is groupId. It would look something like
return guestbookPersistence.findByGroupId(groupId);
3.To create a groupid and name find it would look similar to your entry finder.
<finder name="G_N" return-type="Collection">
<finder-column name="groupId"></finder-column>
<finder-column name="name"></finder-column>
</finder>
and your java code
return guestbookPersistence.findByG_N(groupId, name);
service.xml
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE service-builder PUBLIC "-//Liferay//DTD Service Builder 7.0.0//EN" "http://www.liferay.com/dtd/liferay-service-builder_7_0_0.dtd">
<service-builder package-path="com.latham.data">
<author>muthuvignesh.k</author>
<namespace>GB</namespace>
<entity name="Guestbook" local-service="true" uuid="true">
<!-- PK fields -->
<column name="guestbookId" type="long" primary="true"></column>
<!-- Group instance -->
<column name="groupId" type="long"></column>
<!-- Audit fields -->
<column name="companyId" type="long"></column>
<column name="userId" type="long"></column>
<column name="userName" type="String"></column>
<column name="createDate" type="Date"></column>
<column name="modifiedDate" type="Date"></column>
<column name="name" type="String"></column>
<finder name="GroupId" return-type="Collection">
<finder-column name="groupId"></finder-column>
</finder>
<finder name="G_N" return-type="Collection">
<finder-column name="groupId"></finder-column>
<finder-column name="name"></finder-column>
</finder>
</entity>
<entity name="Entry" local-service="true" uuid="true">
<!-- PK fields -->
<column name="entryId" type="long" primary="true"></column>
<!-- Group instance -->
<column name="groupId" type="long"></column>
<!-- Audit fields -->
<column name="companyId" type="long"></column>
<column name="userId" type="long"></column>
<column name="userName" type="String"></column>
<column name="createDate" type="Date"></column>
<column name="modifiedDate" type="Date"></column>
<column name="name" type="String"></column>
<column name="email" type="String"></column>
<column name="message" type="String"></column>
<column name="guestbookId" type="long"></column>
<finder name="G_G" return-type="Collection">
<finder-column name="groupId"></finder-column>
<finder-column name="guestbookId"></finder-column>
</finder>
</entity>
<exceptions>
<exception>GuestbookName</exception>
<exception>EntryName</exception>
<exception>EntryMessage</exception>
<exception>EntryEmail</exception>
</exceptions>
</service-builder>
The tutorial you linked to is for Liferay 6.2 but your document definition is for Liferay 7. There were some very big changes between 6.2 and 7. Your code seems to be compatible with both however you should still keep that in mind.

Liferay and relationships in it

I have a portlet, which can add/update/delete books and add authors. Moreover, you can choose existing authors when you try to add book.
And now I need to show how many books were written by each author in "author" table. How can I do it? Im a newbie in liferay and I even have no idea.
It's my service.xml
<entity name="Book" local-service="true" remote-service="true" cache-enabled="false">
<column name="bookId" type="long" primary="true" />
<column name="bookName" type="String" />
<column name="bookDescription" type="String" />
<column name="authors" type="Collection" entity="Author" mapping-table="Books_Authors" />
<finder return-type="Collection" name="bookName">
<finder-column name="bookName"></finder-column>
</finder>
</entity>
<entity name="Author" local-service="true" remote-service="true" cache-enabled="false">
<column name="authorId" type="long" primary="true" />
<column name="authorName" type="String" />
<column name="books" type="Collection" entity="Book" mapping-table="Books_Authors" />
</entity>
Service Builder is your friend.
You just need to add a finder in your book entity in service.xml. If your entity has a field named author:
<finder name="Author" return-type="Collection">
<finder-column name="author" />
</finder>
The execution of build-service will generate the methods BookUtil.findByAuthor() and BookUtil.countByAuthor().
You can implement now the corresponding methods in BookLocalServiceImpl, calling the previous, and after another run of build-serivce, they're available in your Util class. Something like
public List<Book> getByAuthor(String author) {
return getPersistence().findByAuthor(author);
}
public int countByAuthor(String author) {
return getPersistence().countByAuthor(author);
}
After the last call to build-service you can call them from your BookLocalServiceUtil.
If you just want the count, don't retrieve all the collection. If there are many records, it's a bad idea. Invoke the count instead.

How to create listerners for Custom entity in liferay?

I have created custom entity employee. Now I want to add listeners for this entity so that I can track add/edit/delete employee operations.
In Liferay for portal enitites like Blogs, Group, User etc we can add properties like
value.object.listener.com.liferay.portal.model.Group=com.smb.test.hook.listeners.GroupListener
in portal.properties via hook-plugin.
But for custom entity this approach does not seem to work.
Any help would be appreciated.
For custom entity, we need to add the listener property in service-ext.properties instead of the portal.properties file.
For my employee entity I have added following property in service-ext.properties file:
value.object.listener.com.smb.employee.model.Employee=com.smb.employee.hook.listeners.EmployeeListener
Note: We need to manually create service-ext.properties file in src folder besides the service.properties file. We could have updated service.properties but since it auto-generates our changes would be lost and hence service-ext.properties is the correct liferay approach.
Here is the location of the service-ext.properties file:
Here is my service.xml:
<service-builder package-path="com.smb.employee">
<author>Suyash</author>
<namespace>smb</namespace>
<entity name="Employee" local-service="true" remote-service="true">
<!-- PK fields -->
<column name="fooId" type="long" primary="true" />
<!-- Audit fields -->
<column name="companyId" type="long" />
<column name="userId" type="long" />
<column name="userName" type="String" />
<column name="createDate" type="Date" />
<column name="modifiedDate" type="Date" />
<!-- Other fields -->
<column name="field1" type="String" />
<column name="field2" type="boolean" />
<column name="field3" type="int" />
<column name="field4" type="Date" />
<column name="field5" type="String" />
<!-- Order -->
<order by="asc">
<order-column name="field1" />
</order>
<!-- Finder methods -->
<finder name="Field2" return-type="Collection">
<finder-column name="field2" />
</finder>
</entity>
</entity>
</service-builder>

NLog code line logging

I am using NLog to log error messages into csv:
<target name="csv" xsi:type="File"
fileName="${basedir}/Logs/log.csv"
archiveFileName="${basedir}/Logs/Archives/log.{#####}.csv"
archiveAboveSize="10240"
archiveNumbering="Sequence"
concurrentWrites="true"
keepFileOpen="false">
<layout xsi:type="CSVLayout" delimiter="Comma" withHeader="false">
<column name="time" layout="${longdate}" />
<column name="message" layout="${message}" />
<column name="logger" layout="${logger}"/>
<column name="level" layout="${level}"/>
</layout>
</target>
How can I add a column to track the code line number?
Thank you.
Try to add ${callsite} layout renderer.
<column name="source" layout="${callsite:fileName=true}" />

Resources