Uploaded image for project: 'WildFly WIP'
  1. WildFly WIP
  2. WFWIP-75

it's not possible to enable Hibernate Bytecode Transformer using j-d-s.xml

    • Icon: Bug Bug
    • Resolution: Done
    • Icon: Blocker Blocker
    • JPA
    • None
    • Hide

      run test Hibernate51CompatibilityTransformerTest from https://github.com/simkam/wildfly/commit/950cb329063f91e000689882356baa77a6326a45

      Show
      run test Hibernate51CompatibilityTransformerTest from https://github.com/simkam/wildfly/commit/950cb329063f91e000689882356baa77a6326a45
    • Workaround Exists
    • Hide

      enable transformer globally with system property -DHibernate51CompatibilityTransformer=true

      Show
      enable transformer globally with system property -DHibernate51CompatibilityTransformer=true

      based on testing with https://github.com/scottmarlow/wildfly/tree/WFLY-10520_pr_hack

      it's not possible to enable transformer for application in jboss-deployment-structure.xml.

      there are probably more issues

      1. application has to have dependency on module org.hibernate.bytecodetransfomer (which is ok, users must edit j-d-s.xml anyway) / or org.hibernate.bytecodetransfomer must be global module
      2. transformer has private constructor so ClassFileTransformerProcessor cannot instantiate it

            [WFWIP-75] it's not possible to enable Hibernate Bytecode Transformer using j-d-s.xml

            Scott Marlow added a comment - Resolved in topic branch https://github.com/scottmarlow/wildfly/tree/WFLY-10520_pr_hack .

            Marker support is working, turns out it was working before but adding a marker interface to application classes is not safe, as that can confuse the EJB deployer. Instead, we are adding a class instance field, which works better.

            Scott Marlow added a comment - Marker support is working, turns out it was working before but adding a marker interface to application classes is not safe, as that can confuse the EJB deployer. Instead, we are adding a class instance field, which works better.

            Currently, we can use the globally with system property -DHibernate51CompatibilityTransformer=true or the j-d-s.xml, I'm not sure if it is safe to enable the transformer via both options at the same time, which is why I started working on the https://github.com/scottmarlow/wildfly/tree/WFLY-10520_pr_hack_TransformedMarkerInterface change.

            Scott Marlow added a comment - Currently, we can use the globally with system property -DHibernate51CompatibilityTransformer=true or the j-d-s.xml, I'm not sure if it is safe to enable the transformer via both options at the same time, which is why I started working on the https://github.com/scottmarlow/wildfly/tree/WFLY-10520_pr_hack_TransformedMarkerInterface change.

            https://github.com/scottmarlow/wildfly/tree/WFLY-10520_pr_hack_TransformedMarkerInterface contains an attempt to add a marker interface but it fails the test so must be missing something.

            Scott Marlow added a comment - https://github.com/scottmarlow/wildfly/tree/WFLY-10520_pr_hack_TransformedMarkerInterface contains an attempt to add a marker interface but it fails the test so must be missing something.

            I pushed test changes to the WFLY-10520_pr_hack branch. I removed the setting of the system property from arquillian.xml and added a j-d-s.xml file that includes the transformer settings.

            Scott Marlow added a comment - I pushed test changes to the WFLY-10520 _pr_hack branch. I removed the setting of the system property from arquillian.xml and added a j-d-s.xml file that includes the transformer settings.

            I should be able to merge the support fro WFWIP-75 after adding a org.jboss.as.hibernate.Transformed marker interface that means that an application class has been transformed, which we will use to avoid transforming the same class more than once.

            Scott Marlow added a comment - I should be able to merge the support fro WFWIP-75 after adding a org.jboss.as.hibernate.Transformed marker interface that means that an application class has been transformed, which we will use to avoid transforming the same class more than once.

            Applications shouldn't need to add a dependency on org.hibernate.bytecodetransfomer, as we will remove that module in the future.

            With my other local changes, the following j-d-s.xml (moved to a separate file) seems to work:

            <jboss-deployment-structure>
                <deployment>
                    <transformers>
                        <transformer class="org.jboss.as.hibernate.Hibernate51CompatibilityTransformer"/>
                    </transformers>
                    <dependencies>
                        <module name="com.h2database.h2" />
                        <module name="org.slf4j"/>
                    </dependencies>
                </deployment>
                <sub-deployment name="beans.jar">
                    <transformers>
                        <transformer class="org.jboss.as.hibernate.Hibernate51CompatibilityTransformer"/>
                    </transformers>
                </sub-deployment>
                <sub-deployment name="main.war">
                    <transformers>
                        <transformer class="org.jboss.as.hibernate.Hibernate51CompatibilityTransformer"/>
                    </transformers>
                </sub-deployment>
            
            </jboss-deployment-structure>
            

            Scott Marlow added a comment - Applications shouldn't need to add a dependency on org.hibernate.bytecodetransfomer, as we will remove that module in the future. With my other local changes, the following j-d-s.xml (moved to a separate file) seems to work: <jboss-deployment-structure> <deployment> <transformers> <transformer class= "org.jboss.as.hibernate.Hibernate51CompatibilityTransformer" /> </transformers> <dependencies> <module name= "com.h2database.h2" /> <module name= "org.slf4j" /> </dependencies> </deployment> <sub-deployment name= "beans.jar" > <transformers> <transformer class= "org.jboss.as.hibernate.Hibernate51CompatibilityTransformer" /> </transformers> </sub-deployment> <sub-deployment name= "main.war" > <transformers> <transformer class= "org.jboss.as.hibernate.Hibernate51CompatibilityTransformer" /> </transformers> </sub-deployment> </jboss-deployment-structure>

              smarlow1@redhat.com Scott Marlow
              msimka@redhat.com Martin Simka
              Martin Simka Martin Simka
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

                Created:
                Updated:
                Resolved: