Your SlideShare is downloading. ×
Java EE | Apache TomEE - Java EE Web Profile on Tomcat | Jonathan Gallimore
Upcoming SlideShare
Loading in...5
×

Thanks for flagging this SlideShare!

Oops! An error has occurred.

×

Saving this for later?

Get the SlideShare app to save on your phone or tablet. Read anywhere, anytime - even offline.

Text the download link to your phone

Standard text messaging rates apply

Java EE | Apache TomEE - Java EE Web Profile on Tomcat | Jonathan Gallimore

3,230
views

Published on

2011-11-01 | 04:20 PM - 05:10 PM …

2011-11-01 | 04:20 PM - 05:10 PM
This session explores Apache TomEE, pronounced “Tommy”, an all-Apache Web Profile stack built on Tomcat, which adds all the Java EE Web Profile features, while taking nothing away. The session will show you how to get started with TomEE, how to use it with a sample application, and how you can test your application with TomEE using tools like Arquillian.

Published in: Technology

0 Comments
2 Likes
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total Views
3,230
On Slideshare
0
From Embeds
0
Number of Embeds
10
Actions
Shares
0
Downloads
48
Comments
0
Likes
2
Embeds 0
No embeds

Report content
Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
No notes for slide

Transcript

  • 1. Jonathan Gallimore @jongallimore #TomEE Apache TomEE // JavaEE Web Profile on TomcatMonday, 31 October 11
  • 2. What is Apache TomEE • Tomcat + Java EE = TomEE • Complete Tomcat with nothing taken away • Java EE 6 Web profile certified stack • All Apache components • MyFaces • OpenEJB • OpenWebBeans • OpenJPA 2Monday, 31 October 11
  • 3. Philosophy • Be small, be certified, be Tomcat • Integrate OpenEJB into Tomcat, not the other way around • Get more, don’t give up anything • Leverage existing Tomcat features (JNDI, Security) • Lightweight • just 24MB • no extra memory requirement • No need to learn new server environment • Use existing IDE tools 3Monday, 31 October 11
  • 4. Flavours of TomEE • Apache TomEE Web Profile (Java EE 6 certified) • OpenEJB • OpenWebBeans • OpenJPA • Bean validation • MyFaces • Apache TomEE Plus (not Java EE 6 certified) • CXF • ActiveMQ • Geronimo connector • Embedded Apache TomEE 4Monday, 31 October 11
  • 5. Stats • Size: the entire Web Profile is only 24Mb • Memory usage: very little required, passed the TCK without changing any default JVM memory settings • Agility: the server can go through a start/deploy/test/ undeploy/stop cycle in 2-3 seconds, when run in embedded mode 5Monday, 31 October 11
  • 6. Certification • Certified on Amazon EC2 • t1.micro linux images, lot’s of them • 100 spot instances going at once (sometimes more)! • Each has 613MB memory max • Use default JVM memory settings • Current certified OSs • Amazon Linux AMI 2011.09, EBS boot, 32-bit EC2 t1.micro • Amazon Linux AMI 2011.09, EBS boot, 32-bit EC2 m1.small • Amazon Linux AMI 2011.09, EBS boot, 32-bit EC2 c1.medium 6Monday, 31 October 11
  • 7. Getting started • Unzip • Start with usual Catalina scripts or services • Deploy application .war or .ear in webapps • Console application at http://localhost:8080/openejb • Or deploy openejb.war in any standard Tomcat 7 installation 7Monday, 31 October 11
  • 8. Demo • Moviefun sample - demonstrates: • Servlets • CDI • JSF • EJBs • JPA • Available in OpenEJB source code repository • Over 50 different examples available for various Java EE features 8Monday, 31 October 11
  • 9. Why not just use Tomcat? • Plain Tomcat doesn’t have support for: • Transactions • Transaction aware connection pooling • @Resource • @PersistenceUnit • @Inject • @EJB • Global JNDI (java:module, java:app, java:global) • Are you adding libraries to provide EE features (e.g. persistence or CDI)? 9Monday, 31 October 11
  • 10. Configuration • Resources configured in conf/openejb.xml • Simple XML + properties format • Tags match Annotation names • <Resource id="moviesDatabase" type="DataSource"> • Can be injected using this code • @Resource DataSource moviesDatabase 10Monday, 31 October 11
  • 11. Transactions • Connection pooling is Transaction aware • Everyone in same transaction, shares same connection • Servlets, ManagedBeans, etc. can start transactions • @Resource UserTransaction transaction; • No need for EJBs to use transactions 11Monday, 31 October 11
  • 12. Persistence • All persistence.xml files found and deployed • Connection persistence.xml values filled in automatically • Servlets, ManagedBeans, Session Beans, etc now use • @PersistenceUnit EntityManagerFactory emf; • @PersistenceContext EntityManager em; • OpenJPA included, easy to remove • Hibernate used in many Apache TomEE installs 12Monday, 31 October 11
  • 13. EJBs • EJBs can be added directly to webapp • Servlets, Managed beans can use @EJB • EJB 3.1 provides no-interface view • HTTP can be used for EJB remote communication (http://localhost:8080/openejb/ejb) • User/Pass supplied with InitialContext params • HTTP or HTTPS 13Monday, 31 October 11
  • 14. What next? • How small can we get? • Below 20MB download? • 6000 classes loaded, can we get to 2000? • Optimisations • Certify more parts • Connector • JAX-WS • JAX-RS 14Monday, 31 October 11
  • 15. Testing - Embedded TomEE • Very straightforward to use, very little config needed • Maven users can add tomee-embedded dependency, or add all-in-one jar to classpath • Could be used with frameworks like HtmlUnit or Selenium to test your application Properties p = new Properties(); p.setProperty(EJBContainer.APP_NAME, "moviefun"); p.setProperty(EJBContainer.PROVIDER, "tomee-embedded"); // need web feature p.setProperty(EJBContainer.MODULES, webApp.getAbsolutePath()); p.setProperty(EmbeddedTomEEContainer.TOMEE_EJBCONTAINER_HTTP_PORT, "9999"); container = EJBContainer.createEJBContainer(p); 15Monday, 31 October 11
  • 16. Arquillian tests • Test harness from JBoss (http://www.jboss.org/ arquillian) • Allows you to run your test in any supported container • Adapters available for a number of servers • Skip the build • Run tests straight from the IDE 16Monday, 31 October 11
  • 17. TomEE Arquillian Adapters • Embedded • Boots TomEE embedded directly in the test • Remote • Can connect to a running instance of TomEE • OR download and start TomEE bundle • OR any version of Tomcat/OpenEJB • Configured in arquillian.xml 17Monday, 31 October 11
  • 18. Anatomy of an Arquillian Test • Deployment • Build an archive using the ShrinkWrap API • Choose parts of your application to test • Build archive with test settings • Test logic • Exercise your application • HtmlUnit • Selenium 18Monday, 31 October 11
  • 19. Questions?Monday, 31 October 11
  • 20. Thanks! http://openejb.apache.org users@openejb.apache.org dev@openejb.apache.org @ApacheTomEE #TomEEMonday, 31 October 11