[
https://issues.apache.org/jira/browse/MYFACES-2290?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12770993#action_12770993
]
Leonardo Uribe commented on MYFACES-2290:
-----------------------------------------
It seems spring dm has already solved the problem with
Thread.currentThread().getContextClassLoader(). Look this blog:
http://blog.springsource.com/2008/05/02/running-spring-applications-on-osgi-with-the-springsource-application-platform
the important part is below:
"......Thread context classloader management
Many third-party libraries use the thread context ClassLoader to access
application types and resources. Each bundle in OSGi has it's own ClassLoader,
so therefore, only one bundle can be exposed as the thread context ClassLoader
at any time. This means that if a third-party library needs to see types that
are distributed across multiple bundles, it isn't going to work as expected.
The Platform fixes this by creating a ClassLoader that imports all the exported
packages of every module in your application. This ClassLoader is then exposed
as the thread context ClassLoader, enabling third-party libraries to see all
the exported types in your application........"
Use a BundleActivator is the OSGi suggested way to solve this issues, but given
the context of the problem, it seems better to do not use a BundleActivator and
use spring dm to deal with this stuff.
But note this link:
http://www.springsource.com/repository/app/bundle/version/detail?name=com.springsource.org.apache.myfaces.javax.faces&version=1.2.2&searchType=bundlesByName&searchQuery=jsf
in SpringSource Bundle Repository it is possible to find a OSGi bundle for
myfaces. This is the manifest for myfaces-api.jar
Manifest-Version: 1.0
Export-Package: javax.faces;provider="myfaces";version="1.2.2",javax.f
aces.application;provider="myfaces";version="1.2.2";uses:="javax.el,j
avax.faces,javax.faces.component,javax.faces.context,javax.faces.conv
ert,javax.faces.el,javax.faces.event,javax.faces.validator",javax.fac
es.component;provider="myfaces";version="1.2.2";uses:="javax.el,javax
.faces,javax.faces.application,javax.faces.context,javax.faces.conver
t,javax.faces.el,javax.faces.event,javax.faces.model,javax.faces.rend
er,javax.faces.validator",javax.faces.component.html;provider="myface
s";version="1.2.2";uses:="javax.faces.context",javax.faces.context;pr
ovider="myfaces";version="1.2.2";uses:="javax.el,javax.faces,javax.fa
ces.application,javax.faces.component,javax.faces.lifecycle,javax.fac
es.render",javax.faces.convert;provider="myfaces";version="1.2.2";use
s:="javax.faces.application,javax.faces.component,javax.faces.context
",javax.faces.el;provider="myfaces";version="1.2.2";uses:="javax.face
s.context",javax.faces.event;provider="myfaces";version="1.2.2";uses:
="javax.el,javax.faces.component,javax.faces.context,javax.faces.life
cycle",javax.faces.lifecycle;provider="myfaces";version="1.2.2";uses:
="javax.faces,javax.faces.context,javax.faces.event",javax.faces.mode
l;provider="myfaces";version="1.2.2";uses:="javax.servlet.jsp.jstl.sq
l",javax.faces.render;provider="myfaces";version="1.2.2";uses:="javax
.faces.application,javax.faces.component,javax.faces.context,javax.fa
ces.convert",javax.faces.validator;provider="myfaces";version="1.2.2"
;uses:="javax.el,javax.faces.application,javax.faces.component,javax.
faces.context",javax.faces.webapp;provider="myfaces";version="1.2.2";
uses:="javax.el,javax.faces.component,javax.faces.context,javax.faces
.convert,javax.faces.validator,javax.servlet,javax.servlet.jsp,javax.
servlet.jsp.tagext"
Implementation-Title: Apache Myfaces JSF Core-1.2 API
Bundle-Classpath: .
Implementation-Version: 1.2.2
Built-By: lu4242
Bundle-Name: Apache MyFaces JSF API
Created-By: Apache Maven
Bundle-Vendor: SpringSource
Implementation-Vendor: The Apache Software Foundation
Implementation-Vendor-Id: org.apache.myfaces.core
Build-Jdk: 1.6.0_02
Bundle-Version: 1.2.2
Bundle-ManifestVersion: 2
Bundle-SymbolicName: com.springsource.org.apache.myfaces.javax.faces
Import-Package: javax.el;version="[1.0.0, 2.0.0)",javax.servlet;versio
n="[2.5.0, 3.0.0)",javax.servlet.http;version="[2.5.0, 3.0.0)",javax.
servlet.jsp;version="[2.1.0, 3.0.0)",javax.servlet.jsp.jstl.core;vers
ion="[1.1.2, 2.0.0)",javax.servlet.jsp.jstl.sql;version="[1.1.2, 2.0.
0)",javax.servlet.jsp.tagext;version="[2.1.0, 3.0.0)",org.apache.comm
ons.logging;version="[1.1.1, 2.0.0)"
Archiver-Version: Plexus Archiver
Conclusion: The best we can do from myfaces side is use org.apache.felix
maven-bundle-plugin to create a manifest in the way described before without
include BundleActivator classes, and let this issue open, so if somebody wants
to use the BundleActivator way, he/she can change the code adding it. The only
thing left is set the context class loader for Digester instances to
org.apache.myfaces.shared_impl.util.ClassUtils.getContextClassLoader().
> Add OSGi bundle information and bundle classloader / activator
> --------------------------------------------------------------
>
> Key: MYFACES-2290
> URL: https://issues.apache.org/jira/browse/MYFACES-2290
> Project: MyFaces Core
> Issue Type: New Feature
> Components: General
> Affects Versions: 1.2.8-SNAPSHOT
> Environment: OSGi (Equinox, Apache Felix, ...)
> Reporter: Felix Röthenbacher
> Assignee: Leonardo Uribe
> Priority: Critical
> Attachments: myfaces-core.diff.txt, myfaces-shared.diff.txt
>
>
> The provided patch will add OSGi information to bundle manifest. A bundle
> activator class makes the MyFaces framework aware that it is running in a
> bundle environment. A bundle classloader is used to load classes and
> resources from the bundle classpath. The patch doesn't require any new
> runtime dependencies and doesn't affect class loading in a non-OSGi
> environment. Though, small modifications to classloading were needed. This
> was mainly replacing Thread.currentThread.getContextClassLoader() with
> ClassUtils methods.
> To run MyFaces in an OSGi environment both bundles (myfaces-api and
> myfaces-impl) have to be started in the OSGi container. Additionally, the
> myfaces-impl bundle has to be made available to myfaces-api. Use a fragment
> bundle with myfaces-api as Fragment-Host and myfaces-impl as Required-Bundle.
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.