try removing javax.persistence* from properties *Romain Manni-Bucau* *Twitter: @rmannibucau <https://twitter.com/rmannibucau>* *Blog: **http://rmannibucau.wordpress.com/*<http://rmannibucau.wordpress.com/> *LinkedIn: **http://fr.linkedin.com/in/rmannibucau* *Github: https://github.com/rmannibucau*
2013/2/21 Antonio <[email protected]> > You were right! I configure my bean to use JTA transactions as follow but > now > it says that it can't connect against the database. I tried many different > configurations since this morning but i couldn't find the right one: > > The error I get is this on: > > Test set: com.altobridge.omc.orm.dao.UserDaoLocalTest > > ------------------------------------------------------------------------------- > Tests run: 2, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 5.396 sec > <<< FAILURE! > testCreateUser(com.altobridge.omc.orm.dao.UserDaoLocalTest) Time elapsed: > 5.32 sec <<< ERROR! > javax.ejb.EJBException: The bean encountered a non-application exception; > nested exception is: > javax.persistence.PersistenceException: > java.lang.UnsupportedOperationException: Not supported by BasicDataSource > at > > org.apache.openejb.core.ivm.BaseEjbProxyHandler.convertException(BaseEjbProxyHandler.java:363) > at > > org.apache.openejb.core.ivm.BaseEjbProxyHandler.invoke(BaseEjbProxyHandler.java:283) > at $Proxy43.createUser(Unknown Source) > at > > com.altobridge.omc.orm.dao.UserDaoLocalTest.testCreateUser(UserDaoLocalTest.java:48) > at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) > at > > sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) > at > > sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) > at java.lang.reflect.Method.invoke(Method.java:601) > at > > org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:45) > at > > org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15) > at > > org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:42) > at > > org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:20) > at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:263) > at > > org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:68) > at > > org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:47) > at org.junit.runners.ParentRunner$3.run(ParentRunner.java:231) > at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:60) > at > org.junit.runners.ParentRunner.runChildren(ParentRunner.java:229) > at org.junit.runners.ParentRunner.access$000(ParentRunner.java:50) > at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:222) > at org.junit.runners.ParentRunner.run(ParentRunner.java:300) > at > > org.apache.maven.surefire.junit4.JUnit4TestSet.execute(JUnit4TestSet.java:53) > at > > org.apache.maven.surefire.junit4.JUnit4Provider.executeTestSet(JUnit4Provider.java:123) > at > > org.apache.maven.surefire.junit4.JUnit4Provider.invoke(JUnit4Provider.java:104) > at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) > at > > sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) > at > > sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) > at java.lang.reflect.Method.invoke(Method.java:601) > at > > org.apache.maven.surefire.util.ReflectionUtils.invokeMethodWithArray(ReflectionUtils.java:164) > at > > org.apache.maven.surefire.booter.ProviderFactory$ProviderProxy.invoke(ProviderFactory.java:110) > at > > org.apache.maven.surefire.booter.SurefireStarter.invokeProvider(SurefireStarter.java:175) > at > > org.apache.maven.surefire.booter.SurefireStarter.runSuitesInProcessWhenForked(SurefireStarter.java:107) > at > org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:68) > Caused by: javax.persistence.PersistenceException: > java.lang.UnsupportedOperationException: Not supported by BasicDataSource > at > > org.eclipse.persistence.internal.jpa.EntityManagerSetupImpl.deploy(EntityManagerSetupImpl.java:517) > at > > org.eclipse.persistence.internal.jpa.EntityManagerFactoryDelegate.getDatabaseSession(EntityManagerFactoryDelegate.java:188) > at > > org.eclipse.persistence.internal.jpa.EntityManagerFactoryDelegate.createEntityManagerImpl(EntityManagerFactoryDelegate.java:277) > at > > org.eclipse.persistence.internal.jpa.EntityManagerFactoryImpl.createEntityManagerImpl(EntityManagerFactoryImpl.java:294) > at > > org.eclipse.persistence.internal.jpa.EntityManagerFactoryImpl.createEntityManager(EntityManagerFactoryImpl.java:279) > at > > org.apache.openejb.assembler.classic.ReloadableEntityManagerFactory.createEntityManager(ReloadableEntityManagerFactory.java:138) > at > > org.apache.openejb.persistence.JtaEntityManagerRegistry.getEntityManager(JtaEntityManagerRegistry.java:115) > at > > org.apache.openejb.persistence.JtaEntityManager.getEntityManager(JtaEntityManager.java:80) > at > > org.apache.openejb.persistence.JtaEntityManager.persist(JtaEntityManager.java:126) > at com.altobridge.omc.orm.dao.UserDao.createUser(UserDao.java:29) > at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) > at > > sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) > at > > sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) > at java.lang.reflect.Method.invoke(Method.java:601) > at > > org.apache.openejb.core.interceptor.ReflectionInvocationContext$Invocation.invoke(ReflectionInvocationContext.java:181) > at > > org.apache.openejb.core.interceptor.ReflectionInvocationContext.proceed(ReflectionInvocationContext.java:163) > at > org.apache.openejb.cdi.CdiInterceptor.invoke(CdiInterceptor.java:128) > at > org.apache.openejb.cdi.CdiInterceptor.access$000(CdiInterceptor.java:43) > at > org.apache.openejb.cdi.CdiInterceptor$1.call(CdiInterceptor.java:64) > at > org.apache.openejb.cdi.CdiInterceptor.aroundInvoke(CdiInterceptor.java:70) > at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) > at > > sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) > at > > sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) > at java.lang.reflect.Method.invoke(Method.java:601) > at > > org.apache.openejb.core.interceptor.ReflectionInvocationContext$Invocation.invoke(ReflectionInvocationContext.java:181) > at > > org.apache.openejb.core.interceptor.ReflectionInvocationContext.proceed(ReflectionInvocationContext.java:163) > at > > org.apache.openejb.monitoring.StatsInterceptor.record(StatsInterceptor.java:176) > at > > org.apache.openejb.monitoring.StatsInterceptor.invoke(StatsInterceptor.java:95) > at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) > at > > sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) > at > > sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) > at java.lang.reflect.Method.invoke(Method.java:601) > at > > org.apache.openejb.core.interceptor.ReflectionInvocationContext$Invocation.invoke(ReflectionInvocationContext.java:181) > at > > org.apache.openejb.core.interceptor.ReflectionInvocationContext.proceed(ReflectionInvocationContext.java:163) > at > > org.apache.openejb.core.interceptor.InterceptorStack.invoke(InterceptorStack.java:138) > at > > org.apache.openejb.core.stateless.StatelessContainer._invoke(StatelessContainer.java:237) > at > > org.apache.openejb.core.stateless.StatelessContainer.invoke(StatelessContainer.java:189) > at > > org.apache.openejb.core.ivm.EjbObjectProxyHandler.synchronizedBusinessMethod(EjbObjectProxyHandler.java:253) > at > > org.apache.openejb.core.ivm.EjbObjectProxyHandler.businessMethod(EjbObjectProxyHandler.java:248) > at > > org.apache.openejb.core.ivm.EjbObjectProxyHandler._invoke(EjbObjectProxyHandler.java:92) > at > > org.apache.openejb.core.ivm.BaseEjbProxyHandler.invoke(BaseEjbProxyHandler.java:279) > ... 31 more > Caused by: java.lang.UnsupportedOperationException: Not supported by > BasicDataSource > at > > org.apache.commons.dbcp.BasicDataSource.getConnection(BasicDataSource.java:1062) > at > > org.eclipse.persistence.sessions.JNDIConnector.connect(JNDIConnector.java:132) > at > > org.eclipse.persistence.sessions.DatasourceLogin.connectToDatasource(DatasourceLogin.java:162) > at > > org.eclipse.persistence.internal.sessions.DatabaseSessionImpl.loginAndDetectDatasource(DatabaseSessionImpl.java:584) > at > > org.eclipse.persistence.internal.jpa.EntityManagerFactoryProvider.login(EntityManagerFactoryProvider.java:206) > at > > org.eclipse.persistence.internal.jpa.EntityManagerSetupImpl.deploy(EntityManagerSetupImpl.java:488) > > The configuration I have in my persistence.xml in the model is this one: > > <?xml version="1.0" encoding="UTF-8"?> > <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="com.altobridge_omc-aomdb_ejb_1.0-SNAPSHOTPU" > transaction-type="JTA"> > <provider>org.eclipse.persistence.jpa.PersistenceProvider</provider> > <jta-data-source>postgresDatabase</jta-data-source> > <non-jta-data-source>postgresDatabaseUnmanaged</non-jta-data-source> > ... > <class>com.altobridge.omc.orm.entities.User</class> > ... > <exclude-unlisted-classes>false</exclude-unlisted-classes> > <properties> > <property name="javax.persistence.jdbc.url" > value="jdbc:postgresql://localhost:5432/aomdb"/> > <property name="javax.persistence.jdbc.password" value="omcad1n"/> > <property name="javax.persistence.jdbc.driver" > value="org.postgresql.Driver"/> > <property name="javax.persistence.jdbc.user" value="omcadmin"/> > <property name="openjpa.jdbc.SynchronizeMappings" > value="buildSchema(ForeignKeys=true)"/> > </properties> > </persistence-unit> > </persistence> > > The Unit Test: > > /* > * To change this template, choose Tools | Templates > * and open the template in the editor. > */ > package com.altobridge.omc.orm.dao; > > import com.altobridge.omc.orm.entities.User; > import java.util.Properties; > import java.util.logging.Level; > import java.util.logging.Logger; > import javax.naming.Context; > import javax.naming.InitialContext; > import javax.naming.NamingException; > import org.junit.Test; > > /** > * > * @author antonio > */ > public class UserDaoLocalTest { > > public UserDaoLocalTest() { > } > > /** > * Test of createUser method, of class UserDaoLocal. > */ > @Test > public void testCreateUser() throws NamingException > { > Properties p = > new Properties(); > p.put(Context.INITIAL_CONTEXT_FACTORY, > "org.apache.openejb.core.LocalInitialContextFactory"); > p.put("openejb.deployments.classpath.ear", "true"); > p.put("postgresDatabase", "new://Resource?type=DataSource"); > p.put("postgresDatabase.JdbcDriver", "org.postgresql.Driver"); > p.put("postgresDatabase.JdbcUrl", > "jdbc:postgresql://localhost:5432/aomdb"); > p.put("postgresDatabase.UserName", "omcadmin"); > p.put("postgresDatabase.JtaManaged", "true"); > > Context context = > new InitialContext(p); > UserDaoLocal users = > (UserDaoLocal) context.lookup("UserDaoLocal"); > User user = > new User(); > user.setUsername("Quentin Tarantino"); > user.setId("QuentinTarantino.0"); > users.createUser(user); > } > > /** > * Test of deleteUser method, of class UserDaoLocal. > */ > @Test > public void testDeleteUser() { > } > > > } > > I'm using the same url to connect to my database from netbeans and it > works. > The database is up and running. > > > > > > -- > View this message in context: > http://openejb.979440.n4.nabble.com/I-can-not-look-up-for-a-bean-in-my-Unit-test-tp4660917p4660951.html > Sent from the OpenEJB User mailing list archive at Nabble.com. >
