eclipse-lyo / lyo

Eclipse Lyo, a Java SDK for OSLC-based tool integration
https://oslc.github.io/developing-oslc-applications/eclipse_lyo/eclipse-lyo.html
Eclipse Public License 2.0
17 stars 17 forks source link

Property #createdOn could not be parsed as datatype #dateTime #46

Open Kira-Cesonia opened 4 years ago

Kira-Cesonia commented 4 years ago

I have a slight issue when trying to read requirements from DOORS via DWA via OSLC via LYO. For most attribute values this works. However, for the dates, the following error is shown:

2020-08-10 09:59:32 WARN  org.eclipse.lyo.oslc4j.provider.jena.JenaModelHelper:1132 - Property http://jazz.net/ns/rm/doors/attribute#createdOn could not be parsed as datatype http://www.w3.org/2001/XMLSchema#dateTime
org.apache.jena.datatypes.DatatypeFormatException: Lexical form '2020-08-10' is not a legal instance of Datatype[http://www.w3.org/2001/XMLSchema#dateTime -> class org.apache.jena.datatypes.xsd.XSDDateTime] Lexical form '2020-08-10' is not a legal instance of Datatype[http://www.w3.org/2001/XMLSchema#dateTime -> class org.apache.jena.datatypes.xsd.XSDDateTime] during parse -org.apache.xerces.impl.dv.InvalidDatatypeValueException: cvc-datatype-valid.1.2.1: '2020-08-10' is not a valid value for 'dateTime'.
    at org.apache.jena.graph.impl.LiteralLabelImpl.getValue(LiteralLabelImpl.java:338)
    at org.apache.jena.graph.Node_Literal.getLiteralValue(Node_Literal.java:44)
    at org.apache.jena.rdf.model.impl.LiteralImpl.getValue(LiteralImpl.java:98)
    at org.eclipse.lyo.oslc4j.provider.jena.JenaModelHelper.handleExtendedPropertyValue(JenaModelHelper.java:1120)
    at org.eclipse.lyo.oslc4j.provider.jena.JenaModelHelper.fromResource(JenaModelHelper.java:637)
    at org.eclipse.lyo.oslc4j.provider.jena.JenaModelHelper.createObjectResultList(JenaModelHelper.java:507)
    at org.eclipse.lyo.oslc4j.provider.jena.JenaModelHelper.fromJenaModel(JenaModelHelper.java:391)
    at org.eclipse.lyo.oslc4j.provider.jena.AbstractOslcRdfXmlProvider.readFrom(AbstractOslcRdfXmlProvider.java:349)
    at org.eclipse.lyo.oslc4j.provider.jena.OslcRdfXmlProvider.readFrom(OslcRdfXmlProvider.java:271)
    at org.apache.wink.client.internal.handlers.ClientResponseImpl.readEntity(ClientResponseImpl.java:126)
    at org.apache.wink.client.internal.handlers.ClientResponseImpl.getEntity(ClientResponseImpl.java:65)
    at org.apache.wink.client.internal.handlers.ClientResponseImpl.getEntity(ClientResponseImpl.java:52)
    at doors.api.DoorsRequirementGetter.readRequirementFromDoorsDirectlyBy(DoorsRequirementGetter.java:112)
    at doors.api.DoorsRequirementGetterTest.readRequirementFromDoorsDirectlyByShouldReturnSpecObject(DoorsRequirementGetterTest.java:89)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.base/java.lang.reflect.Method.invoke(Method.java:566)
    at org.junit.platform.commons.util.ReflectionUtils.invokeMethod(ReflectionUtils.java:686)
    at org.junit.jupiter.engine.execution.MethodInvocation.proceed(MethodInvocation.java:60)
    at org.junit.jupiter.engine.execution.InvocationInterceptorChain$ValidatingInvocation.proceed(InvocationInterceptorChain.java:131)
    at org.junit.jupiter.engine.extension.TimeoutExtension.intercept(TimeoutExtension.java:149)
    at org.junit.jupiter.engine.extension.TimeoutExtension.interceptTestableMethod(TimeoutExtension.java:140)
    at org.junit.jupiter.engine.extension.TimeoutExtension.interceptTestMethod(TimeoutExtension.java:84)
    at org.junit.jupiter.engine.execution.ExecutableInvoker$ReflectiveInterceptorCall.lambda$ofVoidMethod$0(ExecutableInvoker.java:115)
    at org.junit.jupiter.engine.execution.ExecutableInvoker.lambda$invoke$0(ExecutableInvoker.java:105)
    at org.junit.jupiter.engine.execution.InvocationInterceptorChain$InterceptedInvocation.proceed(InvocationInterceptorChain.java:106)
    at org.junit.jupiter.engine.execution.InvocationInterceptorChain.proceed(InvocationInterceptorChain.java:64)
    at org.junit.jupiter.engine.execution.InvocationInterceptorChain.chainAndInvoke(InvocationInterceptorChain.java:45)
    at org.junit.jupiter.engine.execution.InvocationInterceptorChain.invoke(InvocationInterceptorChain.java:37)
    at org.junit.jupiter.engine.execution.ExecutableInvoker.invoke(ExecutableInvoker.java:104)
    at org.junit.jupiter.engine.execution.ExecutableInvoker.invoke(ExecutableInvoker.java:98)
    at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.lambda$invokeTestMethod$6(TestMethodTestDescriptor.java:205)
    at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
    at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.invokeTestMethod(TestMethodTestDescriptor.java:201)
    at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.execute(TestMethodTestDescriptor.java:137)
    at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.execute(TestMethodTestDescriptor.java:71)
    at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$5(NodeTestTask.java:135)
    at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
    at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$7(NodeTestTask.java:125)
    at org.junit.platform.engine.support.hierarchical.Node.around(Node.java:135)
    at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$8(NodeTestTask.java:123)
    at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
    at org.junit.platform.engine.support.hierarchical.NodeTestTask.executeRecursively(NodeTestTask.java:122)
    at org.junit.platform.engine.support.hierarchical.NodeTestTask.execute(NodeTestTask.java:80)
    at java.base/java.util.ArrayList.forEach(ArrayList.java:1540)
    at org.junit.platform.engine.support.hierarchical.SameThreadHierarchicalTestExecutorService.invokeAll(SameThreadHierarchicalTestExecutorService.java:38)
    at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$5(NodeTestTask.java:139)
    at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
    at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$7(NodeTestTask.java:125)
    at org.junit.platform.engine.support.hierarchical.Node.around(Node.java:135)
    at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$8(NodeTestTask.java:123)
    at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
    at org.junit.platform.engine.support.hierarchical.NodeTestTask.executeRecursively(NodeTestTask.java:122)
    at org.junit.platform.engine.support.hierarchical.NodeTestTask.execute(NodeTestTask.java:80)
    at java.base/java.util.ArrayList.forEach(ArrayList.java:1540)
    at org.junit.platform.engine.support.hierarchical.SameThreadHierarchicalTestExecutorService.invokeAll(SameThreadHierarchicalTestExecutorService.java:38)
    at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$5(NodeTestTask.java:139)
    at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
    at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$7(NodeTestTask.java:125)
    at org.junit.platform.engine.support.hierarchical.Node.around(Node.java:135)
    at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$8(NodeTestTask.java:123)
    at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
    at org.junit.platform.engine.support.hierarchical.NodeTestTask.executeRecursively(NodeTestTask.java:122)
    at org.junit.platform.engine.support.hierarchical.NodeTestTask.execute(NodeTestTask.java:80)
    at org.junit.platform.engine.support.hierarchical.SameThreadHierarchicalTestExecutorService.submit(SameThreadHierarchicalTestExecutorService.java:32)
    at org.junit.platform.engine.support.hierarchical.HierarchicalTestExecutor.execute(HierarchicalTestExecutor.java:57)
    at org.junit.platform.engine.support.hierarchical.HierarchicalTestEngine.execute(HierarchicalTestEngine.java:51)
    at org.junit.platform.launcher.core.DefaultLauncher.execute(DefaultLauncher.java:248)
    at org.junit.platform.launcher.core.DefaultLauncher.lambda$execute$5(DefaultLauncher.java:211)
    at org.junit.platform.launcher.core.DefaultLauncher.withInterceptedStreams(DefaultLauncher.java:226)
    at org.junit.platform.launcher.core.DefaultLauncher.execute(DefaultLauncher.java:199)
    at org.junit.platform.launcher.core.DefaultLauncher.execute(DefaultLauncher.java:141)
    at org.eclipse.jdt.internal.junit5.runner.JUnit5TestReference.run(JUnit5TestReference.java:89)
    at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:41)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:542)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:770)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:464)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:210)

