users@glassfish.java.net

Re: Using embedded GF 3.1.1 for unit testing

From: Marina Vatkina <marina.vatkina_at_oracle.com>
Date: Fri, 02 Sep 2011 13:33:22 -0700

Do you use maven/ant/anything else?

forums_at_java.net wrote:
> what i do is the following:
>
> @Test
> public void TestGFStart() throws NamingException,
> InterruptedException
> {
> Map<String, Object> properties = new HashMap<String,
> Object>();
>
> properties.put("org.glassfish.ejb.embedded.glassfish.installation.root",
>
> "./src/test/resources/glassfish");
> properties.put(EJBContainer.APP_NAME, "app");
> EJBContainer c = EJBContainer.createEJBContainer(properties);
> Context ic = c.getContext();
>
> ActivitiServiceEJB activiti = (ActivitiServiceEJB)
> ic.lookup("java:global/app/ActivitiServiceEJB");
> ProcessEngine processEngine = activiti.getProcessEngine();

By calling 'properties.put(EJBContainer.APP_NAME, "app")' you are
creating an temp ear file called 'app' - is it what you want? If yes,
the lookup will be "java:global/app/*module-name*/ActivitiServiceEJB"

If your module is called 'app', and there is only one EJB module in the
classpath, you do not need to specify any extra property.

>
> c.close();
> }
>
> under installation.root i have the directory structure:
>
> glassfish / domains / domain1 / config / domain.xml
>
> \ lib / install / applications / _[cp|dm|ds|xa]_jdbc_ra / ...
>
> \ META-INF / MANIFEST.MF
>
> i use domain.xml to configure some jdbc resources.
>
> need i change something in this setup?

When you specify 'root', the code expects all of the GF being installed
there. You need to specify only 'configuration.file' to use your own
domain.xml. I do not think you need _jdbc_ra files extracted.

>
>
>
> besides this error it seems that my EJBs are deployed (SessionBeans,
> SingletonBean...), but

No, the deployment fails (because close() is called during
createEJBContainer()).

