Red Hat

In Relation To JBoss AS

In Relation To JBoss AS

JBoss AS 7.1 on OpenShift

Posted by Pete Muir    |    May 9, 2012    |    Tagged as JBoss AS

Excited about JBoss AS 7.1 in the cloud? JBoss AS 7.1 is now available on OpenShift and provides a small memory footprint and lightning fast startup times.

OpenShift is a free Platform-as-a-Service (PaaS) that enables developers to get deployed to the cloud without having to worry about downloading and managing the stack, writing scripts or installing agents. You can build your applications using the built in Jenkins support, easily add persistence, like MySQL or MongoDB, test using Arquillian or deploy from JBDS.

Getting started simply requires signing up for OpenShift.

To celebrate the availability of JBoss AS 7.1 on OpenShift, we've put together a series of 6 videos. Learn how to build a mobile ready application, deployed to OpenShift in 5 minutes. Deploy REST services to the cloud, and consume them. Add a portal, courtesy of the GateIn project. Add very high performance messaging, from HornetQ. Or add atomic transactions over Web Services.

And that's on top of the web profile support, available for about a year!

Enjoy!

I recently had the pleasure and attending and presenting at the Greater Indian Developer Summit (GIDS) in Bangalore. I was joined by fellow JBossians Andrew, Bruno, Manik and Mike.

The conference was excellent, I think we all noticed the really high calibre of the attendees - lots of excellent questions throughout the sessions!

On my way home, I stopped off at the London JBUG (kudos to Steve & co for breathing new life into the group!).

I captured both the presentations I did, and they are up on vimeo - check them out if either topic interests you!

I had the chance to get to sit down with Jason Greene, Emanuel Muckenhuber and their manager Bruno Georges while they were having an JBoss Application Server team meeting in our Neuchatel offices.

We talked about how things changed since our last podcast about AS 7.0 (Episode 15) and from that got to cover what is new and great in AS 7.1 and what the new JBoss Enterprise Application Platform 6 Beta have to offer.

Show notes and episode downloads are at Asylum Website

Enjoy!

JavaOne, Jigsaw, JBoss Modules, and the Community (you!)

Posted by David Lloyd    |    Oct 14, 2011    |    Tagged as Events JBoss AS

I had the pleasure of gabbing about JBoss Modules a couple times at the Red Hat/JBoss booth at JavaOne this year, drawing frankly more interest than I thought I'd see. As a part of my talk (the video for which you can download here [well, soon anyway]), I chatted a bit about what the future may hold for Java in terms of modular runtime, modular development lifecycle, and distribution management. Some things seem certain - that the current paradigm won't hold, for example - and some are very uncertain - such as what, if anything, will replace Maven as the ubiquitous modular build/distribution system of the future.

There are many things that we, as a community, have learned over time about how projects are built, deployed, maintained, and integrated. However, every popular build and deployment system in existence today is crafted from only a limited subset of this shared knowledge, usually from the point of view of that project's particular czar. The advent of modularity in common usage, and ultimately the JDK, is the final call to arms for the community to step up and share their knowledge.

Because Oracle continues to turn a deaf ear to the community when it comes to Jigsaw, it is left to the community itself to establish and understand the true nature of the problem of program and library distribution for Java. The requirements published thus far by Oracle are presented from the perspective of a company whose expertise lies not in the development of the applications that you write, but in the sales and marketing of the platform that they develop. This is why there is a community process, which is unfortunately thus far being largely bypassed in the development of Jigsaw and its supporting infrastructure. History has clearly shown that the success of any given Java specification depends largely on community involvement and empowerment. So it seems clear to me that the success of the modularity initiative will also depend on the community.

With that in mind, members of the jigsaw-dev mailing list recently discussed the idea of holding a community meeting for the purpose of brainstorming requirements for modularity in Java. I am hoping that we can discuss topics ranging from run-time modular resolution requirements and technical details to build dependency resolution to library distribution paradigms; if the chat goes well we could even evolve it into a regular or semi-regular event.

