Configuring EclipseLink 2.3.1 in JBoss 7.1

Configuring EclipseLink as a module within JBoss is really a breeze and helps standardize the web applications that are deployed because this means that the eclipselink jar does not need to be contained within the web archive (war) file. Glassfish also does not require the eclipselink jar within the web archive unless the application requires a different version than the one supplied by the application server.

The first step is to create the directory structure under the module directory.

<JBOSS INSTALLATION>\modules\org\eclipse\persistence\main

Under the main directory create the module.xml

<?xml version="1.0" encoding="UTF-8"?>
<!-- Represents the EclipseLink 2.3.x module-->
<module xmlns="urn:jboss:module:1.1" name="org.eclipse.persistence">
 <resources>
 <resource-root path="eclipselink-2.3.1.jar"/>
 </resources>
 <dependencies>
  <module name="asm.asm"/>
  <module name="javax.api"/>
  <module name="javax.persistence.api"/>
  <module name="javax.transaction.api"/>
  <module name="javax.validation.api"/>
  <module name="javax.xml.bind.api"/>
  <module name="org.antlr"/>
  <module name="org.apache.ant"/>
  <module name="org.apache.commons.collections"/>
  <module name="org.dom4j"/>
  <module name="org.javassist"/>
  <module name="org.jboss.logging"/>
 </dependencies>
</module>

Next copy the EclipseLink jar and make sure that the file name matches the resource-root node in the module.xml.

Although JBoss does auto detect dependencies it is always a good practice to explicitly declare these dependencies. This is done by including either a jboss-deployment-structure.xml or a MANIFEST.MF with the dependency declaration.

Here is a MANIFEST.MF example

Manifest-Version: 1.0
Created-By: Apache Maven
Dependencies: org.eclipse.persistence

Here is a jboss-deployment-structure.xml

<jboss-deployment-structure>
  <deployment>
    <dependencies>
      <module name="org.eclipse.persistence" />
    </dependencies>
  </deployment>
</jboss-deployment-structure>

The zip containing the EclipseLink module con be downloaded here.

About these ads

16 responses to “Configuring EclipseLink 2.3.1 in JBoss 7.1”

  1. Ankhbayar says :

    Thanks.
    but I have a following problem.

    org.jboss.modules.ModuleNotFoundException : Module org.apache.ant:main is not found.

    How to configure org.apache.ant module in Jboss AS 7.1

    • mpashworth says :

      The problem pops up with a number of libraries that provide ant tasks bundled in the jar. I had the problem with Liquibase and it was resolved by providing an ant module with the following module.xml


      <module xmlns="urn:jboss:module:1.1" name="org.apache.ant">
      <resources>
      <resource-root path="ant.jar"/>
      </resources>

      <dependencies>
      </dependencies>
      </module>

      together with the ant jar in the module.

      I have put together a minimal Apache Ant module for JBoss on the Yellowfire download site here

  2. charleswmiller says :

    I’ve have followed your instructions. However, I am getting an exception.

    Requests:
    1) Please forward references related entries created within the “standalone.xml” for installation.
    2) Modification/Reference modifications related to Hibernate JPA configution

    • mpashworth says :

      Hi Charles,

      Could you please be a bit more specific about the exception that you are getting. There are no references in the standalone.xml because it is a module used by the application and the post is concerning EclipseLink not Hibernate which is the default JPA provider in JBoss AS.

      Regards,
      Mark P Ashworth

      • Arilson says :

        So, the my JBOSS has performed ok, but anyone data was persisted.

      • mpashworth says :

        Hi Alison, The problem you are experiencing where the EclipseLink queries are returning data but the em.persist and em.merge does not commit data to the database is because you need to specify in the persistence.xml the application server platform as an EclipseLink property.

        For more information on this please go to the EclipseLink wiki here

      • Arilson says :

        Hi Mpashworth,

        Thank you for answer but I think the problem is not that because I have this im my persistence.xml:
        “…..

        org.eclipse.persistence.jpa.PersistenceProvider
        ………..”

  3. Arilson says :

    Just works if I put the explict Transaction..

    “getEntityManager().getTransaction().begin();
    getEntityManager().persist(entity);
    getEntityManager().getTransaction().commit();”

    But I’m using EJB it would not need to say when begin and commit the transaction.

    (sorry my englihs)

  4. Arilson says :

    Hi again :)

    Actually the solution was there.

    It works!!!

    THANK YOU!

  5. Bob says :

    Thanks for the post. I am close! I am getting the following error. Where do I need to put the javax.resource.jar so it is correctly picked up? Adding to my application did not work.

    java.lang.NoClassDefFoundError: javax/resource/ResourceException

  6. Prakash Saswadkar says :

    Hi,

    This is really a nice article. In earlier versions of JBoss(5.1) we used to just copy the jars in lib directory. Me too had encountered the same error on JBoss 7 and have resolved the error with the help of this article. Came to know that we have to configure our modules.

    I am new to JBoss 7 and Java EE 6 to some extent. Forgive me if some of my questions below does not make sense…

    1. Why do we have to configure our libraries as modules?(as in earlier versions we just used to copy the jars in lib directory).

    2. I want to know that is this a standard of JBoss 7 or Java EE 6. Do other servers have a similar way of configuring module?

    3. How do we know that what are the dependencies of a module that we are going to configure? (You have specified the dependencies of eclipselink (from asm to org.jboss.logging). From where you got this list? Are the dependencies listed on eclipselink site? Can you provide me a general pointer for knowing the dependencies for a module that we are going to configure with JBoss 7?

    Thanks
    Prakash

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Java Magic

Blog about Tapestry5, Plastic and related technologies

Steps & Leaps

Thoughts and Comments on (Mainly) Creativity, Innovation and Management

Facilitating Agility

Scrum and Agile Facilitation

Jan's Blog

Mainly development and technology stuff I haven't easily found in the net

WatirMelon

A 93% Software Testing Blog by Alister Scott

Dan Haywood

domain driven design, restful objects, apache isis, the naked objects pattern, agile and more

Marko A. Rodriguez

Supporting the Emerging Graph Landscape

A developer's journal

On Oracle, JEE, SOA and whatmore

RedStack

Musings on Integration with Oracle Fusion Middleware

oracle-stack-support

Oracle Stack Support (One Window Support)

Struberg's Blog

Yet another blog site?

Exit Condition

Andrew Lee Rubinger

Antonio's Blog

A blog mainly about Java

Sematext Blog

Search, Big Data, Analytics, Natural Language Processing

WordPress.com News

The latest news on WordPress.com and the WordPress community.

Follow

Get every new post delivered to your Inbox.

%d bloggers like this: