In my previous post I presented you BAR format which is usable with BatchEE CLI. This works fine with Spring, DeltaSpike CdiContainer and JSE stuff but not that well with EE containers which don’t know (yet?) this format.
That’s why BatchEE CLI can now support WAR format.
This mainly targets OpenEJB integration to be able to use CDI, EJBs, @Resource, JTA…without advanced custom (and to do ;)) hacks!
The idea is to package your batch as a WAR then deploy it in BatchEE CLI. To get OpenEJB feature you need to specify “openejb” lifecycle and openejb libraries folder.
This looks like:
$ ./bin/batchee start -lifecycle openejb -shared-libs /openejb/4.6.1/lib/ -archive /batch/simple-batch.war -name mybatch
Logs will look like:
janv. 19, 2014 8:40:19 PM org.apache.openejb.OpenEJB$Instance <init> Infos: ******************************************************************************** janv. 19, 2014 8:40:19 PM org.apache.openejb.OpenEJB$Instance <init> Infos: OpenEJB http://openejb.apache.org/ janv. 19, 2014 8:40:19 PM org.apache.openejb.OpenEJB$Instance <init> Infos: Startup: Sun Jan 19 20:40:19 CET 2014 janv. 19, 2014 8:40:19 PM org.apache.openejb.OpenEJB$Instance <init> Infos: Copyright 1999-2013 (C) Apache OpenEJB Project, All Rights Reserved. janv. 19, 2014 8:40:19 PM org.apache.openejb.OpenEJB$Instance <init> Infos: Version: 4.6.1-SNAPSHOT janv. 19, 2014 8:40:19 PM org.apache.openejb.OpenEJB$Instance <init> Infos: Build date: 20140119 janv. 19, 2014 8:40:19 PM org.apache.openejb.OpenEJB$Instance <init> Infos: Build time: 08:26 janv. 19, 2014 8:40:19 PM org.apache.openejb.OpenEJB$Instance <init> Infos: ******************************************************************************** janv. 19, 2014 8:40:19 PM org.apache.openejb.OpenEJB$Instance <init> Infos: openejb.home = D:\01__Romain-Dev\batchee-master\tools\cli\target\apache-batchee-0.1-incubating-SNAPSHOT janv. 19, 2014 8:40:19 PM org.apache.openejb.OpenEJB$Instance <init> Infos: openejb.base = D:\01__Romain-Dev\batchee-master\tools\cli\target\apache-batchee-0.1-incubating-SNAPSHOT janv. 19, 2014 8:40:19 PM org.apache.openejb.cdi.CdiBuilder initializeOWB Infos: Created new singletonService org.apache.openejb.cdi.ThreadSingletonServiceImpl@1357842 janv. 19, 2014 8:40:19 PM org.apache.openejb.cdi.CdiBuilder initializeOWB Infos: Succeeded in installing singleton service janv. 19, 2014 8:40:19 PM org.apache.openejb.config.ConfigurationFactory init Infos: openejb configuration file is 'D:\01__Romain-Dev\batchee-master\tools\cli\target\apache-batchee-0.1-incubating-SNAPSHOT\conf\openejb.xml' janv. 19, 2014 8:40:19 PM org.apache.openejb.config.ConfigurationFactory configureService Infos: Configuring Service(id=Default Security Service, type=SecurityService, provider-id=Default Security Service) janv. 19, 2014 8:40:19 PM org.apache.openejb.config.ConfigurationFactory configureService Infos: Configuring Service(id=Default Transaction Manager, type=TransactionManager, provider-id=Default Transaction Manager) janv. 19, 2014 8:40:19 PM org.apache.openejb.config.ConfigurationFactory configureService Infos: Configuring Service(id=My DataSource, type=Resource, provider-id=Default JDBC Database) janv. 19, 2014 8:40:19 PM org.apache.openejb.config.ConfigurationFactory configureService Infos: Configuring Service(id=My Unmanaged DataSource, type=Resource, provider-id=Default JDBC Database) janv. 19, 2014 8:40:19 PM org.apache.openejb.config.ConfigurationFactory configureService Infos: Configuring Service(id=My Singleton Container, type=Container, provider-id=Default Singleton Container) janv. 19, 2014 8:40:19 PM org.apache.openejb.config.ConfigurationFactory configureService Infos: Configuring Service(id=My Stateful Container, type=Container, provider-id=Default Stateful Container) janv. 19, 2014 8:40:19 PM org.apache.openejb.config.ConfigurationFactory configureService Infos: Configuring Service(id=My Stateless Container, type=Container, provider-id=Default Stateless Container) janv. 19, 2014 8:40:19 PM org.apache.openejb.util.OptionsLog info Infos: Using 'openejb.deployments.classpath=false' janv. 19, 2014 8:40:19 PM org.apache.openejb.assembler.classic.Assembler createRecipe Infos: Creating TransactionManager(id=Default Transaction Manager) janv. 19, 2014 8:40:19 PM org.apache.openejb.assembler.classic.Assembler createRecipe Infos: Creating SecurityService(id=Default Security Service) janv. 19, 2014 8:40:19 PM org.apache.openejb.assembler.classic.Assembler createRecipe Infos: Creating Resource(id=My DataSource) janv. 19, 2014 8:40:20 PM org.apache.openejb.assembler.classic.Assembler createRecipe Infos: Creating Resource(id=My Unmanaged DataSource) janv. 19, 2014 8:40:20 PM org.apache.openejb.assembler.classic.Assembler createRecipe Infos: Creating Container(id=My Singleton Container) janv. 19, 2014 8:40:20 PM org.apache.openejb.assembler.classic.Assembler createRecipe Infos: Creating Container(id=My Stateful Container) janv. 19, 2014 8:40:20 PM org.apache.openejb.core.stateful.SimplePassivater init Infos: Using directory D:\cygwin\tmp for stateful session passivation janv. 19, 2014 8:40:20 PM org.apache.openejb.assembler.classic.Assembler createRecipe Infos: Creating Container(id=My Stateless Container) janv. 19, 2014 8:40:21 PM org.apache.openejb.config.ConfigurationFactory configureApplication Infos: Configuring enterprise application: D:\cygwin\tmp\batchee\simple-batch-1.0-SNAPSHOT.war janv. 19, 2014 8:40:21 PM org.apache.openejb.config.ConfigurationFactory configureService Infos: Configuring Service(id=Default Managed Container, type=Container, provider-id=Default Managed Container) janv. 19, 2014 8:40:21 PM org.apache.openejb.config.AutoConfig createContainer Infos: Auto-creating a container for bean simple-batch-1.0-SNAPSHOT.Comp12836828: Container(type=MANAGED, id=Default Managed Container) janv. 19, 2014 8:40:21 PM org.apache.openejb.assembler.classic.Assembler createRecipe Infos: Creating Container(id=Default Managed Container) janv. 19, 2014 8:40:21 PM org.apache.openejb.core.managed.SimplePassivater init Infos: Using directory D:\cygwin\tmp for stateful session passivation janv. 19, 2014 8:40:21 PM org.apache.openejb.config.AppInfoBuilder build Infos: Enterprise application "D:\cygwin\tmp\batchee\simple-batch-1.0-SNAPSHOT.war" loaded. janv. 19, 2014 8:40:21 PM org.apache.openejb.assembler.classic.Assembler createApplication Infos: Assembling app: D:\cygwin\tmp\batchee\simple-batch-1.0-SNAPSHOT.war janv. 19, 2014 8:40:21 PM org.apache.openejb.cdi.CdiBuilder initSingleton Infos: Existing thread singleton service in SystemInstance(): org.apache.openejb.cdi.ThreadSingletonServiceImpl@1357842 janv. 19, 2014 8:40:21 PM org.apache.openejb.cdi.OpenEJBLifecycle startApplication Infos: OpenWebBeans Container is starting... janv. 19, 2014 8:40:21 PM org.apache.webbeans.plugins.PluginLoader startUp Infos: Adding OpenWebBeansPlugin : [CdiPlugin] janv. 19, 2014 8:40:21 PM org.apache.webbeans.config.BeansDeployer validateInjectionPoints Infos: All injection points were validated successfully. janv. 19, 2014 8:40:21 PM org.apache.openejb.cdi.OpenEJBLifecycle startApplication Infos: OpenWebBeans Container has started, it took 157 ms. janv. 19, 2014 8:40:21 PM org.apache.openejb.assembler.classic.Assembler createApplication Infos: Deployed Application(path=D:\cygwin\tmp\batchee\simple-batch-1.0-SNAPSHOT.war) ____ _ _ ______ ______ | _ \ | | | | | ____| ____| | |_) | __ _| |_ ___| |__ | |__ | |__ | _ < / _` | __/ __| '_ \| __| | __| | |_) | (_| | || (__| | | | |____| |____ |____/ \__,_|\__\___|_| |_|______|______|0.1-incubating-SNAPSHOT Admin mode deactivated, use -socket to activate it Batch 'mybatch' started with id #0 >>> Batch in progress...with CDI on! ========================= Batch status: COMPLETED Exit status: COMPLETED Duration: 0s ========================= janv. 19, 2014 8:40:22 PM org.apache.openejb.assembler.classic.Assembler destroyApplication Infos: Undeploying app: D:\cygwin\tmp\batchee\simple-batch-1.0-SNAPSHOT.war janv. 19, 2014 8:40:22 PM org.apache.openejb.util.ServiceManagerProxy stop Infos: Stopping network services janv. 19, 2014 8:40:22 PM org.apache.openejb.server.SimpleServiceManager stop Infos: Stopping server services janv. 19, 2014 8:40:22 PM org.apache.openejb.core.LocalInitialContext tearDownOpenEJB Infos: Destroying container system janv. 19, 2014 8:40:22 PM org.apache.openejb.assembler.classic.Assembler destroyResource Infos: Closing DataSource: My DataSource janv. 19, 2014 8:40:22 PM org.apache.openejb.assembler.classic.Assembler destroyResource Infos: Closing DataSource: My Unmanaged DataSource
This really makes “EE” batches finally easy to deploy and avoid to deploy a custom interface to start/stop/manage them.