SlideShare a Scribd company logo
S314613:
OSGI Migration
headaches




Krasimir Semerdzhiev
SAP Labs Bulgaria
Development Architect


Peter Peshev
SAP Labs Bulgaria
Development Architect
Agenda




OSGI intro
Headaches
Painkiller options
Q&A
Modularity
Alternative implementations




                              VW Golf
                               91-97
Good architecture and interchangeable



       minilang      party        pos.           product          workeffort     workflow         …

      accounting   assetmaint    content            bi              ebay        ecommerce     googlebase

       guiapp      hhfacility   manufact.       marketing          minerva        oagis          order


                                             Application layer

       common       catalina      base           datafile           entity        widget          …


       resolver      rome       serializer       servlets          tomcat          xalan          bsf

         mail        mx4j        naming            jetty             poi          wsdl4j          bsh

        jenks       jpos18       jython           looks            lucene         xerces        velocity

       jakarta         jcl        json            jdbm              jdom          xmlapis     ws-commons

        log4j      barcode4j      axis             batik          commons         xmlrpc       geronimo

       httpunit    freemarker   ezmorph            fop              derby       xmlgraphics    Libs..

                                                 Java VM

          rt          jce         jsse            plugin         sunjce_prov.     dnsns            ..
Problem: CLASSPATH



         Java VM         party      common       resolver     axis        xerces

Begin       rt

            jce
                      assetmaint

                       hhfacility
                                     catalina

                                      base
                                                   mail

                                                  jenks
                                                             ezmorph

                                                             servlets
                                                                          xmlapis

                                                                          xmlrpc
Here       jsse          pos.        datafile     jakarta     jetty     xmlgraphics

          plugin       content        entity      log4j       looks
        sunjce_prov   manufact.      widget      httpunit     jdbm
             .
          dnsns        product          …          mx4j        bsf

             ..           bi          rome        batik        bsh       Class
         marketing     workflow      jpos18        fop        velocity

        workeffort    ecommerce        jcl        tomcat    ws-commons
                                                                          Not
           ebay          oagis      barcode4j      poi       geronimo   Found
         minerva          …         freemarker    lucene         ..
                                                                       Exception
         minilang     googlebase    serializer    jdom        json
        accounting       order       naming      commons      xalan

          guiapp         ofbiz        jython      derby      wsdl4j
The OSGi Alliance




    Started March 1999 as an initiative from ERICSSON, SUN and IBM
    Today: A stable Alliance with almost 100 members
    Now practically all of the Java Server vendors are represented there
    A standardization body…
OSGi Framework Layers




 Staircase
    Applications can make use
     of different layers directly
    Module Layer defines
     packaging , deployment
     dependancies among
     modules
    Lifecycle Layer controls
     lifecycyle operations of a
     bundle
Module Layer: Bundles



Bundles
 Are   JAR files

 Contain   classes, other resources like HTML, images, specific metadata

 Contain
        manifest file (META-INF/MANIFEST.MF) with OSGI specific
 headers used to manage the bundle
   Describes the content of the JAR file
   Export  Import package
   Require-Bundle
Module Layer: Runtime class loading


load class com.foo.classA
Class Loading Architecture: Class Space
Class Loading Architecture: Delegation



Basic properties
 Parent delegation
 Wire importers and exporters
 There can be fragment bundles
 Class loading traversal based on importers and their wires
Lifecycle Layer


Runtime representation of bundles
 Forevery bundle, the framework creates a Bundle java object
 Bundles are identified by Bundle ID, Bundle Symbolic Name and
  Bundle Location
 Bundle has a runtime state:
What is the story?


                                               Web          Web Module   bundle
                   Web Module
  Web Modules                                 Modules         (war)
                     (war)                                               bundle

                                                      Web Modules        bundle
         Web Modules
                                                            State 2
                                                                         bundle
 Lib   Lib   Lib   Lib EAR file
                         EAR file                                 OSGi framework

        Java EE compliant runtime
                                    bundle   bundle      bundle

                                    bundle   bundle      bundle

                                    bundle   bundle      bundle

                                    bundle   bundle      bundle

                                    bundle   bundle      bundle
                                             OSGi framework
What do we aim to get from OSGi?


■   Standardized execution environment
■   Java-based modularization
■   Well defined module contract
■   Strict dependency management at build and run time
■   Manifest as a single point of truth
■   Deterministic declarative runtime resolution




or in other words…

■ Evolve from JARs/modules to “interchangeable/reusable parts”
Agenda




OSGI intro
Headaches
Painkiller options
Q&A
Step 1: Choose an OSGi runtime
Step 2: How to create bundles?


Manifest-Version: 1.0
Bundle-Name: My First Bundle
Bundle-SymbolicName: com.acme.myfirstbundle
Bundle-Version: 1.0.0
Bundle-Description: Small Bundle
Bundle-Vendor: ACME
Bundle-Activator: com.acme.myfirstbundle.impl.Activator
Bundle-Category: example
Import-Package: org.osgi.framework
Export-Package: com.acme.myfirstbundle.api



    Export-Package ::= export(‘,’ export)*
      export ::= package-names(‘;’ parameter)*
      package-names ::= package-name(‘;’ package-name)*
    Import-Package ::= import(‘,’ import)*
      import ::= package-names(‘;’ parameter)*
      package-names ::= package-name(‘;’ package-name)*
    Require-Bundle ::= bundle-description ( ',' bundle-description )*
      bundle-description ::= symbolic-name (';' parameter )*
