fillumina / krasa-jaxb-tools

XJC / JAXB plugin for generation of Bean Validation Annotations 2.0 (JSR-380)
Apache License 2.0
6 stars 10 forks source link

Version 2.1 fails with ClassCastException #4

Closed michael-o closed 2 years ago

michael-o commented 2 years ago

Following configuration in POM:

  <plugins>
    <plugin>
      <groupId>org.jvnet.jaxb2.maven2</groupId>
      <artifactId>maven-jaxb2-plugin</artifactId>
      <version>0.14.0</version>
      <configuration>
        <schemaIncludes>
          <include>**/*.xsd</include>
        </schemaIncludes>
        <bindingIncludes>
          <include>**/*.xjb</include>
        </bindingIncludes>
        <readOnly>true</readOnly>
        <episode>true</episode>
        <specVersion>2.3</specVersion>
        <extension>true</extension>
        <removeOldOutput>true</removeOldOutput>
        <locale>en</locale>
        <strict>false</strict>
        <args>
          <arg>-no-header</arg>
          <arg>-XJsr303Annotations</arg>
          <arg>-XJsr303Annotations:JSR_349=true</arg>
          <arg>-Xnamespace-prefix</arg>
          <arg>-Xcommons-lang</arg>
          <arg>-XJsr303Annotations:verbose=false</arg>
        </args>
        <plugins>
          <plugin>
            <groupId>com.fillumina</groupId>
            <artifactId>krasa-jaxb-tools</artifactId>
            <version>2.1</version>
          </plugin>
          <plugin>
            <groupId>org.jvnet.jaxb2_commons</groupId>
            <artifactId>jaxb2-namespace-prefix</artifactId>
            <version>1.2</version>
          </plugin>
          <plugin>
            <groupId>org.jvnet.jaxb2_commons</groupId>
            <artifactId>jaxb2-commons-lang</artifactId>
            <version>2.4</version>
          </plugin>
        </plugins>
      </configuration>
    </plugin>

Execution gives me:

[ERROR] Failed to execute goal org.jvnet.jaxb2.maven2:maven-jaxb2-plugin:0.14.0:generate (generate-model) on project x2tc-iec-import-input-model: A type incompatibility occurred while executing org.jvnet.jaxb2.maven2:maven-jaxb2-plugin:0.14.0:generate: com.sun.xml.xsom.impl.ModelGroupImpl cannot be cast to com.sun.xml.xsom.impl.ElementDecl
[ERROR] -----------------------------------------------------
[ERROR] realm =    plugin>org.jvnet.jaxb2.maven2:maven-jaxb2-plugin:0.14.0
[ERROR] strategy = org.codehaus.plexus.classworlds.strategy.SelfFirstStrategy
[ERROR] urls[0] = file:/C:/Users/osipovmi/.m2/repository/org/jvnet/jaxb2/maven2/maven-jaxb2-plugin/0.14.0/maven-jaxb2-plugin-0.14.0.jar
[ERROR] urls[1] = file:/C:/Users/osipovmi/.m2/repository/org/jvnet/jaxb2/maven2/maven-jaxb2-plugin-core/0.14.0/maven-jaxb2-plugin-core-0.14.0.jar
[ERROR] urls[2] = file:/C:/Users/osipovmi/.m2/repository/org/apache/commons/commons-lang3/3.2.1/commons-lang3-3.2.1.jar
[ERROR] urls[3] = file:/C:/Users/osipovmi/.m2/repository/com/sun/org/apache/xml/internal/resolver/20050927/resolver-20050927.jar
[ERROR] urls[4] = file:/C:/Users/osipovmi/.m2/repository/org/glassfish/jaxb/txw2/2.3.0/txw2-2.3.0.jar
[ERROR] urls[5] = file:/C:/Users/osipovmi/.m2/repository/org/sonatype/plexus/plexus-build-api/0.0.7/plexus-build-api-0.0.7.jar
[ERROR] urls[6] = file:/C:/Users/osipovmi/.m2/repository/junit/junit/4.8.1/junit-4.8.1.jar
[ERROR] urls[7] = file:/C:/Users/osipovmi/.m2/repository/org/codehaus/plexus/plexus-utils/1.5.15/plexus-utils-1.5.15.jar
[ERROR] urls[8] = file:/C:/Users/osipovmi/.m2/repository/org/jvnet/jaxb2/maven2/maven-jaxb23-plugin/0.14.0/maven-jaxb23-plugin-0.14.0.jar
[ERROR] urls[9] = file:/C:/Users/osipovmi/.m2/repository/org/glassfish/jaxb/jaxb-runtime/2.3.0/jaxb-runtime-2.3.0.jar
[ERROR] urls[10] = file:/C:/Users/osipovmi/.m2/repository/org/glassfish/jaxb/jaxb-core/2.3.0/jaxb-core-2.3.0.jar
[ERROR] urls[11] = file:/C:/Users/osipovmi/.m2/repository/javax/xml/bind/jaxb-api/2.3.0/jaxb-api-2.3.0.jar
[ERROR] urls[12] = file:/C:/Users/osipovmi/.m2/repository/org/jvnet/staxex/stax-ex/1.7.8/stax-ex-1.7.8.jar
[ERROR] urls[13] = file:/C:/Users/osipovmi/.m2/repository/com/sun/xml/fastinfoset/FastInfoset/1.2.13/FastInfoset-1.2.13.jar
[ERROR] urls[14] = file:/C:/Users/osipovmi/.m2/repository/org/glassfish/jaxb/jaxb-xjc-jdk9/2.3.0/jaxb-xjc-jdk9-2.3.0.jar
[ERROR] urls[15] = file:/C:/Users/osipovmi/.m2/repository/org/glassfish/jaxb/jaxb-xjc/2.3.0/jaxb-xjc-2.3.0.jar
[ERROR] urls[16] = file:/C:/Users/osipovmi/.m2/repository/com/sun/xml/dtd-parser/dtd-parser/1.2/dtd-parser-1.2.jar
[ERROR] urls[17] = file:/C:/Users/osipovmi/.m2/repository/org/glassfish/jaxb/xsom/2.3.0/xsom-2.3.0.jar
[ERROR] urls[18] = file:/C:/Users/osipovmi/.m2/repository/org/glassfish/jaxb/codemodel/2.3.0/codemodel-2.3.0.jar
[ERROR] urls[19] = file:/C:/Users/osipovmi/.m2/repository/com/sun/xml/bind/external/rngom/2.3.0/rngom-2.3.0.jar
[ERROR] urls[20] = file:/C:/Users/osipovmi/.m2/repository/com/sun/istack/istack-commons-tools/3.0.5/istack-commons-tools-3.0.5.jar
[ERROR] urls[21] = file:/C:/Users/osipovmi/.m2/repository/com/sun/istack/istack-commons-runtime/3.0.5/istack-commons-runtime-3.0.5.jar
[ERROR] urls[22] = file:/C:/Users/osipovmi/.m2/repository/relaxngDatatype/relaxngDatatype/20020414/relaxngDatatype-20020414.jar
[ERROR] urls[23] = file:/C:/Users/osipovmi/.m2/repository/com/sun/activation/javax.activation/1.2.0/javax.activation-1.2.0.jar
[ERROR] urls[24] = file:/C:/Users/osipovmi/.m2/repository/org/apache/maven/plugin-tools/maven-plugin-annotations/3.5/maven-plugin-annotations-3.5.jar
[ERROR] Number of foreign imports: 1
[ERROR] import: Entry[import  from realm ClassRealm[maven.api, parent: null]]

