Hi Romain,

From: http://download.oracle.com/otndocs/jcp/persistence-2.0-fr-eval-oth-JSpec/

<snippet>
8.2.1.5 jta-data-source, non-jta-data-source
In Java EE environments, the jta-data-source and non-jta-data-source elements 
are
used to specify the global JNDI name of the JTA and/or non-JTA data source to 
be used by the persistence
provider. If neither is specified, the deployer must specify a JTA data source 
at deployment or a
JTA data source must be provided by the container, and a JTA 
EntityManagerFactory will be created to
correspond to it.

These elements name the data source in the local environment; the format of 
these names and the ability
to specify the names are product specific.
</snippet>

Specifically the "elements are used to specify the *global JNDI name*". Granted 
that the "format of these names and the ability to specify the names are 
product specific". That's why it's 'java:/DefaultDS' (JBoss 6) or 
'java:jboss/datasources/ExampleDS' (JBoss 7) or 'jdbc/__default' (Glassfish) 
etc... and if the code does a new InitialContext("java:/DefaultDS") it will get 
that datasource.

Where you getting your info from about standards?

So back to OpenEJB ... <jta-data-source>foo</jta-data-source> ... I cannot get 
datasource if I do new InitialContext("foo") because it's actually new 
InitialContext("java:openejb/Resource/xyz") or whatever the resource name is. 
It doesn't match up.

Some samples to the above that I noticed ...

#1. I don't have an OpenEJB managed datasource, but I have my own DBCP that I 
manually loaded into JNDI at java:/jdbc/arquillian/dbUnitDS (not sure how this 
setup will play out with JTA). I get this in the log:
INFO - Adjusting PersistenceUnit test <jta-data-source> to Resource ID 'Default 
JDBC Database' from '/jdbc/arquillian/dbUnitDS'

#2. I have <jta-data-source>blah</jta-data-source> and 
dbUnitDS=new://Resource?type=DataSource. I get this in the log:
INFO - Adjusting PersistenceUnit test <jta-data-source> to Resource ID 
'dbUnitDS' from 'blah'

Okay... thanks... I would have preferred an error and have to correct (align) 
the entries.

I don't know what the behaviour would be if I had multiple OpenEJB managed 
datasources. Didn't try it.

I appreciate the discussion on the format of <jta-data-source>, but like said 
earlier it's how OpenEJB swaps it out behind the scenes that throws me off as, 
IMHO, it doesn't respect the global JNDI entry that I put in there.

Am I missing something?


Wow... this is really getting off-topic to my initial question. Good 
discussion, though. I'll try to get back on track ...

I'm going to change the name from jndi.properties to something custom 
(openejb.properties) and create some custom glue Arquillian extension to load 
the contents of the file and set the entries in InitialContext. I think that 
will work. Some hoping I wouldn't have write up some custom thing for this. Oh 
well. C'est la vie.

Sorry for the long email.

Thanks,
Trev

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

wrong "<jta-data-source>foo</jta-data-source>" is the standard.
java:... names are not. You can use java:openejb/Resource/foo too i guess...but 
well not better ;)

OpenEJB 4.5.1 should support java:global or java:app (can't remember) names for 
datasources. But well clearly not something portable between application 
servers.

about root utl we can't guess it from arquillian so the heuristic is to use the 
place where persistence.xml is (well it is the marker then we update it).

You can't compare openejb to jboss or was because openejb arquilliana dapter 
doesn't dump the archive on the disk. If you need it use tomee remote 
arquillian adapter (or embedded) maybe


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]>:
> <jta-data-source>foo</jta-data-source>

Reply via email to