Eclipse Lyo 2.4 - Error when POSTing to a creation factory

Hello,

sorry for posting a Lyo question into the general SDKs category, but I was unable to select the Lyo category (does not show up in the list). Please feel free to move or relabel this topic.

When I send a POST request to any of the generated resource creation factories, I receive this error in the response: (for all resources, not just the AutomationPlan)

<oslc:Error>
    <oslc:message rdf:datatype="http://www.w3.org/2001/XMLSchema#string">OSLC011: Missing corresponding set method for method getSubject of class org.eclipse.lyo.oslc.domains.auto.AutomationPlan</oslc:message>
    <oslc:statusCode rdf:datatype="http://www.w3.org/2001/XMLSchema#string">400</oslc:statusCode>
</oslc:Error>

The error occurs only when the resource created by the creation factory contains a property that has an occurrence of x-many (as opposed to x-1 or 1).
And at the same time the error occurs only when I send a non-empty POST request.

I am using Lyo Designer 2.4 and Lyo Generator 2.4 in Eclipse 2018-09 (4.9.0), and my adapter uses OSLC core version 2.4 (or 2.4.0.M1). I followed the Toolchain modeling manual from the Lyo wiki (User Manual for Toolchain Modelling · eclipse/lyo.designer Wiki · GitHub) to model an OSLC adapter for the Automation domain. I have used predefined domain specifications (GitHub - eclipse/lyo.domains: POJOs that implement resources in OSLC domains).

I think the error might be caused by the adapter using different versions of OSLC core and Lyo in some parts of it, because I have seen the same error on adapter startup when I was using OSLC core 2.2 with Lyo 2.4 (error was fixed by changing the OSLC core version in the adapters pom file).

Can you, please, help with this issue? Maybe providing a sample pom file for OSLC core 2.4, because the OSLC4J project creation guide (Lyo/creating OSLC4J project - Eclipsepedia) uses OSLC core 2.2, and I didnt find any project in Lyo samples (GitHub - OSLC/lyo-samples) that uses 2.4.

If you need more info, let me know (project pom, toolchain diagram, etc.)

Ondřej Vašíček

The problem seems to be that oslc4j is not finding the setter-method (setSubject) in the class AutomationPlan, for the corresponding getter-method getSubject.

Can you please check if the class AutomationPlan has such a method called setSubject? What is its signature?
I see that the method exists in the class from GitHub - eclipse/lyo.domains: POJOs that implement resources in OSLC domains. So I wonder if you have made any modifications to that class?

We do indeed need to update the instructions for LyoDesigner and the OSLC4J project creation guide, to refer to the latest versions of Lyo. But I don’t think this is the problem here. The only update we’d need to do is to update the version numbers.
I believe the problem is most likely to be in the AutomationPlan class.

1 Like

I have not made any modifications to the classes before.
I have, however, managed to fix the error by editing the class after reading an issue on the Lyo github. The problem was that Lyo generated setters with input parameters of type Set but getters were generated with a return type HashSet.

public HashSet<String> getSubject()
public void setSubject(final Set<String> subject )

I just changed return types of all getters from HashSet to Set, and now it works.

Is this caused by a bug in Lyo 2.4, or did I just setup something wrong?

Hi

This is indeed a bug in the generated code, as reported recently on https://github.com/eclipse/lyo.designer/issues/61.
To be clear, it is a bug in LyoDesigner, and not the Lyo SDK.

I can reproduce your problem, and I hope to fix it soon.

2 Likes

I have now regenerated the domain code to fix this bug.
Please see the Master branch on https://github.com/eclipse/lyo.domains

1 Like

I am actually using just the domain models, and generate the code myself. But, seeing the commit changes, I can easily repeat your fix for my generated code.

Thanks for the assistance!

1 Like