users@glassfish.java.net

JUnit Test with Embeddable Glassfish fails with Error: "No EJB Container

From: <forums_at_java.net>
Date: Sun, 19 Jun 2011 02:47:46 -0500 (CDT)

Hello everybody,

i am trying to JUnit-test an EJB 3.1 Web Application from within NetBeans 7.0
with the Glassfish Embeddable Server. The app itself runs well on Glassfish
3.1 (b43), but the JUnit tests continue to produce failures. I feel like I
read almost every thread, blog, whatever about that matter in the web and
meanwhile I am somewhat lost, because everybody talks about how easy it
should be to get the stuff up and running. Hope somebody can help me.

To make sure JPA and Co don't have to do anything with it I created a simple
"hello world" Web Application with just a single Stateless Local (read about
the @Remote Issue) Session Bean to test.

Now here's the code I use to test the bean:

<code>

import javax.ejb.embeddable.EJBContainer;
import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.Test;
import static org.junit.Assert.*;
public class SimpleBeanTest {
    private static EJBContainer container;
    public SimpleBeanTest() {
    }
    @BeforeClass
    public static void setUpClass() throws Exception {
        container =
javax.ejb.embeddable.EJBContainer.createEJBContainer();
    }
    @AfterClass
    public static void tearDownClass() throws Exception {
        container.close();
    }
    @Test
    public void testCountToThree() throws Exception {
        System.out.println("countToThree");
        SimpleBean instance = (SimpleBean)
container.getContext().lookup("java:global/classes/SimpleBean");
        int expResult = 0;
        int result = instance.countToThree();
        assertEquals(expResult, result);
    }
}
</code>

 

And here's what comes out of it:

<code>

19.06.2011 09:31:56 com.sun.enterprise.v3.server.CommonClassLoaderServiceImpl
findDerbyClient
INFO: Cannot find javadb client jar file, derby jdbc driver will not be
available by default.
19.06.2011 09:31:56
org.glassfish.flashlight.impl.provider.FlashlightProbeProviderFactory
processXMLProbeProviders
SCHWERWIEGEND: MNTG0301:Cannot process XML ProbeProvider, xml =
META-INF/gfprobe-provider.xml
java.lang.IllegalStateException: Provider already mapped
glassfish:javamail:smtp-transport

(StackTrace here)

19.06.2011 09:31:57
org.glassfish.flashlight.impl.provider.FlashlightProbeProviderFactory
processXMLProbeProviders
SCHWERWIEGEND: MNTG0301:Cannot process XML ProbeProvider, xml =
META-INF/mojarra-jsf-api-probe-provider.xml
java.lang.IllegalStateException: Provider already mapped
glassfish:jsf:faces-servlet

(StackTrace here)

19.06.2011 09:31:57
org.glassfish.flashlight.impl.provider.FlashlightProbeProviderFactory
processXMLProbeProviders
SCHWERWIEGEND: MNTG0301:Cannot process XML ProbeProvider, xml =
jersey-gf-server-probe-provider.xml
java.lang.IllegalStateException: Provider already mapped
glassfish:jersey:server-hidden

(StackTrace here)

19.06.2011 09:31:57
org.glassfish.flashlight.impl.provider.FlashlightProbeProviderFactory
processXMLProbeProviders
SCHWERWIEGEND: MNTG0301:Cannot process XML ProbeProvider, xml =
jersey-gf-statsprovider-probe-provider.xml
java.lang.IllegalStateException: Provider already mapped
glassfish:jersey:server

(StackTrace here)

19.06.2011 09:31:57 org.glassfish.ha.store.spi.BackingStoreFactoryRegistry
register
INFO: Registered org.glassfish.ha.store.adapter.cache.ShoalBackingStoreProxy
for persistence-type = replicated in BackingStoreFactoryRegistry
19.06.2011 09:31:57 org.glassfish.ha.store.spi.BackingStoreFactoryRegistry
register
INFO: Registered org.glassfish.ha.store.adapter.cache.ShoalBackingStoreProxy
for persistence-type = replicated in BackingStoreFactoryRegistry
19.06.2011 09:31:57 com.sun.enterprise.v3.server.AppServerStartup run
SCHWERWIEGEND: Startdienst konnte nicht gestartet werden:
com.sun.enterprise.naming.GlassFishNamingBuilder
19.06.2011 09:31:57 com.sun.enterprise.v3.server.AppServerStartup run
INFO: GlassFish Server Open Source Edition 3.1 (43) Startzeit: Embedded
(597ms), Startdienste(929ms), gesamt(1.526ms)
19.06.2011 09:31:57
org.glassfish.admin.mbeanserver.JMXStartupService$JMXConnectorsStarterThread
run
INFO: JMXStartupService: JMXConnector system is disabled, skipping.

</code>

 

I have the glasfish-embedded-static-shell.jar in my classpath, and also tried
to use the glassfish-embedded-all-3.1 but it also didn't work.

Hope somebody can help.

Thanks,

christian


--
[Message sent by forum member 'christianhuening']
View Post: http://forums.java.net/node/813738