Hi David!

> Do you have any log output you could post?
I've attached a tee of the mvn test output and the surefire log.

> As a trivial implementation you could maybe just list the
> units under openejb/PersistenceUnit/, chop off the hash code
Thanks for pointing this again! I was not clear enough in my previous post: the 
problem is that there isn't any openejb/PersistenceUnit node at all - I only 
can find openejb/ejb.

I debuged through and found that the JtaEntityManager doesn't get initialised 
at all, because the JndiEncBuilder#build() doesn't get called but only the 
JndiBuilder#build(). So I have a few questions:
1.) What is the difference between those 2? 
2.) How can I force the ContextFactory to call the JndiEncBuilder or does it 
make no sense at all?
3.) Is this way to get the JtaEntityManager basically correct, or is there 
another way where we still can be sure that EJBs and WebBeans get the same 
JtaEntityManager instance?

txs and LieGrue,
strub


--- David Blevins <[email protected]> schrieb am Mo, 13.4.2009:
> Von: David Blevins <[email protected]>
> Betreff: Re: using OpenEJB in JUnit tests
> An: [email protected]
> Datum: Montag, 13. April 2009, 0:40
> 
> On Apr 12, 2009, at 2:41 PM, Mark Struberg wrote:
> 
> > 
> > Hi!
> > 
> > Somehow this doesn't work.
> > 
> > If I startup OpenEJB like the examples do:
> > 
> >> Properties p = new Properties();
> >> p.put(Context.INITIAL_CONTEXT_FACTORY,
> "org.apache.openejb.client.LocalInitialContextFactory");
> >> Context context = new InitialContext(p);
> > 
> > then no JtaEntityManager gets initialised.
> > 
> > Do I have to add additional properties?
> > 
> > persistence.xml and all other things should be in
> place.
> > 
> > The source is currently only in my git repo:
> > http://ns1.backwork.net/git/index.php?p=openwebbeans.git
> 
> Do you have any log output you could post?
> 
> 
> Regarding your question on IRC:
> 
> [13:32]    
> <struberg>    hi david! fine to see you
> around :)
> [13:32]    
> <struberg>    I have a little question
> concerning the OpenWebBeans/OpenEJB integration
> [13:32]    
> <struberg>    I started the EJB
> container but cannot find my PersistenceUnit in the JNDI
> context
> [13:33]    
> <struberg>    factory =
> (EntityManagerFactory)
> context.lookup("openejb/PersistenceUnit/" + unitName);
> [13:33]    
> <struberg>    any ideas?
> 
> I mentioned this in the "obtaining the JtaEntityManager"
> thread:
> 
> On Mar 25, 2009, at 7:59 PM, David Blevins wrote:
> 
> > The tricky part of that is the unit names have a hash
> code on them to get around the issue that they aren't
> required to be unique outside the persistence.xml file and
> there can be multiple persistence.xml files in an app. 
> As a trivial implementation you could maybe just list the
> units under openejb/PersistenceUnit/, chop off the hash code
> and use the first one with a matching name.  Supporting
> the case where the user has multiple units of the same name
> could be a feature to add later.
> 
> 
> The long and short of that is we don't use
> "openejb/PersistenceUnit/" + unitName as the JNDI name, so
> that won't work as is.
> 
> -David
> 
>


      
<?xml version="1.0" encoding="UTF-8" ?>
<testsuite failures="0" time="2.404" errors="1" skipped="0" tests="1" name="org.apache.webbeans.test.geronimo.openejb.OpenEJBIntegrationTest">
  <properties>
    <property name="openejb.version" value="3.0.1"/>
    <property name="java.runtime.name" value="Java(TM) SE Runtime Environment"/>
    <property name="sun.boot.library.path" value="/usr/java/jdk1.6.0_12/jre/lib/amd64"/>
    <property name="java.vm.version" value="11.2-b01"/>
    <property name="java.vm.vendor" value="Sun Microsystems Inc."/>
    <property name="java.vendor.url" value="http://java.sun.com/"/>
    <property name="path.separator" value=":"/>
    <property name="java.vm.name" value="Java HotSpot(TM) 64-Bit Server VM"/>
    <property name="file.encoding.pkg" value="sun.io"/>
    <property name="javax.security.jacc.PolicyConfigurationFactory.provider" value="org.apache.openejb.core.security.JaccProvider$Factory"/>
    <property name="user.country" value="AT"/>
    <property name="sun.java.launcher" value="SUN_STANDARD"/>
    <property name="sun.os.patch.level" value="unknown"/>
    <property name="java.vm.specification.name" value="Java Virtual Machine Specification"/>
    <property name="user.dir" value="/home/msx/develop/java/backwork/openwebbeans/webbeans-geronimo/target"/>
    <property name="java.runtime.version" value="1.6.0_12-ea-b03"/>
    <property name="derby.system.home" value="/home/msx/develop/java/backwork/openwebbeans/webbeans-geronimo/target"/>
    <property name="java.awt.graphicsenv" value="sun.awt.X11GraphicsEnvironment"/>
    <property name="basedir" value="/home/msx/develop/java/backwork/openwebbeans/webbeans-geronimo"/>
    <property name="java.endorsed.dirs" value="/usr/java/jdk1.6.0_12/jre/lib/endorsed"/>
    <property name="os.arch" value="amd64"/>
    <property name="java.io.tmpdir" value="/tmp"/>
    <property name="line.separator" value="