Step 2: How to create bundles?


Let‘s take one example – Apache Derby
org.apache.derby.*
     authentication            iapi.services.timer              impl.jdbc.authentication         impl.store.access.sort
     catalog                   iapi.services.uuid               impl.load                        impl.store.raw
     catalog.types             iapi.sql                         impl.services                    impl.store.raw.data
     database                  iapi.sql.compile                 impl.services.bytecode           impl.store.raw.log
     diag                      iapi.sql.conn                    impl.services.cache              impl.store.raw.xact
     iapi                      iapi.sql.depend                  impl.services.daemon             impl.store.replication
     iapi.db                   iapi.sql.dictionary              impl.services.jce                impl.store.replication.buffer
     iapi.error                iapi.sql.execute                 impl.services.jmx                impl.store.replication.master
     iapi.jdbc                 iapi.store                       impl.services.jmxnone            impl.store.replication.net
     iapi.security             iapi.store.access                impl.services.locks              impl.store.replication.slave
     iapi.services             iapi.store.access.conglomerate   impl.services.monitor            impl.tools
     iapi.services.cache       iapi.store.access.xa             impl.services.reflect            impl.tools.sysinfo
     iapi.services.classfile   iapi.store.raw                   impl.services.stream             info
     iapi.services.compiler    iapi.store.raw.data              impl.services.timer              io
     iapi.services.context     iapi.store.raw.log               impl.services.uuid               jdbc
     iapi.services.crypto      iapi.store.raw.xact              impl.sql                         loc
     iapi.services.daemon      iapi.store.replication           impl.sql.catalog                 mbeans
     iapi.services.diag        iapi.store.replication.master    impl.sql.compile                 osgi
     iapi.services.i18n        iapi.store.replication.slave     impl.sql.conn                    security
     iapi.services.info        iapi.tools                       impl.sql.depend                  shared
     iapi.services.io          iapi.tools.i18n                  impl.sql.execute                 shared.common
     iapi.services.jmx         iapi.types                       impl.sql.execute.rts             shared.common.error
     iapi.services.loader      iapi.util                        impl.store                       shared.common.sanity
     iapi.services.locks       impl                             impl.store.access                tools
     iapi.services.memory      impl.db                          impl.store.access.btree          vti
     iapi.services.monitor     impl.io                          impl.store.access.btree.index
     iapi.services.property    impl.io.vfmem                    impl.store.access.conglomerate
     iapi.services.stream      impl.jdbc                        impl.store.access.heap
Step 2: How to create bundles?


Apache Derby – impl.* gone
org.apache.derby.*
     authentication            iapi.services.timer              osgi
     catalog                   iapi.services.uuid               security
     catalog.types             iapi.sql                         shared
     database                  iapi.sql.compile                 shared.common
     diag                      iapi.sql.conn                    shared.common.error
     iapi                      iapi.sql.depend                  shared.common.sanity
     iapi.db                   iapi.sql.dictionary              tools
     iapi.error                iapi.sql.execute                 vti
     iapi.jdbc                 iapi.store
     iapi.security             iapi.store.access
     iapi.services             iapi.store.access.conglomerate
     iapi.services.cache       iapi.store.access.xa
     iapi.services.classfile   iapi.store.raw
     iapi.services.compiler    iapi.store.raw.data
     iapi.services.context     iapi.store.raw.log
     iapi.services.crypto      iapi.store.raw.xact
     iapi.services.daemon      iapi.store.replication
     iapi.services.diag        iapi.store.replication.master
     iapi.services.i18n        iapi.store.replication.slave
     iapi.services.info        iapi.tools
     iapi.services.io          iapi.tools.i18n
     iapi.services.jmx         iapi.types
     iapi.services.loader      iapi.util
     iapi.services.locks       info
     iapi.services.memory      io
     iapi.services.monitor     jdbc
     iapi.services.property    loc
     iapi.services.stream      mbeans
Step 2: How to create bundles?


Apache Derby – what Eclipse uses out of it :-)
org.apache.derby.*
     authentication
     database
     io
     jdbc
     vti                             How to create manifests?
                                      By hand
                                      BND tool
                                      Apache Felix Maven plugin
                                      Eclipse PDE
                                      Bundlor




or in other words…

■ Don’t rush to define manifests, for modules you know nothing of!
Step 3: Let‘s try to activate the bundle.



java.lang.NoClassDefFoundException                                Class definition is
                                                                          missing!


                                 The forName() method in class Class.
Possible causes?                 The findSystemClass method() in class ClassLoader.
                                 The loadClass() method in class ClassLoader
 Missing import-package
 Missing export-package
 Import version mismatch       [1.2.3, 2.0); “1.2.3”
 Forgotten/missing component (really missing!)
 Wrong boot class delegation property
 Missing file system permissions (can’t read the JARs)
Step 3: Separate a the first library as a bundle



java.lang.NoClassDefFoundError                                 Class definition is
                                                                     found, but
                                                             instantiation failed!


