SlideShare a Scribd company logo
Juggling Java EE with
Enterprise Apache Maven
Jesse McConnell -
jmcconnell@apache.org
Who Am I?
• On Maven PMC
• Active in Continuum
• Some maven plugins
• Some mojo plugins @ codehaus
– axistools-maven-plugin - don’t hold that against
me…pls
• Redback @ codehaus
Is this you?
Java EE Application
Development by Convention
• No laughing matter
• People cry everyday because of java ee
• Maven can help keep crying to a minimum
– hopefully
– Planning is key
Components of Java EE
• Enterprise Java Beans’s
– maven-ejb-plugin
• V. 2 and 3 specs
• Web Services
– axistools-maven-plugin
– cxf-maven-plugin
– others
• Web Archives (Wars)
– maven-war-plugin
• Enterprise Archives (Ears)
– maven-ear-plugin
You should end up with…
Maven Lifecycle
• Supported since the beginning with maven
2
• Java EE artifact linkage is managed through
dependencies
• Artifact construction dictated by <type/>
Understanding Structure in
Maven
• Follow Conventions
• Archiva and Continuum are good example
Web Applications
• Redback is security overlay packaged as a
Web Application and overlaid
Library Code
• Understanding the final goal and scoping
dependencies appropriately.
• That means…understand Java EE
classloaders
• Understand your Container
– Like to think they are all interchangeable
– Can be harder in practice
EJB Structure and Management
• <packaging>ejb</packaging>
• Directory Layout
|-- pom.xml
`-- src
`-- main
`-- resources
`-- META-INF
`-- ejb-jar.xml
EJB Structure and Management
• Plugin Example
<plugin>
<artifactId>maven-ejb-plugin</artifactId>
<configuration>
<generateClient>true</generateClient>
</configuration>
</plugin>
Linking into Build
• Validates ejb-jar.xml file existence
• Unless you specify ejbVersion 3.0
Testing EJB Code
• Best bet is testing modularly like with
normal junit testing.
• Otherwise test when in ear and under
typical ejb conditions
Web Service Structures and
Management
• No strict lifecycle phase
• No strict directory layout
• Depends on web service architecture in use
• xfire -> CXF, Axis, etc
• Code generation components
– wsdl2java
– java2wsdl
Linking into Build
• Consider services, clients, resource libraries
• Common project layout
• Annotations of services
– All kind of implementation specific
– Real deal is testing them
Testing Web Services
• Can be hard to test directly
• Client testing against established servers
begs irreproducibility
• Test by deploying services to embedded
jetty and running client code
War Structure and Management
<packaging>war</packaging>
Directory Layout
|-- pom.xml
`-- src
`-- main
|-- java
| `-- com
| `-- example
| `-- projects
| `-- SampleAction.java
|-- resources
| |-- images
| | `-- sampleimage.jpg
| `-- sampleresource
`-- webapp
|-- WEB-INF
| `-- web.xml
|-- index.jsp
`-- jsp
`-- websource.jsp
War Structure and Management
• Plugin Example
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>2.0</version>
<configuration>
<webappDirectory>/container/deploy/dir</webappDirectory>
</configuration>
</plugin>
War Overlay
• Often handy to build component oriented
wars.
• Overlay multiple war files to create actual
war file.
– Continuum and Archiva do this is redback for
shared security and user management bits
Linking into Build
• Dependency management scoping is key
• Dig into your war file and see what is in there
– Don’t be afraid, its doesn’t bite
• <scope>provided</scope> can be your friend
• Other Options:
– <warSourceExcludes>WEB-INF/lib/*.jar</warSourceExcludes>
Three different usages
• War:war - standard war creation
• War:exploded - builds out war in exploded
format in target dir
• War:inplace - builds out webapp in
src/main/webapp
• Dependency Management scoping key for
war usability
War Overlay I - Clean
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-clean-plugin</artifactId>
<version>2.1.1</version>
<!-- This configuration is added to cleanup from war:inplace -->
<configuration>
<filesets>
<fileset>
<directory>${basedir}/src/main/webapp</directory>
<includes>
<include>images/redback</include>
<!-- Images from other wars -->
<include>template/</include>
<!-- validation.js -->
<include>template/redback</include>
<!-- Templates from other wars -->
<include>WEB-INF/classes</include>
<!-- Classes and Resources from other wars -->
<include>WEB-INF/lib</include>
</includes>
</fileset>
</filesets>
</configuration>
</plugin>
War Overlay II - War
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>2.0.1</version>
<configuration>
<archiveClasses>false</archiveClasses>
<dependentWarExcludes>META-INF/**,WEB-INF/web.xml,WEB-INF/classes/xwork.xml,WEB-INF/lib/**
</dependentWarExcludes>
</configuration>
<executions>
<execution>
<phase>compile</phase>
<goals>
<!-- Needed to get the plexus-security war overlay to do its thing before jetty:run -->
<goal>inplace</goal>
</goals>
</execution>
</executions>
</plugin>
Jetty Configuration
<plugin>
<groupId>org.mortbay.jetty</groupId>
<artifactId>maven-jetty-plugin</artifactId>
<version>6.1.0</version>
<configuration>
<scanIntervalSeconds>10</scanIntervalSeconds>
<contextPath>/</contextPath>
<jettyEnvXml>${basedir}/src/jetty-env.xml</jettyEnvXml>
<connectors>
<connector implementation="org.mortbay.jetty.nio.SelectChannelConnector">
<port>9090</port>
<maxIdleTime>60000</maxIdleTime>
</connector>
</connectors>
</configuration>
<dependencies>
<dependency>
<groupId>org.apache.derby</groupId>
<artifactId>derby</artifactId>
<version>10.1.3.1</version>
</dependency>
</dependencies>
</plugin>
<systemProperties>
<systemProperty>
<name>appserver.base</name>
<value>${project.build.directory}/appserver-base</value>
</systemProperty>
<systemProperty>
<name>appserver.home</name>
<value>${project.build.directory}/appserver-home</value>
</systemProperty>
<systemProperty>
<name>derby.system.home</name>
<value>${project.build.directory}/appserver-base/logs</value>
</systemProperty>
</systemProperties>
Testing Wars I
• jetty-maven-plugin for ‘click testing’
– mvn jetty:run
• Integration testing a bit more involved…
TestingWars II
• generate-resources
– dependency-maven-plugin
• Unzip the webapp
• Prepare provided dependencies
• package
– maven-antrun-plugin
• Copy container configuration
• Copy provided dependencies
• pre-integration-test
– selenium-maven-plugin
• Start server
– cargo-maven2-plugin
• Start container
• integration-test
– maven-antrun-plugin
• Check continuum started
– maven-surefire-plugin
• Run tests
• Post-integration-test
– Cargo-maven2-plugin
• Stop container
Scoping War Dependencies
• Two Approaches, different scoping
– Deploying Wars
– Integrating into Ears
Ear Structure and Management
• Directory Layout
– No specific directories required
– Dependencies are key to ear files
• Automatic application.xml creation
• MANIFEST.MF Creation
Ear Structure and Management
• Plugin Example
<plugin>
<artifactId>maven-ear-plugin</artifactId>
<configuration>
<archive>
<manifest>
<addClasspath>true</addClasspath>
</manifest>
</archive>
</configuration>
</plugin>
Linking into Build
• Just do it…
• Then triage.
• Primary recommendation, keep your
project modular
• Test your modules
• Use ear module as simply the
aggregation of the project
• packaging
Supported Ear Modules
• ejb3Module - ejb3 (Enterprise Java Bean version 3)
• ejbClientModule - ejb-client (Enterprise Java Bean Client)
• ejbModule - ejb (Enterprise Java Bean)
• jarModule - jar (Java Archive)
• harModule - har (Hibernate Archive)
• parModule - par (Plexus Archive)
• rarModule - rar (Resource Adapter Archive)
• sarModule - sar (JBoss Service Archive)
• webModule - war (Web Application Archive)
• wsrModule - wsr (JBoss Web Service Archive)
Testing Ears
• Functionally the same kind of process as the
war integration testing
• use cargo
– Bind start app server to pre-integration-test
phase
– Start Selenium server
– Run any surefire tests
– Bind stop app server to post-integration-test
Scoping Ear Dependencies
• Learn Dependency Management in parent poms
– Love it
• Plan for ear deployment, scope things that are
used by multiple war and ejb’s as provided or test
in those poms
• Scope for inclusion in ear, leave versioning to the
dependencyManagement, its why it is there
Application Deployment
Options
• Cargo - cargo.codehaus.org
– Supported containers
• Geronimo 1.x - geronimo1x
• JBoss 3.x, 4.x - jboss3x, jboss4x
• Jetty 4.x, 5.x, 6.x - jetty4x, jetty5x, jetty6x
• jo! 1.x - jo1x
• OC4J 9.x - oc4j9x
• Orion 1.x, 2.x - orion1x, orion2x
• Resin 2.x, 3.x - resin2x, resin3x
• Tomcat 3.x, 4.x, 5.x - tomcat3x, tomcat4x, tomcat5x
• WebLogic 8.x - weblogic8x
– Maven2 plugin support
• Deployment area largely untargeted by maven conventions
• Hard to standardize in real world
Tips and Tricks
• Got a 300meg ear file?
– Check the scoping
– Pull apart the artifacts and look for jar
duplication
– Understand Java EE classloaders
Tips and Tricks II
<build>
<plugins>
<plugin>
<artifactId>maven-ejb-plugin</artifactId>
<configuration>
<ejbVersion>3.0</ejbVersion>
<classifier>${server.type}</classifier>
</configuration>
</plugin>
</plugins>
</build>
<profiles>
<profile>
<id>prod</id>
<properties>
<ejb.jdbc.url>jdbc:odbc:prod;UID=prod;PWD=p4ssw0rd</ejb.jdbc.url>
<server.type>prod</server.type>
</properties>
</profile>
<profile>
<id>test</id>
<properties>
<ejb.jdbc.url>jdbc:odbc:test;UID=test;PWD=p4ssw0rd</ejb.jdbc.url>
<server.type>test</server.type>
</properties>
</profile>
<profile>
<id>dev</id>
<properties>
<ejb.jdbc.url>jdbc:derby:dev</ejb.jdbc.url>
<server.type>dev</server.type>
</properties>
</profile>
</profiles>
Using Archetypes
• maven-archetype-j2ee-simple
– Sample aggregate project
• Geronimo sample archetypes
• Many jetty sample archetypes
– http://www.webtide.com/resources.jsp
Questions?
• Jesse McConnell - jmcconnell@apache.org
• Resources
– Better Builds with Maven
– Maven: The Definitive Guide

More Related Content

What's hot

Learning Maven by Example
Learning Maven by ExampleLearning Maven by Example
Learning Maven by Example
Hsi-Kai Wang
 
Maven for Dummies
Maven for DummiesMaven for Dummies
Maven for Dummies
Tomer Gabel
 
Introduction to Maven
Introduction to MavenIntroduction to Maven
Introduction to Maven
Onkar Deshpande
 
Liferay maven sdk
Liferay maven sdkLiferay maven sdk
Liferay maven sdk
Mika Koivisto
 
Maven
MavenMaven
Maven tutorial
Maven tutorialMaven tutorial
Maven tutorial
Dragos Balan
 
Note - Apache Maven Intro
Note - Apache Maven IntroNote - Apache Maven Intro
Note - Apache Maven Intro
boyw165
 
Maven Introduction
Maven IntroductionMaven Introduction
Maven Introduction
Sandeep Chawla
 
MyFaces CODI Conversations
MyFaces CODI ConversationsMyFaces CODI Conversations
MyFaces CODI Conversations
os890
 
Wsadminlib.wasug.2011 0125-0726
Wsadminlib.wasug.2011 0125-0726Wsadminlib.wasug.2011 0125-0726
Wsadminlib.wasug.2011 0125-0726
Rohit Kelapure
 
Maven Overview
Maven OverviewMaven Overview
Maven Overview
FastConnect
 
Clustering Multiple Instances in Cold Fusion
Clustering Multiple Instances in Cold FusionClustering Multiple Instances in Cold Fusion
Clustering Multiple Instances in Cold Fusion
Mindfire Solutions
 
Использование maven для сборки больших модульных c++ проектов на примере Odin...
Использование maven для сборки больших модульных c++ проектов на примере Odin...Использование maven для сборки больших модульных c++ проектов на примере Odin...
Использование maven для сборки больших модульных c++ проектов на примере Odin...
Platonov Sergey
 
Maven ppt
Maven pptMaven ppt
Maven ppt
natashasweety7
 
Make JSF more type-safe with CDI and MyFaces CODI
Make JSF more type-safe with CDI and MyFaces CODIMake JSF more type-safe with CDI and MyFaces CODI
Make JSF more type-safe with CDI and MyFaces CODI
os890
 
Apache DeltaSpike
Apache DeltaSpikeApache DeltaSpike
Apache DeltaSpike
os890
 
Maven Basics - Explained
Maven Basics - ExplainedMaven Basics - Explained
Maven Basics - Explained
Smita Prasad
 
Introduction to selenium_grid_workshop
Introduction to selenium_grid_workshopIntroduction to selenium_grid_workshop
Introduction to selenium_grid_workshop
seleniumconf
 
Configuring CQ Security
Configuring CQ SecurityConfiguring CQ Security
Configuring CQ Security
connectwebex
 

What's hot (19)

Learning Maven by Example
Learning Maven by ExampleLearning Maven by Example
Learning Maven by Example
 
Maven for Dummies
Maven for DummiesMaven for Dummies
Maven for Dummies
 
Introduction to Maven
Introduction to MavenIntroduction to Maven
Introduction to Maven
 
Liferay maven sdk
Liferay maven sdkLiferay maven sdk
Liferay maven sdk
 
Maven
MavenMaven
Maven
 
Maven tutorial
Maven tutorialMaven tutorial
Maven tutorial
 
Note - Apache Maven Intro
Note - Apache Maven IntroNote - Apache Maven Intro
Note - Apache Maven Intro
 
Maven Introduction
Maven IntroductionMaven Introduction
Maven Introduction
 
MyFaces CODI Conversations
MyFaces CODI ConversationsMyFaces CODI Conversations
MyFaces CODI Conversations
 
Wsadminlib.wasug.2011 0125-0726
Wsadminlib.wasug.2011 0125-0726Wsadminlib.wasug.2011 0125-0726
Wsadminlib.wasug.2011 0125-0726
 
Maven Overview
Maven OverviewMaven Overview
Maven Overview
 
Clustering Multiple Instances in Cold Fusion
Clustering Multiple Instances in Cold FusionClustering Multiple Instances in Cold Fusion
Clustering Multiple Instances in Cold Fusion
 
Использование maven для сборки больших модульных c++ проектов на примере Odin...
Использование maven для сборки больших модульных c++ проектов на примере Odin...Использование maven для сборки больших модульных c++ проектов на примере Odin...
Использование maven для сборки больших модульных c++ проектов на примере Odin...
 
Maven ppt
Maven pptMaven ppt
Maven ppt
 
Make JSF more type-safe with CDI and MyFaces CODI
Make JSF more type-safe with CDI and MyFaces CODIMake JSF more type-safe with CDI and MyFaces CODI
Make JSF more type-safe with CDI and MyFaces CODI
 
Apache DeltaSpike
Apache DeltaSpikeApache DeltaSpike
Apache DeltaSpike
 
Maven Basics - Explained
Maven Basics - ExplainedMaven Basics - Explained
Maven Basics - Explained
 
Introduction to selenium_grid_workshop
Introduction to selenium_grid_workshopIntroduction to selenium_grid_workshop
Introduction to selenium_grid_workshop
 
Configuring CQ Security
Configuring CQ SecurityConfiguring CQ Security
Configuring CQ Security
 

Similar to Juggling Java EE with Enterprise Apache Maven

Maven introduction in Mule
Maven introduction in MuleMaven introduction in Mule
Maven introduction in Mule
Shahid Shaik
 
Maven
MavenMaven
Maven in Mule
Maven in MuleMaven in Mule
Maven in Mule
Anand kalla
 
Embrace Maven
Embrace MavenEmbrace Maven
Embrace Maven
Guy Marom
 
Intelligent Projects with Maven - DevFest Istanbul
Intelligent Projects with Maven - DevFest IstanbulIntelligent Projects with Maven - DevFest Istanbul
Intelligent Projects with Maven - DevFest Istanbul
Mert Çalışkan
 
4 maven junit
4 maven junit4 maven junit
4 maven junit
Honnix Liang
 
Introduction tomaven
Introduction tomavenIntroduction tomaven
Introduction tomaven
Manav Prasad
 
Developing Liferay Plugins with Maven
Developing Liferay Plugins with MavenDeveloping Liferay Plugins with Maven
Developing Liferay Plugins with Maven
Mika Koivisto
 
Maven
MavenMaven
Maven
javeed_mhd
 
Maven
MavenMaven
Ci jenkins maven svn
Ci jenkins maven svnCi jenkins maven svn
Ci jenkins maven svn
Ankur Goyal
 
Maven
MavenMaven
Maven
Shraddha
 
Jakarta EE Test Strategies (2022)
Jakarta EE Test Strategies (2022)Jakarta EE Test Strategies (2022)
Jakarta EE Test Strategies (2022)
Ryan Cuprak
 
Training in Android with Maven
Training in Android with MavenTraining in Android with Maven
Training in Android with Maven
Arcadian Learning
 
Jenkins advance topic
Jenkins advance topicJenkins advance topic
Jenkins advance topic
Gourav Varma
 
II - Angular.js app structure
II - Angular.js app structureII - Angular.js app structure
II - Angular.js app structure
WebF
 
MyFaces CODI and JBoss Seam3 become Apache DeltaSpike
MyFaces CODI and JBoss Seam3 become Apache DeltaSpikeMyFaces CODI and JBoss Seam3 become Apache DeltaSpike
MyFaces CODI and JBoss Seam3 become Apache DeltaSpike
os890
 
Version Control and Continuous Integration
Version Control and Continuous IntegrationVersion Control and Continuous Integration
Version Control and Continuous Integration
Geff Henderson Chang
 
Chris OBrien - Pitfalls when developing with the SharePoint Framework (SPFx)
Chris OBrien - Pitfalls when developing with the SharePoint Framework (SPFx)Chris OBrien - Pitfalls when developing with the SharePoint Framework (SPFx)
Chris OBrien - Pitfalls when developing with the SharePoint Framework (SPFx)
Chris O'Brien
 
Maven
MavenMaven

Similar to Juggling Java EE with Enterprise Apache Maven (20)

Maven introduction in Mule
Maven introduction in MuleMaven introduction in Mule
Maven introduction in Mule
 
Maven
MavenMaven
Maven
 
Maven in Mule
Maven in MuleMaven in Mule
Maven in Mule
 
Embrace Maven
Embrace MavenEmbrace Maven
Embrace Maven
 
Intelligent Projects with Maven - DevFest Istanbul
Intelligent Projects with Maven - DevFest IstanbulIntelligent Projects with Maven - DevFest Istanbul
Intelligent Projects with Maven - DevFest Istanbul
 
4 maven junit
4 maven junit4 maven junit
4 maven junit
 
Introduction tomaven
Introduction tomavenIntroduction tomaven
Introduction tomaven
 
Developing Liferay Plugins with Maven
Developing Liferay Plugins with MavenDeveloping Liferay Plugins with Maven
Developing Liferay Plugins with Maven
 
Maven
MavenMaven
Maven
 
Maven
MavenMaven
Maven
 
Ci jenkins maven svn
Ci jenkins maven svnCi jenkins maven svn
Ci jenkins maven svn
 
Maven
MavenMaven
Maven
 
Jakarta EE Test Strategies (2022)
Jakarta EE Test Strategies (2022)Jakarta EE Test Strategies (2022)
Jakarta EE Test Strategies (2022)
 
Training in Android with Maven
Training in Android with MavenTraining in Android with Maven
Training in Android with Maven
 
Jenkins advance topic
Jenkins advance topicJenkins advance topic
Jenkins advance topic
 
II - Angular.js app structure
II - Angular.js app structureII - Angular.js app structure
II - Angular.js app structure
 
MyFaces CODI and JBoss Seam3 become Apache DeltaSpike
MyFaces CODI and JBoss Seam3 become Apache DeltaSpikeMyFaces CODI and JBoss Seam3 become Apache DeltaSpike
MyFaces CODI and JBoss Seam3 become Apache DeltaSpike
 
Version Control and Continuous Integration
Version Control and Continuous IntegrationVersion Control and Continuous Integration
Version Control and Continuous Integration
 
Chris OBrien - Pitfalls when developing with the SharePoint Framework (SPFx)
Chris OBrien - Pitfalls when developing with the SharePoint Framework (SPFx)Chris OBrien - Pitfalls when developing with the SharePoint Framework (SPFx)
Chris OBrien - Pitfalls when developing with the SharePoint Framework (SPFx)
 
Maven
MavenMaven
Maven
 

More from elliando dias

Clojurescript slides
Clojurescript slidesClojurescript slides
Clojurescript slides
elliando dias
 
Why you should be excited about ClojureScript
Why you should be excited about ClojureScriptWhy you should be excited about ClojureScript
Why you should be excited about ClojureScript
elliando dias
 
Functional Programming with Immutable Data Structures
Functional Programming with Immutable Data StructuresFunctional Programming with Immutable Data Structures
Functional Programming with Immutable Data Structures
elliando dias
 
Nomenclatura e peças de container
Nomenclatura  e peças de containerNomenclatura  e peças de container
Nomenclatura e peças de container
elliando dias
 
Geometria Projetiva
Geometria ProjetivaGeometria Projetiva
Geometria Projetiva
elliando dias
 
Polyglot and Poly-paradigm Programming for Better Agility
Polyglot and Poly-paradigm Programming for Better AgilityPolyglot and Poly-paradigm Programming for Better Agility
Polyglot and Poly-paradigm Programming for Better Agility
elliando dias
 
Javascript Libraries
Javascript LibrariesJavascript Libraries
Javascript Libraries
elliando dias
 
How to Make an Eight Bit Computer and Save the World!
How to Make an Eight Bit Computer and Save the World!How to Make an Eight Bit Computer and Save the World!
How to Make an Eight Bit Computer and Save the World!
elliando dias
 
Ragel talk
Ragel talkRagel talk
Ragel talk
elliando dias
 
A Practical Guide to Connecting Hardware to the Web
A Practical Guide to Connecting Hardware to the WebA Practical Guide to Connecting Hardware to the Web
A Practical Guide to Connecting Hardware to the Web
elliando dias
 
Introdução ao Arduino
Introdução ao ArduinoIntrodução ao Arduino
Introdução ao Arduino
elliando dias
 
Minicurso arduino
Minicurso arduinoMinicurso arduino
Minicurso arduino
elliando dias
 
Incanter Data Sorcery
Incanter Data SorceryIncanter Data Sorcery
Incanter Data Sorcery
elliando dias
 
Rango
RangoRango
Fab.in.a.box - Fab Academy: Machine Design
Fab.in.a.box - Fab Academy: Machine DesignFab.in.a.box - Fab Academy: Machine Design
Fab.in.a.box - Fab Academy: Machine Design
elliando dias
 
The Digital Revolution: Machines that makes
The Digital Revolution: Machines that makesThe Digital Revolution: Machines that makes
The Digital Revolution: Machines that makes
elliando dias
 
Hadoop + Clojure
Hadoop + ClojureHadoop + Clojure
Hadoop + Clojure
elliando dias
 
Hadoop - Simple. Scalable.
Hadoop - Simple. Scalable.Hadoop - Simple. Scalable.
Hadoop - Simple. Scalable.
elliando dias
 
Hadoop and Hive Development at Facebook
Hadoop and Hive Development at FacebookHadoop and Hive Development at Facebook
Hadoop and Hive Development at Facebook
elliando dias
 
Multi-core Parallelization in Clojure - a Case Study
Multi-core Parallelization in Clojure - a Case StudyMulti-core Parallelization in Clojure - a Case Study
Multi-core Parallelization in Clojure - a Case Study
elliando dias
 

More from elliando dias (20)

Clojurescript slides
Clojurescript slidesClojurescript slides
Clojurescript slides
 
Why you should be excited about ClojureScript
Why you should be excited about ClojureScriptWhy you should be excited about ClojureScript
Why you should be excited about ClojureScript
 
Functional Programming with Immutable Data Structures
Functional Programming with Immutable Data StructuresFunctional Programming with Immutable Data Structures
Functional Programming with Immutable Data Structures
 
Nomenclatura e peças de container
Nomenclatura  e peças de containerNomenclatura  e peças de container
Nomenclatura e peças de container
 
Geometria Projetiva
Geometria ProjetivaGeometria Projetiva
Geometria Projetiva
 
Polyglot and Poly-paradigm Programming for Better Agility
Polyglot and Poly-paradigm Programming for Better AgilityPolyglot and Poly-paradigm Programming for Better Agility
Polyglot and Poly-paradigm Programming for Better Agility
 
Javascript Libraries
Javascript LibrariesJavascript Libraries
Javascript Libraries
 
How to Make an Eight Bit Computer and Save the World!
How to Make an Eight Bit Computer and Save the World!How to Make an Eight Bit Computer and Save the World!
How to Make an Eight Bit Computer and Save the World!
 
Ragel talk
Ragel talkRagel talk
Ragel talk
 
A Practical Guide to Connecting Hardware to the Web
A Practical Guide to Connecting Hardware to the WebA Practical Guide to Connecting Hardware to the Web
A Practical Guide to Connecting Hardware to the Web
 
Introdução ao Arduino
Introdução ao ArduinoIntrodução ao Arduino
Introdução ao Arduino
 
Minicurso arduino
Minicurso arduinoMinicurso arduino
Minicurso arduino
 
Incanter Data Sorcery
Incanter Data SorceryIncanter Data Sorcery
Incanter Data Sorcery
 
Rango
RangoRango
Rango
 
Fab.in.a.box - Fab Academy: Machine Design
Fab.in.a.box - Fab Academy: Machine DesignFab.in.a.box - Fab Academy: Machine Design
Fab.in.a.box - Fab Academy: Machine Design
 
The Digital Revolution: Machines that makes
The Digital Revolution: Machines that makesThe Digital Revolution: Machines that makes
The Digital Revolution: Machines that makes
 
Hadoop + Clojure
Hadoop + ClojureHadoop + Clojure
Hadoop + Clojure
 
Hadoop - Simple. Scalable.
Hadoop - Simple. Scalable.Hadoop - Simple. Scalable.
Hadoop - Simple. Scalable.
 
Hadoop and Hive Development at Facebook
Hadoop and Hive Development at FacebookHadoop and Hive Development at Facebook
Hadoop and Hive Development at Facebook
 
Multi-core Parallelization in Clojure - a Case Study
Multi-core Parallelization in Clojure - a Case StudyMulti-core Parallelization in Clojure - a Case Study
Multi-core Parallelization in Clojure - a Case Study
 

Recently uploaded

Northern Engraving | Modern Metal Trim, Nameplates and Appliance Panels
Northern Engraving | Modern Metal Trim, Nameplates and Appliance PanelsNorthern Engraving | Modern Metal Trim, Nameplates and Appliance Panels
Northern Engraving | Modern Metal Trim, Nameplates and Appliance Panels
Northern Engraving
 
Connector Corner: Seamlessly power UiPath Apps, GenAI with prebuilt connectors
Connector Corner: Seamlessly power UiPath Apps, GenAI with prebuilt connectorsConnector Corner: Seamlessly power UiPath Apps, GenAI with prebuilt connectors
Connector Corner: Seamlessly power UiPath Apps, GenAI with prebuilt connectors
DianaGray10
 
Freshworks Rethinks NoSQL for Rapid Scaling & Cost-Efficiency
Freshworks Rethinks NoSQL for Rapid Scaling & Cost-EfficiencyFreshworks Rethinks NoSQL for Rapid Scaling & Cost-Efficiency
Freshworks Rethinks NoSQL for Rapid Scaling & Cost-Efficiency
ScyllaDB
 
inQuba Webinar Mastering Customer Journey Management with Dr Graham Hill
inQuba Webinar Mastering Customer Journey Management with Dr Graham HillinQuba Webinar Mastering Customer Journey Management with Dr Graham Hill
inQuba Webinar Mastering Customer Journey Management with Dr Graham Hill
LizaNolte
 
PRODUCT LISTING OPTIMIZATION PRESENTATION.pptx
PRODUCT LISTING OPTIMIZATION PRESENTATION.pptxPRODUCT LISTING OPTIMIZATION PRESENTATION.pptx
PRODUCT LISTING OPTIMIZATION PRESENTATION.pptx
christinelarrosa
 
LF Energy Webinar: Carbon Data Specifications: Mechanisms to Improve Data Acc...
LF Energy Webinar: Carbon Data Specifications: Mechanisms to Improve Data Acc...LF Energy Webinar: Carbon Data Specifications: Mechanisms to Improve Data Acc...
LF Energy Webinar: Carbon Data Specifications: Mechanisms to Improve Data Acc...
DanBrown980551
 
Your One-Stop Shop for Python Success: Top 10 US Python Development Providers
Your One-Stop Shop for Python Success: Top 10 US Python Development ProvidersYour One-Stop Shop for Python Success: Top 10 US Python Development Providers
Your One-Stop Shop for Python Success: Top 10 US Python Development Providers
akankshawande
 
5th LF Energy Power Grid Model Meet-up Slides
5th LF Energy Power Grid Model Meet-up Slides5th LF Energy Power Grid Model Meet-up Slides
5th LF Energy Power Grid Model Meet-up Slides
DanBrown980551
 
Taking AI to the Next Level in Manufacturing.pdf
Taking AI to the Next Level in Manufacturing.pdfTaking AI to the Next Level in Manufacturing.pdf
Taking AI to the Next Level in Manufacturing.pdf
ssuserfac0301
 
Choosing The Best AWS Service For Your Website + API.pptx
Choosing The Best AWS Service For Your Website + API.pptxChoosing The Best AWS Service For Your Website + API.pptx
Choosing The Best AWS Service For Your Website + API.pptx
Brandon Minnick, MBA
 
Skybuffer SAM4U tool for SAP license adoption
Skybuffer SAM4U tool for SAP license adoptionSkybuffer SAM4U tool for SAP license adoption
Skybuffer SAM4U tool for SAP license adoption
Tatiana Kojar
 
AppSec PNW: Android and iOS Application Security with MobSF
AppSec PNW: Android and iOS Application Security with MobSFAppSec PNW: Android and iOS Application Security with MobSF
AppSec PNW: Android and iOS Application Security with MobSF
Ajin Abraham
 
"Frontline Battles with DDoS: Best practices and Lessons Learned", Igor Ivaniuk
"Frontline Battles with DDoS: Best practices and Lessons Learned",  Igor Ivaniuk"Frontline Battles with DDoS: Best practices and Lessons Learned",  Igor Ivaniuk
"Frontline Battles with DDoS: Best practices and Lessons Learned", Igor Ivaniuk
Fwdays
 
Northern Engraving | Nameplate Manufacturing Process - 2024
Northern Engraving | Nameplate Manufacturing Process - 2024Northern Engraving | Nameplate Manufacturing Process - 2024
Northern Engraving | Nameplate Manufacturing Process - 2024
Northern Engraving
 
Must Know Postgres Extension for DBA and Developer during Migration
Must Know Postgres Extension for DBA and Developer during MigrationMust Know Postgres Extension for DBA and Developer during Migration
Must Know Postgres Extension for DBA and Developer during Migration
Mydbops
 
[OReilly Superstream] Occupy the Space: A grassroots guide to engineering (an...
[OReilly Superstream] Occupy the Space: A grassroots guide to engineering (an...[OReilly Superstream] Occupy the Space: A grassroots guide to engineering (an...
[OReilly Superstream] Occupy the Space: A grassroots guide to engineering (an...
Jason Yip
 
Mutation Testing for Task-Oriented Chatbots
Mutation Testing for Task-Oriented ChatbotsMutation Testing for Task-Oriented Chatbots
Mutation Testing for Task-Oriented Chatbots
Pablo Gómez Abajo
 
Overcoming the PLG Trap: Lessons from Canva's Head of Sales & Head of EMEA Da...
Overcoming the PLG Trap: Lessons from Canva's Head of Sales & Head of EMEA Da...Overcoming the PLG Trap: Lessons from Canva's Head of Sales & Head of EMEA Da...
Overcoming the PLG Trap: Lessons from Canva's Head of Sales & Head of EMEA Da...
saastr
 
"Scaling RAG Applications to serve millions of users", Kevin Goedecke
"Scaling RAG Applications to serve millions of users",  Kevin Goedecke"Scaling RAG Applications to serve millions of users",  Kevin Goedecke
"Scaling RAG Applications to serve millions of users", Kevin Goedecke
Fwdays
 
Introduction of Cybersecurity with OSS at Code Europe 2024
Introduction of Cybersecurity with OSS  at Code Europe 2024Introduction of Cybersecurity with OSS  at Code Europe 2024
Introduction of Cybersecurity with OSS at Code Europe 2024
Hiroshi SHIBATA
 

Recently uploaded (20)

Northern Engraving | Modern Metal Trim, Nameplates and Appliance Panels
Northern Engraving | Modern Metal Trim, Nameplates and Appliance PanelsNorthern Engraving | Modern Metal Trim, Nameplates and Appliance Panels
Northern Engraving | Modern Metal Trim, Nameplates and Appliance Panels
 
Connector Corner: Seamlessly power UiPath Apps, GenAI with prebuilt connectors
Connector Corner: Seamlessly power UiPath Apps, GenAI with prebuilt connectorsConnector Corner: Seamlessly power UiPath Apps, GenAI with prebuilt connectors
Connector Corner: Seamlessly power UiPath Apps, GenAI with prebuilt connectors
 
Freshworks Rethinks NoSQL for Rapid Scaling & Cost-Efficiency
Freshworks Rethinks NoSQL for Rapid Scaling & Cost-EfficiencyFreshworks Rethinks NoSQL for Rapid Scaling & Cost-Efficiency
Freshworks Rethinks NoSQL for Rapid Scaling & Cost-Efficiency
 
inQuba Webinar Mastering Customer Journey Management with Dr Graham Hill
inQuba Webinar Mastering Customer Journey Management with Dr Graham HillinQuba Webinar Mastering Customer Journey Management with Dr Graham Hill
inQuba Webinar Mastering Customer Journey Management with Dr Graham Hill
 
PRODUCT LISTING OPTIMIZATION PRESENTATION.pptx
PRODUCT LISTING OPTIMIZATION PRESENTATION.pptxPRODUCT LISTING OPTIMIZATION PRESENTATION.pptx
PRODUCT LISTING OPTIMIZATION PRESENTATION.pptx
 
LF Energy Webinar: Carbon Data Specifications: Mechanisms to Improve Data Acc...
LF Energy Webinar: Carbon Data Specifications: Mechanisms to Improve Data Acc...LF Energy Webinar: Carbon Data Specifications: Mechanisms to Improve Data Acc...
LF Energy Webinar: Carbon Data Specifications: Mechanisms to Improve Data Acc...
 
Your One-Stop Shop for Python Success: Top 10 US Python Development Providers
Your One-Stop Shop for Python Success: Top 10 US Python Development ProvidersYour One-Stop Shop for Python Success: Top 10 US Python Development Providers
Your One-Stop Shop for Python Success: Top 10 US Python Development Providers
 
5th LF Energy Power Grid Model Meet-up Slides
5th LF Energy Power Grid Model Meet-up Slides5th LF Energy Power Grid Model Meet-up Slides
5th LF Energy Power Grid Model Meet-up Slides
 
Taking AI to the Next Level in Manufacturing.pdf
Taking AI to the Next Level in Manufacturing.pdfTaking AI to the Next Level in Manufacturing.pdf
Taking AI to the Next Level in Manufacturing.pdf
 
Choosing The Best AWS Service For Your Website + API.pptx
Choosing The Best AWS Service For Your Website + API.pptxChoosing The Best AWS Service For Your Website + API.pptx
Choosing The Best AWS Service For Your Website + API.pptx
 
Skybuffer SAM4U tool for SAP license adoption
Skybuffer SAM4U tool for SAP license adoptionSkybuffer SAM4U tool for SAP license adoption
Skybuffer SAM4U tool for SAP license adoption
 
AppSec PNW: Android and iOS Application Security with MobSF
AppSec PNW: Android and iOS Application Security with MobSFAppSec PNW: Android and iOS Application Security with MobSF
AppSec PNW: Android and iOS Application Security with MobSF
 
"Frontline Battles with DDoS: Best practices and Lessons Learned", Igor Ivaniuk
"Frontline Battles with DDoS: Best practices and Lessons Learned",  Igor Ivaniuk"Frontline Battles with DDoS: Best practices and Lessons Learned",  Igor Ivaniuk
"Frontline Battles with DDoS: Best practices and Lessons Learned", Igor Ivaniuk
 
Northern Engraving | Nameplate Manufacturing Process - 2024
Northern Engraving | Nameplate Manufacturing Process - 2024Northern Engraving | Nameplate Manufacturing Process - 2024
Northern Engraving | Nameplate Manufacturing Process - 2024
 
Must Know Postgres Extension for DBA and Developer during Migration
Must Know Postgres Extension for DBA and Developer during MigrationMust Know Postgres Extension for DBA and Developer during Migration
Must Know Postgres Extension for DBA and Developer during Migration
 
[OReilly Superstream] Occupy the Space: A grassroots guide to engineering (an...
[OReilly Superstream] Occupy the Space: A grassroots guide to engineering (an...[OReilly Superstream] Occupy the Space: A grassroots guide to engineering (an...
[OReilly Superstream] Occupy the Space: A grassroots guide to engineering (an...
 
Mutation Testing for Task-Oriented Chatbots
Mutation Testing for Task-Oriented ChatbotsMutation Testing for Task-Oriented Chatbots
Mutation Testing for Task-Oriented Chatbots
 
Overcoming the PLG Trap: Lessons from Canva's Head of Sales & Head of EMEA Da...
Overcoming the PLG Trap: Lessons from Canva's Head of Sales & Head of EMEA Da...Overcoming the PLG Trap: Lessons from Canva's Head of Sales & Head of EMEA Da...
Overcoming the PLG Trap: Lessons from Canva's Head of Sales & Head of EMEA Da...
 
"Scaling RAG Applications to serve millions of users", Kevin Goedecke
"Scaling RAG Applications to serve millions of users",  Kevin Goedecke"Scaling RAG Applications to serve millions of users",  Kevin Goedecke
"Scaling RAG Applications to serve millions of users", Kevin Goedecke
 
Introduction of Cybersecurity with OSS at Code Europe 2024
Introduction of Cybersecurity with OSS  at Code Europe 2024Introduction of Cybersecurity with OSS  at Code Europe 2024
Introduction of Cybersecurity with OSS at Code Europe 2024
 

Juggling Java EE with Enterprise Apache Maven

  • 1. Juggling Java EE with Enterprise Apache Maven Jesse McConnell - jmcconnell@apache.org
  • 2. Who Am I? • On Maven PMC • Active in Continuum • Some maven plugins • Some mojo plugins @ codehaus – axistools-maven-plugin - don’t hold that against me…pls • Redback @ codehaus
  • 4. Java EE Application Development by Convention • No laughing matter • People cry everyday because of java ee • Maven can help keep crying to a minimum – hopefully – Planning is key
  • 5. Components of Java EE • Enterprise Java Beans’s – maven-ejb-plugin • V. 2 and 3 specs • Web Services – axistools-maven-plugin – cxf-maven-plugin – others • Web Archives (Wars) – maven-war-plugin • Enterprise Archives (Ears) – maven-ear-plugin
  • 6. You should end up with…
  • 7. Maven Lifecycle • Supported since the beginning with maven 2 • Java EE artifact linkage is managed through dependencies • Artifact construction dictated by <type/>
  • 8. Understanding Structure in Maven • Follow Conventions • Archiva and Continuum are good example Web Applications • Redback is security overlay packaged as a Web Application and overlaid
  • 9. Library Code • Understanding the final goal and scoping dependencies appropriately. • That means…understand Java EE classloaders • Understand your Container – Like to think they are all interchangeable – Can be harder in practice
  • 10. EJB Structure and Management • <packaging>ejb</packaging> • Directory Layout |-- pom.xml `-- src `-- main `-- resources `-- META-INF `-- ejb-jar.xml
  • 11. EJB Structure and Management • Plugin Example <plugin> <artifactId>maven-ejb-plugin</artifactId> <configuration> <generateClient>true</generateClient> </configuration> </plugin>
  • 12. Linking into Build • Validates ejb-jar.xml file existence • Unless you specify ejbVersion 3.0
  • 13. Testing EJB Code • Best bet is testing modularly like with normal junit testing. • Otherwise test when in ear and under typical ejb conditions
  • 14. Web Service Structures and Management • No strict lifecycle phase • No strict directory layout • Depends on web service architecture in use • xfire -> CXF, Axis, etc • Code generation components – wsdl2java – java2wsdl
  • 15. Linking into Build • Consider services, clients, resource libraries • Common project layout • Annotations of services – All kind of implementation specific – Real deal is testing them
  • 16. Testing Web Services • Can be hard to test directly • Client testing against established servers begs irreproducibility • Test by deploying services to embedded jetty and running client code
  • 17. War Structure and Management <packaging>war</packaging> Directory Layout |-- pom.xml `-- src `-- main |-- java | `-- com | `-- example | `-- projects | `-- SampleAction.java |-- resources | |-- images | | `-- sampleimage.jpg | `-- sampleresource `-- webapp |-- WEB-INF | `-- web.xml |-- index.jsp `-- jsp `-- websource.jsp
  • 18. War Structure and Management • Plugin Example <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-war-plugin</artifactId> <version>2.0</version> <configuration> <webappDirectory>/container/deploy/dir</webappDirectory> </configuration> </plugin>
  • 19. War Overlay • Often handy to build component oriented wars. • Overlay multiple war files to create actual war file. – Continuum and Archiva do this is redback for shared security and user management bits
  • 20. Linking into Build • Dependency management scoping is key • Dig into your war file and see what is in there – Don’t be afraid, its doesn’t bite • <scope>provided</scope> can be your friend • Other Options: – <warSourceExcludes>WEB-INF/lib/*.jar</warSourceExcludes>
  • 21. Three different usages • War:war - standard war creation • War:exploded - builds out war in exploded format in target dir • War:inplace - builds out webapp in src/main/webapp • Dependency Management scoping key for war usability
  • 22. War Overlay I - Clean <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-clean-plugin</artifactId> <version>2.1.1</version> <!-- This configuration is added to cleanup from war:inplace --> <configuration> <filesets> <fileset> <directory>${basedir}/src/main/webapp</directory> <includes> <include>images/redback</include> <!-- Images from other wars --> <include>template/</include> <!-- validation.js --> <include>template/redback</include> <!-- Templates from other wars --> <include>WEB-INF/classes</include> <!-- Classes and Resources from other wars --> <include>WEB-INF/lib</include> </includes> </fileset> </filesets> </configuration> </plugin>
  • 23. War Overlay II - War <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-war-plugin</artifactId> <version>2.0.1</version> <configuration> <archiveClasses>false</archiveClasses> <dependentWarExcludes>META-INF/**,WEB-INF/web.xml,WEB-INF/classes/xwork.xml,WEB-INF/lib/** </dependentWarExcludes> </configuration> <executions> <execution> <phase>compile</phase> <goals> <!-- Needed to get the plexus-security war overlay to do its thing before jetty:run --> <goal>inplace</goal> </goals> </execution> </executions> </plugin>
  • 24. Jetty Configuration <plugin> <groupId>org.mortbay.jetty</groupId> <artifactId>maven-jetty-plugin</artifactId> <version>6.1.0</version> <configuration> <scanIntervalSeconds>10</scanIntervalSeconds> <contextPath>/</contextPath> <jettyEnvXml>${basedir}/src/jetty-env.xml</jettyEnvXml> <connectors> <connector implementation="org.mortbay.jetty.nio.SelectChannelConnector"> <port>9090</port> <maxIdleTime>60000</maxIdleTime> </connector> </connectors> </configuration> <dependencies> <dependency> <groupId>org.apache.derby</groupId> <artifactId>derby</artifactId> <version>10.1.3.1</version> </dependency> </dependencies> </plugin> <systemProperties> <systemProperty> <name>appserver.base</name> <value>${project.build.directory}/appserver-base</value> </systemProperty> <systemProperty> <name>appserver.home</name> <value>${project.build.directory}/appserver-home</value> </systemProperty> <systemProperty> <name>derby.system.home</name> <value>${project.build.directory}/appserver-base/logs</value> </systemProperty> </systemProperties>
  • 25. Testing Wars I • jetty-maven-plugin for ‘click testing’ – mvn jetty:run • Integration testing a bit more involved…
  • 26. TestingWars II • generate-resources – dependency-maven-plugin • Unzip the webapp • Prepare provided dependencies • package – maven-antrun-plugin • Copy container configuration • Copy provided dependencies • pre-integration-test – selenium-maven-plugin • Start server – cargo-maven2-plugin • Start container • integration-test – maven-antrun-plugin • Check continuum started – maven-surefire-plugin • Run tests • Post-integration-test – Cargo-maven2-plugin • Stop container
  • 27. Scoping War Dependencies • Two Approaches, different scoping – Deploying Wars – Integrating into Ears
  • 28. Ear Structure and Management • Directory Layout – No specific directories required – Dependencies are key to ear files • Automatic application.xml creation • MANIFEST.MF Creation
  • 29. Ear Structure and Management • Plugin Example <plugin> <artifactId>maven-ear-plugin</artifactId> <configuration> <archive> <manifest> <addClasspath>true</addClasspath> </manifest> </archive> </configuration> </plugin>
  • 30. Linking into Build • Just do it… • Then triage. • Primary recommendation, keep your project modular • Test your modules • Use ear module as simply the aggregation of the project • packaging
  • 31. Supported Ear Modules • ejb3Module - ejb3 (Enterprise Java Bean version 3) • ejbClientModule - ejb-client (Enterprise Java Bean Client) • ejbModule - ejb (Enterprise Java Bean) • jarModule - jar (Java Archive) • harModule - har (Hibernate Archive) • parModule - par (Plexus Archive) • rarModule - rar (Resource Adapter Archive) • sarModule - sar (JBoss Service Archive) • webModule - war (Web Application Archive) • wsrModule - wsr (JBoss Web Service Archive)
  • 32. Testing Ears • Functionally the same kind of process as the war integration testing • use cargo – Bind start app server to pre-integration-test phase – Start Selenium server – Run any surefire tests – Bind stop app server to post-integration-test
  • 33. Scoping Ear Dependencies • Learn Dependency Management in parent poms – Love it • Plan for ear deployment, scope things that are used by multiple war and ejb’s as provided or test in those poms • Scope for inclusion in ear, leave versioning to the dependencyManagement, its why it is there
  • 34. Application Deployment Options • Cargo - cargo.codehaus.org – Supported containers • Geronimo 1.x - geronimo1x • JBoss 3.x, 4.x - jboss3x, jboss4x • Jetty 4.x, 5.x, 6.x - jetty4x, jetty5x, jetty6x • jo! 1.x - jo1x • OC4J 9.x - oc4j9x • Orion 1.x, 2.x - orion1x, orion2x • Resin 2.x, 3.x - resin2x, resin3x • Tomcat 3.x, 4.x, 5.x - tomcat3x, tomcat4x, tomcat5x • WebLogic 8.x - weblogic8x – Maven2 plugin support • Deployment area largely untargeted by maven conventions • Hard to standardize in real world
  • 35. Tips and Tricks • Got a 300meg ear file? – Check the scoping – Pull apart the artifacts and look for jar duplication – Understand Java EE classloaders
  • 36. Tips and Tricks II <build> <plugins> <plugin> <artifactId>maven-ejb-plugin</artifactId> <configuration> <ejbVersion>3.0</ejbVersion> <classifier>${server.type}</classifier> </configuration> </plugin> </plugins> </build> <profiles> <profile> <id>prod</id> <properties> <ejb.jdbc.url>jdbc:odbc:prod;UID=prod;PWD=p4ssw0rd</ejb.jdbc.url> <server.type>prod</server.type> </properties> </profile> <profile> <id>test</id> <properties> <ejb.jdbc.url>jdbc:odbc:test;UID=test;PWD=p4ssw0rd</ejb.jdbc.url> <server.type>test</server.type> </properties> </profile> <profile> <id>dev</id> <properties> <ejb.jdbc.url>jdbc:derby:dev</ejb.jdbc.url> <server.type>dev</server.type> </properties> </profile> </profiles>
  • 37. Using Archetypes • maven-archetype-j2ee-simple – Sample aggregate project • Geronimo sample archetypes • Many jetty sample archetypes – http://www.webtide.com/resources.jsp
  • 38. Questions? • Jesse McConnell - jmcconnell@apache.org • Resources – Better Builds with Maven – Maven: The Definitive Guide

Editor's Notes

  1. What goes here?
  2. Add slide showing overlay
  3. Example of jetty maven configuration from continuum for this
  4. Mentioning this too many times
  5. Add some of eric’s tips