Hi.

I'm using embedded openEJB to test some Session Beans during my build. The
project I'm working on uses toplink JPA provider, so I want to use topLink
with openEJB.

Problem: 
I want to add a new Taxon:

@Entity
@Table(name = "TAXA")
public class Taxa implements Serializable, Comparable<Taxa> {
    private static final long serialVersionUID = 1L;
    @TableGenerator(
        name = "Taxa_Gen", 
        table = "ID_GEN", 
        pkColumnName = "GENERATOR_NAME", 
        valueColumnName = "GENERATOR_VALUE", 
        pkColumnValue = "Taxa_Gen")
    @Id
    @GeneratedValue(strategy=GenerationType.TABLE, generator="Taxa_Gen")
    @Column(name = "RECORD_ID", nullable = false)
.
.
}

My unitTest basicly calls a Session Facade, the facade delegates the
em.persist(..) to an EAO (DAO):

public class Sp2kServiceBean implements Sp2kService {

    @EJB
    TaxaEAO taxaEAO;

  @Override
    public Taxa createTaxa(Long parentId, String name) {
    ... //Creates new Taxa
    taxaEAO.create(newTaxa);
.
.
}

TaxaEAOBean looks like this:

@Stateless
public class TaxaEAOBean implements TaxaEAO {

    @PersistenceContext(name="sp2k")
    private EntityManager em;

    @Override
    public void create(Taxa taxa) {
        em.persist(taxa);
        /em.flush();
    }
.
.
}

The problem started when I tried to add GenerationType.TABLE, the test ran
without error, but the Taxon was not added to the DB. So i tried em.flush()
in TaxaEAOBean, which resulted in the following error:

The transaction has been marked rollback only because the bean encountered a
non-application exception :javax.persistence.TransactionRequiredException : 
Exception Description: No transaction is currently active

Any ideas?
Does the use of toplink with openEJB need any more configuration than
changing the provider in persistence.xml?

I also tried it with openJPA, but it doesn't seem to use the table generated
primary key.
-- 
View this message in context: 
http://www.nabble.com/Toplink%2BopenEJB-%3D-TransactionRequiredException-tp16348298p16348298.html
Sent from the OpenEJB Dev mailing list archive at Nabble.com.

Reply via email to