-marina
>
> after my last bean is initialised i get the following error:
>
> 02.09.2011 20:10:51 org.activiti.engine.ProcessEngines
> initProcessEnginFromResource
> INFO: initialised process engine default
> 02.09.2011 20:10:51 erp.domain.activiti.mgnt.ActivitiServiceEJB
> initEngine
> INFO: Process engine org.activiti.engine.impl.ProcessEngineImpl_at_d38525
> created and initialized.
> 02.09.2011 20:11:25 erp.domain.activiti.mgnt.ActivitiServiceEJB
> createActivitiUserData
> WARNUNG: Creating user test data for Activiti. Should be removed in a
> production environment!
> 02.09.2011 20:15:50 org.glassfish.deployment.admin.DeployCommand execute
> SCHWERWIEGEND: null
> PlainTextActionReporterFAILUREDescription: deploy AdminCommandError
> occurred
> during deployment: null. Please see server.log for more details.
> [name=app
> 02.09.2011 20:15:50 org.glassfish.ejb.embedded.EJBContainerProviderImpl
> createEJBContainer
> INFO: [EJBContainerProviderImpl] Cleaning up on failure ...
> java.util.logging.ErrorManager: 5
> java.lang.NullPointerException
> at
> java.util.PropertyResourceBundle.handleGetObject(PropertyResourceBundle.java:136)
>
> at java.util.ResourceBundle.getObject(ResourceBundle.java:368)
> at java.util.ResourceBundle.getString(ResourceBundle.java:334)
> at java.util.logging.Formatter.formatMessage(Formatter.java:108)
> at java.util.logging.SimpleFormatter.format(SimpleFormatter.java:63)
> at java.util.logging.StreamHandler.publish(StreamHandler.java:179)
> at java.util.logging.ConsoleHandler.publish(ConsoleHandler.java:88)
> at java.util.logging.Logger.log(Logger.java:481)
> at com.sun.logging.LogDomains$1.log(LogDomains.java:354)
> at java.util.logging.Logger.doLog(Logger.java:503)
> at java.util.logging.Logger.log(Logger.java:592)
> at
> com.sun.enterprise.v3.server.ApplicationLoaderService.stopApplication(ApplicationLoaderService.java:456)
>
> at
> com.sun.enterprise.v3.server.ApplicationLoaderService.preDestroy(ApplicationLoaderService.java:431)
>
> at
> com.sun.hk2.component.AbstractCreatorInhabitantImpl.dispose(AbstractCreatorInhabitantImpl.java:83)
>
> at
> com.sun.hk2.component.SingletonInhabitant.release(SingletonInhabitant.java:81)
>
> at
> com.sun.hk2.component.EventPublishingInhabitant.release(EventPublishingInhabitant.java:108)
>
> at
> com.sun.hk2.component.LazyInhabitant.release(LazyInhabitant.java:133)
> at
> com.sun.enterprise.v3.server.AppServerStartup.stop(AppServerStartup.java:425)
>
> at
> com.sun.enterprise.glassfish.bootstrap.GlassFishImpl.stop(GlassFishImpl.java:88)
>
> at
> org.glassfish.ejb.embedded.EJBContainerImpl.stop(EJBContainerImpl.java:253)
>
> at
> org.glassfish.ejb.embedded.EJBContainerImpl.forceClose(EJBContainerImpl.java:201)
>
> at
> org.glassfish.ejb.embedded.EJBContainerImpl.close(EJBContainerImpl.java:180)
>
> at
> org.glassfish.ejb.embedded.EJBContainerProviderImpl.createEJBContainer(EJBContainerProviderImpl.java:147)
>
> at
> javax.ejb.embeddable.EJBContainer.createEJBContainer(EJBContainer.java:127)
>
> at erp.test.TransactionTest.saveAndGetKlant(TransactionTest.java:61)
> at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> at
> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
>
> at
> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
>
> at java.lang.reflect.Method.invoke(Method.java:597)
> at
> org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:44)
>
> at
> org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15)
>
> at
> org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:41)
>
> at
> org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:20)
>
> at
> org.junit.runners.BlockJUnit4ClassRunner.runNotIgnored(BlockJUnit4ClassRunner.java:79)
>
> at
> org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:71)
>
> at
> org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:49)
>
> at org.junit.runners.ParentRunner$3.run(ParentRunner.java:193)
> at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:52)
> at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:191)
> at org.junit.runners.ParentRunner.access$000(ParentRunner.java:42)
> at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:184)
> at org.junit.runners.ParentRunner.run(ParentRunner.java:236)
> at
> org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50)
>
> at
> org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
>
> at
> org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467)
>
> at
> org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
>
> at
> org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)
>
> at
> org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)
>
> 02.09.2011 20:15:50
> com.sun.enterprise.connectors.service.ResourceAdapterAdminServiceImpl
> sendStopToResourceAdapter
> INFO: RAR7094: __xa_jdbc_ra shutdown successful.
> 02.09.2011 20:15:50
> com.sun.enterprise.connectors.service.ResourceAdapterAdminServiceImpl
> sendStopToResourceAdapter
> INFO: RAR7094: __ds_jdbc_ra shutdown successful.
> 02.09.2011 20:15:50 org.glassfish.admin.mbeanserver.JMXStartupService
> shutdown
> INFO: JMXStartupService and JMXConnectors have been shut down.
> 02.09.2011 20:15:50 org.glassfish.admin.mbeanserver.JMXStartupService
> shutdown
> INFO: JMXStartupService and JMXConnectors have been shut down.
> 02.09.2011 20:15:50 com.sun.enterprise.v3.server.AppServerStartup stop
> INFO: Shutdown procedure finished
> 02.09.2011 20:15:50 AppServerStartup run
> INFO: [Thread[GlassFish Kernel Main Thread,5,main]] exiting
>
> i found some issues reported in Jira but i dont know how to interpret
> them
> for my case :)
>
>
>
>
> --
>
> [Message sent by forum member 'chris.joelly']
>
> View Post: http://forums.java.net/node/839727
>
>