Over a million developers have joined DZone.
{{announcement.body}}
{{announcement.title}}

Using Envers with AS7

DZone's Guide to

Using Envers with AS7

· Java Zone
Free Resource

Bitbucket is for the code that takes us to Mars, decodes the human genome, or drives your next car. What will your code do? Get started with Bitbucket today, it's free.

Recently I tried deploying a web application which uses Envers into AS7, but unfortunately I encountered some problems (see the forum discussion). Luckily thanks to the helpful JBoss guys I’ve got it working now. Moreover, thanks to the work done by Strong Liu, you should see full Envers integration (included OOTB as a module) in AS7.1!

Until then, here’s how to use Envers in a webapp in AS7.

First, we need to create an Envers module. Create a directory: jboss-as-7.0.0.Final/modules/org/hibernate/envers/main and inside it, create a module.xml with the following content:

<?xml version="1.0" encoding="UTF-8"?>
<module xmlns="urn:jboss:module:1.0" name="org.hibernate.envers">
  <resources>
    <resource-root path="hibernate-envers-4.0.0.Beta1.jar"/>
  </resources>
 
  <dependencies>
    <module name="org.hibernate"/>
    <module name="org.jboss.logging"/>
    <module name="org.dom4j"/>
    <module name="javax.api"/>
    <module name="javax.persistence.api"/>
    <module name="javax.transaction.api"/>
    <module name="org.javassist"/>
  </dependencies>
</module>

Moreover, you’ll need to put the Envers jar inside that directory. You can download it straight from the JBoss Maven repository.

I’ve prepared a ready zip of the module, which can be downloaded here. Just unpack its contents to jboss-as-7.0.0.Final/modules/org/hibernate.

Secondly, you must add an entry in your manifest file (META-INF/MANIFEST.MF) to make the new module available to your application:

Dependencies: org.hibernate.envers services

And you’re done. Enjoy! :)

From http://www.warski.org/blog/2011/08/using-envers-with-as7/

Bitbucket is the Git solution for professional teams who code with a purpose, not just as a hobby. Get started today, it's free.

Topics:

Opinions expressed by DZone contributors are their own.

The best of DZone straight to your inbox.

SEE AN EXAMPLE
Please provide a valid email address.

Thanks for subscribing!

Awesome! Check your inbox to verify your email so you can start receiving the latest in tech news and resources.
Subscribe

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}