jibx 1.2.3 模块化模式到代码生成 - 绑定编译导致内部错误 - 无法修改类

发布于 2024-12-06 14:34:06 字数 24818 浏览 1 评论 0原文

我有一个具有层次结构的 Maven 多模块项目:

parent
    + ota-module
       + ota-common
       + ota-veh-avail-rate

OTA2003B ( http:// /www.opentravel.org/Specifications/SchemaIndex.aspx?FolderName=2003B )我正在使用的模式:

   Common:  
    OTA_CommonPrefs.xsd  
    OTA_CommonTypes.xsd  
    OTA_SimpleTypes.xsd  
    OTA_VehicleCommonTypes.xsd  

VehAvailRate
    OTA_VehAvailRateRQ.xsd
    OTA_VehAvailRateRS.xsd

ota-module - pom.xml

    <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
      <modelVersion>4.0.0</modelVersion>
      <parent>
        <artifactId>parent</artifactId>
        <groupId>com.poc.multimodule</groupId>
        <version>0.0.1-SNAPSHOT</version>
        <relativePath>..</relativePath>
      </parent>
      <artifactId>ota-module</artifactId>
      <packaging>pom</packaging>
      <name>MultiModule OTA Parent Project</name>

      <build>
        <pluginManagement>
            <plugins>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-compiler-plugin</artifactId>
                    <version>2.3.2</version>
                    <configuration>
                        <source>1.6</source>
                        <target>1.6</target>
                    </configuration>
                </plugin>
            </plugins>
        </pluginManagement>
      </build>

      <dependencies>
        <!-- JiBX dependencies -->
        <dependency>
            <groupId>org.jibx</groupId>
            <artifactId>jibx-run</artifactId>
            <version>1.2.3</version>
        </dependency>

        <dependency>
            <groupId>org.jibx</groupId>
            <artifactId>jibx-extras</artifactId>
            <version>1.2.3</version>
        </dependency>

        <dependency>
            <groupId>org.jibx</groupId>
            <artifactId>jibx-bind</artifactId>
            <version>1.2.3</version>
        </dependency>

        <!-- JUnit -->
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>4.9</version>
        </dependency>
      </dependencies>

      <modules>
        <module>ota-common</module>
        <module>ota-veh-avail-rate</module>
      </modules>
    </project>

ota-common - pom.xml

    <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
      <modelVersion>4.0.0</modelVersion>
      <parent>
        <artifactId>ota-module</artifactId>
        <groupId>com.poc.multimodule</groupId>
        <version>0.0.1-SNAPSHOT</version>
        <relativePath>..</relativePath>
      </parent>
      <artifactId>ota-common</artifactId>
      <name>Multi Module OTA Common Project</name>
      <packaging>jar</packaging>

      <properties>
            <ota_common_base_path>/media/data/Practice/Maven_Multi_Module/parent/ota-module/ota-common</ota_common_base_path>
      </properties>

      <build>
        <plugins>
            <plugin>
                <groupId>org.jibx</groupId>
                <artifactId>jibx-maven-plugin</artifactId>
                <version>1.2.3</version>
                <configuration>
                    <!-- 
                    <multimodule>true</multimodule>
                     -->
                    <customizations>
                    <customization>${ota_common_base_path}/src/main/resources/jibx/customizations/custom_a.xml</customization>
                    </customizations>   

                    <schemaLocation>${ota_common_base_path}/src/main/resources/schemas/OTA2003B/Common</schemaLocation>

                    <includeSchemas>
                  <includeSchema>*.xsd</includeSchema>
            </includeSchemas>

            <schemaBindingDirectory>${ota_common_base_path}/src/main/java</schemaBindingDirectory>

            <includeSchemaBindings>
                <includeSchemaBindings>*binding.xml</includeSchemaBindings>
            </includeSchemaBindings>

             <options>
                 <u>http://www.opentravel.org/OTA/2003/05</u>
             </options>
                 </configuration>

                 <executions>
                        <execution>
                        <id>generate-java-code-from-schema</id>
                        <goals>
                            <goal>schema-codegen</goal>
                        </goals>
                    </execution>

                    <execution>
                        <id>compile-jibx-binding</id>
                        <goals>
                            <goal>bind</goal>
                        </goals>
                  </execution>
                 </executions>
            </plugin>
        </plugins>
      </build>
    </project>

custom_a.xml

<schema-set prefer-inline="true" package="com.poc.multimodule.ota.common"
        xmlns:xs="http://www.w3.org/2001/XMLSchema"
        type-substitutions="xs:integer xs:int xs:decimal xs:float"
        binding-file-name="base-binding.xml">

  <schema name="OTA_CommonPrefs.xsd" />
  <schema name="OTA_CommonTypes.xsd" />
  <schema name="OTA_SimpleTypes.xsd" />
  <schema name="OTA_VehicleCommonTypes.xsd">
     <complexType name="VehicleProfileRentalPrefType">
    <element path="**" name="VendorPref" ignore="true"/>
    </complexType>
  </schema>

</schema-set>

ota-veh-avail-rate - pom .xml

    <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
      <modelVersion>4.0.0</modelVersion>
      <parent>
        <artifactId>ota-module</artifactId>
        <groupId>com.poc.multimodule</groupId>
        <version>0.0.1-SNAPSHOT</version>
        <relativePath>..</relativePath>
      </parent>
      <artifactId>ota-veh-avail-rate</artifactId>
      <name>OTA Multi Module VehAvailRate Project</name>

      <properties>
            <ota_veh_avail_rate_base_path>/media/data/Practice/Maven_Multi_Module/parent/ota-module/ota-veh-avail-rate</ota_veh_avail_rate_base_path>
      </properties>

      <dependencies>
        <dependency>
            <groupId>com.poc.multimodule</groupId>
            <artifactId>ota-common</artifactId>
            <version>0.0.1-SNAPSHOT</version>
        </dependency>
      </dependencies>

      <build>
        <plugins>
            <plugin>
                <groupId>org.jibx</groupId>
                <artifactId>jibx-maven-plugin</artifactId>
                <version>1.2.3</version>
                <configuration>
                    <multimodule>true</multimodule>

                    <modules>
                        <module>com.poc.multimodule:ota-common</module>
                    </modules>

                    <customizations>
                    <customization>${ota_veh_avail_rate_base_path}/src/main/resources/jibx/customizations/custom_b.xml</customization>
                    </customizations>   

                    <schemaLocation>${ota_veh_avail_rate_base_path}/src/main/resources/schemas/OTA2003B/VehAvailRate</schemaLocation>

                    <includeSchemas>
                  <includeSchema>OTA_VehAvailRateRQ.xsd</includeSchema>
                  <includeSchema>OTA_VehAvailRateRS.xsd</includeSchema>
            </includeSchemas>

            <schemaBindingDirectory>${ota_veh_avail_rate_base_path}/src/main/java</schemaBindingDirectory>

            <includeSchemaBindings>
                <includeSchemaBindings>*binding.xml</includeSchemaBindings>
            </includeSchemaBindings>

            <options>
                <i>classpath:base-binding.xml</i>
            </options>

                 </configuration>

                 <executions>
                        <execution>
                        <id>generate-java-code-from-schema</id>
                        <goals>
                            <goal>schema-codegen</goal>
                        </goals>
                    </execution>

                    <execution>
                        <id>compile-jibx-binding</id>
                        <goals>
                            <goal>bind</goal>
                        </goals>
                  </execution>
                 </executions>
            </plugin>
        </plugins>
      </build>
    </project>

custom_b.xml

<schema-set prefer-inline="true" 
        xmlns:xs="http://www.w3.org/2001/XMLSchema"
        type-substitutions="xs:integer xs:int xs:decimal xs:float" 
        package="com.poc.multimodule.ota.vehavailrate">

    <name-converter strip-prefixes="OTA_"
      strip-suffixes="Type AttributeGroup Group Attributes"/>

    <schema name="OTA_VehAvailRateRQ.xsd" includes="OTA_VehAvailRateRQ" />

    <schema name="OTA_VehAvailRateRS.xsd" includes="OTA_VehAvailRateRS" />             
</schema-set>

mvn install 输出

    $ mvn -e -Dskiptests=true install
    [INFO] Error stacktraces are turned on.
    [INFO] Scanning for projects...
    [INFO] ------------------------------------------------------------------------
    [INFO] Reactor Build Order:
    [INFO] 
    [INFO] MultiModule Parent Project
    [INFO] MultiModule OTA Parent Project
    [INFO] Multi Module OTA Common Project
    [INFO] OTA Multi Module VehAvailRate Project
    [INFO]                                                                         
    [INFO] ------------------------------------------------------------------------
    [INFO] Building MultiModule Parent Project 0.0.1-SNAPSHOT
    [INFO] ------------------------------------------------------------------------
    [INFO] 
    [INFO] --- maven-install-plugin:2.3.1:install (default-install) @ parent ---
    [INFO] Installing /media/data/Practice/Maven_Multi_Module/parent/pom.xml to /media/data/Env/Local_Maven_Repository/com/poc/multimodule/parent/0.0.1-SNAPSHOT/parent-0.0.1-SNAPSHOT.pom
    [INFO]                                                                         
    [INFO] ------------------------------------------------------------------------
    [INFO] Building MultiModule OTA Parent Project 0.0.1-SNAPSHOT
    [INFO] ------------------------------------------------------------------------
    [INFO] 
    [INFO] --- maven-install-plugin:2.3.1:install (default-install) @ ota-module ---
    [INFO] Installing /media/data/Practice/Maven_Multi_Module/parent/ota-module/pom.xml to /media/data/Env/Local_Maven_Repository/com/poc/multimodule/ota-module/0.0.1-SNAPSHOT/ota-module-0.0.1-SNAPSHOT.pom
    [INFO]                                                                         
    [INFO] ------------------------------------------------------------------------
    [INFO] Building Multi Module OTA Common Project 0.0.1-SNAPSHOT
    [INFO] ------------------------------------------------------------------------
    [INFO] 
    [INFO] --- jibx-maven-plugin:1.2.3:schema-codegen (generate-java-code-from-schema) @ ota-common ---
    [INFO] Generating Java sources in /media/data/Practice/Maven_Multi_Module/parent/ota-module/ota-common/src/main/java from schemas available in /media/data/Practice/Maven_Multi_Module/parent/ota-module/ota-common/src/main/resources/schemas/OTA2003B/Common...
    Loaded and validated 4 specified schema(s)
    Generated 202 top-level classes (plus 46 inner classes) in package com.poc.multimodule.ota.common
    Total top-level classes in model: 202
    Total classes (including inner classes) in model: 248
    [INFO] 
    [INFO] --- maven-resources-plugin:2.4.3:resources (default-resources) @ ota-common ---
    [WARNING] Using platform encoding (UTF-8 actually) to copy filtered resources, i.e. build is platform dependent!
    [INFO] Copying 5 resources
    [INFO] 
    [INFO] --- maven-compiler-plugin:2.3.2:compile (default-compile) @ ota-common ---
    [WARNING] File encoding has not been set, using platform encoding UTF-8, i.e. build is platform dependent!
    [INFO] Compiling 202 source files to /media/data/Practice/Maven_Multi_Module/parent/ota-module/ota-common/target/classes
    [INFO] 
    [INFO] --- jibx-maven-plugin:1.2.3:bind (compile-jibx-binding) @ ota-common ---
    [INFO] Running JiBX binding compiler (single-module mode) on 1 binding file(s)
    [INFO] 
    [INFO] --- maven-resources-plugin:2.4.3:testResources (default-testResources) @ ota-common ---
    [WARNING] Using platform encoding (UTF-8 actually) to copy filtered resources, i.e. build is platform dependent!
    [INFO] Copying 0 resource
    [INFO] 
    [INFO] --- maven-compiler-plugin:2.3.2:testCompile (default-testCompile) @ ota-common ---
    [INFO] Nothing to compile - all classes are up to date
    [INFO] 
    [INFO] --- maven-surefire-plugin:2.7.2:test (default-test) @ ota-common ---
    [INFO] Surefire report directory: /media/data/Practice/Maven_Multi_Module/parent/ota-module/ota-common/target/surefire-reports

    -------------------------------------------------------
     T E S T S
    -------------------------------------------------------
    There are no tests to run.

    Results :

    Tests run: 0, Failures: 0, Errors: 0, Skipped: 0

    [INFO] 
    [INFO] --- maven-jar-plugin:2.3.1:jar (default-jar) @ ota-common ---
    [INFO] Building jar: /media/data/Practice/Maven_Multi_Module/parent/ota-module/ota-common/target/ota-common-0.0.1-SNAPSHOT.jar
    [INFO] META-INF/maven/com.poc.multimodule/ota-common/pom.xml already added, skipping
    [INFO] META-INF/maven/com.poc.multimodule/ota-common/pom.properties already added, skipping
    [INFO] 
    [INFO] --- maven-install-plugin:2.3.1:install (default-install) @ ota-common ---
    [INFO] Installing /media/data/Practice/Maven_Multi_Module/parent/ota-module/ota-common/target/ota-common-0.0.1-SNAPSHOT.jar to /media/data/Env/Local_Maven_Repository/com/poc/multimodule/ota-common/0.0.1-SNAPSHOT/ota-common-0.0.1-SNAPSHOT.jar
    [INFO] Installing /media/data/Practice/Maven_Multi_Module/parent/ota-module/ota-common/pom.xml to /media/data/Env/Local_Maven_Repository/com/poc/multimodule/ota-common/0.0.1-SNAPSHOT/ota-common-0.0.1-SNAPSHOT.pom
    [INFO]                                                                         
    [INFO] ------------------------------------------------------------------------
    [INFO] Building OTA Multi Module VehAvailRate Project 0.0.1-SNAPSHOT
    [INFO] ------------------------------------------------------------------------
    [INFO] 
    [INFO] --- jibx-maven-plugin:1.2.3:schema-codegen (generate-java-code-from-schema) @ ota-veh-avail-rate ---
    [INFO] Generating Java sources in /media/data/Practice/Maven_Multi_Module/parent/ota-module/ota-veh-avail-rate/src/main/java from schemas available in /media/data/Practice/Maven_Multi_Module/parent/ota-module/ota-veh-avail-rate/src/main/resources/schemas/OTA2003B/VehAvailRate...
    Loaded and validated 2 specified schema(s) and 4 referenced schema(s)
    Generated 6 top-level classes (plus 4 inner classes) in package com.poc.multimodule.ota.vehavailrate
    Total top-level classes in model: 6
    Total classes (including inner classes) in model: 10
    [INFO] 
    [INFO] --- maven-resources-plugin:2.4.3:resources (default-resources) @ ota-veh-avail-rate ---
    [WARNING] Using platform encoding (UTF-8 actually) to copy filtered resources, i.e. build is platform dependent!
    [INFO] Copying 3 resources
    [INFO] 
    [INFO] --- maven-compiler-plugin:2.3.2:compile (default-compile) @ ota-veh-avail-rate ---
    [WARNING] File encoding has not been set, using platform encoding UTF-8, i.e. build is platform dependent!
    [INFO] Compiling 6 source files to /media/data/Practice/Maven_Multi_Module/parent/ota-module/ota-veh-avail-rate/target/classes
    [INFO] 
    [INFO] --- jibx-maven-plugin:1.2.3:bind (compile-jibx-binding) @ ota-veh-avail-rate ---
    [INFO] Running JiBX binding compiler (restricted multi-module mode) on 1 binding file(s)
    [INFO] ------------------------------------------------------------------------
    [INFO] Reactor Summary:
    [INFO] 
    [INFO] MultiModule Parent Project ........................ SUCCESS [0.325s]
    [INFO] MultiModule OTA Parent Project .................... SUCCESS [0.006s]
    [INFO] Multi Module OTA Common Project ................... SUCCESS [7.079s]
    [INFO] OTA Multi Module VehAvailRate Project ............. FAILURE [0.964s]
    [INFO] ------------------------------------------------------------------------
    [INFO] BUILD FAILURE
    [INFO] ------------------------------------------------------------------------
    [INFO] Total time: 8.489s
    [INFO] Finished at: Tue Sep 27 16:54:14 IST 2011
    [INFO] Final Memory: 28M/195M
    [INFO] ------------------------------------------------------------------------
    [ERROR] Failed to execute goal org.jibx:jibx-maven-plugin:1.2.3:bind (compile-jibx-binding) on project ota-veh-avail-rate: Internal error - cannot modify class com.poc.multimodule.ota.common.ActionType loaded from /media/data/Practice/Maven_Multi_Module/parent/ota-module/ota-common/target/classes -> [Help 1]
    org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.jibx:jibx-maven-plugin:1.2.3:bind (compile-jibx-binding) on project ota-veh-avail-rate: Internal error - cannot modify class com.poc.multimodule.ota.common.ActionType loaded from /media/data/Practice/Maven_Multi_Module/parent/ota-module/ota-common/target/classes
        at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:217)
        at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153)
        at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145)
        at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:84)
        at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:59)
        at org.apache.maven.lifecycle.internal.LifecycleStarter.singleThreadedBuild(LifecycleStarter.java:183)
        at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:161)
        at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:319)
        at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:156)
        at org.apache.maven.cli.MavenCli.execute(MavenCli.java:537)
        at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:196)
        at org.apache.maven.cli.MavenCli.main(MavenCli.java:141)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:597)
        at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:290)
        at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:230)
        at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:409)
        at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:352)
    Caused by: org.apache.maven.plugin.MojoExecutionException: Internal error - cannot modify class com.poc.multimodule.ota.common.ActionType loaded from /media/data/Practice/Maven_Multi_Module/parent/ota-module/ota-common/target/classes
        at org.jibx.maven.AbstractBaseBindingMojo.compile(AbstractBaseBindingMojo.java:166)
        at org.jibx.maven.AbstractBaseBindingMojo.execute(AbstractBaseBindingMojo.java:133)
        at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:101)
        at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:209)
        ... 19 more
    Caused by: java.lang.IllegalStateException: Internal error - cannot modify class com.poc.multimodule.ota.common.ActionType loaded from /media/data/Practice/Maven_Multi_Module/parent/ota-module/ota-common/target/classes
        at org.jibx.binding.classes.ClassFile.getClassGen(ClassFile.java:1286)
        at org.jibx.binding.classes.ClassFile.removeMethod(ClassFile.java:1339)
        at org.jibx.binding.classes.ExistingMethod.delete(ExistingMethod.java:144)
        at org.jibx.binding.classes.MungedClass.purgeUnusedMethods(MungedClass.java:151)
        at org.jibx.binding.classes.MungedClass.fixDispositions(MungedClass.java:381)
        at org.jibx.binding.Compile.compile(Compile.java:237)
        at org.jibx.maven.AbstractBaseBindingMojo.compile(AbstractBaseBindingMojo.java:163)
        ... 22 more
    [ERROR] 
    [ERROR] Re-run Maven using the -X switch to enable full debug logging.
    [ERROR] 
    [ERROR] For more information about the errors and possible solutions, please read the following articles:
    [ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException
    [ERROR] 
    [ERROR] After correcting the problems, you can resume the build with the command
    [ERROR]   mvn <goals> -rf :ota-veh-avail-rate

错误原因:

Caused by: java.lang.IllegalStateException: Internal error - cannot modify class com.poc.multimodule.ota.common.ActionType loaded from /media/data/Practice/Maven_Multi_Module/parent/ota-module/ota-common/target/classes
            at org.jibx.binding.classes.ClassFile.getClassGen(ClassFile.java:1286)
            at org.jibx.binding.classes.ClassFile.removeMethod(ClassFile.java:1339)
            at org.jibx.binding.classes.ExistingMethod.delete(ExistingMethod.java:144)
            at org.jibx.binding.classes.MungedClass.purgeUnusedMethods(MungedClass.java:151)
            at org.jibx.binding.classes.MungedClass.fixDispositions(MungedClass.java:381)
            at org.jibx.binding.Compile.compile(Compile.java:237)
            at org.jibx.maven.AbstractBaseBindingMojo.compile(AbstractBaseBindingMojo.java:163)
            ... 22 more

com.poc.multimodule.ota.common。 ActionType是生成的类型由 ota-common 模块生成,并且存在于我正在使用的生成的 base-binding.xml 中。它是架构 OTA_SimpleTypes.xsd

ActionType 架构文件中定义

<xs:simpleType name="ActionType">
    <xs:restriction base="xs:string">
        <xs:enumeration value="Add-Update"/>
        <xs:enumeration value="Cancel"/>
        <xs:enumeration value="Delete"/>
    </xs:restriction>
</xs:simpleType>

的一部分导致的原因这个 java.lang.IllegalStateException: 内部错误 - 无法修改类以及如何解决这个问题?

谢谢,
吉涅什

I have a maven multi-module project having hierarchy:

parent
    + ota-module
       + ota-common
       + ota-veh-avail-rate

OTA2003B ( http://www.opentravel.org/Specifications/SchemaIndex.aspx?FolderName=2003B ) Schemas I am using:

   Common:  
    OTA_CommonPrefs.xsd  
    OTA_CommonTypes.xsd  
    OTA_SimpleTypes.xsd  
    OTA_VehicleCommonTypes.xsd  

VehAvailRate
    OTA_VehAvailRateRQ.xsd
    OTA_VehAvailRateRS.xsd

ota-module - pom.xml

    <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
      <modelVersion>4.0.0</modelVersion>
      <parent>
        <artifactId>parent</artifactId>
        <groupId>com.poc.multimodule</groupId>
        <version>0.0.1-SNAPSHOT</version>
        <relativePath>..</relativePath>
      </parent>
      <artifactId>ota-module</artifactId>
      <packaging>pom</packaging>
      <name>MultiModule OTA Parent Project</name>

      <build>
        <pluginManagement>
            <plugins>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-compiler-plugin</artifactId>
                    <version>2.3.2</version>
                    <configuration>
                        <source>1.6</source>
                        <target>1.6</target>
                    </configuration>
                </plugin>
            </plugins>
        </pluginManagement>
      </build>

      <dependencies>
        <!-- JiBX dependencies -->
        <dependency>
            <groupId>org.jibx</groupId>
            <artifactId>jibx-run</artifactId>
            <version>1.2.3</version>
        </dependency>

        <dependency>
            <groupId>org.jibx</groupId>
            <artifactId>jibx-extras</artifactId>
            <version>1.2.3</version>
        </dependency>

        <dependency>
            <groupId>org.jibx</groupId>
            <artifactId>jibx-bind</artifactId>
            <version>1.2.3</version>
        </dependency>

        <!-- JUnit -->
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>4.9</version>
        </dependency>
      </dependencies>

      <modules>
        <module>ota-common</module>
        <module>ota-veh-avail-rate</module>
      </modules>
    </project>

ota-common - pom.xml

    <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
      <modelVersion>4.0.0</modelVersion>
      <parent>
        <artifactId>ota-module</artifactId>
        <groupId>com.poc.multimodule</groupId>
        <version>0.0.1-SNAPSHOT</version>
        <relativePath>..</relativePath>
      </parent>
      <artifactId>ota-common</artifactId>
      <name>Multi Module OTA Common Project</name>
      <packaging>jar</packaging>

      <properties>
            <ota_common_base_path>/media/data/Practice/Maven_Multi_Module/parent/ota-module/ota-common</ota_common_base_path>
      </properties>

      <build>
        <plugins>
            <plugin>
                <groupId>org.jibx</groupId>
                <artifactId>jibx-maven-plugin</artifactId>
                <version>1.2.3</version>
                <configuration>
                    <!-- 
                    <multimodule>true</multimodule>
                     -->
                    <customizations>
                    <customization>${ota_common_base_path}/src/main/resources/jibx/customizations/custom_a.xml</customization>
                    </customizations>   

                    <schemaLocation>${ota_common_base_path}/src/main/resources/schemas/OTA2003B/Common</schemaLocation>

                    <includeSchemas>
                  <includeSchema>*.xsd</includeSchema>
            </includeSchemas>

            <schemaBindingDirectory>${ota_common_base_path}/src/main/java</schemaBindingDirectory>

            <includeSchemaBindings>
                <includeSchemaBindings>*binding.xml</includeSchemaBindings>
            </includeSchemaBindings>

             <options>
                 <u>http://www.opentravel.org/OTA/2003/05</u>
             </options>
                 </configuration>

                 <executions>
                        <execution>
                        <id>generate-java-code-from-schema</id>
                        <goals>
                            <goal>schema-codegen</goal>
                        </goals>
                    </execution>

                    <execution>
                        <id>compile-jibx-binding</id>
                        <goals>
                            <goal>bind</goal>
                        </goals>
                  </execution>
                 </executions>
            </plugin>
        </plugins>
      </build>
    </project>

custom_a.xml

<schema-set prefer-inline="true" package="com.poc.multimodule.ota.common"
        xmlns:xs="http://www.w3.org/2001/XMLSchema"
        type-substitutions="xs:integer xs:int xs:decimal xs:float"
        binding-file-name="base-binding.xml">

  <schema name="OTA_CommonPrefs.xsd" />
  <schema name="OTA_CommonTypes.xsd" />
  <schema name="OTA_SimpleTypes.xsd" />
  <schema name="OTA_VehicleCommonTypes.xsd">
     <complexType name="VehicleProfileRentalPrefType">
    <element path="**" name="VendorPref" ignore="true"/>
    </complexType>
  </schema>

</schema-set>

ota-veh-avail-rate - pom.xml

    <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
      <modelVersion>4.0.0</modelVersion>
      <parent>
        <artifactId>ota-module</artifactId>
        <groupId>com.poc.multimodule</groupId>
        <version>0.0.1-SNAPSHOT</version>
        <relativePath>..</relativePath>
      </parent>
      <artifactId>ota-veh-avail-rate</artifactId>
      <name>OTA Multi Module VehAvailRate Project</name>

      <properties>
            <ota_veh_avail_rate_base_path>/media/data/Practice/Maven_Multi_Module/parent/ota-module/ota-veh-avail-rate</ota_veh_avail_rate_base_path>
      </properties>

      <dependencies>
        <dependency>
            <groupId>com.poc.multimodule</groupId>
            <artifactId>ota-common</artifactId>
            <version>0.0.1-SNAPSHOT</version>
        </dependency>
      </dependencies>

      <build>
        <plugins>
            <plugin>
                <groupId>org.jibx</groupId>
                <artifactId>jibx-maven-plugin</artifactId>
                <version>1.2.3</version>
                <configuration>
                    <multimodule>true</multimodule>

                    <modules>
                        <module>com.poc.multimodule:ota-common</module>
                    </modules>

                    <customizations>
                    <customization>${ota_veh_avail_rate_base_path}/src/main/resources/jibx/customizations/custom_b.xml</customization>
                    </customizations>   

                    <schemaLocation>${ota_veh_avail_rate_base_path}/src/main/resources/schemas/OTA2003B/VehAvailRate</schemaLocation>

                    <includeSchemas>
                  <includeSchema>OTA_VehAvailRateRQ.xsd</includeSchema>
                  <includeSchema>OTA_VehAvailRateRS.xsd</includeSchema>
            </includeSchemas>

            <schemaBindingDirectory>${ota_veh_avail_rate_base_path}/src/main/java</schemaBindingDirectory>

            <includeSchemaBindings>
                <includeSchemaBindings>*binding.xml</includeSchemaBindings>
            </includeSchemaBindings>

            <options>
                <i>classpath:base-binding.xml</i>
            </options>

                 </configuration>

                 <executions>
                        <execution>
                        <id>generate-java-code-from-schema</id>
                        <goals>
                            <goal>schema-codegen</goal>
                        </goals>
                    </execution>

                    <execution>
                        <id>compile-jibx-binding</id>
                        <goals>
                            <goal>bind</goal>
                        </goals>
                  </execution>
                 </executions>
            </plugin>
        </plugins>
      </build>
    </project>

custom_b.xml

<schema-set prefer-inline="true" 
        xmlns:xs="http://www.w3.org/2001/XMLSchema"
        type-substitutions="xs:integer xs:int xs:decimal xs:float" 
        package="com.poc.multimodule.ota.vehavailrate">

    <name-converter strip-prefixes="OTA_"
      strip-suffixes="Type AttributeGroup Group Attributes"/>

    <schema name="OTA_VehAvailRateRQ.xsd" includes="OTA_VehAvailRateRQ" />

    <schema name="OTA_VehAvailRateRS.xsd" includes="OTA_VehAvailRateRS" />             
</schema-set>

mvn install output:

    $ mvn -e -Dskiptests=true install
    [INFO] Error stacktraces are turned on.
    [INFO] Scanning for projects...
    [INFO] ------------------------------------------------------------------------
    [INFO] Reactor Build Order:
    [INFO] 
    [INFO] MultiModule Parent Project
    [INFO] MultiModule OTA Parent Project
    [INFO] Multi Module OTA Common Project
    [INFO] OTA Multi Module VehAvailRate Project
    [INFO]                                                                         
    [INFO] ------------------------------------------------------------------------
    [INFO] Building MultiModule Parent Project 0.0.1-SNAPSHOT
    [INFO] ------------------------------------------------------------------------
    [INFO] 
    [INFO] --- maven-install-plugin:2.3.1:install (default-install) @ parent ---
    [INFO] Installing /media/data/Practice/Maven_Multi_Module/parent/pom.xml to /media/data/Env/Local_Maven_Repository/com/poc/multimodule/parent/0.0.1-SNAPSHOT/parent-0.0.1-SNAPSHOT.pom
    [INFO]                                                                         
    [INFO] ------------------------------------------------------------------------
    [INFO] Building MultiModule OTA Parent Project 0.0.1-SNAPSHOT
    [INFO] ------------------------------------------------------------------------
    [INFO] 
    [INFO] --- maven-install-plugin:2.3.1:install (default-install) @ ota-module ---
    [INFO] Installing /media/data/Practice/Maven_Multi_Module/parent/ota-module/pom.xml to /media/data/Env/Local_Maven_Repository/com/poc/multimodule/ota-module/0.0.1-SNAPSHOT/ota-module-0.0.1-SNAPSHOT.pom
    [INFO]                                                                         
    [INFO] ------------------------------------------------------------------------
    [INFO] Building Multi Module OTA Common Project 0.0.1-SNAPSHOT
    [INFO] ------------------------------------------------------------------------
    [INFO] 
    [INFO] --- jibx-maven-plugin:1.2.3:schema-codegen (generate-java-code-from-schema) @ ota-common ---
    [INFO] Generating Java sources in /media/data/Practice/Maven_Multi_Module/parent/ota-module/ota-common/src/main/java from schemas available in /media/data/Practice/Maven_Multi_Module/parent/ota-module/ota-common/src/main/resources/schemas/OTA2003B/Common...
    Loaded and validated 4 specified schema(s)
    Generated 202 top-level classes (plus 46 inner classes) in package com.poc.multimodule.ota.common
    Total top-level classes in model: 202
    Total classes (including inner classes) in model: 248
    [INFO] 
    [INFO] --- maven-resources-plugin:2.4.3:resources (default-resources) @ ota-common ---
    [WARNING] Using platform encoding (UTF-8 actually) to copy filtered resources, i.e. build is platform dependent!
    [INFO] Copying 5 resources
    [INFO] 
    [INFO] --- maven-compiler-plugin:2.3.2:compile (default-compile) @ ota-common ---
    [WARNING] File encoding has not been set, using platform encoding UTF-8, i.e. build is platform dependent!
    [INFO] Compiling 202 source files to /media/data/Practice/Maven_Multi_Module/parent/ota-module/ota-common/target/classes
    [INFO] 
    [INFO] --- jibx-maven-plugin:1.2.3:bind (compile-jibx-binding) @ ota-common ---
    [INFO] Running JiBX binding compiler (single-module mode) on 1 binding file(s)
    [INFO] 
    [INFO] --- maven-resources-plugin:2.4.3:testResources (default-testResources) @ ota-common ---
    [WARNING] Using platform encoding (UTF-8 actually) to copy filtered resources, i.e. build is platform dependent!
    [INFO] Copying 0 resource
    [INFO] 
    [INFO] --- maven-compiler-plugin:2.3.2:testCompile (default-testCompile) @ ota-common ---
    [INFO] Nothing to compile - all classes are up to date
    [INFO] 
    [INFO] --- maven-surefire-plugin:2.7.2:test (default-test) @ ota-common ---
    [INFO] Surefire report directory: /media/data/Practice/Maven_Multi_Module/parent/ota-module/ota-common/target/surefire-reports

    -------------------------------------------------------
     T E S T S
    -------------------------------------------------------
    There are no tests to run.

    Results :

    Tests run: 0, Failures: 0, Errors: 0, Skipped: 0

    [INFO] 
    [INFO] --- maven-jar-plugin:2.3.1:jar (default-jar) @ ota-common ---
    [INFO] Building jar: /media/data/Practice/Maven_Multi_Module/parent/ota-module/ota-common/target/ota-common-0.0.1-SNAPSHOT.jar
    [INFO] META-INF/maven/com.poc.multimodule/ota-common/pom.xml already added, skipping
    [INFO] META-INF/maven/com.poc.multimodule/ota-common/pom.properties already added, skipping
    [INFO] 
    [INFO] --- maven-install-plugin:2.3.1:install (default-install) @ ota-common ---
    [INFO] Installing /media/data/Practice/Maven_Multi_Module/parent/ota-module/ota-common/target/ota-common-0.0.1-SNAPSHOT.jar to /media/data/Env/Local_Maven_Repository/com/poc/multimodule/ota-common/0.0.1-SNAPSHOT/ota-common-0.0.1-SNAPSHOT.jar
    [INFO] Installing /media/data/Practice/Maven_Multi_Module/parent/ota-module/ota-common/pom.xml to /media/data/Env/Local_Maven_Repository/com/poc/multimodule/ota-common/0.0.1-SNAPSHOT/ota-common-0.0.1-SNAPSHOT.pom
    [INFO]                                                                         
    [INFO] ------------------------------------------------------------------------
    [INFO] Building OTA Multi Module VehAvailRate Project 0.0.1-SNAPSHOT
    [INFO] ------------------------------------------------------------------------
    [INFO] 
    [INFO] --- jibx-maven-plugin:1.2.3:schema-codegen (generate-java-code-from-schema) @ ota-veh-avail-rate ---
    [INFO] Generating Java sources in /media/data/Practice/Maven_Multi_Module/parent/ota-module/ota-veh-avail-rate/src/main/java from schemas available in /media/data/Practice/Maven_Multi_Module/parent/ota-module/ota-veh-avail-rate/src/main/resources/schemas/OTA2003B/VehAvailRate...
    Loaded and validated 2 specified schema(s) and 4 referenced schema(s)
    Generated 6 top-level classes (plus 4 inner classes) in package com.poc.multimodule.ota.vehavailrate
    Total top-level classes in model: 6
    Total classes (including inner classes) in model: 10
    [INFO] 
    [INFO] --- maven-resources-plugin:2.4.3:resources (default-resources) @ ota-veh-avail-rate ---
    [WARNING] Using platform encoding (UTF-8 actually) to copy filtered resources, i.e. build is platform dependent!
    [INFO] Copying 3 resources
    [INFO] 
    [INFO] --- maven-compiler-plugin:2.3.2:compile (default-compile) @ ota-veh-avail-rate ---
    [WARNING] File encoding has not been set, using platform encoding UTF-8, i.e. build is platform dependent!
    [INFO] Compiling 6 source files to /media/data/Practice/Maven_Multi_Module/parent/ota-module/ota-veh-avail-rate/target/classes
    [INFO] 
    [INFO] --- jibx-maven-plugin:1.2.3:bind (compile-jibx-binding) @ ota-veh-avail-rate ---
    [INFO] Running JiBX binding compiler (restricted multi-module mode) on 1 binding file(s)
    [INFO] ------------------------------------------------------------------------
    [INFO] Reactor Summary:
    [INFO] 
    [INFO] MultiModule Parent Project ........................ SUCCESS [0.325s]
    [INFO] MultiModule OTA Parent Project .................... SUCCESS [0.006s]
    [INFO] Multi Module OTA Common Project ................... SUCCESS [7.079s]
    [INFO] OTA Multi Module VehAvailRate Project ............. FAILURE [0.964s]
    [INFO] ------------------------------------------------------------------------
    [INFO] BUILD FAILURE
    [INFO] ------------------------------------------------------------------------
    [INFO] Total time: 8.489s
    [INFO] Finished at: Tue Sep 27 16:54:14 IST 2011
    [INFO] Final Memory: 28M/195M
    [INFO] ------------------------------------------------------------------------
    [ERROR] Failed to execute goal org.jibx:jibx-maven-plugin:1.2.3:bind (compile-jibx-binding) on project ota-veh-avail-rate: Internal error - cannot modify class com.poc.multimodule.ota.common.ActionType loaded from /media/data/Practice/Maven_Multi_Module/parent/ota-module/ota-common/target/classes -> [Help 1]
    org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.jibx:jibx-maven-plugin:1.2.3:bind (compile-jibx-binding) on project ota-veh-avail-rate: Internal error - cannot modify class com.poc.multimodule.ota.common.ActionType loaded from /media/data/Practice/Maven_Multi_Module/parent/ota-module/ota-common/target/classes
        at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:217)
        at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153)
        at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145)
        at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:84)
        at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:59)
        at org.apache.maven.lifecycle.internal.LifecycleStarter.singleThreadedBuild(LifecycleStarter.java:183)
        at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:161)
        at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:319)
        at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:156)
        at org.apache.maven.cli.MavenCli.execute(MavenCli.java:537)
        at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:196)
        at org.apache.maven.cli.MavenCli.main(MavenCli.java:141)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:597)
        at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:290)
        at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:230)
        at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:409)
        at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:352)
    Caused by: org.apache.maven.plugin.MojoExecutionException: Internal error - cannot modify class com.poc.multimodule.ota.common.ActionType loaded from /media/data/Practice/Maven_Multi_Module/parent/ota-module/ota-common/target/classes
        at org.jibx.maven.AbstractBaseBindingMojo.compile(AbstractBaseBindingMojo.java:166)
        at org.jibx.maven.AbstractBaseBindingMojo.execute(AbstractBaseBindingMojo.java:133)
        at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:101)
        at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:209)
        ... 19 more
    Caused by: java.lang.IllegalStateException: Internal error - cannot modify class com.poc.multimodule.ota.common.ActionType loaded from /media/data/Practice/Maven_Multi_Module/parent/ota-module/ota-common/target/classes
        at org.jibx.binding.classes.ClassFile.getClassGen(ClassFile.java:1286)
        at org.jibx.binding.classes.ClassFile.removeMethod(ClassFile.java:1339)
        at org.jibx.binding.classes.ExistingMethod.delete(ExistingMethod.java:144)
        at org.jibx.binding.classes.MungedClass.purgeUnusedMethods(MungedClass.java:151)
        at org.jibx.binding.classes.MungedClass.fixDispositions(MungedClass.java:381)
        at org.jibx.binding.Compile.compile(Compile.java:237)
        at org.jibx.maven.AbstractBaseBindingMojo.compile(AbstractBaseBindingMojo.java:163)
        ... 22 more
    [ERROR] 
    [ERROR] Re-run Maven using the -X switch to enable full debug logging.
    [ERROR] 
    [ERROR] For more information about the errors and possible solutions, please read the following articles:
    [ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException
    [ERROR] 
    [ERROR] After correcting the problems, you can resume the build with the command
    [ERROR]   mvn <goals> -rf :ota-veh-avail-rate

Error Cause:

Caused by: java.lang.IllegalStateException: Internal error - cannot modify class com.poc.multimodule.ota.common.ActionType loaded from /media/data/Practice/Maven_Multi_Module/parent/ota-module/ota-common/target/classes
            at org.jibx.binding.classes.ClassFile.getClassGen(ClassFile.java:1286)
            at org.jibx.binding.classes.ClassFile.removeMethod(ClassFile.java:1339)
            at org.jibx.binding.classes.ExistingMethod.delete(ExistingMethod.java:144)
            at org.jibx.binding.classes.MungedClass.purgeUnusedMethods(MungedClass.java:151)
            at org.jibx.binding.classes.MungedClass.fixDispositions(MungedClass.java:381)
            at org.jibx.binding.Compile.compile(Compile.java:237)
            at org.jibx.maven.AbstractBaseBindingMojo.compile(AbstractBaseBindingMojo.java:163)
            ... 22 more

com.poc.multimodule.ota.common.ActionType is a type generated by ota-common module and is there in generated base-binding.xml I am using.It is part of the schema OTA_SimpleTypes.xsd

ActionType definition in schema file

<xs:simpleType name="ActionType">
    <xs:restriction base="xs:string">
        <xs:enumeration value="Add-Update"/>
        <xs:enumeration value="Cancel"/>
        <xs:enumeration value="Delete"/>
    </xs:restriction>
</xs:simpleType>

What is causing this java.lang.IllegalStateException: Internal error - cannot modify class and how to resolve this?

Thanks,
Jignesh

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

坦然微笑 2024-12-13 14:34:06

Jignesh,

maven 插件不支持 classpath: 选项。
您应该使用参数包含基本绑定。

我建议您查看 JiBX 模式库中预构建的 opentravel.org 模式绑定:http://jibx.sourceforge.net/schema-library/site.html#opentravel.org

您可以找到为 2010B 构建完整库的项目和 2011A 架构。 Maven 项目位于我们的源存储库中: http: //jibx.svn.sourceforge.net/viewvc/jibx/trunk/schema-library/org.opentravel/

您应该能够调整这些项目以用于2003B 模式。

祝你好运!

大学教师

Jignesh,

The classpath: option is not supported by the maven plugin.
You should use the <includeBaseBindings> param to include a base binding.

I would suggest you take a look at the pre-built opentravel.org schema bindings in the JiBX schema library: http://jibx.sourceforge.net/schema-library/site.html#opentravel.org

You can find projects that build a complete library for the 2010B and 2011A schema. The maven projects are in our source repo at: http://jibx.svn.sourceforge.net/viewvc/jibx/trunk/schema-library/org.opentravel/

You should be able to adapt these projects for use in the 2003B schema.

Good Luck!

Don

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文