users@glassfish.java.net

Re: glassfish-embedded-shell.jar 3.0.1 deployment issue

From: Major Péter <majorpetya_at_sch.bme.hu>
Date: Tue, 22 Jun 2010 00:19:05 +0200

The problem with JNDI is, that from tests you can only use the Global
JNDI names, so java:comp/env won't work, when you made your testclass
into an EJB, the EJB container will manage your JNDI lookups, that's why
you could use the original names without problem. (As this was stated in
the thread I mentioned).

Regards,
Peter

2010-06-22 00:05 keltezéssel, glassfish_at_javadesktop.org írta:
> My project structure is that of a simple jar file.
>
> pom.xml
> src/
> src/main/java/
> ......... my java classes (jpa entities, dao classes)
> src/main/resources/
> ......... my spring configuration files
> src/test/java/
> ......... my JUnit test cases
> src/test/resources/
> ......... my spring context.xml files
> src/test/resources/org/glassfish/embed/domain.xml
>
> I made my AppTest.class a @Stateless EJB because otherwise the application would not load. I don't have any EJB's in my project, only Spring managed POJOs. Without the @Stateless annotation EclipseLink was unable to locate the DataSource specified in persistence.xml. When I add the @Stateless back, then the application can at least load and the DataSource gets resolved.
>
> The Test code belongs to the same module that I have the entities currently defined in, which is a simple jar project. I do not have an EJB Project defined.
>
> I'll try the 3.1-SNAPSHOT and see what occurs. I'm still stuck as to how I can retrieve the EntityManager from JNDI so I can inject it into my Dao objects. If I define all of my dao objects as EJBs, then I would need to perform a lookup to locate each bean. Seeing as I don't have an EJB project or a Web Project I cannot specify the refs in ejb-jar.xml or web.xml and would need to perform a lookup in the global namespace. It would be much simpler if I could simply lookup the EntityManager and inject it into my Dao objects.