Skip to Main Content

Java EE (Java Enterprise Edition) General Discussion

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Over-riding the class javax.faces.context.FacesContext: SUN App Server 9.1

843844Feb 28 2008
The method to over ride the faces context has changed between SUN Application Server 8.2 and 9.1, as a result the instructions which were previously provided on the MyFaces wiki (http://wiki.apache.org/myfaces/Installation_and_Configuration) no longer work. What I am looking for is instructions that will allow me to use our own faces jars and not (javaee.jar) which is provided as part of the application server.

-----------------------------------------------
What I need to do is to get Sun Application Server 9.1 to allow me to over ride the faces context /javax/faces/context/ with that from my local jars, in version 8.X the following steps were enough:

Start 8.X instructions:

1. Change the config security file so that MyFaces <http://wiki.apache.org/myfaces/MyFaces> can delete it's temporary files.


Change permission
    java.io.FilePermission <http://wiki.apache.org/myfaces/FilePermission> "<<ALL FILES>>", "read,write";
to
  java.io.FilePermission <http://wiki.apache.org/myfaces/FilePermission> "<<ALL FILES>>", "read,write,delete";
2. Prevent the sun reference implementation from being used

In your WEB-INF, create a sun-web.xml file containing
    <?xml version="1.0" encoding="UTF-8"?>

    <sun-web-app>

    *

    <class-loader delegate="false"/>

    </sun-web-app>
3. That way, myfaces classes will be loaded instead of Sun RI ones.

And prevent MyFaces <http://wiki.apache.org/myfaces/MyFaces> from loading the Sun RI context listener

By creating in your webapp a "fake"
com.sun.faces.config.ConfigureListener
<http://wiki.apache.org/myfaces/ConfigureListener> that will be loaded BEFORE the sun RI one's.

The war file I am making available as a test case has just such a file in my case it is called fakefaces.jar

End instructions for 8.2
-----------------------------------------------

However these steps have changed for version 9.1 as following the exact same procedures does not result in the Application Server using the correct jars, the following is a test using a simple find.jsp, notice how Application Server 9.1 is still using the default jars and not the ones shipping with included as part of my testApp.

Within the war file is a jsp called find.jsp using this I can check which jar file file is being used for any class in my case I'm interested in the the /javax/faces/context/FacesContext.class, in 9.1 it always uses teh copy from javaee.jar and never teh local copy:
For example running: http://<ip address>:<port>/test/find.jsp?class=javax.faces.context.FacesContext
Version 9.1 returns: file:/u01/software/Apps/SunAppServer9.1/lib/javaee.jar!/javax/faces/context/FacesContext.class
Version 8.2 returns: file:/u01/software/Apps/SunAppServer8.2/domains/domain1/applications/j2ee-apps/TestApp/test_war/WEB-INF/lib/myfaces-api.jar!/javax/faces/context/FacesContext.class

Hence 9.1 is still using the copy provided by SUN and not our copy.
--------------------------------------------------

The code for find.jsp is:
<%
    String className = request.getParameter("class");

    Class theClass;
    try
        {
        theClass = Class.forName(className);
        java.net.URL url = theClass.getResource("/" + theClass.getName().replace('.', '/') + ".class");
        out.println(url.getFile());
        }
    catch (ClassNotFoundException e)
        {
        // TODO Auto-generated catch block
        out.println(e);
        }
%>
-------------------------------------------------

Any idea how to over-ride the FacesContext class in version 9.1 to allow for similar functionality as 8.X

Thanks,
ERIC GANDT
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Mar 27 2008
Added on Feb 28 2008
0 comments
117 views