[
https://issues.apache.org/jira/browse/MYFACES-4449?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17598362#comment-17598362
]
Paul Nicolucci commented on MYFACES-4449:
-----------------------------------------
[~tandraschko] you're right the API does not have a dependency on the
Implementation, the Implementation
has a dependency on the API. However, the ClassUtils in the Implementation is
calling into the
API to find resources/classes. Take the following as an example:
In DefaultFacesConfigurationProvider.getStandardFacesConfig ClassUtils is used
to load: META-INF/standard-faces-config.xml
which resides in the implementation:
{code:java}
BundleLoader[gateway.bundle.Thread_Context.WebModule_SimpleTest_SimpleTest.war_0.0.0].findResource(META-INF/standard-faces-config.xml)
BundleLoader[gateway.bundle.Thread_Context.WebModule_SimpleTest_SimpleTest.war_0.0.0]
attempting to resolve dynamic package: META-INF
BundleLoader[gateway.bundle.WebModule.SimpleTest_SimpleTest.war_0.0.0].findResource(META-INF/standard-faces-config.xml)
BundleLoader[gateway.bundle.WebModule.SimpleTest_SimpleTest.war_0.0.0]
attempting to resolve dynamic package: META-INF
ModuleClassLoader[io.openliberty.jakarta.faces.4.0_1.0.69.202208301414].getResource(META-INF/standard-faces-config.xml)
BundleLoader[io.openliberty.jakarta.faces.4.0_1.0.69.202208301414].findResource(META-INF/standard-faces-config.xml)
ModuleClassLoader[io.openliberty.jakarta.faces.4.0_1.0.69.202208301414].getResource(META-INF/standard-faces-config.xml)
failed.
[ERROR ] An error occured while initializing MyFaces: Standard faces config
META-INF/standard-faces-config.xml not found
Standard faces config META-INF/standard-faces-config.xml not found{code}
As you can see above the io.openliberty.jakarta.faces.4.0 classloader is being
used (API) and the file is not resolved.
Once the getResourceAsStream method is moved to the Implementation ClassUtils
the following occurs:
{code:java}
BundleLoader[gateway.bundle.Thread_Context.WebModule_SimpleTest_SimpleTest.war_0.0.0].findResource(META-INF/standard-faces-config.xml)
BundleLoader[gateway.bundle.Thread_Context.WebModule_SimpleTest_SimpleTest.war_0.0.0]
attempting to resolve dynamic package: META-INF
BundleLoader[gateway.bundle.WebModule.SimpleTest_SimpleTest.war_0.0.0].findResource(META-INF/standard-faces-config.xml)
BundleLoader[gateway.bundle.WebModule.SimpleTest_SimpleTest.war_0.0.0]
attempting to resolve dynamic package: META-INF
ModuleClassLoader[io.openliberty.org.apache.myfaces.4.0_1.0.69.202208310842].getResource(META-INF/standard-faces-config.xml)
BundleLoader[io.openliberty.org.apache.myfaces.4.0_1.0.69.202208310842].findResource(META-INF/standard-faces-config.xml){code}
In the above, the correct io.openliberty.org.apache.myfaces.4.0 classloader is
being used (Implementation) and the resource is resolved correctly.
> Implementation ClassUtils needs methods added to support OSGI runtimes
> ----------------------------------------------------------------------
>
> Key: MYFACES-4449
> URL: https://issues.apache.org/jira/browse/MYFACES-4449
> Project: MyFaces Core
> Issue Type: Bug
> Components: General
> Affects Versions: 4.0.0-RC1
> Reporter: Paul Nicolucci
> Assignee: Paul Nicolucci
> Priority: Major
>
> Historically in MyFaces, there existed an {{ClassUtils}} in the
> implementation as well as the API. In Faces 4.0 the code was refactored to
> have the {{Classutils}} in the Impl extend the {{ClassUtils}} in the API:
> API:
> [https://github.com/apache/myfaces/blob/main/api/src/main/java/org/apache/myfaces/core/api/shared/lang/ClassUtils.java]
> Impl:
> [https://github.com/apache/myfaces/blob/main/impl/src/main/java/org/apache/myfaces/util/lang/ClassUtils.java]
>
> If we look at the 3.0 branches you'll see the implementation class does not
> extend the API class:
> API:
> [https://github.com/apache/myfaces/blob/3.0.x/api/src/main/java/jakarta/faces/component/html/_ClassUtils.java]
> Impl:
> [https://github.com/apache/myfaces/blob/3.0.x/shared-public/src/main/java/org/apache/myfaces/shared/util/ClassUtils.java]
>
> Having all the classloading methods in the API class works fine when the API
> and IMPL are bundled within an application but when trying to integrate
> MyFaces into an OSGI runtime where the API has no visibility into the
> implementation then a number of classloading issues occur.
>
> I've identified the following methods that need to be placed back into the
> implementation ClassUtils:
> * public static URL getResource(String resource)
> * public static InputStream getResourceAsStream(String resource)
> * public static Class simpleClassForName(String type)
> * public static Class simpleClassForName(String type, boolean logException)
> * public static Class classForName(String type) throws ClassNotFoundException
--
This message was sent by Atlassian Jira
(v8.20.10#820010)