The chat is scheduled to be held at 10:00 A.M. US Pacific time on Friday, October 21, 2011 in the ##java-modularity channel at irc.freenode.net (web chat link). If you have any experience you'd like to share, either as a user or a developer of an existing build or modularity system, or you just want to see what happens, please join in the discussion. It's undecided at the moment but the discussion may be moderated, depending on attendance. Note! Make sure you have a registered nickname ahead of time so you can join in without any issues when the time arrives.

I look forward to chatting with you!

Using the jboss-as maven plugin to deploy DataSources to AS7

Posted by Stuart Douglas    |    Aug 19, 2011    |    Tagged as JBoss AS

With the 7.0.1 release of AS7 comes a new release of the JBoss AS7 Maven Plugin. In addition to allowing you to deploy your apps to AS7, the plugin now has the ability to automatically add datasources to a running AS7 instance.

Deploying a datasource is a two stage process, first we have to deploy the driver, then we setup a datasource through the AS7 management api. The example below walks you through the process of deploying a postgresql datasource, but for the impatient among you a complete example can be found here.

Deploying a database driver

To deploy a database driver we first have to list our driver in the <dependencies> section of pom.xml:

<dependencies>
  <dependency>
    <groupId>postgresql</groupId>
    <artifactId>postgresql</artifactId>
    <version>8.4-702.jdbc4</version>
  </dependency>
</dependencies>

We then have to setup the JBoss AS7 Maven plugin to deploy the datasource to the app server:

<plugin>
    <groupId>org.jboss.as.plugins</groupId>
    <artifactId>jboss-as-maven-plugin</artifactId>
    <executions>
        <execution>
            <id>deploy-driver</id>
            <phase>package</phase>
            <configuration>
                <groupId>postgresql</groupId>
                <artifactId>postgresql</artifactId>
                <name>postgresql.jar</name>
            </configuration>
            <goals>
                <goal>deploy-artifact</goal>
            </goals>
        </execution>
    </executions>
</plugin>

Running mvn package will now connect to a running AS7 instance on localhost and deploy the driver as a deployment named postgresql.jar.

Note that this capability it not limited to just deploying database drivers, using the deploy-artifact goal it is possible to deploy any maven artifact to the app server.

Creating the DataSource

Now that we have our driver deployed, we need to create the DataSource. To do this, we will need to update our pom again so it looks like this:

<plugin>
    <groupId>org.jboss.as.plugins</groupId>
    <artifactId>jboss-as-maven-plugin</artifactId>
    <executions>
        <execution>
            <id>deploy-driver</id>
            <phase>package</phase>
            <configuration>
                <groupId>postgresql</groupId>
                <artifactId>postgresql</artifactId>
                <name>postgresql.jar</name>
            </configuration>
            <goals>
                <goal>deploy-artifact</goal>
            </goals>
        </execution>
        <execution>
            <id>add-datasource</id>
            <phase>install</phase>
            <configuration>
                <address>subsystem=datasources,data-source=myDatasource</address>
                <properties>
                    <connection-url>jdbc:postgresql://localhost/myDatabase</connection-url>
                    <jndi-name>myDatasource</jndi-name>
                    <enabled>true</enabled>
                    <pool-name>myPool</pool-name>
                    <user-name>dmusername</user-name>
                    <password>secret</password>
                    <driver-name>postgresql.jar</driver-name>
                </properties>
            </configuration>
            <goals>
                <goal>add-resource</goal>
            </goals>
        </execution>
    </executions>
</plugin>

With this configuration running mvn install should deploy a Postgresql datasource to AS7.

For some more examples, including XA DataSource and MySQL examples, please see my example pom.xml at https://github.com/stuartwdouglas/quickstart/blob/master/datasource/pom.xml.

How it works

You may have noticed about that the name of the maven goal is add-resource, rather than add-datasource. This is because the plugin is not limited to just adding datasources, but can also be used to add other resources to AS7. Internally the plugin uses the AS7 management API, and the <address> and <properties> elements correspond exactly to the management API / command line equivalents. This means that we can add other resources as well, e.g. JMS Queues.

The first thing we need to do is figure out the syntax we need to use to add a JMS Queue. To do this we are going to use the command line client. Fire up an instance of AS7, and then in another terminal window run jboss-admin.sh in the bin directory. You should see the following:

You are disconnected at the moment. Type 'connect' to connect to the server or 'help' for the list of supported commands.
[disconnected /]

Type connect and you should connect to the running AS7 instance. Now we need to figure out the syntax to add a JMS Queue. To do this we run the following command:

[standalone@localhost:9999 /] /subsystem=messaging/jms-queue=*:read-operation-description(name="add")

This should give us the following result:

{
    "outcome" => "success",
    "result" => {
        "operation-name" => "add",
        "description" => "Add a queue.",
        "request-properties" => {
            "entries" => {
                "type" => LIST,
                "description" => "The jndi names the queue will be bound to.",
                "required" => true,
                "nillable" => false
            },
            "selector" => {
                "type" => STRING,
                "description" => "The queue selector.",
                "required" => false,
                "nillable" => true
            },
            "durable" => {
                "type" => BOOLEAN,
                "description" => "Whether the queue is durable or not.",
                "required" => false,
                "nillable" => true
            }
        },
        "reply-properties" => {}
    }
}

This output means that the operation has three parameters, entries, selector and durable, Of type List, String, and Boolean respectively. Using this information we can add queue on the command line as follows:

[standalone@localhost:9999 /] /subsystem=messaging/jms-queue=cmdLineQueue:add(entries=["java:jboss/cmdLineQueue"], durable=true)
{"outcome" => "success"}

Now lets re-create this from the maven plugin:

<plugin>
    <groupId>org.jboss.as.plugins</groupId>
    <artifactId>jboss-as-maven-plugin</artifactId>
    <executions>
        <execution>
            <id>add-queue</id>
            <phase>install</phase>
            <configuration>
                <address>subsystem=messaging,jms-queue=myQueue</address>
                <properties>
                    <entries>!!["java:jboss/myQueue", "java:jboss/anotherJndiBinding"]</entries>
                    <durable>true</durable>
                </properties>
            </configuration>
            <goals>
                <goal>add-resource</goal>
            </goals>
        </execution>
    </executions>
</plugin>

The most interesting part of the above configuration is the <entries> element. Because the parameter is of a non-primitive type (in this case LIST), it must be specified as a DMR String. The !! escape as the start of the test tells the plugin to interpret it as such.

Using a different persistence provider with AS 7.0.1

Posted by Scott Marlow    |    Aug 18, 2011    |    Tagged as JBoss AS JPA

AS 7.0.1 is released!!!

AS 7.0.1 is released, which includes improvements for using different persistence providers (beside the included Hibernate 4.0.0). The framework is in place to plug in Hibernate 3.5 (or greater) persistence providers. This addressed user feedback, that its important to use Hibernate 3.x on AS7, to give more time before migrating to Hibernate 4.0.0. Switching your application to Hibernate 4.x, should be done as soon as possible. Hibernate 4.0.0 has been modified to support the AS7 modular classloading environment and JBoss logging (and other many other improvements).

Drop in a Hibernate 3.6.6.Final module

By default, JPA applications will use Hibernate 4.0.0 with AS7, unless you add property jboss.as.jpa.providerModule set to org.hibernate:3 to your persistence.xml properties list. You also need to create an org.hibernate:3 module that represents the Hibernate 3.6.6.Final release jars that will be used by your application. I downloaded the hibernate-distribution-3.6.6.Final for creating the new module.

Steps to create the Hibernate 3.6.6.Final module

  1. Create as/modules/org/hibernate/3 folder
  2. Copy jars from the hibernate-distribution-3.6.6.Final folder into the as/modules/org/hibernate/3 folder
  3. Create as/modules/org/hibernate/3/module.xml file
  4. update your persistence.xml to use the org.hibernate:3 module
