7 Replies Latest reply on Sep 12, 2012 5:52 PM by Danilo Diaz

    Custom facescontextfactory and InstantationException

    riboriori riboriori Newbie

      Hi all

      i'm migrating a ear packaged application from jboss 6/ant to jboss 7.1.0/maven.

      My ear structure is classic (one ejb, one war and all libraries under lib of ear root.

      Under ear/lib there is a jar a set of classes wich i would share with the war) that contains a class that extends FacesContextFactory

       

       

      public class CustomFacesContextFactory extends FacesContextFactory {

       

       

                private FacesContextFactory delegate;

       

       

                public CustomFacesContextFactory(FacesContextFactory facesContextFactory) {

                          delegate = facesContextFactory;

                }

       

       

                public FacesContext getFacesContext(Object context, Object request, Object response,Lifecycle lifecycle) throws FacesException {

                          return new CustomFacesContext(delegate.getFacesContext(context, request, response, lifecycle));

                }

       

                @Override

                public FacesContextFactory getWrapped() {

                          return delegate;

                }

       

       

       

       

      }

       

       

      Under META-INF dir of that jar i put a faces-config.xml file:

       

       

      <?xml version="1.0" encoding="UTF-8"?>

      <faces-config version="2.0" xmlns="http://java.sun.com/xml/ns/javaee"

         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"

         xsi:schemaLocation="http://java.sun.com/xml/ns/javaee

                                         http://java.sun.com/xml/ns/javaee/web-facesconfig_2_0.xsd">

       

       

                <factory>

                            <faces-context-factory>com.mycompany.myapp.utils.faces.context.CustomFacesContextFactory</faces-context-factory>

                </factory> 

       

      </faces-config>

       

       

       

      But when jboss run i have a strange InstantiationException:

       

       

      23:40:03,266 GRAVE [javax.enterprise.resource.webcontainer.jsf.config] (MSC service thread 1-12) Critical error during deployment: : com.sun.faces.config.ConfigurationException: Factory 'javax.faces.context.FacesContextFactory' was not configured properly.

                at com.sun.faces.config.processor.FactoryConfigProcessor.verifyFactoriesExist(FactoryConfigProcessor.java:305) [jsf-impl-2.1.7.jar:2.1.7-SNAPSHOT]

                at com.sun.faces.config.processor.FactoryConfigProcessor.process(FactoryConfigProcessor.java:219) [jsf-impl-2.1.7.jar:2.1.7-SNAPSHOT]

                at com.sun.faces.config.ConfigManager.initialize(ConfigManager.java:360) [jsf-impl-2.1.7.jar:2.1.7-SNAPSHOT]

                at com.sun.faces.config.ConfigureListener.contextInitialized(ConfigureListener.java:225) [jsf-impl-2.1.7.jar:2.1.7-SNAPSHOT]

                at org.apache.catalina.core.StandardContext.contextListenerStart(StandardContext.java:3392) [jbossweb-7.0.13.Final.jar:]

                at org.apache.catalina.core.StandardContext.start(StandardContext.java:3850) [jbossweb-7.0.13.Final.jar:]

                at org.jboss.as.web.deployment.WebDeploymentService.start(WebDeploymentService.java:90) [jboss-as-web-7.1.1.Final.jar:7.1.1.Final]

                at org.jboss.msc.service.ServiceControllerImpl$StartTask.startService(ServiceControllerImpl.java:1811)

                at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1746)

                at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(Unknown Source) [rt.jar:1.6.0_23-ea]

                at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source) [rt.jar:1.6.0_23-ea]

                at java.lang.Thread.run(Unknown Source) [rt.jar:1.6.0_23-ea]

      Caused by: javax.faces.FacesException: com.mycompany.utils.faces.context.CustomFacesContextFactory

                at javax.faces.FactoryFinder.getImplGivenPreviousImpl(FactoryFinder.java:643) [jboss-jsf-api_2.1_spec-2.0.1.Final.jar:2.0.1.Final]

                at javax.faces.FactoryFinder.getImplementationInstance(FactoryFinder.java:509) [jboss-jsf-api_2.1_spec-2.0.1.Final.jar:2.0.1.Final]

                at javax.faces.FactoryFinder.access$400(FactoryFinder.java:139) [jboss-jsf-api_2.1_spec-2.0.1.Final.jar:2.0.1.Final]

                at javax.faces.FactoryFinder$FactoryManager.getFactory(FactoryFinder.java:993) [jboss-jsf-api_2.1_spec-2.0.1.Final.jar:2.0.1.Final]

                at javax.faces.FactoryFinder.getFactory(FactoryFinder.java:343) [jboss-jsf-api_2.1_spec-2.0.1.Final.jar:2.0.1.Final]

                at com.sun.faces.config.processor.FactoryConfigProcessor.verifyFactoriesExist(FactoryConfigProcessor.java:303) [jsf-impl-2.1.7.jar:2.1.7-SNAPSHOT]

                ... 11 more

      Caused by: java.lang.InstantiationException: com.mycompany.utils.faces.context.CustomFacesContextFactory

                at java.lang.Class.newInstance0(Unknown Source) [rt.jar:1.6.0_23-ea]

                at java.lang.Class.newInstance(Unknown Source) [rt.jar:1.6.0_23-ea]

                at javax.faces.FactoryFinder.getImplGivenPreviousImpl(FactoryFinder.java:641) [jboss-jsf-api_2.1_spec-2.0.1.Final.jar:2.0.1.Final]

                ... 16 more

       

       

      23:40:03,276 FINE  [javax.enterprise.resource.webcontainer.jsf.config] (MSC service thread 1-12) Completed initializing Mojarra (2.1.7 (SNAPSHOT 20120206)) for context ''{0}''

      23:40:03,276 FINE  [javax.enterprise.resource.webcontainer.jsf.timing] (MSC service thread 1-12)  [TIMING] - [387ms] : Initialization of context /MyApp-web

      23:40:03,277 ERROR [org.apache.catalina.core.ContainerBase.[jboss.web].[default-host].[/MyApp-web]] (MSC service thread 1-12) Exception sending context initialized event to listener instance of class com.sun.faces.config.ConfigureListener: java.lang.RuntimeException: com.sun.faces.config.ConfigurationException: Factory 'javax.faces.context.FacesContextFactory' was not configured properly.

                at com.sun.faces.config.ConfigureListener.contextInitialized(ConfigureListener.java:292) [jsf-impl-2.1.7.jar:2.1.7-SNAPSHOT]

                at org.apache.catalina.core.StandardContext.contextListenerStart(StandardContext.java:3392) [jbossweb-7.0.13.Final.jar:]

                at org.apache.catalina.core.StandardContext.start(StandardContext.java:3850) [jbossweb-7.0.13.Final.jar:]

                at org.jboss.as.web.deployment.WebDeploymentService.start(WebDeploymentService.java:90) [jboss-as-web-7.1.1.Final.jar:7.1.1.Final]

                at org.jboss.msc.service.ServiceControllerImpl$StartTask.startService(ServiceControllerImpl.java:1811)

                at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1746)

                at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(Unknown Source) [rt.jar:1.6.0_23-ea]

                at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source) [rt.jar:1.6.0_23-ea]

                at java.lang.Thread.run(Unknown Source) [rt.jar:1.6.0_23-ea]

      Caused by: com.sun.faces.config.ConfigurationException: Factory 'javax.faces.context.FacesContextFactory' was not configured properly.

                at com.sun.faces.config.processor.FactoryConfigProcessor.verifyFactoriesExist(FactoryConfigProcessor.java:305) [jsf-impl-2.1.7.jar:2.1.7-SNAPSHOT]

                at com.sun.faces.config.processor.FactoryConfigProcessor.process(FactoryConfigProcessor.java:219) [jsf-impl-2.1.7.jar:2.1.7-SNAPSHOT]

                at com.sun.faces.config.ConfigManager.initialize(ConfigManager.java:360) [jsf-impl-2.1.7.jar:2.1.7-SNAPSHOT]

                at com.sun.faces.config.ConfigureListener.contextInitialized(ConfigureListener.java:225) [jsf-impl-2.1.7.jar:2.1.7-SNAPSHOT]

                ... 8 more

      Caused by: javax.faces.FacesException: com.mycompany.utils.faces.context.CustomFacesContextFactory

                at javax.faces.FactoryFinder.getImplGivenPreviousImpl(FactoryFinder.java:643) [jboss-jsf-api_2.1_spec-2.0.1.Final.jar:2.0.1.Final]

                at javax.faces.FactoryFinder.getImplementationInstance(FactoryFinder.java:509) [jboss-jsf-api_2.1_spec-2.0.1.Final.jar:2.0.1.Final]

                at javax.faces.FactoryFinder.access$400(FactoryFinder.java:139) [jboss-jsf-api_2.1_spec-2.0.1.Final.jar:2.0.1.Final]

                at javax.faces.FactoryFinder$FactoryManager.getFactory(FactoryFinder.java:993) [jboss-jsf-api_2.1_spec-2.0.1.Final.jar:2.0.1.Final]

                at javax.faces.FactoryFinder.getFactory(FactoryFinder.java:343) [jboss-jsf-api_2.1_spec-2.0.1.Final.jar:2.0.1.Final]

                at com.sun.faces.config.processor.FactoryConfigProcessor.verifyFactoriesExist(FactoryConfigProcessor.java:303) [jsf-impl-2.1.7.jar:2.1.7-SNAPSHOT]

                ... 11 more

      Caused by: java.lang.InstantiationException: com.mycompany.utils.faces.context.CustomFacesContextFactory

                at java.lang.Class.newInstance0(Unknown Source) [rt.jar:1.6.0_23-ea]

                at java.lang.Class.newInstance(Unknown Source) [rt.jar:1.6.0_23-ea]

                at javax.faces.FactoryFinder.getImplGivenPreviousImpl(FactoryFinder.java:641) [jboss-jsf-api_2.1_spec-2.0.1.Final.jar:2.0.1.Final]

                ... 16 more

       

       

       

      Regarding of jsf i'm using implementation and api shipped with jboss as 7 distribution.

       

      Can anyone help me?

      Best regards

        • 1. Re: Custom facescontextfactory and InstantationException
          riboriori riboriori Newbie

          In last post loose faces-config:

           

          <?xml version="1.0" encoding="UTF-8"?>

          <faces-config version="2.0" xmlns="http://java.sun.com/xml/ns/javaee"

             xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"

             xsi:schemaLocation="http://java.sun.com/xml/ns/javaee

                                             http://java.sun.com/xml/ns/javaee/web-facesconfig_2_0.xsd">

                <factory>

                                <faces-context-factory>com.mycompany.utils.faces.context.CustomFacesContextFactory</faces-context-factory>

                    </factory> 

           

           

             

             

          </faces-config>

           

           

           

           

          • 3. Re: Custom facescontextfactory and InstantationException
            riboriori riboriori Newbie

            A little update: i disabled my jar that contains FacesContextFactory extension, and having primefaces under ear/lib (like my above jar) this time i have same exception on primefaces:

             

            17:22:11,339 GRAVE [javax.enterprise.resource.webcontainer.jsf.config] (MSC service thread 1-4) Critical error during deployment: : com.sun.faces.config.ConfigurationException: Factory 'javax.faces.context.PartialViewContextFactory' was not configured properly.

                      at com.sun.faces.config.processor.FactoryConfigProcessor.verifyFactoriesExist(FactoryConfigProcessor.java:305) [jsf-impl-2.1.7.jar:2.1.7-SNAPSHOT]

                      at com.sun.faces.config.processor.FactoryConfigProcessor.process(FactoryConfigProcessor.java:219) [jsf-impl-2.1.7.jar:2.1.7-SNAPSHOT]

                      at com.sun.faces.config.ConfigManager.initialize(ConfigManager.java:360) [jsf-impl-2.1.7.jar:2.1.7-SNAPSHOT]

                      at com.sun.faces.config.ConfigureListener.contextInitialized(ConfigureListener.java:225) [jsf-impl-2.1.7.jar:2.1.7-SNAPSHOT]

                      at org.apache.catalina.core.StandardContext.contextListenerStart(StandardContext.java:3392) [jbossweb-7.0.13.Final.jar:]

                      at org.apache.catalina.core.StandardContext.start(StandardContext.java:3850) [jbossweb-7.0.13.Final.jar:]

                      at org.jboss.as.web.deployment.WebDeploymentService.start(WebDeploymentService.java:90) [jboss-as-web-7.1.1.Final.jar:7.1.1.Final]

                      at org.jboss.msc.service.ServiceControllerImpl$StartTask.startService(ServiceControllerImpl.java:1811)

                      at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1746)

                      at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(Unknown Source) [rt.jar:1.6.0_23-ea]

                      at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source) [rt.jar:1.6.0_23-ea]

                      at java.lang.Thread.run(Unknown Source) [rt.jar:1.6.0_23-ea]

            Caused by: javax.faces.FacesException: org.primefaces.context.PrimePartialViewContextFactory

                      at javax.faces.FactoryFinder.getImplGivenPreviousImpl(FactoryFinder.java:643) [jboss-jsf-api_2.1_spec-2.0.1.Final.jar:2.0.1.Final]

                      at javax.faces.FactoryFinder.getImplementationInstance(FactoryFinder.java:509) [jboss-jsf-api_2.1_spec-2.0.1.Final.jar:2.0.1.Final]

                      at javax.faces.FactoryFinder.access$400(FactoryFinder.java:139) [jboss-jsf-api_2.1_spec-2.0.1.Final.jar:2.0.1.Final]

                      at javax.faces.FactoryFinder$FactoryManager.getFactory(FactoryFinder.java:993) [jboss-jsf-api_2.1_spec-2.0.1.Final.jar:2.0.1.Final]

                      at javax.faces.FactoryFinder.getFactory(FactoryFinder.java:343) [jboss-jsf-api_2.1_spec-2.0.1.Final.jar:2.0.1.Final]

                      at com.sun.faces.config.processor.FactoryConfigProcessor.verifyFactoriesExist(FactoryConfigProcessor.java:303) [jsf-impl-2.1.7.jar:2.1.7-SNAPSHOT]

                      ... 11 more

            Caused by: java.lang.InstantiationException: org.primefaces.context.PrimePartialViewContextFactory

                      at java.lang.Class.newInstance0(Unknown Source) [rt.jar:1.6.0_23-ea]

                      at java.lang.Class.newInstance(Unknown Source) [rt.jar:1.6.0_23-ea]

                      at javax.faces.FactoryFinder.getImplGivenPreviousImpl(FactoryFinder.java:641) [jboss-jsf-api_2.1_spec-2.0.1.Final.jar:2.0.1.Final]

                      ... 16 more

             

             

            What can be the problem?

             

            17:22:11,361 FINE  [javax.enterprise.resource.webcontainer.jsf.config] (MSC service thread 1-4) Completed initializing Mojarra (2.1.7 (SNAPSHOT 20120206)) for context ''{0}''

            17:22:11,362 FINE  [javax.enterprise.resource.webcontainer.jsf.timing] (MSC service thread 1-4)  [TIMING] - [489ms] : Initialization of context /MyApp-web

            17:22:11,362 ERROR [org.apache.catalina.core.ContainerBase.[jboss.web].[default-host].[/MyApp-web]] (MSC service thread 1-4) Exception sending context initialized event to listener instance of class com.sun.faces.config.ConfigureListener: java.lang.RuntimeException: com.sun.faces.config.ConfigurationException: Factory 'javax.faces.context.PartialViewContextFactory' was not configured properly.

                      at com.sun.faces.config.ConfigureListener.contextInitialized(ConfigureListener.java:292) [jsf-impl-2.1.7.jar:2.1.7-SNAPSHOT]

                      at org.apache.catalina.core.StandardContext.contextListenerStart(StandardContext.java:3392) [jbossweb-7.0.13.Final.jar:]

                      at org.apache.catalina.core.StandardContext.start(StandardContext.java:3850) [jbossweb-7.0.13.Final.jar:]

                      at org.jboss.as.web.deployment.WebDeploymentService.start(WebDeploymentService.java:90) [jboss-as-web-7.1.1.Final.jar:7.1.1.Final]

                      at org.jboss.msc.service.ServiceControllerImpl$StartTask.startService(ServiceControllerImpl.java:1811)

                      at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1746)

                      at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(Unknown Source) [rt.jar:1.6.0_23-ea]

                      at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source) [rt.jar:1.6.0_23-ea]

                      at java.lang.Thread.run(Unknown Source) [rt.jar:1.6.0_23-ea]

            Caused by: com.sun.faces.config.ConfigurationException: Factory 'javax.faces.context.PartialViewContextFactory' was not configured properly.

                      at com.sun.faces.config.processor.FactoryConfigProcessor.verifyFactoriesExist(FactoryConfigProcessor.java:305) [jsf-impl-2.1.7.jar:2.1.7-SNAPSHOT]

                      at com.sun.faces.config.processor.FactoryConfigProcessor.process(FactoryConfigProcessor.java:219) [jsf-impl-2.1.7.jar:2.1.7-SNAPSHOT]

                      at com.sun.faces.config.ConfigManager.initialize(ConfigManager.java:360) [jsf-impl-2.1.7.jar:2.1.7-SNAPSHOT]

                      at com.sun.faces.config.ConfigureListener.contextInitialized(ConfigureListener.java:225) [jsf-impl-2.1.7.jar:2.1.7-SNAPSHOT]

                      ... 8 more

            Caused by: javax.faces.FacesException: org.primefaces.context.PrimePartialViewContextFactory

                      at javax.faces.FactoryFinder.getImplGivenPreviousImpl(FactoryFinder.java:643) [jboss-jsf-api_2.1_spec-2.0.1.Final.jar:2.0.1.Final]

                      at javax.faces.FactoryFinder.getImplementationInstance(FactoryFinder.java:509) [jboss-jsf-api_2.1_spec-2.0.1.Final.jar:2.0.1.Final]

                      at javax.faces.FactoryFinder.access$400(FactoryFinder.java:139) [jboss-jsf-api_2.1_spec-2.0.1.Final.jar:2.0.1.Final]

                      at javax.faces.FactoryFinder$FactoryManager.getFactory(FactoryFinder.java:993) [jboss-jsf-api_2.1_spec-2.0.1.Final.jar:2.0.1.Final]

                      at javax.faces.FactoryFinder.getFactory(FactoryFinder.java:343) [jboss-jsf-api_2.1_spec-2.0.1.Final.jar:2.0.1.Final]

                      at com.sun.faces.config.processor.FactoryConfigProcessor.verifyFactoriesExist(FactoryConfigProcessor.java:303) [jsf-impl-2.1.7.jar:2.1.7-SNAPSHOT]

                      ... 11 more

            Caused by: java.lang.InstantiationException: org.primefaces.context.PrimePartialViewContextFactory

                      at java.lang.Class.newInstance0(Unknown Source) [rt.jar:1.6.0_23-ea]

                      at java.lang.Class.newInstance(Unknown Source) [rt.jar:1.6.0_23-ea]

                      at javax.faces.FactoryFinder.getImplGivenPreviousImpl(FactoryFinder.java:641) [jboss-jsf-api_2.1_spec-2.0.1.Final.jar:2.0.1.Final]

                      ... 16 more

            • 4. Re: Custom facescontextfactory and InstantationException
              riboriori riboriori Newbie

              Anyone? i googoled a lot but nothing  found; please can anyone help me?

              • 5. Re: Custom facescontextfactory and InstantationException
                Stephen Coy Master

                Without looking too closely (aka an educated guess), I suspect that classes in your EAR/lib directory are trying to access classes in your WEB-INF/lib directory. This would have worked in the past but it was not really spec compliant class loading behaviour.

                • 6. Re: Custom facescontextfactory and InstantationException
                  Danilo Diaz Newbie

                  I have the same problem... Im using mojarra 2.1.7 in jboss 7.1.1. Here is my stacktrace:

                   

                  Caused by: javax.faces.FacesException: org.jboss.as.weld.webtier.jsf.WeldApplicationFactory

                      at javax.faces.FactoryFinder.getImplGivenPreviousImpl(FactoryFinder.java:643) [jboss-jsf-api_2.1_spec-2.0.1.Final.jar:2.0.1.Final]

                      at javax.faces.FactoryFinder.getImplementationInstance(FactoryFinder.java:509) [jboss-jsf-api_2.1_spec-2.0.1.Final.jar:2.0.1.Final]

                      at javax.faces.FactoryFinder.access$400(FactoryFinder.java:139) [jboss-jsf-api_2.1_spec-2.0.1.Final.jar:2.0.1.Final]

                      at javax.faces.FactoryFinder$FactoryManager.getFactory(FactoryFinder.java:993) [jboss-jsf-api_2.1_spec-2.0.1.Final.jar:2.0.1.Final]

                      at javax.faces.FactoryFinder.getFactory(FactoryFinder.java:343) [jboss-jsf-api_2.1_spec-2.0.1.Final.jar:2.0.1.Final]

                      at com.sun.faces.config.processor.FactoryConfigProcessor.verifyFactoriesExist(FactoryConfigProcessor.java:303) [jsf-impl-2.1.7-jbossorg-2.jar:]

                      ... 11 more

                  Caused by: java.lang.InstantiationException: org.jboss.as.weld.webtier.jsf.WeldApplicationFactory

                      at java.lang.Class.newInstance0(Class.java:357) [rt.jar:1.6.0]

                      at java.lang.Class.newInstance(Class.java:325) [rt.jar:1.6.0]

                      at javax.faces.FactoryFinder.getImplGivenPreviousImpl(FactoryFinder.java:641) [jboss-jsf-api_2.1_spec-2.0.1.Final.jar:2.0.1.Final]

                  I would really apreciatte your help... Im stuck at this point and I can't find any more information about this on google.

                  • 7. Re: Custom facescontextfactory and InstantationException
                    Danilo Diaz Newbie

                    @Riboriori

                    I removed the beans.xml file from my meta-inf folder and everything work fine now