Hi Marina, thanks for your response.
I did make sure the names were the same. When this was all initially
working against 3.0.1 I was just using a name such as "jdbc/test_ds" which
uses no global naming syntax or anything. The persistence.xml used this
name as well. With 3.0.1 I was also able to programmatically get a
reference to the datasource by obtaining a context from the ejb container
reference and doing a lookup.
When working against 3.1, I initially tried without any prefixes but was not
able to do a programatic lookup nor have persistence.xml find the
datasource. If I remove the persistence.xml I'm NOT able to find the
datasource with a lookup.
The database is definitely up and running. In searching for answers I found
two links on a java howto blog which both work:
http://javahowto.blogspot.com/2011/02/ejb-lite-jpa-datasource-embedded-in.html
http://javahowto.blogspot.com/2011/02/glassfish-embedded-jpa-ejb-datasource.html
They both work so I know database connectivity is at least possible, though
the examples are using application scoped resources which seem to not work
for me either :(
On Tue, Mar 1, 2011 at 9:31 PM, Marina Vatkina <marina.vatkina_at_oracle.com>wrote:
> Hi Phillip,
>
> Did you try the name that you gave it in the jdbc-resource definition,
> without any prefixes? Can you look up this resource in your code if you
> remove persistence.xml? Is your database up and running?
>
> -marina
>
>
> Phillip Ross wrote:
>
>> Hi all,
>>
>> I've been working on updating code bases from 3.0.1 to 3.1 and am having
>> problems getting the embedded ejb container to work in unit tests. The
>> existing code simple defines a domain.xml that was sort of hacked from an
>> existing 3.0.1 installation which contained a connection pool and jdbc
>> resource definition of the database being tested against. This works great
>> with 3.0.1.
>>
>> Now with 3.1 I took the domain.xml file that was referred to in the 3.1
>> embedded documentation, added the jdbc connection pool and resource
>> definitions, but the datasource is not found. When the createEJBContainer
>> method is invoked, it returns a null reference, and there are stack traces
>> with naming exceptions explaining that the datasource name which is defined
>> in the persistence.xml is not found. I tried various naming schemes for the
>> datasource such as using java:global, java:app, and java:module prefixes,
>> but none of those make a difference. I also tried creating a
>> glassfish-resources.xml with the pool and datasource definitions in the
>> META-INF dir beside the persistence.xml and tried various naming schemes for
>> the datasource in there... but no luck. If I remove the persistence.xml, I
>> get a container reference that I can use to get a jndi context and lookup
>> the stateless ejbs, so I'm fairly certain this is a datasource resolution
>> issue.
>> I know the domain.xml file is being parsed, as other errors are shown when
>> I induce malformed xml elements in the file, it just seems as if the
>> datasource is not visible to the code. Is there anything else I can do to
>> narrow down the problem or identify the issue? I'm out of ideas.
>>
>> Thanks
>> - Phillip
>>
>