<!-- as/modules/org/hibernate/3/module.xml file -->
<?xml version="1.0" encoding="UTF-8"?>
<module xmlns="urn:jboss:module:1.0" name="org.hibernate" slot="3">
    <resources>
        <resource-root path="hibernate3.jar"/>
        <resource-root path="javassist-3.12.0.GA.jar"/>
        <resource-root path="antlr-2.7.6.jar"/>  
        <resource-root path="commons-collections.jar"/>  
        <resource-root path="dom4j-1.6.1.jar"/>  
        <!-- Insert other Hibernate 3 jars to be used here -->
    </resources>
    <dependencies>
        <module name="org.jboss.as.jpa.hibernate" slot="3"/>
        <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="org.apache.ant"/>
        <module name="org.infinispan"/>
        <module name="org.javassist"/>
        <module name="org.slf4j"/>
    </dependencies>
</module>
<!-- persistence.xml using Hibernate 3.6.6.Final -->
<?xml version="1.0" encoding="UTF-8"?>
<persistence xmlns="http://java.sun.com/xml/ns/persistence" version="1.0">
<persistence-unit name="GameOfThrones_pu">
    <description>my Hibernate 3 persistence unit.</description>
    <jta-data-source>java:jboss/datasources/gameDS</jta-data-source>
    <properties>
        <property name="jboss.as.jpa.providerModule" value="org.hibernate:3"/>
    </properties>
</persistence-unit>
</persistence>

Example of an AS7 (Arquillian) unit test using the org.hibernate:3 module. Note that this test is @Ignored until we arrange for the org.hibernate:3 module to be created by the test build.

I could of created a standalone application but I prefer to push the awesome Arquillian project! ;) I hope that you will contribute similar JPA tests to the AS7 project when you can.

Experimental use of OGM on AS 7.0.1

I wanted to see if I could create an AS7 unit test that created a few entities with (OGM). To accomplish this, I checked out a copy of the OGM sources at and built them.

cd work
git clone git://github.com/hibernate/hibernate-ogm.git
Cloning into hibernate-ogm...
  remote: Counting objects: 4371, done.
  remote: Compressing objects: 100% (1357/1357), done.
  remote: Total 4371 (delta 1694), reused 4262 (delta 1599)
  Receiving objects: 100% (4371/4371), 1.17 MiB, done.
  Resolving deltas: 100% (1694/1694), done.

cd hibernate-ogm
mvn clean install
... lots of output from building ogm jars....

Folder hibernate-ogm-core/target will contain hibernate-ogm-core-3.0.0-SNAPSHOT.jar 

Next, you need to build my experimental OGM branch for AS7 (oh yeah, you need a few tools maven and git).

cd ..
git clone git://github.com/scottmarlow/jboss-as.git
cd jboss-as
git checkout ogm
./build.sh clean install
OR build.bat clean install
  1. Follow instructions above for creating the org.hibernate:3 module
  2. Create as/modules/org/hibernate/ogm folder
  3. Copy hibernate-ogm-core-3.0.0-SNAPSHOT.jar that you just built (from OGM build) into the as/modules/org/hibernate/ogm folder
  4. Create as/modules/org/hibernate/ogm/module.xml file
  5. update your persistence.xml to use the org.hibernate:3 module and org.hibernate:ogm providerModule.
  6. Create a local-only infinispan.xml for your application.
<!-- as/modules/org/hibernate/ogm/module.xml file -->
<?xml version="1.0" encoding="UTF-8"?>
<module xmlns="urn:jboss:module:1.0" name="org.hibernate" slot="ogm">
    <resources>
        <resource-root path="hibernate-ogm-core-3.0.0-SNAPSHOT.jar"/>
    </resources>

    <dependencies>
        <module name="org.jboss.as.jpa.hibernate" slot="3"/>
        <module name="org.hibernate" slot="3" export="true" />
        <module name="javax.api"/>
        <module name="javax.persistence.api"/>
        <module name="javax.transaction.api"/>
        <module name="javax.validation.api"/>
        <module name="org.apache.ant"/>
        <module name="org.infinispan"/>
        <module name="org.javassist"/>
        <module name="org.slf4j"/>
    </dependencies>
