Search code examples
javahibernatespring-bootjibx

jibx marshalling with hibernate 5


We are upgrading our tech stack from hibernate 5(from v3) and spring boot 1.5, particularly facing issues with hibernate and jibx marshalling when we use same domain objects for both hibernate and jibx marshalling.

def compileJibx() {
    ant {
        taskdef(name: 'bind',
            classname: 'org.jibx.binding.ant.CompileTask',
            classpath: configurations.jibx.asPath)

        bind(binding: "${projectDir}/src/main/resources/jibx-binding.xml", verbose: 'false') {
            classpath {
                pathelement(path: "${projectDir}/build/classes/main")
            }
        }
}
}

This jibx compilation task executes after compileJava step.

Using below dependencies

    jibx group: 'org.apache.bcel', name: 'bcel', version:'6.0'
    jibx group: 'org.jibx', name: 'jibx-run', version:'1.1.5'
    jibx group: 'org.jibx', name: 'jibx-extras', version:'1.1.5'
    jibx group: 'org.jibx', name: 'jibx-bind', version:'1.1.5'
    jibx group: 'xmlpull', name: 'xmlpull', version:'1.1.4'
    jibx group: 'xpp3', name: 'xpp3', version:'1.1.4c'
    jibx group: 'org.hibernate.javax.persistence', name: 'hibernate-jpa-2.1-api', version:'1.0.2.Final'
    jibx group: 'javax.xml.bind', name: 'jaxb-api', version:'2.2.11'

After the gradle build I see jibx classes are properly constructed in jar file. But when I start the application, jibx marshalling failed due to below errors.

[2019-09-18 10:30:40.537] [BDSPUSD00000582] [ERROR] [com.abc.UnhandledExceptionHandler] [{Correlation-ID=skdfhjwe39850jkhfsd}] - Unhandled exception
org.springframework.web.util.NestedServletException: Handler dispatch failed; nested exception is java.lang.VerifyError: Expecting a stackmap frame at branch target 26
Exception Details:
  Location:
    com/abc/jibx/domain/JibxDomain.JiBX_ABC_marshal_6_0(Lorg/jibx/runtime/impl/MarshallingContext;)V @19: ifnonnull
  Reason:
    Expected stackmap frame at this location.
  Bytecode:
    0x0000000: 2b2a b600 462b 2b06 1248 b600 4c57 2ab6
    0x0000010: 0050 59c7 0007 57a7 0007 2bb6 0056 0612 
  ...
Caused by: java.lang.VerifyError: Expecting a stackmap frame at branch target 26
Exception Details:
  Location:
    com/abc/jibx/domain/JibxDomain.JiBX_ABC_marshal_6_0(Lorg/jibx/runtime/impl/MarshallingContext;)V @19: ifnonnull
  Reason:
    Expected stackmap frame at this location.
  Bytecode:
    0x0000000: 2b2a b600 462b 2b06 1248 b600 4c57 2ab6
    0x0000010: 0050 59c7 0007 57a7 0007 2bb6 0056 0612

Is there any issue with my compile or build step? Can someone provide some working example which works well with below stack.

Spring boot 1.5, Hibernate 5, Jibx 1.15, Java8


Solution

  • I have fixed this with upgraded versions of bcel/jibx.

    bcel-6.1
    jibx-1.3.1