Uploaded image for project: 'Camel'
  1. Camel
  2. CAMEL-16670

Camel Component & Package Maven Plugins fail on some JSON resource files

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Minor
    • Resolution: Fixed
    • 3.10.0
    • 3.11.0
    • tooling
    • None
    • Unknown

    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.

      Attachments

        Activity

          People

            davsclaus Claus Ibsen
            gramana Zachary Gramana
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: