7 Replies Latest reply: Feb 9, 2012 9:12 PM by Steve Button-Oracle RSS

    could not find Factory: javax.faces.context.FacesContextFactory

    739930
      When I deploy my JSF 1.2 app to weblogic 10.3.4 I get this error:

      java.lang.IllegalStateException: Application was not properly initialized at startup, could not find Factory: javax.faces.context.FacesContextFactory
      at javax.faces.FactoryFinder.getFactory(FactoryFinder.java:263)
      at javax.faces.webapp.FacesServlet.init(FacesServlet.java:142)
      at weblogic.servlet.internal.StubSecurityHelper$ServletInitAction.run(StubSecurityHelper.java:283)
      at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:321)
      at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:120)


      The WAR is packaged inside an EAR. All JSF 1.2 libraries are included in the EAR files /lib folder which should be visible to all WAR components in the EAR according to the java ee 5 spec.

      If I change the packing to include the JSF libraries in the WAR files WEB-INF/lib folder then I get no error.

      Since there are multiple WARs in the EAR id realy like to put the common libs in the EARs lib folder. How can I make JSF find its factory when deployed in the lib folder?
        • 1. Re: could not find Factory: javax.faces.context.FacesContextFactory
          730338
          JSF implementation has used servlet context listener to do some initializing work, and this listener is described in tld which is packaged with the implementation jar. Web container only scans tlds under webapp, which means it only scans under WEB-INF or in jars under WEB-INF/lib directory. So if you put your jsf libraries in ear/lib directory, the web container won't get the tld for jsf implementation, and it won't call the context listener. So that's why it can't find the FacesContextFactory.

          You can put your jars into WEB-INF/lib, or only put the implementation jar into WEB-INF/lib. I guess both would work.
          • 2. Re: could not find Factory: javax.faces.context.FacesContextFactory
            Steve Button-Oracle
            Thanks Tao (Web Container engineer for WLS) for that clarification.

            If you wish to use a single JSF implementation across your application to avoid the need to package it in multiple places, you could follow the advice given in the documentation -- http://download.oracle.com/docs/cd/E17904_01/web.1111/e13712/configurejsfandjtsl.htm#i163440 -- and use the shared-library approach. This will also by default, support the use of dependency injection in any managed beans you have.

            -steve-
            • 3. Re: could not find Factory: javax.faces.context.FacesContextFactory
              739930
              OK I tried the shared lib approach by creating a WAR with my own JSF libs and Trinidad libs which seems to work except I cant use the <specification-version> tag in the dependency declaration.

              The shared WAR lib is deployed with a META-INF/MANIFEST.MF file containing:

              Manifest-Version: 1.0
              Created-By: test
              Specification-Title: xyz
              Specification-Version: 2.0
              Implementation-Title: xyz
              Implementation-Version: 2.0.4
              Original-Implementation-Version-From-RI: 2.0.4
              Implementation-Vendor: Apache
              Extension-Name: myjsf

              My application WAR refers to the lib in WEB-INF/weblogic.xml:

              <library-ref>
                        <library-name>myjsf</library-name>
                        <specification-version>2.0</specification-version>
                        <exact-match>true</exact-match>
                   </library-ref>


              When I deploy the app I get this error:

              weblogic.management.DeploymentException: Error: Unresolved Webapp Library references for ... defined in weblogic.xml [Extension-Name: myjsf, Specification-Version: 2, exact-match: true]


              If I remove the specification-version tag from weblogic.xml then the application works.


              Any idea what could be wrong?

              Steve Button wrote:
              Thanks Tao (Web Container engineer for WLS) for that clarification.

              If you wish to use a single JSF implementation across your application to avoid the need to package it in multiple places, you could follow the advice given in the documentation -- http://download.oracle.com/docs/cd/E17904_01/web.1111/e13712/configurejsfandjtsl.htm#i163440 -- and use the shared-library approach. This will also by default, support the use of dependency injection in any managed beans you have.

              -steve-
              • 4. Re: could not find Factory: javax.faces.context.FacesContextFactory
                Steve Button-Oracle
                Not entirely sure -- there's some discrepancy there.

                I can offer two suggestions that may help:

                1. Use the console to look at what WLS is seeing yourspecification version string as -- if you look in the deployments page, you'll see the myjsf library, which if you then click into, should show you the details.

                2. If you need to have a customized jsf-xx.war shared-library to include additional jar files, make a copy of the original jsf-xx.war (so you the original if you need it) then modify the existing one to add your libraries into. Or extract jsf-xx.war, add your libraries, modify the manifest.mf to change the name for example (myjsf) then jar it back up, making sure to use the existing manifest.mf in the jar file.

                -steve-
                • 5. Re: could not find Factory: javax.faces.context.FacesContextFactory
                  739930
                  The version data is only used when the manifest is packaged in an ear - not in a war.

                  The deployment works in a clean weblogic 10.3.4 server - they web framework is initialized correctly - however now I experince the problem that its not being initilized when I deploy it into a weblogic server with OSB installed. I tried using <prefer-web-inf-classes>true</prefer-web-inf-classes> in weblogic.xml but it didnt help.


                  <04-04-2011 12:52:40 CEST> <Warning> <HTTP> <BEA-101162> <User defined listener org.apache.myfaces.webapp.StartupServletContextListener failed: java.lang.Illega
                  lStateException: No Factories configured for this Application. This happens if the faces-initialization does not work at all - make sure that you properly inclu
                  de all configuration settings necessary for a basic faces application and that all the necessary libs are included. Also check the logging output of your web ap
                  plication and your container for any exceptions!
                  If you did that and find nothing, the mistake might be due to the fact that you use some special web-containers which do not support registering context-listene
                  rs via TLD files and a context listener is not setup in your web.xml.
                  A typical config looks like this;
                  <listener>
                  <listener-class>org.apache.myfaces.webapp.StartupServletContextListener</listener-class>
                  </listener>
                  .
                  java.lang.IllegalStateException: No Factories configured for this Application. This happens if the faces-initialization does not work at all - make sure that yo
                  u properly include all configuration settings necessary for a basic faces application and that all the necessary libs are included. Also check the logging outpu
                  t of your web application and your container for any exceptions!
                  If you did that and find nothing, the mistake might be due to the fact that you use some special web-containers which do not support registering context-listene
                  rs via TLD files and a context listener is not setup in your web.xml.
                  A typical config looks like this;
                  <listener>
                  <listener-class>org.apache.myfaces.webapp.StartupServletContextListener</listener-class>
                  </listener>

                  at javax.faces.FactoryFinder.getFactory(FactoryFinder.java:196)
                  at org.apache.myfaces.context.servlet.FacesContextImplBase.getApplication(FacesContextImplBase.java:131)
                  at org.apache.myfaces.webapp.AbstractFacesInitializer._dispatchApplicationEvent(AbstractFacesInitializer.java:247)
                  at org.apache.myfaces.webapp.AbstractFacesInitializer.destroyFaces(AbstractFacesInitializer.java:279)
                  at org.apache.myfaces.webapp.StartupServletContextListener.contextDestroyed(StartupServletContextListener.java:153)
                  Truncated. see log file for complete stacktrace
                  >

                  ...cut


                  <04-04-2011 12:58:49 CEST> <Error> <org.apache.myfaces.webapp.AbstractFacesInitializer> <BEA-000000> <An error occured while initializing MyFaces: java.io.FileN
                  otFoundException: \Oracle\Middleware\Oracle_OSB1\soa\connectors\FileAdapter.rar!fileAdapter.jar (The system cannot find the file specified)
                  javax.faces.FacesException: java.io.FileNotFoundException: \Oracle\Middleware\Oracle_OSB1\soa\connectors\FileAdapter.rar!fileAdapter.jar (The system cannot find
                  the file specified)
                  at org.apache.myfaces.config.annotation.DefaultAnnotationProvider.getAnnotatedClasses(DefaultAnnotationProvider.java:174)
                  at org.apache.myfaces.config.annotation.AnnotationConfigurator.createFacesConfig(AnnotationConfigurator.java:92)
                  at org.apache.myfaces.config.DefaultFacesConfigurationProvider.getAnnotationsFacesConfig(DefaultFacesConfigurationProvider.java:148)
                  at org.apache.myfaces.config.DefaultFacesConfigurationMerger.getFacesConfigData(DefaultFacesConfigurationMerger.java:91)
                  at org.apache.myfaces.config.FacesConfigurator.configure(FacesConfigurator.java:452)
                  at org.apache.myfaces.webapp.AbstractFacesInitializer.buildConfiguration(AbstractFacesInitializer.java:303)
                  at org.apache.myfaces.webapp.Jsp21FacesInitializer.initContainerIntegration(Jsp21FacesInitializer.java:73)
                  at org.apache.myfaces.webapp.AbstractFacesInitializer.initFaces(AbstractFacesInitializer.java:126)
                  at org.apache.myfaces.webapp.StartupServletContextListener.contextInitialized(StartupServletContextListener.java:111)
                  at weblogic.servlet.internal.EventsManager$FireContextListenerAction.run(EventsManager.java:481)
                  at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:321)
                  at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:120)
                  at weblogic.servlet.internal.EventsManager.notifyContextCreatedEvent(EventsManager.java:181)
                  at weblogic.servlet.internal.WebAppServletContext.preloadResources(WebAppServletContext.java:1872)
                  at weblogic.servlet.internal.WebAppServletContext.start(WebAppServletContext.java:3153)
                  at weblogic.servlet.internal.WebAppModule.startContexts(WebAppModule.java:1508)
                  at weblogic.servlet.internal.WebAppModule.start(WebAppModule.java:482)
                  at weblogic.application.internal.flow.ModuleStateDriver$3.next(ModuleStateDriver.java:425)
                  at weblogic.application.utils.StateMachineDriver.nextState(StateMachineDriver.java:52)
                  at weblogic.application.internal.flow.ModuleStateDriver.start(ModuleStateDriver.java:119)
                  at weblogic.application.internal.flow.ScopedModuleDriver.start(ScopedModuleDriver.java:200)
                  at weblogic.application.internal.flow.ModuleListenerInvoker.start(ModuleListenerInvoker.java:247)
                  at weblogic.application.internal.flow.ModuleStateDriver$3.next(ModuleStateDriver.java:425)
                  at weblogic.application.utils.StateMachineDriver.nextState(StateMachineDriver.java:52)
                  at weblogic.application.internal.flow.ModuleStateDriver.start(ModuleStateDriver.java:119)
                  at weblogic.application.internal.flow.StartModulesFlow.activate(StartModulesFlow.java:27)
                  at weblogic.application.internal.BaseDeployment$2.next(BaseDeployment.java:636)
                  at weblogic.application.utils.StateMachineDriver.nextState(StateMachineDriver.java:52)
                  at weblogic.application.internal.BaseDeployment.activate(BaseDeployment.java:205)
                  at weblogic.application.internal.EarDeployment.activate(EarDeployment.java:58)
                  at weblogic.application.internal.DeploymentStateChecker.activate(DeploymentStateChecker.java:161)
                  at weblogic.deploy.internal.targetserver.AppContainerInvoker.activate(AppContainerInvoker.java:79)
                  at weblogic.deploy.internal.targetserver.operations.AbstractOperation.activate(AbstractOperation.java:569)
                  at weblogic.deploy.internal.targetserver.operations.ActivateOperation.activateDeployment(ActivateOperation.java:150)
                  at weblogic.deploy.internal.targetserver.operations.ActivateOperation.doCommit(ActivateOperation.java:116)
                  at weblogic.deploy.internal.targetserver.operations.AbstractOperation.commit(AbstractOperation.java:323)
                  at weblogic.deploy.internal.targetserver.DeploymentManager.handleDeploymentCommit(DeploymentManager.java:844)
                  at weblogic.deploy.internal.targetserver.DeploymentManager.activateDeploymentList(DeploymentManager.java:1253)
                  at weblogic.deploy.internal.targetserver.DeploymentManager.handleCommit(DeploymentManager.java:440)
                  at weblogic.deploy.internal.targetserver.DeploymentServiceDispatcher.commit(DeploymentServiceDispatcher.java:163)
                  at weblogic.deploy.service.internal.targetserver.DeploymentReceiverCallbackDeliverer.doCommitCallback(DeploymentReceiverCallbackDeliverer.java:195)
                  at weblogic.deploy.service.internal.targetserver.DeploymentReceiverCallbackDeliverer.access$100(DeploymentReceiverCallbackDeliverer.java:13)
                  at weblogic.deploy.service.internal.targetserver.DeploymentReceiverCallbackDeliverer$2.run(DeploymentReceiverCallbackDeliverer.java:68)
                  at weblogic.work.SelfTuningWorkManagerImpl$WorkAdapterImpl.run(SelfTuningWorkManagerImpl.java:528)
                  at weblogic.work.ExecuteThread.execute(ExecuteThread.java:207)
                  at weblogic.work.ExecuteThread.run(ExecuteThread.java:176)
                  Caused By: java.io.FileNotFoundException: \Oracle\Middleware\Oracle_OSB1\soa\connectors\FileAdapter.rar!fileAdapter.jar (The system cannot find the file specifi
                  ed)
                  at java.util.zip.ZipFile.open(Native Method)
                  at java.util.zip.ZipFile.<init>(ZipFile.java:114)
                  at java.util.jar.JarFile.<init>(JarFile.java:135)
                  at java.util.jar.JarFile.<init>(JarFile.java:72)
                  at org.apache.myfaces.view.facelets.util.Classpath._getAlternativeJarFile(Classpath.java:272)
                  at org.apache.myfaces.view.facelets.util.Classpath._searchResource(Classpath.java:86)
                  at org.apache.myfaces.view.facelets.util.Classpath.search(Classpath.java:61)
                  at org.apache.myfaces.config.annotation.DefaultAnnotationProvider.getBaseUrls(DefaultAnnotationProvider.java:213)
                  at org.apache.myfaces.config.annotation.DefaultAnnotationProvider.getAnnotatedClasses(DefaultAnnotationProvider.java:170)
                  at org.apache.myfaces.config.annotation.AnnotationConfigurator.createFacesConfig(AnnotationConfigurator.java:92)
                  at org.apache.myfaces.config.DefaultFacesConfigurationProvider.getAnnotationsFacesConfig(DefaultFacesConfigurationProvider.java:148)
                  at org.apache.myfaces.config.DefaultFacesConfigurationMerger.getFacesConfigData(DefaultFacesConfigurationMerger.java:91)
                  at org.apache.myfaces.config.FacesConfigurator.configure(FacesConfigurator.java:452)
                  at org.apache.myfaces.webapp.AbstractFacesInitializer.buildConfiguration(AbstractFacesInitializer.java:303)
                  at org.apache.myfaces.webapp.Jsp21FacesInitializer.initContainerIntegration(Jsp21FacesInitializer.java:73)
                  at org.apache.myfaces.webapp.AbstractFacesInitializer.initFaces(AbstractFacesInitializer.java:126)
                  at org.apache.myfaces.webapp.StartupServletContextListener.contextInitialized(StartupServletContextListener.java:111)
                  at weblogic.servlet.internal.EventsManager$FireContextListenerAction.run(EventsManager.java:481)
                  at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:321)
                  at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:120)
                  at weblogic.servlet.internal.EventsManager.notifyContextCreatedEvent(EventsManager.java:181)
                  at weblogic.servlet.internal.WebAppServletContext.preloadResources(WebAppServletContext.java:1872)
                  at weblogic.servlet.internal.WebAppServletContext.start(WebAppServletContext.java:3153)
                  at weblogic.servlet.internal.WebAppModule.startContexts(WebAppModule.java:1508)
                  at weblogic.servlet.internal.WebAppModule.start(WebAppModule.java:482)
                  at weblogic.application.internal.flow.ModuleStateDriver$3.next(ModuleStateDriver.java:425)
                  at weblogic.application.utils.StateMachineDriver.nextState(StateMachineDriver.java:52)
                  at weblogic.application.internal.flow.ModuleStateDriver.start(ModuleStateDriver.java:119)
                  at weblogic.application.internal.flow.ScopedModuleDriver.start(ScopedModuleDriver.java:200)
                  at weblogic.application.internal.flow.ModuleListenerInvoker.start(ModuleListenerInvoker.java:247)
                  at weblogic.application.internal.flow.ModuleStateDriver$3.next(ModuleStateDriver.java:425)
                  at weblogic.application.utils.StateMachineDriver.nextState(StateMachineDriver.java:52)
                  at weblogic.application.internal.flow.ModuleStateDriver.start(ModuleStateDriver.java:119)
                  at weblogic.application.internal.flow.StartModulesFlow.activate(StartModulesFlow.java:27)
                  at weblogic.application.internal.BaseDeployment$2.next(BaseDeployment.java:636)
                  at weblogic.application.utils.StateMachineDriver.nextState(StateMachineDriver.java:52)
                  at weblogic.application.internal.BaseDeployment.activate(BaseDeployment.java:205)
                  at weblogic.application.internal.EarDeployment.activate(EarDeployment.java:58)
                  at weblogic.application.internal.DeploymentStateChecker.activate(DeploymentStateChecker.java:161)
                  at weblogic.deploy.internal.targetserver.AppContainerInvoker.activate(AppContainerInvoker.java:79)
                  at weblogic.deploy.internal.targetserver.operations.AbstractOperation.activate(AbstractOperation.java:569)
                  at weblogic.deploy.internal.targetserver.operations.ActivateOperation.activateDeployment(ActivateOperation.java:150)
                  at weblogic.deploy.internal.targetserver.operations.ActivateOperation.doCommit(ActivateOperation.java:116)
                  at weblogic.deploy.internal.targetserver.operations.AbstractOperation.commit(AbstractOperation.java:323)
                  at weblogic.deploy.internal.targetserver.DeploymentManager.handleDeploymentCommit(DeploymentManager.java:844)
                  at weblogic.deploy.internal.targetserver.DeploymentManager.activateDeploymentList(DeploymentManager.java:1253)
                  at weblogic.deploy.internal.targetserver.DeploymentManager.handleCommit(DeploymentManager.java:440)
                  at weblogic.deploy.internal.targetserver.DeploymentServiceDispatcher.commit(DeploymentServiceDispatcher.java:163)
                  at weblogic.deploy.service.internal.targetserver.DeploymentReceiverCallbackDeliverer.doCommitCallback(DeploymentReceiverCallbackDeliverer.java:195)
                  at weblogic.deploy.service.internal.targetserver.DeploymentReceiverCallbackDeliverer.access$100(DeploymentReceiverCallbackDeliverer.java:13)
                  at weblogic.deploy.service.internal.targetserver.DeploymentReceiverCallbackDeliverer$2.run(DeploymentReceiverCallbackDeliverer.java:68)
                  at weblogic.work.SelfTuningWorkManagerImpl$WorkAdapterImpl.run(SelfTuningWorkManagerImpl.java:528)
                  at weblogic.work.ExecuteThread.execute(ExecuteThread.java:207)
                  at weblogic.work.ExecuteThread.run(ExecuteThread.java:176)
                  • 6. Re: could not find Factory: javax.faces.context.FacesContextFactory
                    848356
                    I have a similar problem. I tried to deploy my ear file to a Weblogic 10.3.5 server and it did not have JSF 2.0 support so it failed. After I added the JSF 2.0 in the war's lib contributors and re-deploy. I got this error:

                    weblogic.application.ModuleException:
                    \oracle\Middleware\Oracle_SOA1\soa\connectors\FileAdapter.rar!fileAdapter.jar (The system cannot find the file specified)

                    Odd thing is, C:\oracle\Middleware\Oracle_SOA1\soa\connectors\FileAdapter.rar is there and fileAdapter.jar is inside. I wonder why it could not locate it. Could it be the path?
                    This server also has SAO installed.

                    Please help. Thanks.

                    Edited by: user9976795 on Jan 31, 2012 8:49 AM
                    • 7. Re: could not find Factory: javax.faces.context.FacesContextFactory
                      Steve Button-Oracle
                      I recall there being a bug with zip file handling and custom JSF components. I don't know if this is the same issue (likely not) but it sounds a little similar in that the library claimed to not be present, was actually present.

                      This is a piece of the stacktrace we discovered:

                      SEVERE:
                      java.io.FileNotFoundException:
                      zip:D:/wls1033-0224/user_projects/domains/test/servers/AdminServer/tmp/_WL_user/MedRec-Lite.ear/4m6xxh/war/WEB-INF/lib/primefaces-2.0.0.jar
                      at weblogic.utils.zip.ZipURLConnection.connect(Handler.java:78)
                      at weblogic.utils.zip.ZipURLConnection.getInputStream(Handler.java:53)
                      at sun.net.www.protocol.jar.URLJarFile.retrieve(URLJarFile.java:195)
                      at sun.net.www.protocol.jar.URLJarFile.getJarFile(URLJarFile.java:50)

                      Is there any more information in your error message or a stack trace to look at?

                      -steve-