</module>
<!-- persistence.xml using OGM -->
<?xml version="1.0" encoding="UTF-8"?>
<persistence xmlns="http://java.sun.com/xml/ns/persistence" version="1.0">
<persistence-unit name="OGMExperiment_pu">
    <description>my OGM persistence unit.</description>
    <jta-data-source>java:jboss/datasources/ExampleDS</jta-data-source>
    <properties>
        <property name="jboss.as.jpa.providerModule" value="org.hibernate:ogm"/>
        <property name="jboss.as.jpa.adapterModule" value="org.jboss.as.jpa.hibernate:3"/>
        <property name="hibernate.ogm.infinispan.configuration_resourcename" value="infinispan.xml"/>
    </properties>
</persistence-unit>
</persistence>
<?xml version="1.0" encoding="UTF-8"?>
  
<!-- 
    infinispan.xml
    This is the testing configuration, running in LOCAL clustering mode to speedup tests.
-->
<infinispan
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="urn:infinispan:config:5.0 http://www.infinispan.org/schemas/infinispan-config-5.0.xsd"
    xmlns="urn:infinispan:config:5.0">

    <global>
    </global>

    <!-- *************************** -->
    <!--   Default cache settings    -->
    <!-- *************************** -->

    <default>
    </default>

    <!-- *************************************** -->
    <!--     Cache to store the OGM entities     -->
    <!-- *************************************** -->
    <namedCache
        name="ENTITIES">
    </namedCache>

    <!-- *********************************************** -->
    <!--   Cache to store the relations across entities  -->
    <!-- *********************************************** -->
    <namedCache
        name="ASSOCIATIONS">
    </namedCache>

    <!-- ***************************** -->
    <!--   Cache to store identifiers  -->
    <!-- ***************************** -->
    <namedCache
        name="IDENTIFIERS">
    </namedCache>

</infinispan>

To run the OGM unit test that I added (after manually creating the org.hibernate:ogm module), run the unit test with these steps:

  1. cd testsuite
  2. cd compat
  3. mvn clean install -DallTests

The unit test will run one instance of AS7 and use Infinispan in local-only mode. A few entities will be created (under a JTA transaction) and read back. If you see error org.jboss.as.testsuite.compat.jpa.hibernate.OGMHibernate3SharedModuleProviderTestCase: Could not deploy to container, open the ./target/jbossas/standalone/log/server.log to see what went wrong (did you create the as/modules/org/hibernate/3 and as/modules/org/hibernate/ogm modules?)

See OGM documentation for more about OGM.

Like I said before, using OGM on AS7, is experimental at this point. ;)

AS 7.0.1 JPA documentation

The documentation for AS7 JPA is available here.

I started a new git repo for working on EclipseLink integration. This will require coordination with the EclipseLink project as changes are probably required there as well. EclipseLink has the eclipselink.target.server property that can be set to JBoss but that doesn't support AS7 yet. Also, we need to fix the PersistenceUnitMetadata.getNewTempClassLoader() in AS7. Depending on the level of interest, the EclipseLink integration in AS7 will come together (more of the work may be inside of the EclipeLink project itself).

Community contributions are welcome

Please continue to ask/answer questions on the AS7 user discussion forums. I would like to work with a few more community members on further code changes to the JPA integration support in AS7. If you would like to volunteer, find Scott Marlow on IRC (irc://irc.freenode.org/jboss-as7). As well as working on integration support with other persistence providers.

AS7: Java Connector Architecture (JCA) inflow

Posted by Jesper Pedersen    |    Aug 18, 2011    |    Tagged as JBoss AS

In my previous blog I wrote about what the role of the Java Connector Architecture (JCA) container is inside the JBoss Application Server - and especially the IronJacamar container inside JBoss Application Server 7.

Inflow

JBoss Application Server 7.0.1 was released yesterday with EJB3/MDB support - try it out and report back.

In order for this to work we need a couple of pieces, namely the JBoss EJB3 MessageDrivenBean (MDB) container and HornetQ which is our messaging system.

However, if the JBoss EJB3 project had to integrate with every messaging system out there it would be a mess. Hence the EJB3 specification was made generic such that all types of systems could be plugged in.

This is where JCA inflow comes into the picture.

IronJacamar

The IronJacamar container features a completely new inflow system - as compared to previous JBoss Application Server releases - which was designed to decouple the interaction of the requesting container (f.ex. JBoss EJB3/MDB) and the target system (f.ex. HornetQ) even more.

IronJacamar keeps track of all resource adapter deployments which has support for inflow functionality - like the HornetQ resource adapter. This information can be queried to give a list of say all resource adapters that support the javax.jms.MessageListener interface. The returned list can then be filtered based on the user input and default settings such that correct instance is found. IronJacamar will even provide a list of all supported configuration properties and their type of the target system.

The requesting container can then activate a configuration using generic data types, so no explicit dependencies are needed on the target system's classes.

And by magic the two systems are now connected, and ready to serve you messages to your message-driven beans :)

