SlideShare a Scribd company logo
Public
Migration of existing web
applications to OSGi
ESE 2010
Diyan Yordanov
SAP Labs Bulgaria
© SAP AG 2010. All rights reserved. / Page 2 Public
Agenda
1. OSGi Web Container
2. Migrating Existing Web Applications to OSGi
3. Challenges That We Overcome
4. Conclusions
© SAP AG 2010. All rights reserved. / Page 3 Public
Why web applications on OSGi?
Last years trends of software development
A good choice for product evolving
Encapsulated modules
Versioning
Class space isolation
Declarative dependencies
Dynamic refreshing and updating
Ongoing work to make OSGi platform more appealing to the enterprise
world
Eclipse Gemini – Enterprise Modules project
Eclipse Virgo – Dynamic Enterprise Application Platform project
© SAP AG 2010. All rights reserved. / Page 4 Public
OSGi Web Container
Based on Web Application Specification part of OSGi Enterprise
Specification
Provides support for Web Applications written to
Servlet 2.5 or later
JSP 2.1 or later
Java EE OSGi
WAR
© SAP AG 2010. All rights reserved. / Page 5 Public
Available OSGi specific features
Main Features in OSGi Web Container
Installation of WAR files
Installation of Web Application Bundles (WABs)
Control of configuration properties using URL parameters
Multiple applications with single context path
Web application lifecycle managed by OSGi bundle lifecycle
Facilitates interoperability between web application with other OSGi
components
Modularization – one big blob WAR to be broken into smaller modules
Dynamic deployment, and fast update of individual modules
© SAP AG 2010. All rights reserved. / Page 6 Public
Agenda
1. OSGi Web Container
2. Migrating Existing Web Applications to OSGi
3. Challenges That We Overcome
4. Conclusions
© SAP AG 2010. All rights reserved. / Page 7 Public
Migrating Web Applications to OSGi
• deploying standard WAR
• removing JAR files from WAR and declaring dependencies on
corresponding OSGi bundles
• separating web artifacts from services they depend on
Web Application
WAR
Services
CatalogService
PaymentService
Libraries
Resources
Images CSS
Spring
Hibernate
Services
CatalogService
PaymentService
How to modify the Web application in order to benefit from OSGi?
© SAP AG 2010. All rights reserved. / Page 8 Public
Agenda
1. OSGi Web Container
2. Migrating Existing Web Applications to OSGi
3. Challenges That We Overcome
4. Conclusions
© SAP AG 2010. All rights reserved. / Page 9 Public
Certain APIs and JARs are missing
Web application assumes that Java EE environment provides a certain API
or JARs in the classpath
In OSGi environment:
Manifest – single management point for the bundle
Export-Package
Import-Package
Require-Bundle
Do not rely on automated add for standard Java EE packages
Manual scan and update import packages for required ones
Or use tools like BND, Eclipse PDE, Bundlor STS
Be careful with
org.osgi.framework.bootdelagation
osgi.compatibility.bootdelagation (Eclipse Equinox specific)
© SAP AG 2010. All rights reserved. / Page 10 Public
Support for context.xml
Context.xml is widely adopted by web applications used to run on Tomcat
Support for web application context configuration was contributed to
Gemini Web
The configuration files are located as follow:
 $SERVER_HOME/config/context.xml is the default context configuration file for all
web applications.
 $SERVER_HOME/config/[enginename]/[hostname] directory contains:
o The default context configuration for all web applications of a given virtual host.
o Individual web applications’ context configuration files.
[enginename] is the name of Tomcat’s engine (“Catalina” by default) and [hostname]
names a virtual host, both of which are configured in tomcat-server.xml.
Note that the following context configuration features are not supported in Gemini Web:
• Custom class loaders.
• Specifying the context path. This is specified using the Web-ContextPath header in web
application’s MANIFEST.MF file.
• Specifying the document base directory.
© SAP AG 2010. All rights reserved. / Page 11 Public
WAR extraction
Web application assume it’s extracted on the file system
widely use file system operations
search for resources, configurations, customizations
WAB is installed as bundle
web application is run from the archive
file system operations do not work as expected
Problem
Application cannot access its configurations
Valid for web apps like Orbeon Forms, Jira,
or Confluence wiki
Solution
Implemented support for deploying web application
in exploded form from a file system directory,
following the format of the WAR file
© SAP AG 2010. All rights reserved. / Page 12 Public
Class and resource loading problems – Part I
Known problems for standard bundles are still valid for WAB
java.lang.ClassNotFoundException
Because of:
 Missing import or export package
 Import version mismatch
 Forgotten/missing component (really missing!)
 Wrong boot class delegation property
 Missing file system permissions (can’t read the JARs)