I am using org.eclipse.lyo.clients:oslc-java-client:2.4.0 , excluding xml-apis because otherwise Java complains about it being already on the project path.

My main problem is that I don't see myself as having a lot of influence options on this error. In DOORS, the attribute value in question is of its native "Date" format and displays to me the value "Monday, 10th of August 2020".

Now, here's the environment of this error in my code:

        String requirementURL = retreiveRequirementUrl(
            dwaModuleConnection.oslcOauthClient,
            dwaModuleConnection.moduleQueryCapabilitiesUrl,
            doorsAbsoluteNumber
        );

        ClientResponse getResponse = dwaModuleConnection.oslcOauthClient
            .getResource(requirementURL, OslcMediaType.APPLICATION_RDF_XML);

        // If this is not set, I'll get a hard error saying "org.apache.jena.riot.system.ErrorHandlerFactory$ErrorLogger:95 - Lexical form '2020-08-10' not valid for datatype XSD dateTime"
        System.setProperty(AbstractOslcRdfXmlProvider.OSLC4J_STRICT_DATATYPES, "false");

        Requirement requirement = getResponse.getEntity(Requirement.class);

So, what can I do about this?

jadelkhoury commented 4 years ago

Hi

Have you considered using the latest oslcClient packages instead of org.eclipse.lyo.clients:oslc-java-client:2.4.0 ? namely, oslc4j-client, by adding the following dependency.

    <dependency>
            <groupId>org.eclipse.lyo.clients</groupId>
            <artifactId>oslc4j-client</artifactId>
            <version>4.0.0-SNAPSHOT</version>
    </dependency>

