[ 
https://issues.apache.org/jira/browse/MYFACES-2290?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12846505#action_12846505
 ] 

Leonardo Uribe commented on MYFACES-2290:
-----------------------------------------

I tried to run myfaces in OSGi, but without spring-dm, just to see what are the 
problems that spring-dm are solving and check if we can do something else from 
our code to be more osgi friendly.

For do that, I tried to use pax web extender. Equinox only support jsp 2.0, so 
we can't use it to test what we want to.

An issue in pax web was opened:

http://issues.ops4j.org/browse/PAXWEB-199

that code hides some packages that needs to be exported, because contains 
serializable classes, so myfaces can see them. Also, it was notice another 
issue is there:

http://issues.ops4j.org/browse/PAXWEB-98

I was able to run myfaces with this configuration, but doing some very nasty 
hacks that can't be committed.

The most critical problem to make run jsf in osgi is the class 
javax.faces.FactoryFinder. This class is responsible to load the factories used 
to setup the environment. The problem is it depends on the thread context 
classloader in a way that we just cannot bypass it.

In other words, JSF uses Thread.currentThread().getContextClassLoader() to 
obtain the web context classloader. The problem is OSGi doesn't have this 
concept in its HttpService definition. But in theory this could be solved 
creating a custom classloader that wraps the context classloader but also use 
the bundle classloader of the web application, allowing the user to bypass the 
bundle restriction. Unfortunately I tried this solution but pax uses a 
classloader to make jsp works, so any call to getFactory() fails, because the 
context classloader was replaced (PAXWEB-98). In theory, with this hack it is 
possible to run an application using facelets.

Unfortunately, I can't dedicate more time to this one. Anyway, I think if it is 
possible to do more tests with equinox (in theory myfaces 1.2 could run in 
servlet 2.4, jsp 2.0 and facelets), or maybe fix pax web to allow myfaces works 
there.

> 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: allow-ee6-versioned-apis.diff, 
> MYFACES-2290-no-activator-2.patch, MYFACES-2290-no-activator.patch, 
> myfaces-core.diff.txt, myfaces-shared.diff.txt, 
> myfaces-test-helloworld-osgi-springdm.zip
>
>
> 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.

Reply via email to