users@glassfish.java.net

Re: Embedded testing woes

From: <glassfish_at_javadesktop.org>
Date: Wed, 07 Apr 2010 16:20:59 PDT

> Let me try to explain and answer the questions. (Let
> me know if I missed some in this long thread):

Hello, and thanks.

> EJBContainer.createEJBContainer() does search the
> classpath for any jar or directory that contains EJBs
> (either looking at annotations or at deployment
> descriptors).

But it does exactly what I thought, which is to ignore Class-Path: entries in a jar's manifest:

Apr 7, 2010 6:51:26 PM AppServerStartup run
INFO: [Thread[GlassFish Kernel Main Thread,5,main]] started
Apr 7, 2010 6:51:26 PM org.glassfish.ejb.embedded.EJBContainerProviderImpl addEJBModules
FINE: [EJBContainerProviderImpl] Looking for EJB modules in classpath: C:\DOCUME~1\LAIRDN~1\LOCALS~1\Temp\surefirebooter4360404343466698009.jar
Apr 7, 2010 6:51:26 PM org.glassfish.ejb.embedded.EJBContainerProviderImpl isRequestedEJBModule
FINE: ... Testing ... surefirebooter4360404343466698009.jar
Apr 7, 2010 6:51:26 PM org.glassfish.ejb.embedded.EJBContainerProviderImpl isRequestedEJBModule
FINE: ... is EJB module: false
Apr 7, 2010 6:51:26 PM org.glassfish.ejb.embedded.EJBContainerProviderImpl createEJBContainer
SEVERE: ejb.embedded.no_modules_found

As you can see, obviously the surefire booter is NEVER going to be an EJB, and this is the only classpath Glassfish appears to consult. I'm guessing here, but it looks like it doesn't then read the Class-Path: manifest entry and test its entries--if it did, it would find my stuff, because there are 20-odd entries in Class-Path.

(I suspect the reason that Adam Bien's example (and others' examples) worked was because he wasn't running Maven/Surefire in fork-per-test mode, which causes it to build a classpath as a manifest entry.)

> If more than one EJB module (i.e. dir
> or jar) is found, a temp ear file is created so that
> EJBs in those modules can access each other through
> Local interfaces.

And indeed I've seen this...when I specify EJBContainer.MODULES appropriately (i.e. when I point EJBContainer to the right place "by hand".

> Embeddable EJB container API in GlassFish (in its
> first version) is implemented to work easily against
> an existing GlassFish installation using
> glassfish-embedded-static-shell.jar from
> glassfish/lib/embedded directory (see
> http://docs.sun.com/app/docs/doc/821-1208/gjlde?a=view
> and
> http://docs.sun.com/app/docs/doc/821-1208/giide?a=view
> ). If such jar is used, the code calculates where the
> install location is, and the domain.xml is.

Yes, and that's fine; that doesn't happen to be the way that I have it set up (I have no pre-existing Glassfish installation, and was simply relying on the dependencies provided by Maven, spelled out in your second URL reference). My question here is: are you saying that for the time being this is the ONLY way to use EJBContainer#createContainer()? Because that makes this a non-starter for me.

After all, the sentence from your first URL reference reads:

"You must use this API with a pre-installed, nonembedded Enterprise Server instance."

It's unclear to me whether "this API" means javax.ejb.embeddable.EJBContainer or the proprietary Glassfish embedded APIs.
> If you are using a different (non-default) setup, you
> need to specify either the
> org.glassfish.ejb.embedded.glassfish.installation.root
> property or
> org.glassfish.ejb.embedded.glassfish.instance.root,
> or both to point to the actual locations.

OK, but no tutorial I've seen (not that I've seen all of them) indicates that you have to have a pre-existing Glassfish installation. So, yes, I'm using a non-default setup, but I don't know what values to supply for these parameters in the absence of a pre-existing Glassfish installation. Are you saying that even in a non-default setup I am required to have already downloaded and installed Glassfish somewhere else on my machine? Because all the tutorials and documentation (Alexis' included) seem to indicate that all I need to do is have Maven download some stuff on the fly and everything will work.

Thanks for the time you're taking to get involved in this thread.

Best,
Laird
[Message sent by forum member 'ljnelson']

http://forums.java.net/jive/thread.jspa?messageID=395798