Further reading

You can get an overview of how inflow works on a resource adapter level in our user guide, and of course in the Java Connector Architecture specification itself.

If you combine the power of JCA inflow with the ease of IronJacamar you end up with a very flexible solution for getting your data into JBoss Application Server 7.

For Those About to Rock, We Salute You !

[JBoss AS7] [IronJacamar]

Java EE 6 on OpenShift

Posted by Pete Muir    |    Aug 12, 2011    |    Tagged as CDI Java EE JBoss AS Seam

Unless you've been living under a rock for the past week, then you'll have seen that Red Hat just added support for JBoss AS 7 on OpenShift (both Express and Flex).

Why should you care?

  • OpenShift is the first PaaS to offer Java EE 6 support
  • OpenShift Express is 100% free, and allows you to run as many non-clustered applications you want on JBoss AS 7
  • OpenShift Express offers neat management of your apps via Git, including a source compilation mode
  • OpenShift Flex gives you much more freedom, including the ability to run clustered applications, and offers monitoring and automatic scaling.
  • OpenShift Flex is free, but you need to provide the EC2 instances. However Red Hat is offering a free 1 month/30 hour trial, so there is no reason not to check it out right now
  • JBoss AS 7 implements the Java EE 6 web profile, with all the benefits of the excellent CDI-based programming model it offers. It's very snappy to use, so deploying apps is quick

How can you learn more?

This week we've been pushing out material like crazy. If you want to give Java EE 6 in the cloud a try check out these resources:

To find out more, check out jboss.org.

We're going to dive down into the rabbit hole, and follow up on Wesley Hales great video on deploying the mobile web optimized RichFaces TweetStream application to Red Hat's new, free PaaS offering OpenShift Express complete with JBoss AS 7 under the hood!

Whats Been Covered

There has already been a lot of coverage on OpenShift, and the mobile web optimized TweetStream app. So I'm not going to cover old ground. Check out these blogs and videos:

OpenShift Express Updates

The RichFaces team is in the process of migrating our RichFaces Showcase application from Google App Engine to OpenShift Express, we'll have it ready soon. OpenShift offers a number of benefits over GAE, it is a real Java EE container, supports RichFaces push and has a much less restrictive API

Like many other free PaaS offerings OpenShift Express does have a few limitations that you need to consider. The most important ones for our application are limited threads, and JMS support. Note that all of these go away when you move up to OpenShift Flex!

RichFaces Push streamlined

When RichFaces 4.0.0.Final was released our push component was tied to JMS. This provides excellent enterprise level messaging capabilities, but unfortunately requires some setup to use. Since JMS is not provided by Express out of the box we needed to make some changes. So for 4.1.0 we are adding in a few options!

Starting with RichFaces 4.1.0.M1 RichFace Push can be decoupled from JMS. All that is needed is to set a context param:

<context-param>
    <param-name>org.richfaces.push.jms.disable</param-name>
    <param-value>true</param-value>
</context-param>

This will switch push to using an internal message queue. Look for further blogs, and documentation on this in the future. This is also one step closer to our plan to support CDI events as part of RichFaces Push.

Atmosphere updates on the way

Another change that was needed was moving to a snapshot version of Atmosphere. Atmosphere had a bug where it was creating a new thread for each request - ouch! Since OpenShift Express has limited threads available we needed a way around this.

Thankfully this issue was fixed in the Atmosphere 0.8-SNAPSHOT branch. This version of Atmosphere is due to be released in August, and RichFaces will use it by default once it is (likely in the 4.1.0.M2 release).

