tomcat to javaee with apache tomeetomee.apache.org/presentations/2012_jaxconf_tomcat... · – 100...
TRANSCRIPT
![Page 1: Tomcat to JavaEE with Apache TomEEtomee.apache.org/presentations/2012_JAXConf_Tomcat... · – 100 spot instances – 613mb memory – 64mb used, 549mb free – t1.micros have slow](https://reader034.vdocuments.us/reader034/viewer/2022042219/5ec54103ecda8e73e420e97e/html5/thumbnails/1.jpg)
David Blevins | Apache
Tomcat to JavaEE with Apache TomEE
![Page 2: Tomcat to JavaEE with Apache TomEEtomee.apache.org/presentations/2012_JAXConf_Tomcat... · – 100 spot instances – 613mb memory – 64mb used, 549mb free – t1.micros have slow](https://reader034.vdocuments.us/reader034/viewer/2022042219/5ec54103ecda8e73e420e97e/html5/thumbnails/2.jpg)
@ApachTomEE / #TomEEhttp://tomee.apache.org
![Page 3: Tomcat to JavaEE with Apache TomEEtomee.apache.org/presentations/2012_JAXConf_Tomcat... · – 100 spot instances – 613mb memory – 64mb used, 549mb free – t1.micros have slow](https://reader034.vdocuments.us/reader034/viewer/2022042219/5ec54103ecda8e73e420e97e/html5/thumbnails/3.jpg)
What is Apache TomEE?
![Page 4: Tomcat to JavaEE with Apache TomEEtomee.apache.org/presentations/2012_JAXConf_Tomcat... · – 100 spot instances – 613mb memory – 64mb used, 549mb free – t1.micros have slow](https://reader034.vdocuments.us/reader034/viewer/2022042219/5ec54103ecda8e73e420e97e/html5/thumbnails/4.jpg)
Tomcat + JavaEE = TomEE• Java EE 6 Web Profile certified• Tomcat through and through• All Apache components
– OpenJPA– OpenWebBeans– OpenEJB– MyFaces
• Core Values– Be small– Be certified– Be Tomcat
![Page 5: Tomcat to JavaEE with Apache TomEEtomee.apache.org/presentations/2012_JAXConf_Tomcat... · – 100 spot instances – 613mb memory – 64mb used, 549mb free – t1.micros have slow](https://reader034.vdocuments.us/reader034/viewer/2022042219/5ec54103ecda8e73e420e97e/html5/thumbnails/5.jpg)
Flavors of TomEE• Apache TomEE Web Profile (Java EE 6 Certified)
– CDI– EJB– JPA– JSF– Bean Validation
• Apache TomEE Plus– JAX-RS– JAX-WS– JMS
• Embedded Apache TomEE
![Page 6: Tomcat to JavaEE with Apache TomEEtomee.apache.org/presentations/2012_JAXConf_Tomcat... · – 100 spot instances – 613mb memory – 64mb used, 549mb free – t1.micros have slow](https://reader034.vdocuments.us/reader034/viewer/2022042219/5ec54103ecda8e73e420e97e/html5/thumbnails/6.jpg)
Basic Stats
• Size– 27mb
• Memory usage– very little required– passes TCK with default 64mb
• Agility:– Eclipse deploy ~700ms– embedded test 2-4 seconds
![Page 7: Tomcat to JavaEE with Apache TomEEtomee.apache.org/presentations/2012_JAXConf_Tomcat... · – 100 spot instances – 613mb memory – 64mb used, 549mb free – t1.micros have slow](https://reader034.vdocuments.us/reader034/viewer/2022042219/5ec54103ecda8e73e420e97e/html5/thumbnails/7.jpg)
Certification• Certified on Amazon EC2
– t1.micro linux images,– 100 spot instances– 613mb memory– 64mb used, 549mb free– t1.micros have slow disks, memory is critical
• Current certified OSs– Amazon Linux AMI 2011.09, EBS boot, EC2 t1.micro– Amazon Linux AMI 2011.09, EBS boot, EC2 m1.small– Amazon Linux AMI 2011.09, EBS boot, EC2 c1.medium
• Runs daily• Got a Cloud?
– Donate time!
![Page 8: Tomcat to JavaEE with Apache TomEEtomee.apache.org/presentations/2012_JAXConf_Tomcat... · – 100 spot instances – 613mb memory – 64mb used, 549mb free – t1.micros have slow](https://reader034.vdocuments.us/reader034/viewer/2022042219/5ec54103ecda8e73e420e97e/html5/thumbnails/8.jpg)
“If you are concerned about performance and footprint, but can accept that you'll have to solve problems yourself, go TomEE. (TomEE seems to be _much_ faster than <XXX>)”
-- Jonathan Fisher, User List, July 3rd 2012
“From an architect that switched from <XXX> to Tomee. I can tell you Tomee kicks <XXX>'s ass in every way. Memory, speed, reliability, validation, you name it.”
-- Zeeman, User List, July 3rd 2012
“There is also one point to note. TomEE is insanely fast! ”
-- Łukasz Budnik, CXF JAX-RS on Apache TomEE @ DZone, May 23rd 2012
![Page 9: Tomcat to JavaEE with Apache TomEEtomee.apache.org/presentations/2012_JAXConf_Tomcat... · – 100 spot instances – 613mb memory – 64mb used, 549mb free – t1.micros have slow](https://reader034.vdocuments.us/reader034/viewer/2022042219/5ec54103ecda8e73e420e97e/html5/thumbnails/9.jpg)
Gaps in Tomcat
![Page 10: Tomcat to JavaEE with Apache TomEEtomee.apache.org/presentations/2012_JAXConf_Tomcat... · – 100 spot instances – 613mb memory – 64mb used, 549mb free – t1.micros have slow](https://reader034.vdocuments.us/reader034/viewer/2022042219/5ec54103ecda8e73e420e97e/html5/thumbnails/10.jpg)
Gaps in Tomcat• No Transaction support• No Connection Pooling support
– Pooling should be transactional• No Integrated Security• No support for Global JNDI
– java:module– java:app– java:global
• No support for @DataSourceDefinition• No support for new <env-entry> types:
– java.lang.Class– Enums
![Page 11: Tomcat to JavaEE with Apache TomEEtomee.apache.org/presentations/2012_JAXConf_Tomcat... · – 100 spot instances – 613mb memory – 64mb used, 549mb free – t1.micros have slow](https://reader034.vdocuments.us/reader034/viewer/2022042219/5ec54103ecda8e73e420e97e/html5/thumbnails/11.jpg)
Gaps in Tomcat• No @Resource
– UserTransaction– BeanManager– Validator– ValidatorFactory– Topic/Queue– ConnectionFactory
• No @PersistenceUnit• No @PersistenceContext• No @Inject• No @EJB• No @WebServiceRef
![Page 12: Tomcat to JavaEE with Apache TomEEtomee.apache.org/presentations/2012_JAXConf_Tomcat... · – 100 spot instances – 613mb memory – 64mb used, 549mb free – t1.micros have slow](https://reader034.vdocuments.us/reader034/viewer/2022042219/5ec54103ecda8e73e420e97e/html5/thumbnails/12.jpg)
Migration Issues
![Page 13: Tomcat to JavaEE with Apache TomEEtomee.apache.org/presentations/2012_JAXConf_Tomcat... · – 100 spot instances – 613mb memory – 64mb used, 549mb free – t1.micros have slow](https://reader034.vdocuments.us/reader034/viewer/2022042219/5ec54103ecda8e73e420e97e/html5/thumbnails/13.jpg)
Building your own app server
• Including API jars in the webapp– JPA API– JSF API– etc.
• Including implementations in webapp– Mojarra (works in trunk)– Bitronix/Atomikos
• Non-compliant DataSource and JPA– too many years of Do It Yourself– providers not enforcing rules
![Page 14: Tomcat to JavaEE with Apache TomEEtomee.apache.org/presentations/2012_JAXConf_Tomcat... · – 100 spot instances – 613mb memory – 64mb used, 549mb free – t1.micros have slow](https://reader034.vdocuments.us/reader034/viewer/2022042219/5ec54103ecda8e73e420e97e/html5/thumbnails/14.jpg)
(Mis)Information
• Gaps in Knowledge– “that other stuff”
• Misinformation– don’t use X, it’s heavy
• Leads to...– let’s build own own heavy X!
• Bites you– non-portable apps– lacks tens of thousands of tests– lacks shared experience
![Page 15: Tomcat to JavaEE with Apache TomEEtomee.apache.org/presentations/2012_JAXConf_Tomcat... · – 100 spot instances – 613mb memory – 64mb used, 549mb free – t1.micros have slow](https://reader034.vdocuments.us/reader034/viewer/2022042219/5ec54103ecda8e73e420e97e/html5/thumbnails/15.jpg)
Closing Gaps in Knowledge
![Page 16: Tomcat to JavaEE with Apache TomEEtomee.apache.org/presentations/2012_JAXConf_Tomcat... · – 100 spot instances – 613mb memory – 64mb used, 549mb free – t1.micros have slow](https://reader034.vdocuments.us/reader034/viewer/2022042219/5ec54103ecda8e73e420e97e/html5/thumbnails/16.jpg)
You can’t use this
• unless you understand– JTA Transactions– Container-managed EntityManagers– Container-managed DataSources– How to get references to these, properly!
![Page 17: Tomcat to JavaEE with Apache TomEEtomee.apache.org/presentations/2012_JAXConf_Tomcat... · – 100 spot instances – 613mb memory – 64mb used, 549mb free – t1.micros have slow](https://reader034.vdocuments.us/reader034/viewer/2022042219/5ec54103ecda8e73e420e97e/html5/thumbnails/17.jpg)
Not Just EJBs
• Components with Transaction support– Servlets– JSP– JSF Managed Beans– CDI– EJB– JAX-RS REST Services– JAX-WS Web Services
![Page 18: Tomcat to JavaEE with Apache TomEEtomee.apache.org/presentations/2012_JAXConf_Tomcat... · – 100 spot instances – 613mb memory – 64mb used, 549mb free – t1.micros have slow](https://reader034.vdocuments.us/reader034/viewer/2022042219/5ec54103ecda8e73e420e97e/html5/thumbnails/18.jpg)
What are Transactions?
![Page 19: Tomcat to JavaEE with Apache TomEEtomee.apache.org/presentations/2012_JAXConf_Tomcat... · – 100 spot instances – 613mb memory – 64mb used, 549mb free – t1.micros have slow](https://reader034.vdocuments.us/reader034/viewer/2022042219/5ec54103ecda8e73e420e97e/html5/thumbnails/19.jpg)
“Undo”
![Page 20: Tomcat to JavaEE with Apache TomEEtomee.apache.org/presentations/2012_JAXConf_Tomcat... · – 100 spot instances – 613mb memory – 64mb used, 549mb free – t1.micros have slow](https://reader034.vdocuments.us/reader034/viewer/2022042219/5ec54103ecda8e73e420e97e/html5/thumbnails/20.jpg)
![Page 21: Tomcat to JavaEE with Apache TomEEtomee.apache.org/presentations/2012_JAXConf_Tomcat... · – 100 spot instances – 613mb memory – 64mb used, 549mb free – t1.micros have slow](https://reader034.vdocuments.us/reader034/viewer/2022042219/5ec54103ecda8e73e420e97e/html5/thumbnails/21.jpg)
![Page 22: Tomcat to JavaEE with Apache TomEEtomee.apache.org/presentations/2012_JAXConf_Tomcat... · – 100 spot instances – 613mb memory – 64mb used, 549mb free – t1.micros have slow](https://reader034.vdocuments.us/reader034/viewer/2022042219/5ec54103ecda8e73e420e97e/html5/thumbnails/22.jpg)
![Page 23: Tomcat to JavaEE with Apache TomEEtomee.apache.org/presentations/2012_JAXConf_Tomcat... · – 100 spot instances – 613mb memory – 64mb used, 549mb free – t1.micros have slow](https://reader034.vdocuments.us/reader034/viewer/2022042219/5ec54103ecda8e73e420e97e/html5/thumbnails/23.jpg)
Controlling Transactions
• javax.transaction.UserTransaction– Manual approach– Any JavaEE component
• @javax.ejb.TransactionAttribute– Class or method annotation– EJB only
• @javax.transaction.Transactional – Class or method annotation– Any JavaEE component*– Coming in JavaEE 7
![Page 24: Tomcat to JavaEE with Apache TomEEtomee.apache.org/presentations/2012_JAXConf_Tomcat... · – 100 spot instances – 613mb memory – 64mb used, 549mb free – t1.micros have slow](https://reader034.vdocuments.us/reader034/viewer/2022042219/5ec54103ecda8e73e420e97e/html5/thumbnails/24.jpg)
Transaction Hooks
• SessionSynchronization– @AfterBegin– @BeforeCompletion– @AfterCompletion
• Events– @Observes(during=IN_PROGRESS)– @Observes(during=BEFORE_COMPLETION)– @Observes(during=AFTER_COMPLETION)
• @Observes(during=AFTER_SUCCESS)• @Observes(during=AFTER_FAILURE)
![Page 25: Tomcat to JavaEE with Apache TomEEtomee.apache.org/presentations/2012_JAXConf_Tomcat... · – 100 spot instances – 613mb memory – 64mb used, 549mb free – t1.micros have slow](https://reader034.vdocuments.us/reader034/viewer/2022042219/5ec54103ecda8e73e420e97e/html5/thumbnails/25.jpg)
![Page 26: Tomcat to JavaEE with Apache TomEEtomee.apache.org/presentations/2012_JAXConf_Tomcat... · – 100 spot instances – 613mb memory – 64mb used, 549mb free – t1.micros have slow](https://reader034.vdocuments.us/reader034/viewer/2022042219/5ec54103ecda8e73e420e97e/html5/thumbnails/26.jpg)
“Undo” aware Resources
• DataSource• EntityManager• Sending JMS Messages• Receiving JMS Messages• Timers & @Schedule• (more via Java EE connectors)
[Some restrictions apply. Offer void where prohibited. Container-provided resources required. Must be 18 years or older to apply]
![Page 27: Tomcat to JavaEE with Apache TomEEtomee.apache.org/presentations/2012_JAXConf_Tomcat... · – 100 spot instances – 613mb memory – 64mb used, 549mb free – t1.micros have slow](https://reader034.vdocuments.us/reader034/viewer/2022042219/5ec54103ecda8e73e420e97e/html5/thumbnails/27.jpg)
More specifically
![Page 28: Tomcat to JavaEE with Apache TomEEtomee.apache.org/presentations/2012_JAXConf_Tomcat... · – 100 spot instances – 613mb memory – 64mb used, 549mb free – t1.micros have slow](https://reader034.vdocuments.us/reader034/viewer/2022042219/5ec54103ecda8e73e420e97e/html5/thumbnails/28.jpg)
How does it work?
![Page 29: Tomcat to JavaEE with Apache TomEEtomee.apache.org/presentations/2012_JAXConf_Tomcat... · – 100 spot instances – 613mb memory – 64mb used, 549mb free – t1.micros have slow](https://reader034.vdocuments.us/reader034/viewer/2022042219/5ec54103ecda8e73e420e97e/html5/thumbnails/29.jpg)
TOP SECRET(authorized personnel only)
![Page 30: Tomcat to JavaEE with Apache TomEEtomee.apache.org/presentations/2012_JAXConf_Tomcat... · – 100 spot instances – 613mb memory – 64mb used, 549mb free – t1.micros have slow](https://reader034.vdocuments.us/reader034/viewer/2022042219/5ec54103ecda8e73e420e97e/html5/thumbnails/30.jpg)
This is not a pipe
![Page 31: Tomcat to JavaEE with Apache TomEEtomee.apache.org/presentations/2012_JAXConf_Tomcat... · – 100 spot instances – 613mb memory – 64mb used, 549mb free – t1.micros have slow](https://reader034.vdocuments.us/reader034/viewer/2022042219/5ec54103ecda8e73e420e97e/html5/thumbnails/31.jpg)
Not the real thing
![Page 32: Tomcat to JavaEE with Apache TomEEtomee.apache.org/presentations/2012_JAXConf_Tomcat... · – 100 spot instances – 613mb memory – 64mb used, 549mb free – t1.micros have slow](https://reader034.vdocuments.us/reader034/viewer/2022042219/5ec54103ecda8e73e420e97e/html5/thumbnails/32.jpg)
The EntityManager You Get
![Page 33: Tomcat to JavaEE with Apache TomEEtomee.apache.org/presentations/2012_JAXConf_Tomcat... · – 100 spot instances – 613mb memory – 64mb used, 549mb free – t1.micros have slow](https://reader034.vdocuments.us/reader034/viewer/2022042219/5ec54103ecda8e73e420e97e/html5/thumbnails/33.jpg)
![Page 34: Tomcat to JavaEE with Apache TomEEtomee.apache.org/presentations/2012_JAXConf_Tomcat... · – 100 spot instances – 613mb memory – 64mb used, 549mb free – t1.micros have slow](https://reader034.vdocuments.us/reader034/viewer/2022042219/5ec54103ecda8e73e420e97e/html5/thumbnails/34.jpg)
continued...
![Page 35: Tomcat to JavaEE with Apache TomEEtomee.apache.org/presentations/2012_JAXConf_Tomcat... · – 100 spot instances – 613mb memory – 64mb used, 549mb free – t1.micros have slow](https://reader034.vdocuments.us/reader034/viewer/2022042219/5ec54103ecda8e73e420e97e/html5/thumbnails/35.jpg)
The DataSource You Get
![Page 36: Tomcat to JavaEE with Apache TomEEtomee.apache.org/presentations/2012_JAXConf_Tomcat... · – 100 spot instances – 613mb memory – 64mb used, 549mb free – t1.micros have slow](https://reader034.vdocuments.us/reader034/viewer/2022042219/5ec54103ecda8e73e420e97e/html5/thumbnails/36.jpg)
![Page 37: Tomcat to JavaEE with Apache TomEEtomee.apache.org/presentations/2012_JAXConf_Tomcat... · – 100 spot instances – 613mb memory – 64mb used, 549mb free – t1.micros have slow](https://reader034.vdocuments.us/reader034/viewer/2022042219/5ec54103ecda8e73e420e97e/html5/thumbnails/37.jpg)
better than a pipe
![Page 38: Tomcat to JavaEE with Apache TomEEtomee.apache.org/presentations/2012_JAXConf_Tomcat... · – 100 spot instances – 613mb memory – 64mb used, 549mb free – t1.micros have slow](https://reader034.vdocuments.us/reader034/viewer/2022042219/5ec54103ecda8e73e420e97e/html5/thumbnails/38.jpg)
...better than the real thing
• thread-safe• undo-aware• leak-free
![Page 39: Tomcat to JavaEE with Apache TomEEtomee.apache.org/presentations/2012_JAXConf_Tomcat... · – 100 spot instances – 613mb memory – 64mb used, 549mb free – t1.micros have slow](https://reader034.vdocuments.us/reader034/viewer/2022042219/5ec54103ecda8e73e420e97e/html5/thumbnails/39.jpg)
All boils down to...
![Page 40: Tomcat to JavaEE with Apache TomEEtomee.apache.org/presentations/2012_JAXConf_Tomcat... · – 100 spot instances – 613mb memory – 64mb used, 549mb free – t1.micros have slow](https://reader034.vdocuments.us/reader034/viewer/2022042219/5ec54103ecda8e73e420e97e/html5/thumbnails/40.jpg)
“hashmap”
“listeners”
![Page 41: Tomcat to JavaEE with Apache TomEEtomee.apache.org/presentations/2012_JAXConf_Tomcat... · – 100 spot instances – 613mb memory – 64mb used, 549mb free – t1.micros have slow](https://reader034.vdocuments.us/reader034/viewer/2022042219/5ec54103ecda8e73e420e97e/html5/thumbnails/41.jpg)
...but
![Page 42: Tomcat to JavaEE with Apache TomEEtomee.apache.org/presentations/2012_JAXConf_Tomcat... · – 100 spot instances – 613mb memory – 64mb used, 549mb free – t1.micros have slow](https://reader034.vdocuments.us/reader034/viewer/2022042219/5ec54103ecda8e73e420e97e/html5/thumbnails/42.jpg)
Won’t work with any of this
• DataSource– DriverManager.getConnection(...)– new FooDataSource()– autocommit = true
• EntityManager– PersistenceProvider.createEntityManag...– EntityManagerFactory.createEntityManager– EntityTransaction
![Page 43: Tomcat to JavaEE with Apache TomEEtomee.apache.org/presentations/2012_JAXConf_Tomcat... · – 100 spot instances – 613mb memory – 64mb used, 549mb free – t1.micros have slow](https://reader034.vdocuments.us/reader034/viewer/2022042219/5ec54103ecda8e73e420e97e/html5/thumbnails/43.jpg)
Avoid Do It Yourself
![Page 44: Tomcat to JavaEE with Apache TomEEtomee.apache.org/presentations/2012_JAXConf_Tomcat... · – 100 spot instances – 613mb memory – 64mb used, 549mb free – t1.micros have slow](https://reader034.vdocuments.us/reader034/viewer/2022042219/5ec54103ecda8e73e420e97e/html5/thumbnails/44.jpg)
Rule
• If you didn’t get it from the Container– it isn’t usable with UserTransaction– connections may leak– memory may leak
• Even then there are some BIG notes– EntityManagerFactory
• not usable with UserTransaction– <persistence-unit=RESOURCE_LOCAL>
• not usable with UserTransaction
![Page 45: Tomcat to JavaEE with Apache TomEEtomee.apache.org/presentations/2012_JAXConf_Tomcat... · – 100 spot instances – 613mb memory – 64mb used, 549mb free – t1.micros have slow](https://reader034.vdocuments.us/reader034/viewer/2022042219/5ec54103ecda8e73e420e97e/html5/thumbnails/45.jpg)
![Page 46: Tomcat to JavaEE with Apache TomEEtomee.apache.org/presentations/2012_JAXConf_Tomcat... · – 100 spot instances – 613mb memory – 64mb used, 549mb free – t1.micros have slow](https://reader034.vdocuments.us/reader034/viewer/2022042219/5ec54103ecda8e73e420e97e/html5/thumbnails/46.jpg)
Common Migration Issues& Mistakes
![Page 47: Tomcat to JavaEE with Apache TomEEtomee.apache.org/presentations/2012_JAXConf_Tomcat... · – 100 spot instances – 613mb memory – 64mb used, 549mb free – t1.micros have slow](https://reader034.vdocuments.us/reader034/viewer/2022042219/5ec54103ecda8e73e420e97e/html5/thumbnails/47.jpg)
Wrong
![Page 48: Tomcat to JavaEE with Apache TomEEtomee.apache.org/presentations/2012_JAXConf_Tomcat... · – 100 spot instances – 613mb memory – 64mb used, 549mb free – t1.micros have slow](https://reader034.vdocuments.us/reader034/viewer/2022042219/5ec54103ecda8e73e420e97e/html5/thumbnails/48.jpg)
Wrong
![Page 49: Tomcat to JavaEE with Apache TomEEtomee.apache.org/presentations/2012_JAXConf_Tomcat... · – 100 spot instances – 613mb memory – 64mb used, 549mb free – t1.micros have slow](https://reader034.vdocuments.us/reader034/viewer/2022042219/5ec54103ecda8e73e420e97e/html5/thumbnails/49.jpg)
Wrong
![Page 50: Tomcat to JavaEE with Apache TomEEtomee.apache.org/presentations/2012_JAXConf_Tomcat... · – 100 spot instances – 613mb memory – 64mb used, 549mb free – t1.micros have slow](https://reader034.vdocuments.us/reader034/viewer/2022042219/5ec54103ecda8e73e420e97e/html5/thumbnails/50.jpg)
Still Wrong
![Page 51: Tomcat to JavaEE with Apache TomEEtomee.apache.org/presentations/2012_JAXConf_Tomcat... · – 100 spot instances – 613mb memory – 64mb used, 549mb free – t1.micros have slow](https://reader034.vdocuments.us/reader034/viewer/2022042219/5ec54103ecda8e73e420e97e/html5/thumbnails/51.jpg)
![Page 52: Tomcat to JavaEE with Apache TomEEtomee.apache.org/presentations/2012_JAXConf_Tomcat... · – 100 spot instances – 613mb memory – 64mb used, 549mb free – t1.micros have slow](https://reader034.vdocuments.us/reader034/viewer/2022042219/5ec54103ecda8e73e420e97e/html5/thumbnails/52.jpg)
The worst of them all
![Page 53: Tomcat to JavaEE with Apache TomEEtomee.apache.org/presentations/2012_JAXConf_Tomcat... · – 100 spot instances – 613mb memory – 64mb used, 549mb free – t1.micros have slow](https://reader034.vdocuments.us/reader034/viewer/2022042219/5ec54103ecda8e73e420e97e/html5/thumbnails/53.jpg)
this...
![Page 54: Tomcat to JavaEE with Apache TomEEtomee.apache.org/presentations/2012_JAXConf_Tomcat... · – 100 spot instances – 613mb memory – 64mb used, 549mb free – t1.micros have slow](https://reader034.vdocuments.us/reader034/viewer/2022042219/5ec54103ecda8e73e420e97e/html5/thumbnails/54.jpg)
or this...
![Page 55: Tomcat to JavaEE with Apache TomEEtomee.apache.org/presentations/2012_JAXConf_Tomcat... · – 100 spot instances – 613mb memory – 64mb used, 549mb free – t1.micros have slow](https://reader034.vdocuments.us/reader034/viewer/2022042219/5ec54103ecda8e73e420e97e/html5/thumbnails/55.jpg)
with THIS!
![Page 56: Tomcat to JavaEE with Apache TomEEtomee.apache.org/presentations/2012_JAXConf_Tomcat... · – 100 spot instances – 613mb memory – 64mb used, 549mb free – t1.micros have slow](https://reader034.vdocuments.us/reader034/viewer/2022042219/5ec54103ecda8e73e420e97e/html5/thumbnails/56.jpg)
darn defaults!
![Page 57: Tomcat to JavaEE with Apache TomEEtomee.apache.org/presentations/2012_JAXConf_Tomcat... · – 100 spot instances – 613mb memory – 64mb used, 549mb free – t1.micros have slow](https://reader034.vdocuments.us/reader034/viewer/2022042219/5ec54103ecda8e73e420e97e/html5/thumbnails/57.jpg)
There we go
![Page 58: Tomcat to JavaEE with Apache TomEEtomee.apache.org/presentations/2012_JAXConf_Tomcat... · – 100 spot instances – 613mb memory – 64mb used, 549mb free – t1.micros have slow](https://reader034.vdocuments.us/reader034/viewer/2022042219/5ec54103ecda8e73e420e97e/html5/thumbnails/58.jpg)
JPA Rules
• RESOURCE_LOCAL– Persistence.createEntityManagerFactory– @PersistenceUnit EntityManagerFactory– <non-jta-data-source>
• JTA– @PersistenceContext EntityManager– <jta-data-source>– <non-jta-data-source>
• No other combinations are valid
![Page 59: Tomcat to JavaEE with Apache TomEEtomee.apache.org/presentations/2012_JAXConf_Tomcat... · – 100 spot instances – 613mb memory – 64mb used, 549mb free – t1.micros have slow](https://reader034.vdocuments.us/reader034/viewer/2022042219/5ec54103ecda8e73e420e97e/html5/thumbnails/59.jpg)
Good
• Valid RESOURCE_LOCAL usage
![Page 60: Tomcat to JavaEE with Apache TomEEtomee.apache.org/presentations/2012_JAXConf_Tomcat... · – 100 spot instances – 613mb memory – 64mb used, 549mb free – t1.micros have slow](https://reader034.vdocuments.us/reader034/viewer/2022042219/5ec54103ecda8e73e420e97e/html5/thumbnails/60.jpg)
Better
• Valid RESOURCE_LOCAL usage
![Page 61: Tomcat to JavaEE with Apache TomEEtomee.apache.org/presentations/2012_JAXConf_Tomcat... · – 100 spot instances – 613mb memory – 64mb used, 549mb free – t1.micros have slow](https://reader034.vdocuments.us/reader034/viewer/2022042219/5ec54103ecda8e73e420e97e/html5/thumbnails/61.jpg)
Best
• Valid JTA usage
![Page 62: Tomcat to JavaEE with Apache TomEEtomee.apache.org/presentations/2012_JAXConf_Tomcat... · – 100 spot instances – 613mb memory – 64mb used, 549mb free – t1.micros have slow](https://reader034.vdocuments.us/reader034/viewer/2022042219/5ec54103ecda8e73e420e97e/html5/thumbnails/62.jpg)
DataSource
• Declare– in tomee.xml– in META-INF/resources.xml– via @DataSourceDefinition
• Retrieve– @Resource– <resource-ref>
• Undo-aware and pooled
![Page 63: Tomcat to JavaEE with Apache TomEEtomee.apache.org/presentations/2012_JAXConf_Tomcat... · – 100 spot instances – 613mb memory – 64mb used, 549mb free – t1.micros have slow](https://reader034.vdocuments.us/reader034/viewer/2022042219/5ec54103ecda8e73e420e97e/html5/thumbnails/63.jpg)
Declaring• <tomee-home>/conf/tomee.xml
• WEB-INF/resources.xml
![Page 64: Tomcat to JavaEE with Apache TomEEtomee.apache.org/presentations/2012_JAXConf_Tomcat... · – 100 spot instances – 613mb memory – 64mb used, 549mb free – t1.micros have slow](https://reader034.vdocuments.us/reader034/viewer/2022042219/5ec54103ecda8e73e420e97e/html5/thumbnails/64.jpg)
Recap
![Page 65: Tomcat to JavaEE with Apache TomEEtomee.apache.org/presentations/2012_JAXConf_Tomcat... · – 100 spot instances – 613mb memory – 64mb used, 549mb free – t1.micros have slow](https://reader034.vdocuments.us/reader034/viewer/2022042219/5ec54103ecda8e73e420e97e/html5/thumbnails/65.jpg)
Recap• Use if you need “undo”• Transactions not heavy
– Thread safe management– Help prevent Leaks– Enhance programming
• More than a TransactionManager– TransactionManagers do nothing alone– Resources must cooperate
• Don’t Do It Yourself– Use container-provided resources– no need to re-invent the wheel
![Page 66: Tomcat to JavaEE with Apache TomEEtomee.apache.org/presentations/2012_JAXConf_Tomcat... · – 100 spot instances – 613mb memory – 64mb used, 549mb free – t1.micros have slow](https://reader034.vdocuments.us/reader034/viewer/2022042219/5ec54103ecda8e73e420e97e/html5/thumbnails/66.jpg)
Recap
• Components with Transaction support– Servlets– JSP– JSF Managed Beans– CDI– EJB– JAX-RS REST Services– JAX-WS Web Services
![Page 67: Tomcat to JavaEE with Apache TomEEtomee.apache.org/presentations/2012_JAXConf_Tomcat... · – 100 spot instances – 613mb memory – 64mb used, 549mb free – t1.micros have slow](https://reader034.vdocuments.us/reader034/viewer/2022042219/5ec54103ecda8e73e420e97e/html5/thumbnails/67.jpg)
Recap
• Transactional Resources– DataSource– EntityManager– Sending JMS Messages– Receiving JMS Messages– Timers & @Schedule– (more via Java EE connectors)
![Page 68: Tomcat to JavaEE with Apache TomEEtomee.apache.org/presentations/2012_JAXConf_Tomcat... · – 100 spot instances – 613mb memory – 64mb used, 549mb free – t1.micros have slow](https://reader034.vdocuments.us/reader034/viewer/2022042219/5ec54103ecda8e73e420e97e/html5/thumbnails/68.jpg)
Questions?