with:

PS C:\Entwicklung\workspace-2020-12\x2tc-proxy> mvn -v
Apache Maven 3.8.6 (84538c9988a25aec085021c365c560670ad80f63)
Maven home: C:\Entwicklung\Programme\apache-maven-3.8.6
Java version: 1.8.0_345, vendor: Azul Systems, Inc., runtime: C:\Program Files\Zulu\zulu-8\jre
Default locale: de_DE, platform encoding: Cp1252
OS name: "windows 10", version: "10.0", arch: "amd64", family: "windows"
michael-o commented 2 years ago

I have the feeling that this is the cause: https://github.com/fillumina/krasa-jaxb-tools/blob/master/pom.xml#L96 The JAXB2 Maven Plugin uses version 2.3.x and not 3.x.

See: https://github.com/eclipse-ee4j/jaxb-ri/releases/tag/3.0.0-RI

michael-o commented 2 years ago

Note: I cannot upgrade the plugin because of: https://github.com/highsource/maven-jaxb2-plugin/issues/244

fillumina commented 2 years ago

Can you try using maven-jaxb2-plugin version 0.15.1 (that's the same version of the dependency maven-jaxb2-plugin-testing use by this project) ?

michael-o commented 2 years ago

Can you try using maven-jaxb2-plugin version 0.15.1 (that's the same version of the dependency maven-jaxb2-plugin-testing use by this project) ?

No, I can't because of https://github.com/fillumina/krasa-jaxb-tools/issues/4#issuecomment-1225360431

fillumina commented 2 years ago

I have created a test project and it works. Could you please check if it is working for you and if it solves your problem?

michael-o commented 2 years ago

I have created a test project and it works. Could you please check if it is working for you and if it solves your problem?

Will check...

michael-o commented 2 years ago

While going through your test project one spot is invalid: https://github.com/fillumina/krasa-issue4/blob/148bbb1ece136f10dc039fd6fd10925a1e88e6b8/pom.xml#L54-L60

Looking at the plugin's META-INF/maven/plugin.xml the goal does not have any dependencies parameter. I guess this is a mistype, no? Will fix locally and continue...

michael-o commented 2 years ago

Beat me, I cannot reproduce this anymore with 2.2 and 0.14.0. Tried in and out on Java 8. Darn I am angry. Sorry for the noise. Will continue to investigate the issue in JAXB2 plugin.