"/>
    <property name="java.vm.specification.vendor" value="Sun Microsystems Inc."/>
    <property name="java.naming.factory.url.pkgs" value="org.apache.openejb.core.ivm.naming"/>
    <property name="os.name" value="Linux"/>
    <property name="derby.storage.fileSyncTransactionLog" value="true"/>
    <property name="sun.jnu.encoding" value="UTF-8"/>
    <property name="java.library.path" value="/usr/java/jdk1.6.0_12/jre/lib/amd64/server:/usr/java/jdk1.6.0_12/jre/lib/amd64:/usr/java/jdk1.6.0_12/jre/../lib/amd64:/usr/java/packages/lib/amd64:/lib:/usr/lib"/>
    <property name="java.specification.name" value="Java Platform API Specification"/>
    <property name="java.class.version" value="50.0"/>
    <property name="sun.management.compiler" value="HotSpot 64-Bit Server Compiler"/>
    <property name="os.version" value="2.6.27.21-170.2.56.fc10.x86_64"/>
    <property name="user.home" value="/home/msx"/>
    <property name="user.timezone" value="Europe/Vienna"/>
    <property name="java.awt.printerjob" value="sun.print.PSPrinterJob"/>
    <property name="java.specification.version" value="1.6"/>
    <property name="file.encoding" value="UTF-8"/>
    <property name="user.name" value="msx"/>
    <property name="java.class.path" value="/tmp/surefirebooter4641054162661477867.jar:/home/msx/develop/java/backwork/openwebbeans/webbeans-geronimo/target/openejb-javaagent-3.0-beta-2.jar"/>
    <property name="openjpa.Log" value="log4j"/>
    <property name="noBanner" value="true"/>
    <property name="java.vm.specification.version" value="1.0"/>
    <property name="sun.arch.data.model" value="64"/>
    <property name="java.home" value="/usr/java/jdk1.6.0_12/jre"/>
    <property name="java.specification.vendor" value="Sun Microsystems Inc."/>
    <property name="user.language" value="de"/>
    <property name="java.vm.info" value="mixed mode"/>
    <property name="java.version" value="1.6.0_12-ea"/>
    <property name="org.apache.openejb.core.security.JaccProvider" value="org.apache.openejb.core.security.jacc.BasicJaccProvider"/>
    <property name="java.ext.dirs" value="/usr/java/jdk1.6.0_12/jre/lib/ext:/usr/java/packages/lib/ext"/>
    <property name="sun.boot.class.path" value="/usr/java/jdk1.6.0_12/jre/lib/resources.jar:/usr/java/jdk1.6.0_12/jre/lib/rt.jar:/usr/java/jdk1.6.0_12/jre/lib/sunrsasign.jar:/usr/java/jdk1.6.0_12/jre/lib/jsse.jar:/usr/java/jdk1.6.0_12/jre/lib/jce.jar:/usr/java/jdk1.6.0_12/jre/lib/charsets.jar:/usr/java/jdk1.6.0_12/jre/classes"/>
    <property name="java.vendor" value="Sun Microsystems Inc."/>
    <property name="java.security.auth.login.config" value="jar:file:/home/msx/.m2/repository/org/apache/openejb/openejb-core/3.0.1/openejb-core-3.0.1.jar!/login.config"/>
    <property name="localRepository" value="/home/msx/.m2/repository"/>
    <property name="file.separator" value="/"/>
    <property name="org.apache.security.jacc.EJBMethodPermission.methodInterfaces" value="BusinessLocalHome,BusinessRemoteHome,BusinessRemote,BusinessLocal"/>
    <property name="java.vendor.url.bug" value="http://java.sun.com/cgi-bin/bugreport.cgi"/>
    <property name="sun.cpu.endian" value="little"/>
    <property name="sun.io.unicode.encoding" value="UnicodeLittle"/>
    <property name="sun.desktop" value="gnome"/>
    <property name="sun.cpu.isalist" value=""/>
  </properties>
  <testcase time="2.37" classname="org.apache.webbeans.test.geronimo.openejb.OpenEJBIntegrationTest" name="testIntegration">
    <error message="PersistenceUnit &apos;TestUnit&apos; not found" type="org.apache.webbeans.exception.WebBeansCreationException">org.apache.webbeans.exception.WebBeansCreationException: PersistenceUnit &apos;TestUnit&apos; not found
	at org.apache.webbeans.spi.ee.openejb.JPAServiceOpenEJBImpl.getPersistenceUnit(JPAServiceOpenEJBImpl.java:53)
	at org.apache.webbeans.test.geronimo.openejb.OpenEJBIntegrationTest.testIntegration(OpenEJBIntegrationTest.java:42)
	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:597)
	at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:44)
	at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15)
	at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:41)
	at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:20)
	at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:28)
	at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:31)
	at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:73)
	at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:46)
	at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:180)
	at org.junit.runners.ParentRunner.access$000(ParentRunner.java:41)
	at org.junit.runners.ParentRunner$1.evaluate(ParentRunner.java:173)
	at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:28)
	at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:31)
	at org.junit.runners.ParentRunner.run(ParentRunner.java:220)
	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:165)
	at org.apache.maven.surefire.Surefire.run(Surefire.java:107)
	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:597)
	at org.apache.maven.surefire.booter.SurefireBooter.runSuitesInProcess(SurefireBooter.java:289)
	at org.apache.maven.surefire.booter.SurefireBooter.main(SurefireBooter.java:1005)
