users@glassfish.java.net

Re: embedded ejb container - configured datasource visibility problems

From: Marina Vatkina <marina.vatkina_at_oracle.com>
Date: Tue, 01 Mar 2011 18:31:44 -0800

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