For now - if you are working on your own RichFaces push application and deploying to Express you'll need to override the Atmosphere version. This is simple enough with Maven, just add the following to your pom:

<dependency>
  <groupId>org.atmosphere</groupId>
  <artifactId>atmosphere-runtime</artifactId>
  <version>0.8-SNAPSHOT</version>
</dependency>

Infinispan cache LOCAL support

As was discussed in some of the linked blogs, the TweetStream application uses Infinispan under the covers to provide caching for the tweet data that we process. Infinispan in cluster mode uses jGroups to provide advanced communication support.

The problem here is the threading that accompanies this. For TweetStream it is important to make sure that you are using Infinispan in LOCAL mode. The latest TweetStream source has been updated to use the LOCAL cache.

Where to go from here

Now that we've gone over updates that are needed to take advantage of OpenShift Express I encourage you do give it a shot on your own. The source code is in the TweetStream git repo. Just follow the readme to setup and build it. Then deploy following the instructions in Wesley's video.

There will be more JBoss and OpenShift blogs and videos coming out, so stay tuned and check out JBoss and OpenShift page for the latest news.

[OpenShift Express] [JBoss OpenShift News] [OpenShift Twitter] [TweetStream git Repo] [RichFaces Twitter]

Some tips on using Hibernate in JBoss AS 7.0.0.Final

Posted by Marius Bogoevici    |    Jul 26, 2011    |    Tagged as JBoss AS

Here are a few quick tips when migrating Hibernate 3-based applications to JBoss AS7, covering the options available for JBoss AS 7.0.0.Final.

In previous versions of JBoss AS, a version of Hibernate was always present on the classpath. As a result, applications that used Hibernate directly have traditionally avoided to include it in the deployment in order to avoid classloading conflicts, or have taken additional steps to enforce classloader isolation.

The visibility rules have changed in AS7 due to the new modular classloading model, and so Hibernate libraries are made visible by default only to JPA deployments. The changes may affect existing Hibernate applications, so this is a short breakdown on the available options when running on JBoss AS7. Wherever this is subject to change in future versions, we also provide a succint description of the forthcoming enhancements.

Native Hibernate applications

As of the 7.0.0.Final version of JBoss AS, native (i.e. non-JPA) Hibernate applications can opt between:

  • packaging a Hibernate version of their choice inside the application;
  • adding the 'org.hibernate' module as a dependency to the application (adds Hibernate 4), e.g. by adding to the deployment a META-INF/MANIFEST.MF file that contains the following line:
    Dependencies: org.hibernate
  • creating a custom Hibernate 3 module, and adding it as a dependency to the application,e.g.
    Dependencies: my-custom-hibernate-module
    - noting that future versions of JBoss AS7 may already provide a skeleton Hibernate 3 module.

Application-created persistence units

JPA applications that create an EntityManagerFactory on their own, either using the PersistenceProvider SPI directly or through an intermediary mechanism such as Spring's LocalContainerEntityManagerFactoryBean have the same options as native Hibernate applications, noting that the 'org.hibernate' module may be added by default as a dependency as described here - so you may need to exclude it explicitly if you want to provide a version of your own. Therefore, under typical circumstances such applications can:

  • use the default setup (and use Hibernate 4)
  • package a Hibernate version of their choice and exclude the default 'org.hibernate' module by adding a WEB-INF/jboss-deployment-structure.xml or META-INF/jboss-deployment-structure.xml file (depending whether the deployment is a WAR or not) as follows:
    <jboss-deployment-structure xmlns="urn:jboss:deployment-structure:1.0">
      <deployment>
        <exclusions>
           <module name="org.hibernate"/>
        </exclusions>
      <deployment>
    </jboss-deployment-structure>
  • create a custom module and using it instead of the default 'org.hibernate';

Container-deployed persistence units

Generally speaking, standard Java EE-applications may ignore the provider implementation and rely on the standard features provided by the container - JBoss AS7 supporting standard JPA 1.0 and 2.0.

However, in future versions of JBoss AS7 it will be possible to use alternative persistence provider implementations - for more details please follow AS7-566.

back to top