Hi Romain,

I agree Arquillian in fully embedded is not easy to get right. Been playing 
around with it for weeks. :-) Not only that but OpenEJB has to deal with 
different JPA providers too. I understand the desire to load stuff off of 
file://... because don't have to re-package all the code into a jar://... (or 
some protocol that jives with ShrinkWrap archives) but I think packaging it up 
would solve some Arquillian issues (at least for Hibernate ... not sure about 
other JPA providers). Thoughts?

Ok, <jta-data-source>foo</jta-data-source> is the standard for *OpenEJB*. 
OpenEJB creates the JNDI entry 'java:/openejb/Resource/foo' for the JPA 
providers to use. Why can't I provide my own *explicit* JNDI path (regardless 
of how ugly my JNDI path is :-) ? I've worked with Weblogic and JBoss and they 
don't swap it out like OpenEJB does. It makes my config structure easier 
because then all OpenEJB and JBoss config aligns better and I have fewer 
overrides.

Sounds like OpenEJB 4.5.1 doesn't support explicit JNDI paths for the 
jta-data-source & non-jta-data-source? If it doesn't I'll create a Jira because 
I think it should be something for consideration for a future release.

Trev

-----Original Message-----
From: Romain Manni-Bucau [mailto:[email protected]] 
Sent: Thursday, December 13, 2012 1:50 PM
To: [email protected]
Subject: Re: openejb.xml

about root url with 1.5.1 it should be the build dir (well we look at classpath 
persistence.xml so if resources is in the classpath...) but you can avoid it 
specifying your entities. From arquillian in fully embedded mode that's not so 
easy to get it right (you can specify it using new StringAsset(..) so no root 
url)

about the datasource just define a resource called "foo" (whatever you want but 
not java:foo) and use "foo" in the persistence.xml (java:/my/own/jdbc/dbUnitDS 
is not standard in this place)

Romain Manni-Bucau
Twitter: @rmannibucau
Blog: http://rmannibucau.wordpress.com/
LinkedIn: http://fr.linkedin.com/in/rmannibucau
Github: https://github.com/rmannibucau



2012/12/13 Baker, Trevor <[email protected]>:
> I'm hoping to use config files instead of doing it programmatically.
>
> I tried a src/test/resources/dbUnit-persistence.xml once before with 
> Arquillian putting it into the archive as META-INF/persistence.xml. Sadly, 
> the PU's root url passed to hibernate was incorrect and hibernate didn't 
> obviously find my src/main/java/... @Entity tagged classes. So went the 
> jndi.properties route and overriding entries in 
> src/main/resources/META-INF/persistence.xml. I'll get a test case for you. 
> IIRC, I think it used file://.../src/test/resources as the root url instead 
> of a virtual Jar.
>
> For the PU's <jta-data-source>java:/my/own/jdbc/dbUnitDS</jta-data-source>, 
> OpenEJB does some magic in the back and replaces it. Is there a way I can 
> keep it and I can supply the data source? I got a JNDI tree importer for 
> @Resource(lookup) stuff so I can throw in a DBCP too.
>
> Thanks,
> Trev
>
> -----Original Message-----
> From: Romain Manni-Bucau [mailto:[email protected]]
> Sent: Thursday, December 13, 2012 12:40 PM
> To: [email protected]
> Subject: Re: openejb.xml
>
> hmm jndi.properties is not managed by openejb directly in your case 
> byt InitialContext IIRC
>
> why not simply passing these properties to openejb when starting the 
> container?
>
> Note: "new" EJBContainer API ignores jndi.properties IIRC
>
> for the datasource you can create a conf folder (in ".") and add 
> openejb.xml file. For hibernate you'll need to add it somewhere else 
> (you can use altdd to define a test.persistence.xml normally)
>
> Romain Manni-Bucau
> Twitter: @rmannibucau
> Blog: http://rmannibucau.wordpress.com/
> LinkedIn: http://fr.linkedin.com/in/rmannibucau
> Github: https://github.com/rmannibucau
>
>
>
> 2012/12/13 Neale <[email protected]>:
>> Hi Trevor,
>>
>> Can you tell us your changes/findings so we can adjust the docs to 
>> make it easier for everyone else?
>>
>> Best Regards,
>> Neale
>>
>>
>>
>> ----- Original Message ----- From: "Baker, Trevor"
>> <[email protected]>
>> To: <[email protected]>
>> Sent: Friday, December 14, 2012 7:10 AM
>> Subject: RE: openejb.xml
>>
>>
>>
>> Fixed some line-ending weirdness.
>>
>> -----Original Message-----
>> From: Baker, Trevor [mailto:[email protected]]
>> Sent: Thursday, December 13, 2012 12:07 PM
>> To: [email protected]
>> Subject: openejb.xml
>>
>> Hi,
>>
>> I have the following jndi.properties:
>>
>> ----
>> java.naming.factory.initial=org.apache.openejb.client.LocalInitialCon
>> t
>> extFactory
>>
>> # create a new data source at: java:/openejb/Resource/dbUnitDS 
>> dbUnitDS=new://Resource?type=DataSource
>> dbUnitDS.JdbcUrl=jdbc:h2:mem:arquillian;DB_CLOSE_DELAY=-1
>> dbUnitDS.JdbcDriver=org.h2.Driver
>> dbUnitDS.JtaManaged=true
>>
>> # add properties for the persistence unit 
>> test.hibernate.dialect=org.hibernate.dialect.H2Dialect
>> test.hibernate.hbm2ddl.auto=create-drop
>> test.hibernate.id.new_generator_mappings=true
>> ---
>>
>> Unfortunately, jndi.properties is interfering with non-openejb unit 
>> tests in the project. Would like to convert to openejb.xml but need 
>> some help. Can someone send back the openejb.xml equivalent. I'm 
>> assuming I can place in src/test/resources/openejb.xml.
>>
>> Not being lazy. Just can't find any good resources. Would be nice if 
>> this page could have a sample openejb.xml:
>> http://tomee.apache.org/embedded-configuration.html
>>
>> Thanks,
>> Trev

Reply via email to