java.lang.NoClassDefFoundError
Because of:
 Exception in static block
 Missing imported class (ClassNotFoundException for it)
 Class version mismatch
Class definition is
found, but
instantiation failed!
Class definition
is missing!
© SAP AG 2010. All rights reserved. / Page 13 Public
Class and resource loading problems – Part II
java.lang.ClassCastException
Because of:
 Additional copies (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)
 JavaSE 5 vs.Java SE 6 does make a difference… (a bunch of new packages
added (StAX, JDBC 4.0, JAXB 2.0, etc.)
© SAP AG 2010. All rights reserved. / Page 14 Public
Class and resource loading problems – Part III
Classloader resource assumptions
Access resources as InputStream via the getResourceAsStream()
Access resource using URL object:
URL resourceURL = this.getClass().getResource(“agenda.txt”);
File resourceFile = new File(resourceURL.toURI());
The result is:
java.lang.IllegalArgumentException: URI scheme is not "file"
Because the URL for the resource is returned like this
bundleresource://46.fwk30983464/summit/agenda.txt
This is a limitation for Gemini Web, but is work around in Virgo
(see bug 325578).
© SAP AG 2010. All rights reserved. / Page 15 Public
Cluster Features
Some applications may use setups where some cluster functionality is
needed
If Tomcat’s “cluster-howto” doc is used the result is:
java.lang.ClassNotFoundException: org.apache.catalina.ha.tcp.SimpleTcpCluster
at
org.eclipse.gemini.web.tomcat.internal.loading.ChainedClassLoader.doLoadClass(Cha
inedClassLoader.java:174)
at
org.eclipse.gemini.web.tomcat.internal.loading.ChainedClassLoader.loadClass(Chain
edClassLoader.java:157)
at
org.apache.tomcat.util.digester.ObjectCreateRule.begin(ObjectCreateRule.java:205)
Solution was provided in MS4 if Gemini Web based on fragments and:
Standard Apache Tomcat Cluster configuration is supported
Disabled by default but can be enabled when needed
© SAP AG 2010. All rights reserved. / Page 16 Public
Automatic Tools
There is NO tool for migrating standard Java EE web application (WAR) to
Web Application Bundle (WAB)
 Eclipse PDE – can help with the MANIFEST.MF file
 SpringSource Tool Suite
Different tools for creating MANIFEST.MF
 BND tool
 Apache Felix Maven plugin
 Bundlor
OSGi Enterprise Tools (Eclipse proposal)
 Wizard for creating WAB
 Tools for converting existing Java EE Dynamic Web projects to WAB project
 Tools for editing the OSGi metadata – manifest headers
 Generic OSGi server adapter
© SAP AG 2010. All rights reserved. / Page 17 Public
Agenda
1. OSGi Web Container
2. Migrating Existing Web Applications to OSGi
3. Challenges That We Overcome
4. Conclusions
© SAP AG 2010. All rights reserved. / Page 18 Public
Takeaways
Learning curve
Know your application
Assumption for unique context root
Assumption for availability of default Java EE
lib jars
Know OSGi
How classloaders work
Classloader “hell”
ClassNotFoundException, NoClassDefFoundError, ClassCastException
Avoid Class.forName()
Know your wirings
Make sure that you understand the setup of your OSGi environment
© SAP AG 2010. All rights reserved. / Page 19 Public
Conclusions
Web on OSGi does work.
Just don’t stumble over small defects.
Working together with the community is the key for success.
© SAP AG 2010. All rights reserved. / Page 20 Public
Diyan Yordanov
diyan.yordanov@sap.com
Thank you!

More Related Content

PDF
Hints and Tips for Modularizing Existing Enterprise Applications (OSGi Commun...
PPTX
Migrating From Applets to Java Desktop Apps in JavaFX
PDF
Burns jsf-confess-2015
PPTX
Best Practices for JSF, Gameduell 2013
PPTX
Ed presents JSF 2.2 and WebSocket to Gameduell.
KEY
Yii Introduction
PDF
JavaFX Uni Parthenope
PDF
Oracle ADF Architecture TV - Design - ADF BC Application Module Design
Hints and Tips for Modularizing Existing Enterprise Applications (OSGi Commun...
Migrating From Applets to Java Desktop Apps in JavaFX
Burns jsf-confess-2015
Best Practices for JSF, Gameduell 2013
Ed presents JSF 2.2 and WebSocket to Gameduell.
Yii Introduction
JavaFX Uni Parthenope
Oracle ADF Architecture TV - Design - ADF BC Application Module Design

What's hot (19)

KEY
Embedding Web UIs in your Eclipse application
PDF
Oracle ADF Architecture TV - Design - Architecting for ADF Mobile Integration
PDF
Java EE 6 and GlassFish v3: Paving the path for future
PDF
2015 JavaOne LAD JSF 2.3 & MVC 1.0
PDF
Java EE7 Demystified
PDF
JVMs in Containers - Best Practices
PPT
Enterprise GlassFish
PPTX
JavaOne - 10 Tips for Java EE 7 with PrimeFaces
PDF
How to Thrive on REST/WebSocket-Based Microservices
ODT
Spring framework
PDF
Oracle ADF Architecture TV - Design - MDS Infrastructure Decisions
PDF
Oracle ADF Architecture TV - Planning & Getting Started - Team, Skills and D...
PPTX
JavaFX 2 Using the Spring Framework
PDF
Liferay portals in real projects
PPTX
JavaFX and JEE 7
PDF
Travelling Light for the Long Haul - Ian Robinson
PPT
Java EE7 in action
PDF
GlassFish OSGi Server
PPT
Ankara JUG Ağustos 2013 - Oracle ADF
Embedding Web UIs in your Eclipse application
Oracle ADF Architecture TV - Design - Architecting for ADF Mobile Integration
Java EE 6 and GlassFish v3: Paving the path for future
2015 JavaOne LAD JSF 2.3 & MVC 1.0
Java EE7 Demystified
JVMs in Containers - Best Practices
Enterprise GlassFish
JavaOne - 10 Tips for Java EE 7 with PrimeFaces
How to Thrive on REST/WebSocket-Based Microservices
Spring framework
Oracle ADF Architecture TV - Design - MDS Infrastructure Decisions
Oracle ADF Architecture TV - Planning & Getting Started - Team, Skills and D...
JavaFX 2 Using the Spring Framework
Liferay portals in real projects
JavaFX and JEE 7
Travelling Light for the Long Haul - Ian Robinson
Java EE7 in action
GlassFish OSGi Server
Ankara JUG Ağustos 2013 - Oracle ADF
Ad

Similar to Migration of Existing Web Applications to OSGi at Eclipse Summit Europe 2010 (20)

PDF
OSGi in Java EE Servers - Sneak Peek Under the Hood - Krasimir Semerdzhiev
PDF
Travelling light for the long haul
PPTX
Web Services.pptx
PDF
Hints and Tips for Modularizing Existing Enterprise Applications with OSGi - ...
PDF
IBM WebSphere application server
PPTX
WAS vs JBoss, WebLogic, Tomcat (year 2015)
PPT
ibm websphere admin training | websphere admin course | ibm websphere adminis...
PDF
Was liberty in deployments
PPTX
SCWCD : Servlet web applications : CHAP 3
PDF
XebiaLabs - Optimizing App Deployment to IBM WebSphere
PDF
Building A Simple Web Service With CXF
PDF
Chapter 1 introduction
PDF
Web sphere application transformation and modernization at engie electrabel
PDF
AAI-1305 Choosing WebSphere Liberty for Java EE Deployments
PPT
Introducing OSGi Technology to Existing Projects - Nils Hofseth Andersen
PDF
AAI-1304 Technical Deep-Dive into IBM WebSphere Liberty
PPTX
SCWCD : Servlet web applications : CHAP : 3
PDF
OSGi Community Event 2010 - Enterprise Platform over OSGi - Migration Diary
PDF
Practical lessons from customers performing digital transformation with Azure
PDF
Improve your Developer Experiece using the WAS Liberty Profile with JRebel
OSGi in Java EE Servers - Sneak Peek Under the Hood - Krasimir Semerdzhiev
Travelling light for the long haul
Web Services.pptx
Hints and Tips for Modularizing Existing Enterprise Applications with OSGi - ...
IBM WebSphere application server
WAS vs JBoss, WebLogic, Tomcat (year 2015)
ibm websphere admin training | websphere admin course | ibm websphere adminis...
Was liberty in deployments
SCWCD : Servlet web applications : CHAP 3
XebiaLabs - Optimizing App Deployment to IBM WebSphere
Building A Simple Web Service With CXF
Chapter 1 introduction
Web sphere application transformation and modernization at engie electrabel
AAI-1305 Choosing WebSphere Liberty for Java EE Deployments
Introducing OSGi Technology to Existing Projects - Nils Hofseth Andersen
AAI-1304 Technical Deep-Dive into IBM WebSphere Liberty
SCWCD : Servlet web applications : CHAP : 3
OSGi Community Event 2010 - Enterprise Platform over OSGi - Migration Diary
Practical lessons from customers performing digital transformation with Azure
Improve your Developer Experiece using the WAS Liberty Profile with JRebel
Ad

Recently uploaded (20)

PDF
Optimiser vos workloads AI/ML sur Amazon EC2 et AWS Graviton
PDF
gpt5_lecture_notes_comprehensive_20250812015547.pdf
PPTX
Machine Learning_overview_presentation.pptx
PPTX
Spectroscopy.pptx food analysis technology
PPTX
20250228 LYD VKU AI Blended-Learning.pptx
PDF
Mobile App Security Testing_ A Comprehensive Guide.pdf
PDF
Per capita expenditure prediction using model stacking based on satellite ima...
PDF
The Rise and Fall of 3GPP – Time for a Sabbatical?
PPT
Teaching material agriculture food technology
PPT
“AI and Expert System Decision Support & Business Intelligence Systems”
PDF
cuic standard and advanced reporting.pdf
PDF
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
PDF
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
PDF
Encapsulation theory and applications.pdf
PDF
MIND Revenue Release Quarter 2 2025 Press Release
PDF
Profit Center Accounting in SAP S/4HANA, S4F28 Col11
PPTX
Tartificialntelligence_presentation.pptx
PDF
Agricultural_Statistics_at_a_Glance_2022_0.pdf
PDF
Empathic Computing: Creating Shared Understanding
PDF
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
Optimiser vos workloads AI/ML sur Amazon EC2 et AWS Graviton
gpt5_lecture_notes_comprehensive_20250812015547.pdf
Machine Learning_overview_presentation.pptx
Spectroscopy.pptx food analysis technology
20250228 LYD VKU AI Blended-Learning.pptx
Mobile App Security Testing_ A Comprehensive Guide.pdf
Per capita expenditure prediction using model stacking based on satellite ima...
The Rise and Fall of 3GPP – Time for a Sabbatical?
Teaching material agriculture food technology
“AI and Expert System Decision Support & Business Intelligence Systems”
cuic standard and advanced reporting.pdf
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
Encapsulation theory and applications.pdf
MIND Revenue Release Quarter 2 2025 Press Release
Profit Center Accounting in SAP S/4HANA, S4F28 Col11
Tartificialntelligence_presentation.pptx
Agricultural_Statistics_at_a_Glance_2022_0.pdf
Empathic Computing: Creating Shared Understanding
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf

Migration of Existing Web Applications to OSGi at Eclipse Summit Europe 2010

  • 1. Public Migration of existing web applications to OSGi ESE 2010 Diyan Yordanov SAP Labs Bulgaria
  • 2. © SAP AG 2010. All rights reserved. / Page 2 Public Agenda 1. OSGi Web Container 2. Migrating Existing Web Applications to OSGi 3. Challenges That We Overcome 4. Conclusions
  • 3. © SAP AG 2010. All rights reserved. / Page 3 Public Why web applications on OSGi? Last years trends of software development A good choice for product evolving Encapsulated modules Versioning Class space isolation Declarative dependencies Dynamic refreshing and updating Ongoing work to make OSGi platform more appealing to the enterprise world Eclipse Gemini – Enterprise Modules project Eclipse Virgo – Dynamic Enterprise Application Platform project
  • 4. © SAP AG 2010. All rights reserved. / Page 4 Public OSGi Web Container Based on Web Application Specification part of OSGi Enterprise Specification Provides support for Web Applications written to Servlet 2.5 or later JSP 2.1 or later Java EE OSGi WAR
  • 5. © SAP AG 2010. All rights reserved. / Page 5 Public Available OSGi specific features Main Features in OSGi Web Container Installation of WAR files Installation of Web Application Bundles (WABs) Control of configuration properties using URL parameters Multiple applications with single context path Web application lifecycle managed by OSGi bundle lifecycle Facilitates interoperability between web application with other OSGi components Modularization – one big blob WAR to be broken into smaller modules Dynamic deployment, and fast update of individual modules
  • 6. © SAP AG 2010. All rights reserved. / Page 6 Public Agenda 1. OSGi Web Container 2. Migrating Existing Web Applications to OSGi 3. Challenges That We Overcome 4. Conclusions
  • 7. © SAP AG 2010. All rights reserved. / Page 7 Public Migrating Web Applications to OSGi • deploying standard WAR • removing JAR files from WAR and declaring dependencies on corresponding OSGi bundles • separating web artifacts from services they depend on Web Application WAR Services CatalogService PaymentService Libraries Resources Images CSS Spring Hibernate Services CatalogService PaymentService How to modify the Web application in order to benefit from OSGi?
  • 8. © SAP AG 2010. All rights reserved. / Page 8 Public Agenda 1. OSGi Web Container 2. Migrating Existing Web Applications to OSGi 3. Challenges That We Overcome 4. Conclusions
  • 9. © SAP AG 2010. All rights reserved. / Page 9 Public Certain APIs and JARs are missing Web application assumes that Java EE environment provides a certain API or JARs in the classpath In OSGi environment: Manifest – single management point for the bundle Export-Package Import-Package Require-Bundle Do not rely on automated add for standard Java EE packages Manual scan and update import packages for required ones Or use tools like BND, Eclipse PDE, Bundlor STS Be careful with org.osgi.framework.bootdelagation osgi.compatibility.bootdelagation (Eclipse Equinox specific)
  • 10. © SAP AG 2010. All rights reserved. / Page 10 Public Support for context.xml Context.xml is widely adopted by web applications used to run on Tomcat Support for web application context configuration was contributed to Gemini Web The configuration files are located as follow:  $SERVER_HOME/config/context.xml is the default context configuration file for all web applications.  $SERVER_HOME/config/[enginename]/[hostname] directory contains: o The default context configuration for all web applications of a given virtual host. o Individual web applications’ context configuration files. [enginename] is the name of Tomcat’s engine (“Catalina” by default) and [hostname] names a virtual host, both of which are configured in tomcat-server.xml. Note that the following context configuration features are not supported in Gemini Web: • Custom class loaders. • Specifying the context path. This is specified using the Web-ContextPath header in web application’s MANIFEST.MF file. • Specifying the document base directory.
  • 11. © SAP AG 2010. All rights reserved. / Page 11 Public WAR extraction Web application assume it’s extracted on the file system widely use file system operations search for resources, configurations, customizations WAB is installed as bundle web application is run from the archive file system operations do not work as expected Problem Application cannot access its configurations Valid for web apps like Orbeon Forms, Jira, or Confluence wiki Solution Implemented support for deploying web application in exploded form from a file system directory, following the format of the WAR file
  • 12. © SAP AG 2010. All rights reserved. / Page 12 Public Class and resource loading problems – Part I Known problems for standard bundles are still valid for WAB java.lang.ClassNotFoundException Because of:  Missing import or export package  Import version mismatch  Forgotten/missing component (really missing!)  Wrong boot class delegation property  Missing file system permissions (can’t read the JARs) java.lang.NoClassDefFoundError Because of:  Exception in static block  Missing imported class (ClassNotFoundException for it)  Class version mismatch Class definition is found, but instantiation failed! Class definition is missing!
  • 13. © SAP AG 2010. All rights reserved. / Page 13 Public Class and resource loading problems – Part II java.lang.ClassCastException Because of:  Additional copies (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)  JavaSE 5 vs.Java SE 6 does make a difference… (a bunch of new packages added (StAX, JDBC 4.0, JAXB 2.0, etc.)
  • 14. © SAP AG 2010. All rights reserved. / Page 14 Public Class and resource loading problems – Part III Classloader resource assumptions Access resources as InputStream via the getResourceAsStream() Access resource using URL object: URL resourceURL = this.getClass().getResource(“agenda.txt”); File resourceFile = new File(resourceURL.toURI()); The result is: java.lang.IllegalArgumentException: URI scheme is not "file" Because the URL for the resource is returned like this bundleresource://46.fwk30983464/summit/agenda.txt This is a limitation for Gemini Web, but is work around in Virgo (see bug 325578).
  • 15. © SAP AG 2010. All rights reserved. / Page 15 Public Cluster Features Some applications may use setups where some cluster functionality is needed If Tomcat’s “cluster-howto” doc is used the result is: java.lang.ClassNotFoundException: org.apache.catalina.ha.tcp.SimpleTcpCluster at org.eclipse.gemini.web.tomcat.internal.loading.ChainedClassLoader.doLoadClass(Cha inedClassLoader.java:174) at org.eclipse.gemini.web.tomcat.internal.loading.ChainedClassLoader.loadClass(Chain edClassLoader.java:157) at org.apache.tomcat.util.digester.ObjectCreateRule.begin(ObjectCreateRule.java:205) Solution was provided in MS4 if Gemini Web based on fragments and: Standard Apache Tomcat Cluster configuration is supported Disabled by default but can be enabled when needed
  • 16. © SAP AG 2010. All rights reserved. / Page 16 Public Automatic Tools There is NO tool for migrating standard Java EE web application (WAR) to Web Application Bundle (WAB)  Eclipse PDE – can help with the MANIFEST.MF file  SpringSource Tool Suite Different tools for creating MANIFEST.MF  BND tool  Apache Felix Maven plugin  Bundlor OSGi Enterprise Tools (Eclipse proposal)  Wizard for creating WAB  Tools for converting existing Java EE Dynamic Web projects to WAB project  Tools for editing the OSGi metadata – manifest headers  Generic OSGi server adapter
  • 17. © SAP AG 2010. All rights reserved. / Page 17 Public Agenda 1. OSGi Web Container 2. Migrating Existing Web Applications to OSGi 3. Challenges That We Overcome 4. Conclusions
  • 18. © SAP AG 2010. All rights reserved. / Page 18 Public Takeaways Learning curve Know your application Assumption for unique context root Assumption for availability of default Java EE lib jars Know OSGi How classloaders work Classloader “hell” ClassNotFoundException, NoClassDefFoundError, ClassCastException Avoid Class.forName() Know your wirings Make sure that you understand the setup of your OSGi environment
  • 19. © SAP AG 2010. All rights reserved. / Page 19 Public Conclusions Web on OSGi does work. Just don’t stumble over small defects. Working together with the community is the key for success.
  • 20. © SAP AG 2010. All rights reserved. / Page 20 Public Diyan Yordanov diyan.yordanov@sap.com Thank you!