users@glassfish.java.net

glassfish-embedded-shell.jar 3.0.1 deployment issue

From: <glassfish_at_javadesktop.org>
Date: Sat, 19 Jun 2010 20:14:56 PDT

I'm using the latest 3.0.1 static shell with maven and I simply can't seem to get things working. I have my projects defined using maven and I've imported them into Eclipse. Eclipse is capable of resolving the dependencies without an issue. I've also followed the document "GlassFish 3.0.1 Embedded Server Guide.pdf" pertaining to using the embedded static shell.

I've defined the following in my maven pom.xml:



    <dependency>
      <groupId>org.glassfish.extras</groupId>
      <artifactId>glassfish-embedded-static-shell</artifactId>
      <version>3.0.1</version>
      <scope>compile</scope>
    </dependency>

    <dependency>
      <groupId>javax</groupId>
      <artifactId>javaee-api</artifactId>
      <version>6.0</version>
      <scope>provided</scope>
    </dependency>


I wrote a JUnit class that loads the embedded server in a static method as follows:

    @BeforeClass
    public static void setUpClass() throws Exception {
            
            java.util.Map<String,String> env = System.getenv();
            String gfhome = env.get("glassfish.home");
            String domainDir = gfhome + "domains/domain1/";
            
            java.util.Map<String,String> map = new java.util.HashMap<String, String>();
            map.put("org.glassfish.ejb.embedded.glassfish.instance.root", domainDir);
            ejbContainer = EJBContainer.createEJBContainer(map);
    }

This was per the Embedded Server Guide and it seems to work well except when I try to run the unit test. I get the following exception and stack trace:


java.lang.ClassFormatError: Absent Code attribute in method that is not native or abstract in class file javax/ejb/embeddable/EJBContainer
  at java.lang.ClassLoader.defineClass1(Native Method)
  at java.lang.ClassLoader.defineClassCond(ClassLoader.java:632)
  at java.lang.ClassLoader.defineClass(ClassLoader.java:616)
  at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:141)
  at java.net.URLClassLoader.defineClass(URLClassLoader.java:283)
  at java.net.URLClassLoader.access$000(URLClassLoader.java:58)
  at java.net.URLClassLoader$1.run(URLClassLoader.java:197)
  at java.security.AccessController.doPrivileged(Native Method)
  at java.net.URLClassLoader.findClass(URLClassLoader.java:190)


If I add the glassfish-embedded-all after the glassfish-embedded-static-shell, then I am able to get the class to load without the exception above but it does not seem to load or run with my installed server but rather the embedded server. I've verified this by confirming that my domain.xml was not loaded and nothing was being logged to my server.log file in my installation directory. Also I get a message on my console that states:

INFO: GlassFish Server Open Source Edition 3.0.1 (java_re-private) startup time : Embedded(2372ms) startup services(1232ms) total(3604ms)


Then, after the server appears to be loading, I get the following exception logged to the console:

Jun 19, 2010 7:56:42 PM com.sun.enterprise.web.WebContainer loadSystemDefaultWebModules
INFO: Virtual server server loaded system default web module
Jun 19, 2010 7:56:51 PM org.glassfish.api.ActionReport failure
SEVERE: Exception while invoking class com.sun.enterprise.web.WebDeployer prepare method
java.lang.NullPointerException
        at com.sun.enterprise.web.WebDeployer.loadMetaData(WebDeployer.java:107)
        at com.sun.enterprise.v3.server.ApplicationLifecycle.setupContainerInfos(ApplicationLifecycle.java:567)
        at org.glassfish.javaee.full.deployment.EarDeployer.prepareBundle(EarDeployer.java:264)
        at org.glassfish.javaee.full.deployment.EarDeployer.access$200(EarDeployer.java:79)
        at org.glassfish.javaee.full.deployment.EarDeployer$1.doBundle(EarDeployer.java:131)
        at org.glassfish.javaee.full.deployment.EarDeployer$1.doBundle(EarDeployer.java:129)
        at org.glassfish.javaee.full.deployment.EarDeployer.doOnBundles(EarDeployer.java:197)
        at org.glassfish.javaee.full.deployment.EarDeployer.doOnAllTypedBundles(EarDeployer.java:206)
        at org.glassfish.javaee.full.deployment.EarDeployer.doOnAllBundles(EarDeployer.java:232)
        at org.glassfish.javaee.full.deployment.EarDeployer.prepare(EarDeployer.java:129)
        at com.sun.enterprise.v3.server.ApplicationLifecycle.prepareModule(ApplicationLifecycle.java:644)
        at com.sun.enterprise.v3.server.ApplicationLifecycle.deploy(ApplicationLifecycle.java:296)
        at org.glassfish.kernel.embedded.EmbeddedDeployerImpl.deploy(EmbeddedDeployerImpl.java:214)
        at org.glassfish.kernel.embedded.EmbeddedDeployerImpl.deploy(EmbeddedDeployerImpl.java:144)


So from what I can see, I cannot load the static shell because of some sort of Class dependency that is unsatisfied. But adding the embedded-all prevents my GlassFish 3.0.1 installation from being used, which is what I really want. So how can I get all this to work with maven and Eclipse? I've spent the past 3 days reading the documentation and trying everything that I've read on the internet but still no luck. It's very frustrating trying to get all of these components to play nicely together. I'm simply trying to get my unit tests to run successfully within GlassFish for a jar project that contains JPA. Am I hoping for too much? Is this even possible?

I really need to load the container, have the container load my persistence.xml file so I can run my unit tests within a Transacted unit of work from the EntityManager. I don't want to create a web project to perform simple tests within the build process. I've tried to get this working from within Spring's container but using the LocalContainerEntityManagerFactoryBean it does not seem to play nicely with EclipseLink when the persistence.xml specifies transaction-type="JTA".

I'm eager to get this to work so any help would be greatly appreciated.
Thanks...

If I do try to
[Message sent by forum member 'fericit_bostan']

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