Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TransactionProviderNotFoundException with arquillian-extension-persistence #46

Open
clarenced opened this issue Apr 26, 2016 · 0 comments

Comments

@clarenced
Copy link

When I am using arquillian-persistence-dbunit with Spring java configuration, I always get this error org.jboss.arquillian.transaction.impl.lifecycle.TransactionProviderNotFoundException.

My Test class :

@RunWith(Arquillian.class)
@Transactional(PersistanceTestConfig.TRANSACTION_NAME)
@SpringAnnotationConfiguration(classes = {ArquillianConfiguration.class})
@DataSource(PersistanceTestConfig.MY_DATASOURCE)
@UsingDataSet({"database/myDataset.yml"})
public class MyTestClass{

      @Deployment(testable = false)
      public static WebArchive createArchive(){
          //returns a webArchive
      }

      @Test
      public void myTestMethod(){
        //do something
      }
}

My Persistence SpringConfig :

public class PersistanceTestConfig {
   public static final String TRANSACTION_NAME = "transaction";
   public static final String MY_DATASOURCE = "myDatasource";

 private Properties getJPAProperties() {
    final Properties jpaProperties = new Properties();
    jpaProperties.setProperty("hibernate.hbm2ddl.auto", "create");
    jpaProperties.setProperty("hibernate.show_sql", "true");
    jpaProperties.setProperty("hibernate.format_sql", "true");
    jpaProperties.setProperty("hibernate.dialect", "org.hibernate.dialect.HSQLDialect");

    return jpaProperties;
}


    @Bean(name = MY_DATASOURCE)
    public DataSource getDataSource(){
      return new EmbeddedDatabaseBuilder().setType(EmbeddedDatabaseType.HSQL)
            .continueOnError(false).ignoreFailedDrops(true).build();
    }


@Bean
@Autowired
public LocalContainerEntityManagerFactoryBean getEntityManagerREFCS( DataSource dataSource) {
    final LocalContainerEntityManagerFactoryBean localContainerEntityManagerFactoryBean = new LocalContainerEntityManagerFactoryBean();
    localContainerEntityManagerFactoryBean.setDataSource(dataSource);
    localContainerEntityManagerFactoryBean.setJpaVendorAdapter(new HibernateJpaVendorAdapter());
    localContainerEntityManagerFactoryBean.setPackagesToScan("com.myapp.dao.beans");
    localContainerEntityManagerFactoryBean.setPersistenceUnitName("pUnitName");
    localContainerEntityManagerFactoryBean.setJpaProperties(getJPAProperties());
    return localContainerEntityManagerFactoryBean;
}        
}

You can have more insight of the problem here

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant