'tRules' Component - issue with rule DRL file syntax and KnowledgeBase

Four Stars

'tRules' Component - issue with rule DRL file syntax and KnowledgeBase

Hello,

 

I followed this tutorial and was able to create rules locally (tutorialRule_0.txt attached).  Though I create this DRL file using Talend Studio, I get a syntax error and KnowledgeBase error when I run a job -

 

[statistics] connecting to socket on port 3802
[statistics] connected
[1,0]: [ERR 107] Line 1:0 mismatched input '#' expecting one of the following tokens: '[package, import, global, declare, function, rule, query]'.
[3,25]: [ERR 107] Line 3:25 mismatched input 'here' expecting one of the following tokens: '[package, import, global, declare, function, rule, query]'.
[8,0]: [ERR 107] Line 8:0 mismatched input '#' expecting one of the following tokens: '[package, import, global, declare, function, rule, query]'.
[8,20]: [ERR 102] Line 8:20 mismatched input 'variables'
[9,0]: [ERR 102] Line 9:0 mismatched input 'global'
[9,17]: [ERR 102] Line 9:17 mismatched input 'list'
[10,7]: [ERR 102] Line 10:7 mismatched input 'HashMap'
[13,0]: [ERR 102] Line 13:0 mismatched input 'rule'
[13,5]: [ERR 102] Line 13:5 mismatched input '"ValidEmails"'
[41,2]: [ERR 102] Line 41:2 mismatched input '#' in rule "InvalidEmails"
[0,0]: Parser returned a null Package

 

Exception in component tRules_1
java.lang.IllegalArgumentException: Could not parse knowledge.
    at newproject1.tutorialjob_0_1.tutorialJob$1KnowledgeBase_tRules_1.readKnowledgeBaseDRL(tutorialJob.java:1143)
[FATAL]: newproject1.tutorialjob_0_1.tutorialJob - tRules_1 Could not parse knowledge.
[statistics] disconnected
    at newproject1.tutorialjob_0_1.tutorialJob$1KnowledgeBase_tRules_1.readKnowledgeBase(tutorialJob.java:1116)
    at newproject1.tutorialjob_0_1.tutorialJob.tFileInputExcel_1Process(tutorialJob.java:1195)
    at newproject1.tutorialjob_0_1.tutorialJob.runJobInTOS(tutorialJob.java:2272)
    at newproject1.tutorialjob_0_1.tutorialJob.main(tutorialJob.java:2106)
Job tutorialJob ended at 01:10 03/01/2018. [exit code=1]

 

I tried removing the commented lines with '#'s from rule DRL file but got an error with 'input' and 'output' object types and KnowledgeBase:

 

Unable to resolve ObjectType '$inputStruct$' : [Rule name='ValidEmails']
Unable to resolve ObjectType '$inputStruct$' : [Rule name='InvalidEmails']

Rule Compilation error : [Rule name='ValidEmails']
    defaultpkg/Rule_ValidEmails1914298844.java (7:417) : $outputStruct0$ cannot be resolved to a type
    defaultpkg/Rule_ValidEmails1914298844.java (7:444) : $outputStruct0$ cannot be resolved to a type
    defaultpkg/Rule_ValidEmails1914298844.java (8:485) : Syntax error, insert ":: IdentifierOrNew" to complete ReferenceExpression
    defaultpkg/Rule_ValidEmails1914298844.java (8:485) : Syntax error, insert "AssignmentOperator Expression" to complete Assignment
    defaultpkg/Rule_ValidEmails1914298844.java (8:485) : Syntax error, insert ";" to complete Statement
    defaultpkg/Rule_ValidEmails1914298844.java (8:485) : outputStruct0$ cannot be resolved to a variable
    defaultpkg/Rule_ValidEmails1914298844.java (9:503) : list cannot be resolved
    defaultpkg/Rule_ValidEmails1914298844.java (10:553) : input cannot be resolved to a variable
[FATAL]: newproject1.emailjob1_0_1.EmailJob1 - tRules_2 Could not parse knowledge.
[statistics] disconnected

Rule Compilation error : [Rule name='InvalidEmails']
    defaultpkg/Rule_InvalidEmails477598557.java (7:418) : $outputStruct1$ cannot be resolved to a type
    defaultpkg/Rule_InvalidEmails477598557.java (7:445) : $outputStruct1$ cannot be resolved to a type
    defaultpkg/Rule_InvalidEmails477598557.java (8:486) : Syntax error, insert ":: IdentifierOrNew" to complete ReferenceExpression
    defaultpkg/Rule_InvalidEmails477598557.java (8:486) : Syntax error, insert "AssignmentOperator Expression" to complete Assignment
    defaultpkg/Rule_InvalidEmails477598557.java (8:486) : Syntax error, insert ";" to complete Statement
    defaultpkg/Rule_InvalidEmails477598557.java (8:486) : outputStruct1$ cannot be resolved to a variable
    defaultpkg/Rule_InvalidEmails477598557.java (9:504) : list cannot be resolved
    defaultpkg/Rule_InvalidEmails477598557.java (10:554) : input cannot be resolved to a variable

Exception in component tRules_2
java.lang.IllegalArgumentException: Could not parse knowledge.
    at newproject1.emailjob1_0_1.EmailJob1$1KnowledgeBase_tRules_2.readKnowledgeBaseDRL(EmailJob1.java:1139)
    at newproject1.emailjob1_0_1.EmailJob1$1KnowledgeBase_tRules_2.readKnowledgeBase(EmailJob1.java:1112)
    at newproject1.emailjob1_0_1.EmailJob1.tFileInputExcel_1Process(EmailJob1.java:1191)
    at newproject1.emailjob1_0_1.EmailJob1.runJobInTOS(EmailJob1.java:2259)
    at newproject1.emailjob1_0_1.EmailJob1.main(EmailJob1.java:2093)
Job EmailJob1 ended at 01:22 03/01/2018. [exit code=1]

 
 Can someone help? Thanks.

Moderator

Re: 'tRules' Component - issue with rule DRL file syntax and KnowledgeBase

Hello,

Could you please indicate on which talend build version you got this issue?

Best regards

Sabrina

--
Don't forget to give kudos when a reply is helpful and click Accept the solution when you think you're good with it.

15TH OCTOBER, COUNTY HALL, LONDON

Join us at the Community Lounge.

Register Now

2019 GARNER MAGIC QUADRANT FOR DATA INTEGRATION TOOL

Talend named a Leader.

Get your copy

OPEN STUDIO FOR DATA INTEGRATION

Kickstart your first data integration and ETL projects.

Download now

What’s New for Talend Summer ’19

Watch the recorded webinar!

Watch Now

Best Practices for Using Context Variables with Talend – Part 4

Pick up some tips and tricks with Context Variables

Blog

How Media Organizations Achieved Success with Data Integration

Learn how media organizations have achieved success with Data Integration

Read

Definitive Guide to Data Quality

Create systems and workflow to manage clean data ingestion and data transformation.

Download