You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomee.apache.org by Andreas Karalus <an...@googlemail.com> on 2008/09/04 17:55:04 UTC
UserTransaction in openejb
hello guys,
We already have an application with a lot of junit tests running on JBoss
AS. But jboss embedded causes us a lot of trouble (different jars as in
jboss-as, etc). So I am evaluating now other embedded containers especially
for junit testing of ejb3.0/JPA.
OpenEJB looks very good to me (installation and simple examples worked
well).
Now here is my question:
Is there a way to access the UserTransaction with openEJB from within a
junit testcase?
I tried following, but without succes
initialContext.lookup("java:/comp/UserTransaction");
initialContext.lookup("java:/comp/env/UserTransaction");
initialContext.lookup("UserTransaction");
The way suggested in the openejb Transaction Example would not work in our
case, we have an application with >500 Junit Tests calling EJB3.0 with
UserTransaction and I don't like changing the code.
regards,
andreas
--
View this message in context: http://www.nabble.com/UserTransaction-in-openejb-tp19313741p19313741.html
Sent from the OpenEJB Dev mailing list archive at Nabble.com.
Re: UserTransaction in openejb
Posted by David Blevins <da...@visi.com>.
Hi Andreas,
Try modifying your test code as so:
public class OpenEJBTest {
private InitialContext ctx;
@Before
public void onBefore() throws Exception {
Properties props = new Properties();
props.put(Context.INITIAL_CONTEXT_FACTORY,
"org.apache.openejb.client.LocalInitialContextFactory");
ctx = new InitialContext(props);
}
@After
public void onAfter() throws Exception {
ctx.close();
}
@Test
public void test1() throws Exception {
InitialContext ctx = new InitialContext();
// test some lookups
UserTransaction utx = (UserTransaction)
ctx.lookup("java:comp/UserTransaction");
Assert.assertNotNull(utx);
TransactionManager tm = (TransactionManager)
ctx.lookup("java:comp/TransactionManager");
Assert.assertNotNull(tm);
}
@Test
public void test2() {
System.out.println("run test2");
}
}
Essentially, all the code you had to check if OpenEJB was initialized,
etc. is all handled for you automatically. The first time you create
an InitialContext with the LocalInitialContextFactory we initialize
OpenEJB only if it hasn't been initialized already. Also if you call
close() on the InitialContext instance that "booted" OpenEJB then it
will cleanly destroy OpenEJB. If you call close() on any other
InitialContext it will do nothing.
-David
On Sep 17, 2008, at 4:41 AM, Andreas Karalus wrote:
>
> I attached a simple JUnit to show that OpenEJB.destroy does not work
> well in
> 3.1-SNAPSHOT (with 3.0 the same code works). Maybe it helps...
>
> public class OpenEJBTest {
>
> @Before
> public void onBefore() throws Exception{
>
> if(! OpenEJB.isInitialized()){
> Properties props = new Properties();
> props.put(Context.INITIAL_CONTEXT_FACTORY,
> "org.apache.openejb.client.LocalInitialContextFactory");
> System.setProperty(Context.INITIAL_CONTEXT_FACTORY,
> "org.apache.openejb.client.LocalInitialContextFactory");
>
> InitialContext ctx = new InitialContext(props);
> }
>
> }
>
>
> @After
> public void onAfter() throws Exception{
> if(OpenEJB.isInitialized()){
> OpenEJB.destroy();
> }
> }
>
> @Test
> public void test1() throws Exception{
> InitialContext ctx = new InitialContext();
> // test some lookups
> UserTransaction utx = (UserTransaction)
> ctx.lookup("java:comp/UserTransaction");
> Assert.assertNotNull(utx);
>
> TransactionManager tm = (TransactionManager)
> ctx.lookup("java:comp/TransactionManager");
> Assert.assertNotNull(tm);
>
> }
>
> @Test
> public void test2(){
> // this is just to test startup shutdown of openejb
> // I run well with 3.0 but I fail with 3.1-SNAPSHOT
> System.out.println("run test2");
>
> }
>
> }
>
>
>
>
> Andreas Karalus wrote:
>>
>> Hi David,
>>
>> thank you for your efforts, I really appreciate it.
>> I tried the new SNAPSHOT libraries, and the lookup works very well.
>> Thank
>> you again for providing a great support. However, I run into other
>> problems (maybe because of SNAPSHOT?). I just want to give feedback
>> on it.
>>
>> - the startup/shutdown behaviour of openejb may have changed? I start
>> openejb in every junit test @BeforeClass, and call
>> OpenEJB.destroy() in
>> @AfterClass. Running a single test works fine, running all tests
>> together
>> (e.g. maven test) fail after the first test. If I do not call
>> OpenEJB.destroy() in @AfterClass, all tests run again fine, so I
>> suppose
>> that OpenEJB.destroy() is the cause. Below is a stacktrace.
>>
>>
>
> --
> View this message in context: http://www.nabble.com/UserTransaction-in-openejb-tp19313741p19529660.html
> Sent from the OpenEJB Dev mailing list archive at Nabble.com.
>
>
Re: UserTransaction in openejb
Posted by Andreas Karalus <an...@googlemail.com>.
I attached a simple JUnit to show that OpenEJB.destroy does not work well in
3.1-SNAPSHOT (with 3.0 the same code works). Maybe it helps...
public class OpenEJBTest {
@Before
public void onBefore() throws Exception{
if(! OpenEJB.isInitialized()){
Properties props = new Properties();
props.put(Context.INITIAL_CONTEXT_FACTORY,
"org.apache.openejb.client.LocalInitialContextFactory");
System.setProperty(Context.INITIAL_CONTEXT_FACTORY,
"org.apache.openejb.client.LocalInitialContextFactory");
InitialContext ctx = new InitialContext(props);
}
}
@After
public void onAfter() throws Exception{
if(OpenEJB.isInitialized()){
OpenEJB.destroy();
}
}
@Test
public void test1() throws Exception{
InitialContext ctx = new InitialContext();
// test some lookups
UserTransaction utx = (UserTransaction)
ctx.lookup("java:comp/UserTransaction");
Assert.assertNotNull(utx);
TransactionManager tm = (TransactionManager)
ctx.lookup("java:comp/TransactionManager");
Assert.assertNotNull(tm);
}
@Test
public void test2(){
// this is just to test startup shutdown of openejb
// I run well with 3.0 but I fail with 3.1-SNAPSHOT
System.out.println("run test2");
}
}
Andreas Karalus wrote:
>
> Hi David,
>
> thank you for your efforts, I really appreciate it.
> I tried the new SNAPSHOT libraries, and the lookup works very well. Thank
> you again for providing a great support. However, I run into other
> problems (maybe because of SNAPSHOT?). I just want to give feedback on it.
>
> - the startup/shutdown behaviour of openejb may have changed? I start
> openejb in every junit test @BeforeClass, and call OpenEJB.destroy() in
> @AfterClass. Running a single test works fine, running all tests together
> (e.g. maven test) fail after the first test. If I do not call
> OpenEJB.destroy() in @AfterClass, all tests run again fine, so I suppose
> that OpenEJB.destroy() is the cause. Below is a stacktrace.
>
>
--
View this message in context: http://www.nabble.com/UserTransaction-in-openejb-tp19313741p19529660.html
Sent from the OpenEJB Dev mailing list archive at Nabble.com.
Re: UserTransaction in openejb
Posted by Andreas Karalus <an...@googlemail.com>.
Hi David,
thank you for your efforts, I really appreciate it.
I tried the new SNAPSHOT libraries, and the lookup works very well. Thank
you again for providing a great support. However, I run into other problems
(maybe because of SNAPSHOT?). I just want to give feedback on it.
- the startup/shutdown behaviour of openejb may have changed? I start
openejb in every junit test @BeforeClass, and call OpenEJB.destroy() in
@AfterClass. Running a single test works fine, running all tests together
(e.g. maven test) fail after the first test. If I do not call
OpenEJB.destroy() in @AfterClass, all tests run again fine, so I suppose
that OpenEJB.destroy() is the cause. Below is a stacktrace.
-------------------------------------------------------------------------------
Test set: de.easycredit.ed02.env.testframework.embedded.SimpleTest
-------------------------------------------------------------------------------
Tests run: 2, Failures: 0, Errors: 2, Skipped: 0, Time elapsed: 0.032 sec
<<< FAILURE!
de.easycredit.ed02.env.testframework.embedded.SimpleTest Time elapsed:
0.141 sec <<< ERROR!
javax.naming.NamingException: Cannot instantiate a LocalInitialContext.
Exception: java.lang.NullPointerException null [Root exception is
java.lang.NullPointerException]
at
org.apache.openejb.client.LocalInitialContextFactory.getLocalInitialContext(LocalInitialContextFactory.java:96)
at
org.apache.openejb.client.LocalInitialContextFactory.getInitialContext(LocalInitialContextFactory.java:42)
at javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:667)
at javax.naming.InitialContext.getDefaultInitCtx(InitialContext.java:247)
at javax.naming.InitialContext.init(InitialContext.java:223)
at javax.naming.InitialContext.<init>(InitialContext.java:197)
at
de.easycredit.ed02.env.testframework.openejb.OpenEJBFactory.initContainer(OpenEJBFactory.java:59)
at
de.easycredit.ed02.env.testframework.BeanFactory.initContainer(BeanFactory.java:208)
at
de.easycredit.ed02.env.testframework.embedded.SimpleTest.onBeforeClass(SimpleTest.java:36)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at
org.junit.internal.runners.BeforeAndAfterRunner.invokeMethod(BeforeAndAfterRunner.java:74)
at
org.junit.internal.runners.BeforeAndAfterRunner.runBefores(BeforeAndAfterRunner.java:50)
at
org.junit.internal.runners.BeforeAndAfterRunner.runProtected(BeforeAndAfterRunner.java:33)
at org.junit.internal.runners.TestClassRunner.run(TestClassRunner.java:52)
at
org.apache.maven.surefire.junit4.JUnit4TestSet.execute(JUnit4TestSet.java:62)
at
org.apache.maven.surefire.suite.AbstractDirectoryTestSuite.executeTestSet(AbstractDirectoryTestSuite.java:140)
at
org.apache.maven.surefire.suite.AbstractDirectoryTestSuite.execute(AbstractDirectoryTestSuite.java:127)
at org.apache.maven.surefire.Surefire.run(Surefire.java:177)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at
org.apache.maven.surefire.booter.SurefireBooter.runSuitesInProcess(SurefireBooter.java:345)
at
org.apache.maven.surefire.booter.SurefireBooter.main(SurefireBooter.java:1009)
Caused by: java.lang.NullPointerException
at
org.apache.openejb.client.LocalInitialContext.getContainerSystemEjbContext(LocalInitialContext.java:191)
at
org.apache.openejb.client.LocalInitialContext.<init>(LocalInitialContext.java:52)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at
sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
at
sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
at java.lang.reflect.Constructor.newInstance(Constructor.java:494)
at
org.apache.openejb.client.LocalInitialContextFactory.getLocalInitialContext(LocalInitialContextFactory.java:84)
... 26 more
- The validation of deployment of multiple persistence units seems to have
changed on 3.1-SNAPSHOT. We have multiple persistence jars belonging to same
ear, each of the jar have its own META-INF/persistence.xml with
unit-name="berechtigung". the deployement/tests run well with 3.0, with 3.1
I get following stacktraces.
Apache OpenEJB 3.1-SNAPSHOT build: 20080915-09:46
http://openejb.apache.org/
INFO - openejb.home = D:\projekte\HEAD\ed02\sys\berechtigung\login-impl
INFO - openejb.base = D:\projekte\HEAD\ed02\sys\berechtigung\login-impl
INFO - Configuring Service(id=Default Security Service,
type=SecurityService, provider-id=Default Security Service)
INFO - Configuring Service(id=Default Transaction Manager,
type=TransactionManager, provider-id=Default Transaction Manager)
INFO - Configuring Service(id=DefaultDS, type=Resource, provider-id=Default
JDBC Database)
INFO - Configuring Service(id=operativDS, type=Resource, provider-id=Default
JDBC Database)
INFO - Found EjbModule in classpath:
D:\projekte\HEAD\ed02\sys\berechtigung\login-impl\target\test-classes
INFO - Found EjbModule in classpath:
D:\m2_repository\repository\de\easycredit\ed02\sys\core\core-technical\4.0-SNAPSHOT\core-technical-4.0-SNAPSHOT.jar
INFO - Found EjbModule in classpath:
D:\projekte\HEAD\ed02\sys\berechtigung\partner-impl\target\test-classes
INFO - Found EjbModule in classpath:
D:\projekte\HEAD\ed02\sys\berechtigung\login-impl\target\classes
INFO - Found EjbModule in classpath:
D:\m2_repository\repository\de\easycredit\ed02\sys\core\core-business-impl\4.0-SNAPSHOT\core-business-impl-4.0-SNAPSHOT.jar
INFO - Found PersistenceModule in classpath:
D:\projekte\HEAD\ed02\sys\berechtigung\berechtigung-journal\target\test-classes
INFO - Found EjbModule in classpath:
D:\projekte\HEAD\ed02\sys\berechtigung\partner-impl\target\classes
INFO - Found EjbModule in classpath:
D:\projekte\HEAD\ed02\sys\berechtigung\rechte-impl\target\classes
INFO - Found EjbModule in classpath:
D:\projekte\HEAD\ed02\sys\berechtigung\berechtigung-core\target\classes
INFO - Found EjbModule in classpath:
D:\m2_repository\repository\de\easycredit\ed02\env\testframework\4.0-SNAPSHOT\testframework-4.0-SNAPSHOT.jar
INFO - Found EjbModule in classpath:
D:\projekte\HEAD\ed02\sys\berechtigung\rechte-impl\target\test-classes
INFO - Beginning load:
D:\projekte\HEAD\ed02\sys\berechtigung\login-impl\target\test-classes
INFO - Beginning load:
D:\m2_repository\repository\de\easycredit\ed02\sys\core\core-technical\4.0-SNAPSHOT\core-technical-4.0-SNAPSHOT.jar
INFO - Beginning load:
D:\projekte\HEAD\ed02\sys\berechtigung\partner-impl\target\test-classes
INFO - Beginning load:
D:\projekte\HEAD\ed02\sys\berechtigung\login-impl\target\classes
INFO - Beginning load:
D:\m2_repository\repository\de\easycredit\ed02\sys\core\core-business-impl\4.0-SNAPSHOT\core-business-impl-4.0-SNAPSHOT.jar
INFO - Beginning load:
D:\projekte\HEAD\ed02\sys\berechtigung\berechtigung-journal\target\test-classes
INFO - Beginning load:
D:\projekte\HEAD\ed02\sys\berechtigung\partner-impl\target\classes
INFO - Beginning load:
D:\projekte\HEAD\ed02\sys\berechtigung\rechte-impl\target\classes
INFO - Beginning load:
D:\projekte\HEAD\ed02\sys\berechtigung\berechtigung-core\target\classes
INFO - Beginning load:
D:\m2_repository\repository\de\easycredit\ed02\env\testframework\4.0-SNAPSHOT\testframework-4.0-SNAPSHOT.jar
INFO - Beginning load:
D:\projekte\HEAD\ed02\sys\berechtigung\rechte-impl\target\test-classes
INFO - Configuring enterprise application: classpath.ear
INFO - Configuring Service(id=Default Stateless Container, type=Container,
provider-id=Default Stateless Container)
INFO - Auto-creating a container for bean DBServiceImpl:
Container(type=STATELESS, id=Default Stateless Container)
INFO - Configuring Service(id=Default Stateful Container, type=Container,
provider-id=Default Stateful Container)
INFO - Auto-creating a container for bean PartnerElementServiceImpl:
Container(type=STATEFUL, id=Default Stateful Container)
INFO - Configuring PersistenceUnit(name=berechtigung,
provider=org.hibernate.ejb.HibernatePersistence)
INFO - Auto-creating a Resource with id 'operativDSNonJta' of type
'DataSource for 'berechtigung'.
INFO - Configuring Service(id=operativDSNonJta, type=Resource,
provider-id=operativDS)
INFO - Adjusting berechtigung <jta-data-source> to 'operativDS'
INFO - Adjusting berechtigung <non-jta-data-source> to 'operativDSNonJta'
INFO - Configuring PersistenceUnit(name=berechtigungPartner,
provider=org.hibernate.ejb.HibernatePersistence)
INFO - Adjusting berechtigungPartner <jta-data-source> to 'operativDS'
INFO - Adjusting berechtigungPartner <non-jta-data-source> to
'operativDSNonJta'
INFO - Configuring PersistenceUnit(name=berechtigung,
provider=org.hibernate.ejb.HibernatePersistence)
INFO - Adjusting berechtigung <jta-data-source> to 'operativDS'
INFO - Adjusting berechtigung <non-jta-data-source> to 'operativDSNonJta'
INFO - Configuring PersistenceUnit(name=challenge_wertelisten,
provider=org.hibernate.ejb.HibernatePersistence)
INFO - Adjusting challenge_wertelisten <jta-data-source> to 'operativDS'
INFO - Adjusting challenge_wertelisten <non-jta-data-source> to
'operativDSNonJta'
INFO - Configuring PersistenceUnit(name=berechtigung,
provider=org.hibernate.ejb.HibernatePersistence)
INFO - Adjusting berechtigung <jta-data-source> to 'operativDS'
INFO - Adjusting berechtigung <non-jta-data-source> to 'operativDSNonJta'
INFO - Configuring PersistenceUnit(name=berechtigungPartner,
provider=org.hibernate.ejb.HibernatePersistence)
INFO - Adjusting berechtigungPartner <jta-data-source> to 'operativDS'
INFO - Adjusting berechtigungPartner <non-jta-data-source> to
'operativDSNonJta'
INFO - Configuring PersistenceUnit(name=berechtigung,
provider=org.hibernate.ejb.HibernatePersistence)
INFO - Adjusting berechtigung <jta-data-source> to 'operativDS'
INFO - Adjusting berechtigung <non-jta-data-source> to 'operativDSNonJta'
INFO - Configuring PersistenceUnit(name=berechtigung,
provider=org.hibernate.ejb.HibernatePersistence)
INFO - Adjusting berechtigung <jta-data-source> to 'operativDS'
INFO - Adjusting berechtigung <non-jta-data-source> to 'operativDSNonJta'
ERROR - FAIL ... DBServiceImpl: Persistence unit not found for
@PersistenceContext(name="entityManager", unitName=""). Available units
[berechtigung, berechtigung, berechtigung, berechtigung, berechtigung,
berechtigungPartner, berechtigungPartner, challenge_wertelisten]
ERROR - Invalid
EjbModule(path=D:\projekte\HEAD\ed02\sys\berechtigung\partner-impl\target\test-classes)
ERROR - FAIL ... BerechtigungsvorlagenDAOImpl: @PersistenceContext unitName
has multiple matches: unitName "berechtigung" has 8 possible matches.
ERROR - FAIL ... LoginJournalEintragDAOImpl: @PersistenceContext unitName
has multiple matches: unitName "berechtigung" has 8 possible matches.
ERROR - FAIL ... LoginServiceDAOImpl: @PersistenceContext unitName has
multiple matches: unitName "berechtigung" has 8 possible matches.
ERROR - Invalid
EjbModule(path=D:\projekte\HEAD\ed02\sys\berechtigung\login-impl\target\classes)
ERROR - FAIL ... PersonServiceImpl: @PersistenceContext unitName has
multiple matches: unitName "berechtigung" has 8 possible matches.
ERROR - FAIL ... PersonServiceImpl: @PersistenceContext unitName has
multiple matches: unitName "berechtigung" has 8 possible matches.
ERROR - Invalid
EjbModule(path=D:\projekte\HEAD\ed02\sys\berechtigung\berechtigung-journal\target\test-classes)
ERROR - FAIL ... KreditgeberDAOHibernateJpa: Persistence unit not found for
@PersistenceContext(name="em", unitName=""). Available units [berechtigung,
berechtigung, berechtigung, berechtigung, berechtigung, berechtigungPartner,
berechtigungPartner, challenge_wertelisten]
ERROR - FAIL ... LandDAOHibernateJpa: Persistence unit not found for
@PersistenceContext(name="em", unitName=""). Available units [berechtigung,
berechtigung, berechtigung, berechtigung, berechtigung, berechtigungPartner,
berechtigungPartner, challenge_wertelisten]
ERROR - FAIL ... PartnerverwaltungAdminServiceImpl: @PersistenceContext
unitName has multiple matches: unitName "berechtigungPartner" has 8 possible
matches.
ERROR - FAIL ... PartnerverwaltungServiceImpl: Persistence unit not found
for @PersistenceContext(name="entityManager", unitName=""). Available units
[berechtigung, berechtigung, berechtigung, berechtigung, berechtigung,
berechtigungPartner, berechtigungPartner, challenge_wertelisten]
ERROR - FAIL ... VertragspartnerDAOHibernateJpa: Persistence unit not found
for @PersistenceContext(name="em", unitName=""). Available units
[berechtigung, berechtigung, berechtigung, berechtigung, berechtigung,
berechtigungPartner, berechtigungPartner, challenge_wertelisten]
ERROR - FAIL ... VertriebskanalZuordnungDAOHibernateJpa: Persistence unit
not found for @PersistenceContext(name="em", unitName=""). Available units
[berechtigung, berechtigung, berechtigung, berechtigung, berechtigung,
berechtigungPartner, berechtigungPartner, challenge_wertelisten]
ERROR - FAIL ... VertriebsstelleDAOHibernateJpa: Persistence unit not found
for @PersistenceContext(name="em", unitName=""). Available units
[berechtigung, berechtigung, berechtigung, berechtigung, berechtigung,
berechtigungPartner, berechtigungPartner, challenge_wertelisten]
ERROR - FAIL ... VPFusionenDAOHibernateJpa: Persistence unit not found for
@PersistenceContext(name="em", unitName=""). Available units [berechtigung,
berechtigung, berechtigung, berechtigung, berechtigung, berechtigungPartner,
berechtigungPartner, challenge_wertelisten]
ERROR - FAIL ... PartnerJournalServiceImpl: @PersistenceContext unitName has
multiple matches: unitName "berechtigungPartner" has 8 possible matches.
ERROR - FAIL ... PartnerElementServiceImpl: Persistence unit not found for
@PersistenceContext(name="entityManager", unitName=""). Available units
[berechtigung, berechtigung, berechtigung, berechtigung, berechtigung,
berechtigungPartner, berechtigungPartner, challenge_wertelisten]
ERROR - Invalid
EjbModule(path=D:\projekte\HEAD\ed02\sys\berechtigung\partner-impl\target\classes)
ERROR - FAIL ... AufgabenbereichHibernateJpaDAO: @PersistenceContext
unitName has multiple matches: unitName "berechtigung" has 8 possible
matches.
ERROR - FAIL ... RolleHibernateJpaDAO: @PersistenceContext unitName has
multiple matches: unitName "berechtigung" has 8 possible matches.
ERROR - Invalid
EjbModule(path=D:\projekte\HEAD\ed02\sys\berechtigung\rechte-impl\target\classes)
INFO - Set the 'openejb.validation.output.level' system property to VERBOSE
for increased validation details.
WARN - Jar not loaded. classpath.ear. Module failed validation.
AppModule(path=classpath.ear)
WARN - Property "Cache" not supported by "Default Stateful Container"
WARN - Property "Passivator" not supported by "Default Stateful Container"
WARN - Property "TimeOut" not supported by "Default Stateful Container"
WARN - Property "PoolSize" not supported by "Default Stateful Container"
WARN - Property "BulkPassivate" not supported by "Default Stateful
Container"
David Blevins wrote:
>
>
> On Sep 4, 2008, at 10:33 AM, David Blevins wrote:
>
>> Hi Andreas,
>>
>> We could probably hook that up. If you want a temporary workaround
>> you could create the UserTransaction yourself like so:
>>
>> UserTransaction utx = new
>> org.apache.openejb.core.CoreUserTransaction(null);
>>
>> Shouldn't be too difficult to get the JNDI lookup in there, but it
>> will probably be next week before I can get to it.
>
>
> Got this hooked up for you. Now a local client can lookup any of
> these three:
>
> context.lookup("java:comp/TransactionManager")
>
> context.lookup("java:comp/UserTransaction")
>
> context.lookup("java:comp/TransactionSynchronizationRegistry")
>
>
> Published new 3.1-SNAPSHOT jars to the people.apache.org maven repo if
> you'd like to give it a try.
>
> -David
>
>
>
--
View this message in context: http://www.nabble.com/UserTransaction-in-openejb-tp19313741p19529648.html
Sent from the OpenEJB Dev mailing list archive at Nabble.com.
Re: UserTransaction in openejb
Posted by David Blevins <da...@visi.com>.
On Sep 4, 2008, at 10:33 AM, David Blevins wrote:
> Hi Andreas,
>
> We could probably hook that up. If you want a temporary workaround
> you could create the UserTransaction yourself like so:
>
> UserTransaction utx = new
> org.apache.openejb.core.CoreUserTransaction(null);
>
> Shouldn't be too difficult to get the JNDI lookup in there, but it
> will probably be next week before I can get to it.
Got this hooked up for you. Now a local client can lookup any of
these three:
context.lookup("java:comp/TransactionManager")
context.lookup("java:comp/UserTransaction")
context.lookup("java:comp/TransactionSynchronizationRegistry")
Published new 3.1-SNAPSHOT jars to the people.apache.org maven repo if
you'd like to give it a try.
-David
Re: UserTransaction in openejb
Posted by David Blevins <da...@visi.com>.
Hi Andreas,
We could probably hook that up. If you want a temporary workaround
you could create the UserTransaction yourself like so:
UserTransaction utx = new
org.apache.openejb.core.CoreUserTransaction(null);
Shouldn't be too difficult to get the JNDI lookup in there, but it
will probably be next week before I can get to it.
-David
On Sep 4, 2008, at 8:55 AM, Andreas Karalus wrote:
>
> hello guys,
>
> We already have an application with a lot of junit tests running on
> JBoss
> AS. But jboss embedded causes us a lot of trouble (different jars
> as in
> jboss-as, etc). So I am evaluating now other embedded containers
> especially
> for junit testing of ejb3.0/JPA.
>
> OpenEJB looks very good to me (installation and simple examples worked
> well).
>
> Now here is my question:
> Is there a way to access the UserTransaction with openEJB from
> within a
> junit testcase?
>
> I tried following, but without succes
> initialContext.lookup("java:/comp/UserTransaction");
> initialContext.lookup("java:/comp/env/UserTransaction");
> initialContext.lookup("UserTransaction");
>
> The way suggested in the openejb Transaction Example would not work
> in our
> case, we have an application with >500 Junit Tests calling EJB3.0 with
> UserTransaction and I don't like changing the code.
>
>
> regards,
> andreas
> --
> View this message in context: http://www.nabble.com/UserTransaction-in-openejb-tp19313741p19313741.html
> Sent from the OpenEJB Dev mailing list archive at Nabble.com.
>
>