Is that an option? if so, you'll be using the latest versions of LyoClient, which we are in a better situation to solve problems.

I suspect your problem is a result of the few changes you have made (setting OSLC4J_STRICT_DATATYPES, removing xml-apis). Maybe they are hding a more underlying problem with the setup. But let's start with ysing the latest LyoClient.

Kira-Cesonia commented 4 years ago

Is there some sort of documentation for how to do that? I have been using this sample to build everything from here: https://github.com/OSLC/lyo-samples/blob/master/oslc-java-samples/src/main/java/org/eclipse/lyo/client/oslc/samples/DoorsOauthSample.java

And that sample apparently depends on me using org.eclipse.lyo.clients:oslc-java-client:2.4.0. If I switch the dependency to org.eclipse.lyo.clients:oslc4j-client:4.0.0-SNAPSHOT, I get errors like The import org.eclipse cannot be resolved in the line import org.eclipse.lyo.oslc4j.provider.jena.AbstractOslcRdfXmlProvider

jadelkhoury commented 4 years ago

The documentations are unfortunately always not up to date in such open-source projects.

berezovskyi commented 3 years ago

I get errors like The import org.eclipse cannot be resolved in the line import org.eclipse.lyo.oslc4j.provider.jena.AbstractOslcRdfXmlProvider

Strange, https://github.com/eclipse/lyo/blob/master/core/oslc4j-jena-provider/src/main/java/org/eclipse/lyo/oslc4j/provider/jena/AbstractOslcRdfXmlProvider.java is still there in 4.0.0

excluding xml-apis because otherwise Java complains about it being already on the project path.

thank you, we will try to fix it for 4.0.0

Is there some sort of documentation for how to do that?

For now, these are the two best pointers:

I will be very glad if you collect notes and help me will update https://oslc.github.io/developing-oslc-applications/eclipse_lyo/eclipse-lyo.html

berezovskyi commented 3 years ago

Just to be clear, @jadelkhoury, xml-apis are not the culprit, it's a package needed before Java 5 when XML support was added natively to the JDK. We will try to remove it or at least switch it's mode to provided.