531 words

Jboss 6 persistence.xml startup error

#1
2011-04-04 07:38

Hi,

 I'm trying to migrate a small EJB 3.1 project from Postgres to ObjectDb to test out feasibility, but I keep getting stuck on setting up the persistence.xml on JBoss 6 AS.

Here is my setup:

<persistence version="2.0" xmlns="http://java.sun.com/xml/ns/persistence"
             xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
             xsi:schemaLocation="
      http://java.sun.com/xml/ns/persistence
      http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd">
  <persistence-unit name="testUnit" transaction-type="JTA">
    <provider>com.objectdb.jpa.Provider</provider>
    <properties>
      <property name="javax.persistence.jdbc.url" value="$objectdb/db/guests.odb"/>
      <property name="javax.persistence.jdbc.user" value="admin"/>
      <property name="javax.persistence.jdbc.password" value="admin"/>
    </properties>
  </persistence-unit>
</persistence>

and here is the error:

2011-04-04 18:35:23,098 ERROR [org.jboss.kernel.plugins.dependency.AbstractKernelController] (WorkerThread#0[127.0.0.1:53209]) Error installing to Start: name=persistence.unit:unitName=test.war#testUnit state=Create: java.lang.RuntimeException: Specification violation [EJB3 JPA 6.2.1.2] - You have not defined a jta-data-source for a JTA enabled persistence context named: testUnit
        at org.jboss.jpa.impl.deployment.PersistenceUnitInfoImpl.<init>(PersistenceUnitInfoImpl.java:124) [:2.0.0]

I have followed the examples also - but none refer to the jta-data-source element in the persistence.xml that I managed to find. Also, when setting up a jboss datasource it requires a SQL driver (confusing a bit!). Anyhow solved this without referring to the API ? I don't want to use the API as I much rather declarative-ly set it up.

Thanks

Willks
Willks's picture
Joined on 2011-04-04
User Post #1
#2
2011-04-06 04:01

There were a few issues in using ObjectDB with JBoss AS 6.0.

The good news is that a new build of ObjectDB that was just released (2.2.0_03) fixes the main problems and seems to work well with JBoss AS 6.0.

The following are general guidelines for how to use ObjectDB with JBoss AS 6.0 in Java EE 6 application:

  • A JTA data source is ignored by ObjectDB but is required by JBoss. See the attached persistence.xml file. If the IDE requires specifying SQL driver, etc - specify default settings (anything that is acceptable) and later, if necessary, edit the persistence.xml file manually, following the attached sample file.
  • Use objectdb-jee.jar instead of objectdb.jar. The new jar (objectdb-jee.jar) was added to ObjectDB distribution in the new build. It is identical to objectdb.jar, except that JPA and JTA classes are excluded. This is required in order to avoid class collision with JPA and JTA classes that are part of the JBoss server.
  • Due to a JBoss bug - you might have to use JBoss 6.1 (build 32 was tested successfully with ObjectDB) and replace the jboss-reflect.jar file, as explained on https://community.jboss.org/message/591851.
  • To install JBoss AS 6.0 from within NetBeans - version 7.0 beta (or above) is required.
  • A WAR file that contains the Java EE 6 Guestbook tutorial adjusted to JBoss AS 6.0 (including the objectdb-jee.jar) is attached. Just drop it in the JBoss's deploy directory, start JBoss (run) and open the browser at http://localhost:8080/Guestbook/guest (if JBoss is configured to use port 8080).
  • The default ObjectDB home directory is the deploy directory: the default ObjectDB configuration can be placed at deploy/object.conf, the ObjectDB log directory is deploy/log, and the database is created by default at deploy/db/guests.odb.

I hope that the instructions above will help.

 

ObjectDB Support
ObjectDB - Fast Object Database for Java (JPA/JDO)
support
support's picture
Joined on 2010-05-03
User Post #187
#3
2011-04-08 07:54

Thanks for the detailed solution. I think I'll give it a go now with Jboss 6 in the interim while Jboss 6.1 gets ready for a mature release. The examples are a great help!

 

Thanks

Willks
Willks's picture
Joined on 2011-04-04
User Post #2

Post Reply

Please read carefully the posting instructions - before posting to the ObjectDB website.

  • You may have to disable pop up blocking in order to use the toolbar (e.g. in Chrome).
  • Use ctrl + right click to open the browser context menu in the editing area (e.g. for using a browser spell checker).
  • To insert formatted lines (e.g. Java code, stack trace) - select a style in the toolbar and then insert the text in the new created block.
  • Avoid overflow of published source code examples by breaking long lines.
  • You may mark in paragraph code words (e.g. class names) with the code style (can be applied by ctrl + D).
  • Long stack traces (> 50 lines) and complex source examples (> 100 lines) should be posted as attachments.
Attachments:
Maximum file size: 32 MB
Cancel