Apache Maven: J2EE Front to Back - PowerPoint PPT Presentation

About This Presentation
Title:

Apache Maven: J2EE Front to Back

Description:

Apache Maven: J2EE Front to Back Jesse McConnell - jmcconnell_at_apache.org J2EE Application Development by Convention No laughing matter People cry everyday because of ... – PowerPoint PPT presentation

Number of Views:112
Avg rating:3.0/5.0
Slides: 31
Provided by: Jesse150
Category:

less

Transcript and Presenter's Notes

Title: Apache Maven: J2EE Front to Back


1
Apache MavenJ2EE Front to Back
  • Jesse McConnell - jmcconnell_at_apache.org

2
J2EE Application Development by Convention
  • No laughing matter
  • People cry everyday because of j2ee
  • Maven can help keep crying to a minimum
  • hopefully

3
Who Am I?
  • On Maven PMC
  • Active in Continuum
  • Some maven plugins
  • Some mojo plugins _at_ codehaus
  • Axistools-maven-plugin - dont hold that against
    mepls
  • Redback _at_ codehaus

4
Components of J2ee
  • EJBs
  • Maven-ejb-plugin
  • Web Services
  • Axistools-maven-plugin
  • Xfire-maven-plugin
  • others
  • Web Archives (Wars)
  • Maven-war-plugin
  • Enterprise Archives (Ears)
  • Maven-ear-plugin

5
Maven Lifecycle
  • Supported since the beginning with maven 2
  • J2EE artifact lifecycle is managed through
    dependencies
  • Artifact construction dictated by lttype/gt

6
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

7
Library Code
  • Understanding the final goal and scoping
    dependencies appropriately.
  • That meansunderstand J2EE classloaders
  • Understand your Container
  • Like to think they are all interchangeable
  • Can be harder in practice

8
EJB Structure and Management
  • ltpackaginggtejblt/packaginggt
  • Directory Layout
  • -- pom.xml
  • -- src
  • -- main
  • -- resources
  • -- META-INF
  • -- ejb-jar.xml

9
EJB Structure and Management
  • Plugin Example
  • ltplugingt
  • ltartifactIdgtmaven-ejb-pluginlt/artifactIdgt
  • ltconfigurationgt
  • ltgenerateClientgttruelt/generateClientgt
  • lt/configurationgt
  • lt/plugingt

10
Linking into Build
  • Validates ejb-jar.xml file existence
  • Unless you specify ejbVersion 3.0

11
Testing EJB Code
  • Best bet is testing modularly like with normal
    junit testing.

12
Web Service Structures and Management
  • No strict lifecycle phase
  • No strict directory layout
  • Depends on web service architecture in use
  • Xfire -gt CXF, Axis, etc

13
Linking into Build
  • Consider services, clients, resource libraries
  • Common project layout
  • Annotations of services
  • All kinda implementation specific
  • Real deal is testing them

14
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

15
War Structure and Management
  • ltpackaginggtwarlt/packaginggt
  • 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

16
War Structure and Management
  • Plugin Example
  • ltplugingt
  • ltgroupIdgtorg.apache.maven.pluginslt/groupId
    gt
  • ltartifactIdgtmaven-war-pluginlt/artifactIdgt
  • ltversiongt2.0lt/versiongt
  • ltconfigurationgt
  • ltwebappDirectorygt/sample/servlet/contai
    ner/deploy/directorylt/webappDirectorygt
  • lt/configurationgt
  • lt/plugingt

17
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
    common security and user management

18
Linking into Build
  • Dependency management scoping is key
  • Dig into your war file and see what is in there
  • ltscopegtprovidedlt/scopegt can be your friend

19
Three different usages
  • Warwar - standard war creation
  • Warexploded - builds out war in exploded format
    in target dir
  • Warinplace - builds out webapp in
    src/main/webapp
  • Dependency Management scoping key for war
    usability

20
Testing Wars
  • Deploy via Jetty-maven-plugin during development
  • Selenium-maven-plugin for automated testing

21
Scoping War Dependencies
  • Two Approaches, different scoping
  • Deploying Wars
  • Integrating into Ears

22
Ear Structure and Management
  • Directory Layout
  • No specific directories required
  • Dependencies are key to ear files
  • Automatic application.xml creation
  • MANIFEST.MF Creation

23
Ear Structure and Management
  • Plugin Example
  • ltplugingt
  • ltartifactIdgtmaven-ear-pluginlt/artifact
    Idgt
  • ltconfigurationgt
  • ltarchivegt
  • ltmanifestgt
  • ltaddClasspathgttruelt/addClassp
    athgt
  • lt/manifestgt
  • lt/archivegt
  • lt/configurationgt
  • lt/plugingt

24
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

25
Testing Ears
  • No easy peasy way
  • Have to deploy somewhere
  • Have to start something
  • Have to access it
  • Non-trivial task
  • Best off testing your stuff modularly before you
    get to this point.

26
Scoping Ear Dependencies
  • Learn Dependency Management in parent poms
  • Love it
  • Plan for ear deployement, scope things that are
    used by multiple war and ejbs as provided or
    test in those poms
  • Scope for inclusion in ear, leave versioning to
    the dependencyManagement, its why it is there

27
Application Deployment Options
  • Cargo-maven-plugin
  • Largely area untargeted by maven conventions
  • Hard to standardize in real world

28
Tips and Tricks
  • 300M Ear file
  • Check the Scoping
  • Pull apart the artifacts and look for jar
    duplication
  • Understand those classloaders

29
Using Archetypes
  • Example of Quick Project Startup

30
Questions?
  • Jesse McConnell - jmcconnell_at_apache.org
  • Better Builds with Maven, blog at
    http//www.devzuz.org
Write a Comment
User Comments (0)
About PowerShow.com