importStream() throws error: The method toArray() is undefined for the type Collection

0
I have these lines in one of my Java actions where I am converting a JSON string into the appropriate entity using an import mapping: final InputStream inputStream = new ByteArrayInputStream(jsonString.getBytes(StandardCharsets.UTF_8)); List<IMendixObject> mendixObjects = Core.integration().importStream(getContext(), inputStream, importMappingName, null, false); My setup is: Mendix 8.0.0 jdk-11.0.3.7-hotspot Eclipse IDE for Enterprise Java Developers - Version: 2019-03 (4.11.0)    The importStream() call throws the following error when debugging in Eclipse: The method toArray() is undefined for the type Collection… How do I proceed?  
asked
1 answers
0

I created a test project to try and reproduce the issue.

Used Mx 7.23.5 and 8.0.0 with AdoptOpenJDK\jdk-11.0.3.7-hotspot and Eclipse Version: Kepler Service Release 2 Build id: 20140224-0627.

Created and entity with 1 string attribute.

Created a java action with 2 input parameters:

  1. String, for the jsonstring
  2. import mapping, to use the import mapping

Created a simple JSON structure:

{"Attribute":"string"}

From the structure created the import mapping

And with the following code imported the data from the string via the mapping:

// BEGIN USER CODE
		final InputStream inputStream = new ByteArrayInputStream(jsonStr.getBytes(StandardCharsets.UTF_8));
		List<IMendixObject> mendixObjects = Core.integration().importStream(getContext(), inputStream, importmap, null, false);
		return true;
// END USER CODE

This works fine, so I think the issue that you are experiencing should have something to do with the json being supplied to the java action rather than the jdk or Eclipse version. I would investigate this via a simple microflow in which you create a string variable with your json and perform a import activity with the import_mapping and see if that will also fail or not.

answered