views:

98

answers:

1

I'm using NetBeans and GlassFish 3.0.1 to create an EJB3 application. I have written a few Unit Tests, which get run via JUnit and make use of the embedded GlassFish. Whenever I run these tests on my development machine (so from within NetBeans), it's all good.

Now I would like to let Hudson do those tests. At the moment it is failing with lookup failure on a resource (in this case the datasource to a JPA persistance unit):

[junit] SEVERE: Exception while invoking class org.glassfish.persistence.jpa.JPADeployer prepare method
[junit] java.lang.RuntimeException: javax.naming.NamingException: Lookup failed for 'mvs_devel' in SerialContext

After searching around and trying to learn about this, I believe it is related to the embedded GlassFish not having been configured with resources. In other words it's missing a domain.xml file. Right?

Two questions:

  1. Why does it work with NetBeans on my dev box? What magic does NetBeans do in the background?
  2. How should I provide the file? Where does the embedded GlassFish on the Hudson-box expect it?

Hudson is using the same Ant build-scripts (created by NetBeans).

I've read this post about instanceRoot and the EmbeddedFileSystemBuilder, but I don't understand enough of that. Is this needed for every TestCase (Emb. GF gets started/stopped for each bean-under-test)? Is this part of EJBContainer.createEJBContainer()? Again, why is it not necessary to do this when running tests on NetBeans?

Update Following Peter's advice I can confirm: when running ant on a freshly checked out copy of the code, with the same properties as hudson is configured, the tests get executed!

+1  A: 

10-1 it is a classpath issue as IDE's tend to swap paths in and out depending if you run normally or unittests.

Try running the tests on a commandline from a freshly checked out version from your SCM. Chances are you'll have the same error. Debugging on your local machine is a lot easier than on a remote machine.

When it builds reliably on the command line (in a separate directory) then it is time to move to hudson.

Peter Tillemans
@Peter: thanks for the suggestion! When I run 'ant <someoptions> test', the tests actually work and get executed. Any other idea?
Hank
@Hank: Did you run it on the Hudson server from the command line? If yes it might be a permission issue. Run your test with the same credential as Hudson is running?
Peter Schuetze
@2nd Peter: You da man! Thanks mate, that was it. ${GLASSFISH_HOME}/glassfish/domains/domain1/config was not readable to the hudson user. All good now!
Hank