users@glassfish.java.net

Re: [Fwd: [embedded] How to unit test an EJB with Maven ?]

From: Antonio Goncalves <antonio.mailing_at_gmail.com>
Date: Sun, 27 Sep 2009 23:37:40 +0200

Hi all,

I've retested with glassfishv3-b65 and it's working fine (I don't have
the AccessLocalException: Client not authorized for this invocation). After
the simple Hello World test, I've added some JPA and it works fine too.
I then tried to run my testcase with the glassfish-embedded-all but it
doesn't work.

Antonio

2009/9/26 Alexis Moussine-Pouchkine <alexis.mp_at_sun.com>

> Let me try to summarize what works and what doesn't :
>
> 1/ EJBContainer.createEJBContainer() works well (including with JPA) when
> using the static shell JAR (see
> glassfish-samples/ws/javaee6/ejb/ejb-embedded as an example).
> This glassfish/lib/embedded/glassfish-embedded-shell.jar file ships with v3
> and is really just an empty JAR with a ClassPath: entry listing all the
> necessary JAR's. This requires a full GlassFish distro. So running with the
> embedded shell JAR in you classpath should run for your EJB unit tests.
>
> Trying to use this from Maven is a different story :
>
> - adding the static shell JAR artifact as a dependency to your POM does not
> help as neither Maven nor tools read JAR manifests. Setting the working
> directory in the Maven test run might do it (any mvn expert in the room?),
> but this doesn't seem like a clean solution.
>
> - adding the static shell POM as a dependency doesn't help either because
> its dependencies are set to <optional>true</optional>. Not sure why this is
> the case. Filed issue #9785 to track this one.
>
> - adding a set of dependencies (glassfish-embedded-shell, jta,
> ejb-container, gf-ejb-connector, and inmemory.jacc.provider) will get you to
> start EJBContainer.createEJBContainer() and invoke EJBs ...
> ... but JPA operations fail with a "Unable to retrieve EntityManagerFactory
> for unitName" error message.
> I suspect this is more of a generic exception hiding a missing dependency
> (the static shell approach described earlier touches almost twice as many
> JAR files compared to what's available in the classpath via the dependencies
> above).
>
> I could (and probably will) try to find the appropriate set of dependencies
> but I fear that the list of dependencies will be a lot one.
> The best way to solve this IMHO is to either change the POM for the
> embedded shell (if at all possible) or to create a new one which would be
> the equivalent for Maven to the static shell.
>
>
> 2/ EJBContainer.createEJBContainer() does not work with the
> glassfish-embedded-all.jar archive [2].
> Filed issue #9625 to track this one.
>
>
> Add yourselves to the CC list of the issues you want to track (or vote for
> them or comment/contribute).
>
> cheers,
> -Alexis
>
> [1] :
> http://download.java.net/maven/glassfish/org/glassfish/extras/glassfish-embedded-static-shell/
> [2] :
> http://download.java.net/maven/glassfish/org/glassfish/extras/glassfish-embedded-all/
>
>
> On Sep 26, 2009, at 12:36, glassfish_at_javadesktop.org wrote:
>
> Hi Antonio,
>>
>> it seems that I am on the same path as you are, tried to figure out why
>> the examples of chapter 06 aren't working and included
>>
>> <dependency>
>> <groupId>org.glassfish.extras</groupId>
>> <artifactId>glassfish-embedded-all</artifactId>
>> <version>3.0-b65</version>
>> <scope>test</scope>
>> </dependency>
>>
>> to my test module. No way to keep it going. So, I hope when I come back
>> from holiday, that I found a solution or can read the solution in this
>> thread :-)
>>
>> Heiko
>> openwms.org
>> [Message sent by forum member 'openwms' (openwms_at_googlemail.com)]
>>
>> http://forums.java.net/jive/thread.jspa?messageID=365870
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe_at_glassfish.dev.java.net
>> For additional commands, e-mail: users-help_at_glassfish.dev.java.net
>>
>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe_at_glassfish.dev.java.net
> For additional commands, e-mail: users-help_at_glassfish.dev.java.net
>
>


-- 
--
Antonio Goncalves (antonio.goncalves_at_gmail.com)
Software architect
Web site : www.antoniogoncalves.org
Blog: agoncal.wordpress.com
Feed: feeds2.feedburner.com/AntonioGoncalves
Paris JUG leader : www.parisjug.org
LinkedIn: www.linkedin.com/in/agoncal