Я пытаюсь JUnit протестировать веб-приложение J2EE с NB 7.0, JUnit и встроенным сервером Glassfish на машине Win7Professional.
Я разбил его, чтобы просто протестировать простое простое веб-приложение Hello-World содин Session Bean.
У меня есть glasfish-embedded-static-shell.jar в моем classpath, и я также пытался использовать glassfish-embedded-all-3.1, но он также не работал.
Теперь вот код, который я использую для тестирования компонента:
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);
}
}
И вот что из этого получается:
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.
ОБНОВЛЕНИЕ: Иэто исключение, которое может возникнуть при любом тесте:
No EJBContainer provider available
Provider named org.glassfish.ejb.embedded.EJBContainerProviderImpl threw unexpected exception at create EJBContainer:
java.lang.RuntimeException
java.lang.RuntimeException: java.lang.IllegalStateException: AMX Booter MBean is already registered: amx-support:type=boot-amx
at org.glassfish.internal.embedded.Server.<init>(Server.java:290)
at org.glassfish.internal.embedded.Server.<init>(Server.java:66)
at org.glassfish.internal.embedded.Server$Builder.build(Server.java:176)
(Stack Trace here)
Caused by: java.lang.IllegalStateException: AMX Booter MBean is already registered: amx-support:type=boot-amx
Я дважды переустанавливал NetBeans, и он тоже не работает.