Appfoundation - You have not defined a jta-data-source for a JTA enabled

Hello
Earlier I was working in swing but now I need to create RIA app, so I decided to try vaadin because making gui look more like desktop app.
Anyway after long search best way to integrate hibernate and vaadin and not fiding any good solution I give up that idea and decided to try app foundation adon, and here are my problem:

  1. I creating new project with vaadin plugin for eclipse
  2. copying: appfoundation.jar, eclipselink.jar, javax.persistence_1.0.0.jar, javax.persistence_2.0_preview.jar, postgresql-8.3-605.jdbc4.jar, vaadin-6.4.0.jar, xom-1.2.6.jar
    into Myapp->WebContent->WEB-INF->lib
  3. Creating persistence.xml under Myapp->src->META-INF
    And filling it with folowing content

<?xml version="1.0" encoding="UTF-8"?>
<persistence version="1.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_1_0.xsd">


        <persistence-unit name="default">
                <provider>
                        org.eclipse.persistence.jpa.PersistenceProvider
                </provider>
                <class>myapp.Producer</class>
                <exclude-unlisted-classes>false</exclude-unlisted-classes>
                <properties>
                        <property name="eclipselink.logging.level" value="FINE" />
                        <property name="eclipselink.jdbc.driver" value="org.postgresql.Driver" />
                        <property name="eclipselink.jdbc.url" value="jdbc:postgresql://localhost:5432/mydb" />
                        <property name="eclipselink.jdbc.user" value="user" />
                        <property name="eclipselink.jdbc.password" value="pass" />
                        <property name="eclipselink.ddl-generation" value="none" />
                        <property name="eclipselink.ddl-generation.output-mode"
                                value="database" />
                        <property name="eclipselink.orm.throw.exceptions" value="true" />
                </properties>

        </persistence-unit>
</persistence>
  1. i extend my entity class with extends AbstractPojo
  2. Creating class
    MyappContextListener.java

package myapp;

import javax.servlet.ServletContextEvent;
import javax.servlet.ServletContextListener;
import org.vaadin.appfoundation.persistence.facade.FacadeFactory;

public class MyappContextListener implements ServletContextListener {

    public void contextDestroyed(ServletContextEvent arg0) {
        // TODO Auto-generated method stub

    }

    public void contextInitialized(ServletContextEvent arg0) {
        // Setup and register the facade
        try {
            FacadeFactory.registerFacade("default", true);
        } catch (InstantiationException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        } catch (IllegalAccessException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }

    }

}
  1. next I add

  	<listener>
		<listener-class>
			myapp.MyappContextListener</listener-class>
	</listener>

to web.xml

  1. finally trying get data from database with

		List<Producer> producer = FacadeFactory.getFacade().list(Producer.class);
		String producersList = "";
		for(Producer p : producer){
			producersList += p.getSname();
		}
  1. Deploying application on jboss and…

21:07:17,375 ERROR [AbstractKernelController]
 Error installing to Start: name=persistence.unit:unitName=#default 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: default


Full exception

What i do wrong? :frowning:

I was able to reproduce the problem when using JBoss (Tomcat works fine). Apparently, when using JBoss, you need to define some JDBC datasources for your application. I haven’t used EclipseLink with JBoss, so this isn’t familiar territory for me, so I’m unable to give you an exact solution. Anyway, the
EclipseLink wiki
had some instructions on how to do this, although their example was for Oracle. The
JBoss documentation
has more information about defining datasources, there are references on how to make configurations for postgresql and other databases. You’ll also need to define the JTA datasource’s name in your persistence.xml file (
example
). I tried the instructions, but I ran into other problems.

Unfortunately, I’m unable to help you more than this, after this, your guess is as good as mine. Since this question isn’t actually AppFoundation or Vaadin related, but rather has to do with EclipseLink and Jboss, my recommendation is that you try their forums if you’re not able to solve the problem by googling. If you manage to solve this problem, please let us know the solution so that other who are looking for an answer to this question, will benefit from this thread.

Of course, if someone reading this forum knows how more about this subject, please feel free to pitch in :stuck_out_tongue:

  • Kim

I have different exception now so i think there is some progress
i removed libs: eclipselink.jar, javax.persistence_1.0.0.jar, javax.persistence_2.0_preview.jar cause it was generating some problems
then i changed persistence.xml like this

<?xml version="1.0" encoding="UTF-8"?>
<persistence xmlns="http://java.sun.com/xml/ns/persistence"
	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="1.0"
	xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd">
	<persistence-unit name="default"
		transaction-type="JTA">
		<jta-data-source>java:/DefaultDS</jta-data-source>
		<class>myapp.model.Producer</class>
		<properties>
			<property name="hibernate.dialect" value="org.hibernate.dialect.PostgreSQLDialect" />
			<property name="hibernate.hbm2ddl.auto" value="update" />
			<property name="hibernate.show.sql" value="true" />
		</properties>
	</persistence-unit>
</persistence>

and i get this exception

2010-08-09 19:15:29,875 ERROR [org.apache.catalina.core.ContainerBase.[jboss.web]
.[localhost]
.
[/Myapp]] (HDScanner) Exception sending context initialized event to listener instance of class myapp.MyappContextListener
java.lang.NoClassDefFoundError: org/eclipse/persistence/expressions/Expression


full exception

i think i will try my luck with appfound on tomcat or with ejb

Your second attempt uses Hibernate, AppFoundation doesn’t support Hibernate, only EclipseLink.