Description
Given:
- Create a new route project using spring-boot archetype
- Create `src/main/resources/test.json` with contents:
[{ "fizz": "buzz" }]
- Add the following XML to the `<plugins>` node in `pom.xml`:
<plugin>
<groupId>org.apache.camel</groupId>
<artifactId>camel-package-maven-plugin</artifactId>
<version>3.10.0</version>
<executions>
<execution>
<id>generate</id>
<goals>
<goal>generate-component</goal>
</goals>
<phase>process-classes</phase>
</execution>
</executions>
</plugin>
- Run `mvn package`
Expected:
[INFO] BUILD SUCCESS
Observed:
[INFO] BUILD FAILURE [INFO] ------------------------------------------------------------------------ [INFO] Total time: 3.852 s [INFO] Finished at: 2021-05-28T12:34:00-07:00 [INFO] ------------------------------------------------------------------------ [ERROR] Failed to execute goal org.apache.camel:camel-package-maven-plugin:3.10.0:generate-component (generate) on project CommandInvocationRoute: Error generating data org.apache.maven.plugin.MojoFailureException: Unable to create mojo: class org.apache.camel.util.json.JsonArray cannot be cast to class org.apache.camel.util.json.JsonObject (org.apache.camel.util.json.JsonArray and org.apache.camel.util.json.JsonObject are in unnamed module of loader org.codehaus.plexus.classworlds.realm.ClassRealm @7d3fb0ef) -> [Help 1]
Notes:
Removing the square brackets avoids the problem. For example, the following `test.json` contents enables a successful build:
{ "fizz": "buzz" }
In addition, renaming the file to `test.txt` avoids the problem.