You can deploy your OpenXava application on JBoss, indeed you can deploy your OpenXava application in any Java EE server. But, each application server has its own tricks, so we explain here a step by step guide to deploy on JBoss.
This guide uses JBoss 6.1.0.Final and OpenXava 5.3.1. We assume you're new to JBoss. We'll deploy the MySchool example project included in OpenXava distribution, against PostgreSQL.


To define the datasource create a file named my-school-ds.xml in jboss-6.1.0.Final/server/default/deploy with the next content:
<?xml version="1.0" encoding="UTF-8"?>
Of course, you should adapt the connection URL, the driver class, the user and password to your own database.

JDBC driver

Copy JDBC driver jar for you database into jboss-6.1.0.Final/server/default/lib. In our example we copy there postgresql-8.3-604.jdbc3.jar to work with our PostgreSQL 8.3.

Your persistence.xml

In the persistence.xml of your project (in persistence/META-INF) you have to make two changes. The first one is to change the format of the URL, change:
The second change is to enumerate explicitly all the entities of your project. Add the next entries:
The complete persistence.xml for MySchool could be:
<?xml version="1.0" encoding="UTF-8"?>
<persistence xmlns="http://java.sun.com/xml/ns/persistence"
    xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd"
    <persistence-unit name="default">
            <property name="hibernate.dialect" value="org.hibernate.dialect.PostgreSQLDialect"/>
Remember to put the correct dialect for your database.

The web.xml file of OpenXava (only for OpenXava 5.2, 5.2.1, 5.3, 5.3.1)

This step does not apply to XavaPro
Remove the organization servlet definition from OpenXava project. Edit OpenXava/web/WEB-INF/web.xml, and remove or comment the next declarations:
<!-- Remove or comment the next declaration -->
<!-- Remove or comment the next declaration -->

Disable JPA deployers (optional)

The above configuration is enough to run your application in JBoss. However, in that way JBoss will show the next error:
Deployment "persistence.unit:unitName=MySchool.war#default" is in error due to the following reason(s):
java.lang.RuntimeException: Specification violation [EJB3 JPA]
- You have not defined a jta-data-source for a JTA enabled persistence context named: default
You can ignore this error, everything will work fine. But, if you want to remove it, you can. Edit the jpa-deployers-jboss-beans.xml file from the jboss-6.1.0.Final/server/default/deployers/ejb3.deployer/META-INF folder, and remove or comment the bean PersistenceParsingDeployer:
<!-- Remove or comment the next declaration -->
<bean name="PersistenceParsingDeployer" class="org.jboss.jpa.deployers.PersistenceParsingDeployer">
Beware, because this modification can affect other applications deployed in your JBoss, specially if they use the JPA engine provided by JBoss.

Deploy and run your application

Execute the createWar Ant target of your build.xml. It will create a MySchool.war into the workspace.dist/MySchool.dist folder. Take that war and copy it into the jboss-6.1.0.Final/server/default/deploy folder. Start JBoss executing run.bat/.sh in jboss-6.1.0.Final/bin. Open your browser, go to http://localhost:8080/MySchool and you will see your application running on JBoss.