</error>
    <system-out>Apache OpenEJB 3.0.1    build: 20090311-10:01
http://openejb.apache.org/
INFO - 
********************************************************************************
OpenEJB http://openejb.apache.org/
Startup: 13.04.09 10:18
Copyright 1999-2008 (C) Apache OpenEJB Project, All Rights Reserved.
Version: 3.0.1
Build date: 20090311
Build time: 10:01
********************************************************************************


INFO - openejb.home = /home/msx/develop/java/backwork/openwebbeans/webbeans-geronimo/target
INFO - openejb.base = /home/msx/develop/java/backwork/openwebbeans/webbeans-geronimo/target
DEBUG - Instantiating assembler class org.apache.openejb.assembler.classic.Assembler
INFO - Cannot find the configuration file [conf/openejb.xml].  Will attempt to create one for the beans deployed.
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=Default JDK 1.3 ProxyFactory, type=ProxyFactory, provider-id=Default JDK 1.3 ProxyFactory)
DEBUG - Using openejb.deployments.classpath.include &apos;&apos;
DEBUG - Using openejb.deployments.classpath.exclude &apos;.*&apos;
DEBUG - Using openejb.deployments.classpath.filter.systemapps &apos;true&apos;
DEBUG - Using openejb.deployments.classpath.filter.descriptors &apos;false&apos;
DEBUG - Using openejb.deployments.classpath.require.descriptor &apos;false&apos;
DEBUG - Inspecting classpath for applications: 0 urls.
INFO - Found EjbModule in classpath: /home/msx/develop/java/backwork/openwebbeans/webbeans-geronimo/target/test-classes
DEBUG - URLs after filtering: 017
DEBUG - Descriptors path: jar:file:/home/msx/.m2/repository/org/apache/openwebbeans/openwebbeans-impl/1.0.0-incubating-SNAPSHOT/openwebbeans-impl-1.0.0-incubating-SNAPSHOT.jar!/
DEBUG - Descriptors path: jar:file:/home/msx/.m2/repository/org/apache/myfaces/core/myfaces-api/1.2.6/myfaces-api-1.2.6.jar!/
DEBUG - Descriptors path: file:/home/msx/develop/java/backwork/openwebbeans/webbeans-geronimo/target/test-classes/
DEBUG - Descriptors path: jar:file:/home/msx/.m2/repository/net/sf/scannotation/scannotation/1.0.2/scannotation-1.0.2.jar!/
DEBUG - Descriptors path: jar:file:/home/msx/.m2/repository/org/apache/openejb/javaee-api/5.0-1/javaee-api-5.0-1.jar!/
DEBUG - Descriptors path: file:/home/msx/develop/java/backwork/openwebbeans/webbeans-geronimo/target/classes/
DEBUG - Descriptors path: jar:file:/home/msx/.m2/repository/org/apache/geronimo/specs/geronimo-ejb_3.0_spec/1.0-M1/geronimo-ejb_3.0_spec-1.0-M1.jar!/
DEBUG - Descriptors path: jar:file:/home/msx/.m2/repository/org/apache/maven/surefire/surefire-api/2.4.3/surefire-api-2.4.3.jar!/
DEBUG - Descriptors path: jar:file:/home/msx/.m2/repository/org/objectweb/howl/howl/1.0.1-1/howl-1.0.1-1.jar!/
DEBUG - Descriptors path: jar:file:/home/msx/.m2/repository/javassist/javassist/3.8.0.GA/javassist-3.8.0.GA.jar!/
DEBUG - Descriptors path: jar:file:/home/msx/.m2/repository/org/apache/openjpa/openjpa/1.2.1/openjpa-1.2.1.jar!/
DEBUG - Descriptors path: jar:file:/home/msx/.m2/repository/javax/annotation/jsr250-api/1.0/jsr250-api-1.0.jar!/
DEBUG - Descriptors path: jar:file:/home/msx/.m2/repository/org/apache/openwebbeans/openwebbeans-api/1.0.0-incubating-SNAPSHOT/openwebbeans-api-1.0.0-incubating-SNAPSHOT.jar!/
DEBUG - Descriptors path: jar:file:/home/msx/.m2/repository/xml-apis/xml-apis/1.0.b2/xml-apis-1.0.b2.jar!/
DEBUG - Descriptors path: jar:file:/home/msx/.m2/repository/dom4j/dom4j/1.6.1/dom4j-1.6.1.jar!/
DEBUG - Descriptors path: jar:file:/home/msx/.m2/repository/org/apache/maven/surefire/surefire-booter/2.4.3/surefire-booter-2.4.3.jar!/
DEBUG - Descriptors path: jar:file:/home/msx/.m2/repository/org/apache/openejb/commons-dbcp-all/1.3/commons-dbcp-all-1.3.jar!/
DEBUG - Beginning load: /home/msx/develop/java/backwork/openwebbeans/webbeans-geronimo/target/test-classes
DEBUG - Destroying classLoader urlclassloa...@1991458058
INFO - Configuring app: /home/msx/develop/java/backwork/openwebbeans/webbeans-geronimo/target/test-classes
INFO - Configuring PersistenceUnit(name=TestUnit, provider=org.apache.openjpa.persistence.PersistenceProviderImpl)
INFO - Configuring Service(id=Default JDBC Database, type=Resource, provider-id=Default JDBC Database)
INFO - Auto-creating a Resource with id &apos;Default JDBC Database&apos; of type &apos;DataSource for &apos;TestUnit&apos;.
INFO - Configuring Service(id=Default Unmanaged JDBC Database, type=Resource, provider-id=Default Unmanaged JDBC Database)
INFO - Auto-creating a Resource with id &apos;Default Unmanaged JDBC Database&apos; of type &apos;DataSource for &apos;TestUnit&apos;.
INFO - Adjusting TestUnit &lt;jta-data-source&gt; to &apos;Default JDBC Database&apos;
INFO - Adjusting TestUnit &lt;non-jta-data-source&gt; to &apos;Default Unmanaged JDBC Database&apos;
INFO - Loaded Module: /home/msx/develop/java/backwork/openwebbeans/webbeans-geronimo/target/test-classes
INFO - Creating ProxyFactory(id=Default JDK 1.3 ProxyFactory)
DEBUG - createService.success
INFO - Creating TransactionManager(id=Default Transaction Manager)
DEBUG - createService.success
INFO - Creating SecurityService(id=Default Security Service)
DEBUG - Initialized debug=true usersFile=users.properties groupsFile=groups.properties
DEBUG - abort
DEBUG - createService.success
INFO - Creating Resource(id=Default JDBC Database)
DEBUG - createService.success
INFO - Creating Resource(id=Default Unmanaged JDBC Database)
DEBUG - createService.success
INFO - Assembling app: /home/msx/develop/java/backwork/openwebbeans/webbeans-geronimo/target/test-classes
INFO - PersistenceUnit(name=TestUnit, provider=org.apache.openjpa.persistence.PersistenceProviderImpl)
DEBUG - Default configuration information couldn&apos;t be loaded from any configuration provider.
DEBUG - Setting the following properties from &quot;?&quot; into configuration: {javax.persistence.provider=org.apache.openjpa.persistence.PersistenceProviderImpl, openjpa.jdbc.DBDictionary=hsql, openjpa.ConnectionUserName=sa, openjpa.Id=TestUnit, openjpa.ConnectionFactoryMode=managed, openjpa.connectionfactory=org.apache.openejb.resource.jdbc.basicmanageddatasou...@18682406, openjpa.ConnectionPassword=, openjpa.ConnectionDriverName=org.hsqldb.jdbcDriver, openjpa.TransactionMode=managed, openjpa.MetaDataFactory=jpa(Files=/home/msx/develop/java/backwork/openwebbeans/webbeans-geronimo/target/test-classes/), openjpa.classresolver=org.apache.openjpa.persistence.persistenceunitinfoimpl$classresolveri...@40be76c7, openjpa.connectionfactory2=org.apache.openejb.resource.jdbc.basicdatasou...@5d15126e, openjpa.ConnectionURL=jdbc:hsqldb:mem:test}
DEBUG - No cache marshaller found for id org.apache.openjpa.conf.MetaDataCacheMaintenance.
DEBUG - Scanning directory &quot;/home/msx/develop/java/backwork/openwebbeans/webbeans-geronimo/target/test-classes&quot; for persistent types.
DEBUG - Skipping persistent type location association for location &quot;file:/home/msx/develop/java/backwork/openwebbeans/webbeans-geronimo/target/test-classes/org/apache/webbeans/test/geronimo/openejb/MyEntity.class&quot; since it is a class, and will not need to be re-parsed later.
DEBUG - Scan of &quot;/home/msx/develop/java/backwork/openwebbeans/webbeans-geronimo/target/test-classes&quot; found persistent types [org.apache.webbeans.test.geronimo.openejb.MyEntity].
DEBUG - Scanning resource &quot;META-INF/orm.xml&quot; for persistent types.
DEBUG - parsePersistentTypeNames() found [org.apache.webbeans.test.geronimo.openejb.MyEntity].
DEBUG - Found 1 classes with metadata in 34 milliseconds.
DEBUG - Default configuration information couldn&apos;t be loaded from any configuration provider.
DEBUG - Setting the following properties from &quot;?&quot; into configuration: {openjpa.BrokerFactory=jdbc, javax.persistence.provider=org.apache.openjpa.persistence.PersistenceProviderImpl, openjpa.jdbc.DBDictionary=hsql, openjpa.ConnectionUserName=sa, openjpa.Id=TestUnit, openjpa.ConnectionFactoryMode=managed, openjpa.connectionfactory=org.apache.openejb.resource.jdbc.basicmanageddatasou...@18682406, openjpa.ConnectionPassword=, openjpa.ConnectionDriverName=org.hsqldb.jdbcDriver, openjpa.TransactionMode=managed, openjpa.BrokerImpl=non-finalizing, openjpa.MetaDataFactory=jpa(Files=/home/msx/develop/java/backwork/openwebbeans/webbeans-geronimo/target/test-classes/), openjpa.classresolver=org.apache.openjpa.persistence.persistenceunitinfoimpl$classresolveri...@40be76c7, openjpa.connectionfactory2=org.apache.openejb.resource.jdbc.basicdatasou...@5d15126e, openjpa.ConnectionURL=jdbc:hsqldb:mem:test}
DEBUG - Using openejb.jndiname.strategy.class &apos;org.apache.openejb.assembler.classic.JndiBuilder$TemplatedStrategy&apos;
DEBUG - Using openejb.jndiname.format &apos;{deploymentId}{interfaceType.annotationName}&apos;
INFO - Deployed Application(path=/home/msx/develop/java/backwork/openwebbeans/webbeans-geronimo/target/test-classes)
DEBUG - Containers        : 0
DEBUG - Deployments       : 0
DEBUG - SecurityService   : org.apache.openejb.core.security.SecurityServiceImpl
DEBUG - TransactionManager: org.apache.geronimo.transaction.manager.GeronimoTransactionManager
DEBUG - OpenEJB Container System ready.
</system-out>
  </testcase>
</testsuite>

Reply via email to