tags:

views:

585

answers:

2

JSF 1.1 and websphere 6.1 was working properly in my case. Once I deployed that to a websphere 7 server, I received the following error -

Application was not properly initialized at startup, could not find Factory: javax.faces.context.FacesContextFactoryat javax.faces.FactoryFinder.getFactory(FactoryFinder.java:270)
    at javax.faces.webapp.FacesServlet.init(FacesServlet.java:164)
    at com.ibm.ws.webcontainer.servlet.ServletWrapper.init(ServletWrapper.java:358)
    at com.ibm.ws.webcontainer.servlet.ServletWrapperImpl.init(ServletWrapperImpl.java:168)

Not sure what it means, I have enabled JSF1.2 as project facet in the RAD but still keep getting the above error message and none of my jsf files are working.

EDIT

After following BalusC's comment, I see the following directories are lookup by the code (this is the o/p of url.getPath())

/C:/IBM/SDP/runtimes/base_v7/profiles/AppSrv01/properties/
/C:/IBM/SDP/runtimes/base_v7/properties/
/
/C:/IBM/SDP/runtimes/base_v7/java/lib/
/C:/IBM/SDP/runtimes/base_v7/lib/
/C:/IBM/SDP/runtimes/base_v7/deploytool/itp/plugins/com.ibm.etools.ejbdeploy/runtime/
/C:/IBM/SDP/runtimes/base_v7/installedConnectors/sib.api.jmsra.rar/
/C:/IBM/SDP/runtimes/base_v7/installedConnectors/wmq.jmsra.rar/
/C:/DETSphere10/DET_FALL9.0/DETEJB/classes/
/C:/DETSphere10/DET_FALL9.0/.metadata/.plugins/org.eclipse.wst.server.core/tmp0/DETWEB/

There is no jsf impl in among these directories. Now I am more confused as the original lib should be present under c:\IBM\SDP\runtimes\base_v7\plugins !!

+2  A: 

This is a typical error when there are multiple different versioned JSF libraries in the classpath. Websphere ships with builtin JSF libraries. If you'd like to use the webapp-supplied JSF libraries, then you need to set the classloading policy to module after deploying. This usually defaults to application which means that the webapp libraries are loaded by the main classloader. The main classloader may happen to have loaded the JSF API library. When its version is different from the JSF IMPL library in the webapp, then you may receive this kind of errors.


Update to help with nailing down the root cause better here are 2 suggestions:

  1. You can reveal all used classpath roots on the local disk file system as follows:

    for (URL url : Collections.list(Thread.currentThread().getContextClassLoader().getResources(""))) {
        System.out.println(url.getPath());
    }
    

    Execute this in ServletContextListener#contextInitialized() or so.

  2. (eventually after finding that out), install WinRAR, associate it with JAR file type and use its file-search facility to search for a JSF specific file like FacesContext.class and FacesContextImpl.class so that you can find all JAR's which contains the JSF API/impl. You can find out the exact JSF version by extracting the JAR and reading the MANIFEST file.

BalusC
In my case, I am trying to use whatever websphere supplies and do not have any other impl of JSF lib in my classpath. Still I am consistently getting this error.
Shamik
This is just a sign of a dirty classpath. Check for any duplicate different versioned libraries in places they don't belong. Scan the webapp libraries, the Websphere libraries and the JRE/lib(/ext).
BalusC
Sorry BalusC, but this problem is really bothering me. I know I hate websphere but this time it is extreme :( I still dont find any duplicate jsf impl lib under my webapp/web-inf/lib, or WebSphere's C:\IBM\SDP\runtimes\base_v7\lib dir or under the plugins folder. Only com.ibm.ws.webcontainer.jar file has the default sun impl and it is the only jar included in my classpath. Any more pointer would be helpful.
Shamik
Did you also check the JRE (and JDK) libraries? Those are also taken in the classpath. As last resort you may consider to include JSF libs in your own webapp and change the classloading policy.
BalusC
A: 

You need to keep the JSF JAR's (icu4j.jar and jsf-ibm.jar if you are using IBM's component library) in your /WEB-INF/lib folder.

Abid