Possible causes?
 Exception in static block
 Missing imported class (NoClassDefFoundException for it)
 Class version mismatch
 Hotspot reflection JIT optimizations (BugID 6265952 )
         (injection of sun.misc.Unsafe.defineClass)




 or in other words…

 ■Don’t rush blaming the framework! Classloading there is quite solid!
Step 4: Iterative refactoring



My bundle is not updated?!



Possible causes?
 Didyou update the version?
 You’re replacing your bundle directly in the equinox plugins folder
 Package-imports do not fit to the new bundle version?




 or in other words…

 ■Don’t rush blaming the framework! ;)
Step 4: Iterative refactoring



java.lang.ClassCastError



Possible causes?
 Additionalcopies (besides the system bundle) of the
  OSGi framework classes
 Undesired additional JARs in classpath
■ Clash between RT.jar and application libs
 (previously used embedded jars)
■ Java SE 5 vs. Java SE 6 does make a difference…
 (a bunch of new packages added (StAX, JDBC 4.0, JAXB 2.0, etc.)




 or in other words…

 ■Make sure you understand the root cause. (try using Eclipse Memory Analyzer)
Step 4: Iterative refactoring



Works in Eclipse, but doesn‘t work in Equinox


Possible issues
■ Different setting of org.osgi.parentClassloader
    ■   app           (default for Eclipse)
    ■   boot
    ■   ext
    ■   fwk
 Certain expectations of org.osgi.framework.system.packages
 Different values of org.osgi.framework.bootdelegation
■ property osgi.compatibility.bootdelegation (default for Eclipse is false)

 or in other words…

 ■Don’t be fooled by configuration differences
Step 4: Design flaws



Dependencies on startup order



Possible causes?
■ Avoid lookup-error-fail patterns
■ As a last resort – you can use start levels
■ Keep Activators really lean.
■ Typically seen when extracting code from a web module with fixed
  Servlet.init() order.




or in other words…

■Don’t do anything needless in your activator. That’s not init()/start()!
Step 4: Design flaws



Classloader resource assumptions



Possible issues
■ JAR files
■ Folder containing class files/packages
■ URLs (to any of the above)
■ new File(<resource>), after loader resources iteration
  “bundle:xxx” as a resource




 or in other words…

 ■Don’t make assumptions on the classloader resources!
Step 4: Design flaws



Boot delegation specifics



■ org.osgi.framework.bootdelegation – shortcut the OSGi resolution
■ Adding com.foo.* includes all sub-packages, but not the com.foo
  package itself.
■ osgi.compatibility.bootdelegation - true/false




or in other words…

■Make sure that you understand the setup of your OSGi environment
Step 5: Design flaws



SPI pattern limitations


Possible issues
■ Load a class, described in some meta-data file, used via interface
    ■ META-INF/services/javax.xml.ws.spi.Provider
■ Explicit import of the impl packages is required!
Step 5: Design flaws



My process exits unexpectedly?!


Possible issues
■ Lots of code is written with the assumption that it owns the world and not
  that it lives in a small corner of it.
■ Enabling a Security Manager which traces System.exit() and Runtime.halt()
  calls might help
Step 5: Design flaws



Registering objects in the VM has direct impact on the
ability to stop a bundle

                                                             Some of those
                                                                    have no
Possible issues                                          unregister methods!

■ System in and out streams
■ Shutdown hooks
■ MBean server factory
■ Log4J formatters
■ JNDI provider/factory



or in other words…

■Don’t try to do the job of the underlying middleware.
Step 5: Design flaws



ContextClassLoader usage




Possible issues
■ Some code written to run in a web app might make some assumptions on
  the Context classloader.
■ One example here is JNDI.




or in other words…

■Consider environment dependencies when extracting code into bundles
Agenda




OSGI intro
Headaches
Painkiller options
Q&A
Eclipse Virgo shell improvements



Supportability commands
■ Nested OSGi frameworks
■ Classloading
SpringSource Tool Suite
Other relevant sessions


Tue 12:00 PM   Developing OSGi-Enabled Java EE Applications
Tue 6:00 PM    Patterns for modularity
Tue 6:00 PM    OSGI BOF
Tue 9:00 PM    OSGi at a Large-Scale Enterprise: Lessons from eBay


Wed 10:00 AM   Java EE OSGi applications : Design and Deployment for On-Premises and Cloud
Wed 1:00 PM    OSGi and JSR 294: Module Keyword
Wed 4:45 PM    Visualizing the Science of Conversation with JavaFX and OSGi to Save Lives


Thu 3:30 PM    Creating Modular Applications with Apache Aries and OSGi
Thu 3:30 PM    Developing Rich Modular Clients with Java, JavaFX and OSGi Technology
Q&A?
Thank you!


 Krasimir Semerdzhiev
krasimir.semerdzhiev@sap.com

      Peter Peshev
   peter.peshev@sap.com

More Related Content

What's hot (19)

PPT
Ruby on rails
Amol Pujari
 
PDF
Whats New In Java Ee 6
Stephan Janssen
 
PDF
What's new in JSR-283?
David Nuescheler
 
PDF
OSGi-enabled Java EE Applications using GlassFish
Arun Gupta
 
PDF
What's new in Java EE 6
Gal Marder
 
KEY
5장. Execution Engine
김 한도
 
PDF
2008 Sccc Inheritance
bergel
 
PDF
Create *real* modular Java applications - a brief introduction -
Jeffrey Groneberg
 
KEY
6장 Thread Synchronization
김 한도
 
PDF
OSGi-enabled Java EE Applications using GlassFish at JCertif 2011
Arun Gupta
 
KEY
2장. Runtime Data Areas
김 한도
 
PDF
Running your Java EE applications in the Cloud
Arun Gupta
 
KEY
1장 Java란 무엇인가.key
김 한도
 
PDF
A JCR View of the World - adaptTo() 2012 Berlin
Alexander Klimetschek
 
PDF
Building Content Applications with JCR and OSGi
Cédric Hüsler
 
KEY
3장. Garbage Collection
김 한도
 
ODP
Open Source Compiler Construction for the JVM
Tom Lee
 
PDF
Using Java from Ruby with JRuby IRB
Hiro Asari
 
PPTX
JRuby in Java Projects
jazzman1980
 
Ruby on rails
Amol Pujari
 
Whats New In Java Ee 6
Stephan Janssen
 
What's new in JSR-283?
David Nuescheler
 
OSGi-enabled Java EE Applications using GlassFish
Arun Gupta
 
What's new in Java EE 6
Gal Marder
 
5장. Execution Engine
김 한도
 
2008 Sccc Inheritance
bergel
 
Create *real* modular Java applications - a brief introduction -
Jeffrey Groneberg
 
6장 Thread Synchronization
김 한도
 
OSGi-enabled Java EE Applications using GlassFish at JCertif 2011
Arun Gupta
 
2장. Runtime Data Areas
김 한도
 
Running your Java EE applications in the Cloud
Arun Gupta
 
1장 Java란 무엇인가.key
김 한도
 
A JCR View of the World - adaptTo() 2012 Berlin
Alexander Klimetschek
 
Building Content Applications with JCR and OSGi
Cédric Hüsler
 
3장. Garbage Collection
김 한도
 
Open Source Compiler Construction for the JVM
Tom Lee
 
Using Java from Ruby with JRuby IRB
Hiro Asari
 
JRuby in Java Projects
jazzman1980
 

Similar to JavaOne 2010: OSGI Migrat (20)

PDF
OSGi Best Practices - Tim Ward
mfrancis
 
PDF
Introduction to Apache Camel
FuseSource.com
 
PDF
JBoss AS 7, la révolution
Alexis Hassler
 
PDF
The Java Content Repository
nobby
 
PDF
soft-shake.ch - JBoss AS 7, la révolution
soft-shake.ch
 
PDF
Jvm fundamentals
Miguel Pastor
 
PDF
TorqueBox at DC:JBUG - November 2011
bobmcwhirter
 
PDF
Scotas - Oracle Open World Sao Pablo
Julian Arocena
 
PDF
OSGi DevCon US 2010 Review
mfrancis
 
ODP
Chisimba - introduction to practical demo
Derek Keats
 
PDF
TDC 2011: OSGi-enabled Java EE Application
Arun Gupta
 
PDF
Monoliths are so 2001 – What you need is Modularity
Graham Charters
 
PDF
Java EE 6 workshop at Dallas Tech Fest 2011
Arun Gupta
 
KEY
Enterprise Java Web Application Frameworks Sample Stack Implementation
Mert Çalışkan
 
PDF
Zotonic presentation Erlang Camp Boston, august 2011
Arjan
 
KEY
When Two Worlds Collide: Java and Ruby in the Enterprise
benbrowning
 
PDF
Introducing JSR-283
David Nuescheler
 
PDF
Understanding the Dalvik Virtual Machine
National Cheng Kung University
 
PPTX
Visual COBOL Development for Unix and Java
Micro Focus
 
PDF
Haj 4344-java se 9 and the application server-1
Kevin Sutter
 
OSGi Best Practices - Tim Ward
mfrancis
 
Introduction to Apache Camel
FuseSource.com
 
JBoss AS 7, la révolution
Alexis Hassler
 
The Java Content Repository
nobby
 
soft-shake.ch - JBoss AS 7, la révolution
soft-shake.ch
 
Jvm fundamentals
Miguel Pastor
 
TorqueBox at DC:JBUG - November 2011
bobmcwhirter
 
Scotas - Oracle Open World Sao Pablo
Julian Arocena
 
OSGi DevCon US 2010 Review
mfrancis
 
Chisimba - introduction to practical demo
Derek Keats
 
TDC 2011: OSGi-enabled Java EE Application
Arun Gupta
 
Monoliths are so 2001 – What you need is Modularity
Graham Charters
 
Java EE 6 workshop at Dallas Tech Fest 2011
Arun Gupta
 
Enterprise Java Web Application Frameworks Sample Stack Implementation
Mert Çalışkan
 
Zotonic presentation Erlang Camp Boston, august 2011
Arjan
 
When Two Worlds Collide: Java and Ruby in the Enterprise
benbrowning
 
Introducing JSR-283
David Nuescheler
 
Understanding the Dalvik Virtual Machine
National Cheng Kung University
 
Visual COBOL Development for Unix and Java
Micro Focus
 
Haj 4344-java se 9 and the application server-1
Kevin Sutter
 
Ad

More from SAP HANA Cloud Platform (17)

PDF
SAP Hack2Build hackathon - SAP Commerce Cloud & Kyma runtime
SAP HANA Cloud Platform
 
PDF
Gardener: Managed Kubernetes on Your Terms
SAP HANA Cloud Platform
 
PDF
Kyma: Extending Business systems with Kubernetes, Istio and <fill the blank>.
SAP HANA Cloud Platform
 
PDF
Using Kubernetes to Extend Enterprise Software
SAP HANA Cloud Platform
 
PDF
Kubernetes, Istio and Knative - noteworthy practical experience
SAP HANA Cloud Platform
 
PDF
Options for running Kubernetes at scale across multiple cloud providers
SAP HANA Cloud Platform
 
PDF
SAP DKOM 2016 | 30154 | SAP HCP Cloud Extensions Intro
SAP HANA Cloud Platform
 
PDF
SAP TechEd 2015 | DEV109 | Extending Cloud Solutions from SAP using SAP HANA ...
SAP HANA Cloud Platform
 
PDF
SAP D-Code/TechEd 2014|DEV203|Extending SuccessFactors using SAP HANA Cloud P...
SAP HANA Cloud Platform
 
PDF
SAP TechEd 2013: CD105: Extending SuccessFactors EmployeeCentral with apps on...
SAP HANA Cloud Platform
 
PDF
SAP HANA Cloud Platform Community BOF @ Devoxx 2013
SAP HANA Cloud Platform
 
PDF
SAP HANA Cloud Platform: The void between your Datacenter and the Cloud
SAP HANA Cloud Platform
 
PDF
SAP HANA Cloud: From Your Datacenter to the Cloud and Back
SAP HANA Cloud Platform
 
PDF
OSGI in Java EE servers:Sneak peak
SAP HANA Cloud Platform
 
PDF
[BGOUG] Memory analyzer
SAP HANA Cloud Platform
 
PDF
[BGOUG] Java GC - Friend or Foe
SAP HANA Cloud Platform
 
PDF
Eclipse Open Source @ SAP
SAP HANA Cloud Platform
 
SAP Hack2Build hackathon - SAP Commerce Cloud & Kyma runtime
SAP HANA Cloud Platform
 
Gardener: Managed Kubernetes on Your Terms
SAP HANA Cloud Platform
 
Kyma: Extending Business systems with Kubernetes, Istio and <fill the blank>.
SAP HANA Cloud Platform
 
Using Kubernetes to Extend Enterprise Software
SAP HANA Cloud Platform
 
Kubernetes, Istio and Knative - noteworthy practical experience
SAP HANA Cloud Platform
 
Options for running Kubernetes at scale across multiple cloud providers
SAP HANA Cloud Platform
 
SAP DKOM 2016 | 30154 | SAP HCP Cloud Extensions Intro
SAP HANA Cloud Platform
 
SAP TechEd 2015 | DEV109 | Extending Cloud Solutions from SAP using SAP HANA ...
SAP HANA Cloud Platform
 
SAP D-Code/TechEd 2014|DEV203|Extending SuccessFactors using SAP HANA Cloud P...
SAP HANA Cloud Platform
 
SAP TechEd 2013: CD105: Extending SuccessFactors EmployeeCentral with apps on...
SAP HANA Cloud Platform
 
SAP HANA Cloud Platform Community BOF @ Devoxx 2013
SAP HANA Cloud Platform
 
SAP HANA Cloud Platform: The void between your Datacenter and the Cloud
SAP HANA Cloud Platform
 
SAP HANA Cloud: From Your Datacenter to the Cloud and Back
SAP HANA Cloud Platform
 
OSGI in Java EE servers:Sneak peak
SAP HANA Cloud Platform
 
[BGOUG] Memory analyzer
SAP HANA Cloud Platform
 
[BGOUG] Java GC - Friend or Foe
SAP HANA Cloud Platform
 
Eclipse Open Source @ SAP
SAP HANA Cloud Platform
 
Ad

Recently uploaded (20)

PDF
Log-Based Anomaly Detection: Enhancing System Reliability with Machine Learning
Mohammed BEKKOUCHE
 
PDF
Transcript: New from BookNet Canada for 2025: BNC BiblioShare - Tech Forum 2025
BookNet Canada
 
PPTX
✨Unleashing Collaboration: Salesforce Channels & Community Power in Patna!✨
SanjeetMishra29
 
PPTX
Top iOS App Development Company in the USA for Innovative Apps
SynapseIndia
 
PDF
CIFDAQ Weekly Market Wrap for 11th July 2025
CIFDAQ
 
PPTX
WooCommerce Workshop: Bring Your Laptop
Laura Hartwig
 
PPTX
UiPath Academic Alliance Educator Panels: Session 2 - Business Analyst Content
DianaGray10
 
PDF
CIFDAQ Token Spotlight for 9th July 2025
CIFDAQ
 
PDF
Newgen Beyond Frankenstein_Build vs Buy_Digital_version.pdf
darshakparmar
 
PDF
Bitcoin for Millennials podcast with Bram, Power Laws of Bitcoin
Stephen Perrenod
 
PPTX
OpenID AuthZEN - Analyst Briefing July 2025
David Brossard
 
PDF
July Patch Tuesday
Ivanti
 
PDF
How Startups Are Growing Faster with App Developers in Australia.pdf
India App Developer
 
PDF
SFWelly Summer 25 Release Highlights July 2025
Anna Loughnan Colquhoun
 
PDF
Chris Elwell Woburn, MA - Passionate About IT Innovation
Chris Elwell Woburn, MA
 
PDF
DevBcn - Building 10x Organizations Using Modern Productivity Metrics
Justin Reock
 
PDF
"AI Transformation: Directions and Challenges", Pavlo Shaternik
Fwdays
 
PPT
Interview paper part 3, It is based on Interview Prep
SoumyadeepGhosh39
 
PDF
Windsurf Meetup Ottawa 2025-07-12 - Planning Mode at Reliza.pdf
Pavel Shukhman
 
PDF
Newgen 2022-Forrester Newgen TEI_13 05 2022-The-Total-Economic-Impact-Newgen-...
darshakparmar
 
Log-Based Anomaly Detection: Enhancing System Reliability with Machine Learning
Mohammed BEKKOUCHE
 
Transcript: New from BookNet Canada for 2025: BNC BiblioShare - Tech Forum 2025
BookNet Canada
 
✨Unleashing Collaboration: Salesforce Channels & Community Power in Patna!✨
SanjeetMishra29
 
Top iOS App Development Company in the USA for Innovative Apps
SynapseIndia
 
CIFDAQ Weekly Market Wrap for 11th July 2025
CIFDAQ
 
WooCommerce Workshop: Bring Your Laptop
Laura Hartwig
 
UiPath Academic Alliance Educator Panels: Session 2 - Business Analyst Content
DianaGray10
 
CIFDAQ Token Spotlight for 9th July 2025
CIFDAQ
 
Newgen Beyond Frankenstein_Build vs Buy_Digital_version.pdf
darshakparmar
 
Bitcoin for Millennials podcast with Bram, Power Laws of Bitcoin
Stephen Perrenod
 
OpenID AuthZEN - Analyst Briefing July 2025
David Brossard
 
July Patch Tuesday
Ivanti
 
How Startups Are Growing Faster with App Developers in Australia.pdf
India App Developer
 
SFWelly Summer 25 Release Highlights July 2025
Anna Loughnan Colquhoun
 
Chris Elwell Woburn, MA - Passionate About IT Innovation
Chris Elwell Woburn, MA
 
DevBcn - Building 10x Organizations Using Modern Productivity Metrics
Justin Reock
 
"AI Transformation: Directions and Challenges", Pavlo Shaternik
Fwdays
 
Interview paper part 3, It is based on Interview Prep
SoumyadeepGhosh39
 
Windsurf Meetup Ottawa 2025-07-12 - Planning Mode at Reliza.pdf
Pavel Shukhman
 
Newgen 2022-Forrester Newgen TEI_13 05 2022-The-Total-Economic-Impact-Newgen-...
darshakparmar
 

JavaOne 2010: OSGI Migrat

  • 1. S314613: OSGI Migration headaches Krasimir Semerdzhiev SAP Labs Bulgaria Development Architect Peter Peshev SAP Labs Bulgaria Development Architect
  • 5. Good architecture and interchangeable minilang party pos. product workeffort workflow … accounting assetmaint content bi ebay ecommerce googlebase guiapp hhfacility manufact. marketing minerva oagis order Application layer common catalina base datafile entity widget … resolver rome serializer servlets tomcat xalan bsf mail mx4j naming jetty poi wsdl4j bsh jenks jpos18 jython looks lucene xerces velocity jakarta jcl json jdbm jdom xmlapis ws-commons log4j barcode4j axis batik commons xmlrpc geronimo httpunit freemarker ezmorph fop derby xmlgraphics Libs.. Java VM rt jce jsse plugin sunjce_prov. dnsns ..
  • 6. Problem: CLASSPATH Java VM party common resolver axis xerces Begin rt jce assetmaint hhfacility catalina base mail jenks ezmorph servlets xmlapis xmlrpc Here jsse pos. datafile jakarta jetty xmlgraphics plugin content entity log4j looks sunjce_prov manufact. widget httpunit jdbm . dnsns product … mx4j bsf .. bi rome batik bsh Class marketing workflow jpos18 fop velocity workeffort ecommerce jcl tomcat ws-commons Not ebay oagis barcode4j poi geronimo Found minerva … freemarker lucene .. Exception minilang googlebase serializer jdom json accounting order naming commons xalan guiapp ofbiz jython derby wsdl4j
  • 7. The OSGi Alliance  Started March 1999 as an initiative from ERICSSON, SUN and IBM  Today: A stable Alliance with almost 100 members  Now practically all of the Java Server vendors are represented there  A standardization body…
  • 8. OSGi Framework Layers Staircase  Applications can make use of different layers directly  Module Layer defines packaging , deployment dependancies among modules  Lifecycle Layer controls lifecycyle operations of a bundle
  • 9. Module Layer: Bundles Bundles  Are JAR files  Contain classes, other resources like HTML, images, specific metadata  Contain manifest file (META-INF/MANIFEST.MF) with OSGI specific headers used to manage the bundle  Describes the content of the JAR file  Export Import package  Require-Bundle
  • 10. Module Layer: Runtime class loading load class com.foo.classA
  • 12. Class Loading Architecture: Delegation Basic properties  Parent delegation  Wire importers and exporters  There can be fragment bundles  Class loading traversal based on importers and their wires
  • 13. Lifecycle Layer Runtime representation of bundles  Forevery bundle, the framework creates a Bundle java object  Bundles are identified by Bundle ID, Bundle Symbolic Name and Bundle Location  Bundle has a runtime state:
  • 14. What is the story? Web Web Module bundle Web Module Web Modules Modules (war) (war) bundle Web Modules bundle Web Modules State 2 bundle Lib Lib Lib Lib EAR file EAR file OSGi framework Java EE compliant runtime bundle bundle bundle bundle bundle bundle bundle bundle bundle bundle bundle bundle bundle bundle bundle OSGi framework
  • 15. What do we aim to get from OSGi? ■ Standardized execution environment ■ Java-based modularization ■ Well defined module contract ■ Strict dependency management at build and run time ■ Manifest as a single point of truth ■ Deterministic declarative runtime resolution or in other words… ■ Evolve from JARs/modules to “interchangeable/reusable parts”
  • 17. Step 1: Choose an OSGi runtime
  • 18. Step 2: How to create bundles? Manifest-Version: 1.0 Bundle-Name: My First Bundle Bundle-SymbolicName: com.acme.myfirstbundle Bundle-Version: 1.0.0 Bundle-Description: Small Bundle Bundle-Vendor: ACME Bundle-Activator: com.acme.myfirstbundle.impl.Activator Bundle-Category: example Import-Package: org.osgi.framework Export-Package: com.acme.myfirstbundle.api Export-Package ::= export(‘,’ export)* export ::= package-names(‘;’ parameter)* package-names ::= package-name(‘;’ package-name)* Import-Package ::= import(‘,’ import)* import ::= package-names(‘;’ parameter)* package-names ::= package-name(‘;’ package-name)* Require-Bundle ::= bundle-description ( ',' bundle-description )* bundle-description ::= symbolic-name (';' parameter )*
  • 19. Step 2: How to create bundles? Let‘s take one example – Apache Derby org.apache.derby.* authentication iapi.services.timer impl.jdbc.authentication impl.store.access.sort catalog iapi.services.uuid impl.load impl.store.raw catalog.types iapi.sql impl.services impl.store.raw.data database iapi.sql.compile impl.services.bytecode impl.store.raw.log diag iapi.sql.conn impl.services.cache impl.store.raw.xact iapi iapi.sql.depend impl.services.daemon impl.store.replication iapi.db iapi.sql.dictionary impl.services.jce impl.store.replication.buffer iapi.error iapi.sql.execute impl.services.jmx impl.store.replication.master iapi.jdbc iapi.store impl.services.jmxnone impl.store.replication.net iapi.security iapi.store.access impl.services.locks impl.store.replication.slave iapi.services iapi.store.access.conglomerate impl.services.monitor impl.tools iapi.services.cache iapi.store.access.xa impl.services.reflect impl.tools.sysinfo iapi.services.classfile iapi.store.raw impl.services.stream info iapi.services.compiler iapi.store.raw.data impl.services.timer io iapi.services.context iapi.store.raw.log impl.services.uuid jdbc iapi.services.crypto iapi.store.raw.xact impl.sql loc iapi.services.daemon iapi.store.replication impl.sql.catalog mbeans iapi.services.diag iapi.store.replication.master impl.sql.compile osgi iapi.services.i18n iapi.store.replication.slave impl.sql.conn security iapi.services.info iapi.tools impl.sql.depend shared iapi.services.io iapi.tools.i18n impl.sql.execute shared.common iapi.services.jmx iapi.types impl.sql.execute.rts shared.common.error iapi.services.loader iapi.util impl.store shared.common.sanity iapi.services.locks impl impl.store.access tools iapi.services.memory impl.db impl.store.access.btree vti iapi.services.monitor impl.io impl.store.access.btree.index iapi.services.property impl.io.vfmem impl.store.access.conglomerate iapi.services.stream impl.jdbc impl.store.access.heap
  • 20. Step 2: How to create bundles? Apache Derby – impl.* gone org.apache.derby.* authentication iapi.services.timer osgi catalog iapi.services.uuid security catalog.types iapi.sql shared database iapi.sql.compile shared.common diag iapi.sql.conn shared.common.error iapi iapi.sql.depend shared.common.sanity iapi.db iapi.sql.dictionary tools iapi.error iapi.sql.execute vti iapi.jdbc iapi.store iapi.security iapi.store.access iapi.services iapi.store.access.conglomerate iapi.services.cache iapi.store.access.xa iapi.services.classfile iapi.store.raw iapi.services.compiler iapi.store.raw.data iapi.services.context iapi.store.raw.log iapi.services.crypto iapi.store.raw.xact iapi.services.daemon iapi.store.replication iapi.services.diag iapi.store.replication.master iapi.services.i18n iapi.store.replication.slave iapi.services.info iapi.tools iapi.services.io iapi.tools.i18n iapi.services.jmx iapi.types iapi.services.loader iapi.util iapi.services.locks info iapi.services.memory io iapi.services.monitor jdbc iapi.services.property loc iapi.services.stream mbeans
  • 21. Step 2: How to create bundles? Apache Derby – what Eclipse uses out of it :-) org.apache.derby.* authentication database io jdbc vti How to create manifests?  By hand  BND tool  Apache Felix Maven plugin  Eclipse PDE  Bundlor or in other words… ■ Don’t rush to define manifests, for modules you know nothing of!
  • 22. Step 3: Let‘s try to activate the bundle. java.lang.NoClassDefFoundException Class definition is missing! The forName() method in class Class. Possible causes? The findSystemClass method() in class ClassLoader. The loadClass() method in class ClassLoader  Missing import-package  Missing export-package  Import version mismatch [1.2.3, 2.0); “1.2.3”  Forgotten/missing component (really missing!)  Wrong boot class delegation property  Missing file system permissions (can’t read the JARs)
  • 23. Step 3: Separate a the first library as a bundle java.lang.NoClassDefFoundError Class definition is found, but instantiation failed! Possible causes?  Exception in static block  Missing imported class (NoClassDefFoundException for it)  Class version mismatch  Hotspot reflection JIT optimizations (BugID 6265952 ) (injection of sun.misc.Unsafe.defineClass) or in other words… ■Don’t rush blaming the framework! Classloading there is quite solid!
  • 24. Step 4: Iterative refactoring My bundle is not updated?! Possible causes?  Didyou update the version?  You’re replacing your bundle directly in the equinox plugins folder  Package-imports do not fit to the new bundle version? or in other words… ■Don’t rush blaming the framework! ;)
  • 25. Step 4: Iterative refactoring java.lang.ClassCastError Possible causes?  Additionalcopies (besides the system bundle) of the OSGi framework classes  Undesired additional JARs in classpath ■ Clash between RT.jar and application libs (previously used embedded jars) ■ Java SE 5 vs. Java SE 6 does make a difference… (a bunch of new packages added (StAX, JDBC 4.0, JAXB 2.0, etc.) or in other words… ■Make sure you understand the root cause. (try using Eclipse Memory Analyzer)
  • 26. Step 4: Iterative refactoring Works in Eclipse, but doesn‘t work in Equinox Possible issues ■ Different setting of org.osgi.parentClassloader ■ app (default for Eclipse) ■ boot ■ ext ■ fwk  Certain expectations of org.osgi.framework.system.packages  Different values of org.osgi.framework.bootdelegation ■ property osgi.compatibility.bootdelegation (default for Eclipse is false) or in other words… ■Don’t be fooled by configuration differences
  • 27. Step 4: Design flaws Dependencies on startup order Possible causes? ■ Avoid lookup-error-fail patterns ■ As a last resort – you can use start levels ■ Keep Activators really lean. ■ Typically seen when extracting code from a web module with fixed Servlet.init() order. or in other words… ■Don’t do anything needless in your activator. That’s not init()/start()!
  • 28. Step 4: Design flaws Classloader resource assumptions Possible issues ■ JAR files ■ Folder containing class files/packages ■ URLs (to any of the above) ■ new File(<resource>), after loader resources iteration “bundle:xxx” as a resource or in other words… ■Don’t make assumptions on the classloader resources!
  • 29. Step 4: Design flaws Boot delegation specifics ■ org.osgi.framework.bootdelegation – shortcut the OSGi resolution ■ Adding com.foo.* includes all sub-packages, but not the com.foo package itself. ■ osgi.compatibility.bootdelegation - true/false or in other words… ■Make sure that you understand the setup of your OSGi environment
  • 30. Step 5: Design flaws SPI pattern limitations Possible issues ■ Load a class, described in some meta-data file, used via interface ■ META-INF/services/javax.xml.ws.spi.Provider ■ Explicit import of the impl packages is required!
  • 31. Step 5: Design flaws My process exits unexpectedly?! Possible issues ■ Lots of code is written with the assumption that it owns the world and not that it lives in a small corner of it. ■ Enabling a Security Manager which traces System.exit() and Runtime.halt() calls might help
  • 32. Step 5: Design flaws Registering objects in the VM has direct impact on the ability to stop a bundle Some of those have no Possible issues unregister methods! ■ System in and out streams ■ Shutdown hooks ■ MBean server factory ■ Log4J formatters ■ JNDI provider/factory or in other words… ■Don’t try to do the job of the underlying middleware.
  • 33. Step 5: Design flaws ContextClassLoader usage Possible issues ■ Some code written to run in a web app might make some assumptions on the Context classloader. ■ One example here is JNDI. or in other words… ■Consider environment dependencies when extracting code into bundles
  • 35. Eclipse Virgo shell improvements Supportability commands ■ Nested OSGi frameworks ■ Classloading
  • 37. Other relevant sessions Tue 12:00 PM Developing OSGi-Enabled Java EE Applications Tue 6:00 PM Patterns for modularity Tue 6:00 PM OSGI BOF Tue 9:00 PM OSGi at a Large-Scale Enterprise: Lessons from eBay Wed 10:00 AM Java EE OSGi applications : Design and Deployment for On-Premises and Cloud Wed 1:00 PM OSGi and JSR 294: Module Keyword Wed 4:45 PM Visualizing the Science of Conversation with JavaFX and OSGi to Save Lives Thu 3:30 PM Creating Modular Applications with Apache Aries and OSGi Thu 3:30 PM Developing Rich Modular Clients with Java, JavaFX and OSGi Technology
  • 38. Q&A?