Skip to main content
4 of 4
remove private name
Giu Do
  • 847
  • 4
  • 12

How do I resolve a 'No PageFactory configured' error in DD4T?

We decided to create a "homemade" DD4T template to have the Tridion API & an ASP.NET MVC 4 website (the current template contains contains an ASP.NET MVC 3 website)

I added /lib & /config folders inside the /bin folder with .jar & .xml files required (license included)

My projects are named Test.Web.DD4T & Test.Web.UI

Here is the source code producing the error :

(From PageController which inherits from TridionControllerBase) :

public override ActionResult Page(string pageId){
return base.Page(pageId);}

Here is the stack trace :

    [ConfigurationException: No PageFactory configured]
   DD4T.Mvc.Controllers.TridionControllerBase.GetModelForPage(String PageId) +225
   DD4T.Mvc.Controllers.TridionControllerBase.Page(String pageId) +89
   *.Web.DD4T.PageController.Page(String pageId) in C:\Users\$\My Projects\*.Web\*.Web.DD4T\PageController.cs:9
   lambda_method(Closure , ControllerBase , Object[] ) +163
   System.Web.Mvc.ActionMethodDispatcher.Execute(ControllerBase controller, Object[] parameters) +17
   System.Web.Mvc.ReflectedActionDescriptor.Execute(ControllerContext controllerContext, IDictionary`2 parameters) +205
   System.Web.Mvc.ControllerActionInvoker.InvokeActionMethod(ControllerContext controllerContext, ActionDescriptor actionDescriptor, IDictionary`2 parameters) +27
   System.Web.Mvc.Async.<>c__DisplayClass42.<BeginInvokeSynchronousActionMethod>b__41() +28
   System.Web.Mvc.Async.<>c__DisplayClass8`1.<BeginSynchronous>b__7(IAsyncResult _) +12
   System.Web.Mvc.Async.WrappedAsyncResult`1.End() +57
   System.Web.Mvc.Async.AsyncControllerActionInvoker.EndInvokeActionMethod(IAsyncResult asyncResult) +50
   System.Web.Mvc.Async.<>c__DisplayClass39.<BeginInvokeActionMethodWithFilters>b__33() +58
   System.Web.Mvc.Async.<>c__DisplayClass4f.<InvokeActionMethodFilterAsynchronously>b__49() +237
   System.Web.Mvc.Async.<>c__DisplayClass37.<BeginInvokeActionMethodWithFilters>b__36(IAsyncResult asyncResult) +12
   System.Web.Mvc.Async.WrappedAsyncResult`1.End() +57
   System.Web.Mvc.Async.AsyncControllerActionInvoker.EndInvokeActionMethodWithFilters(IAsyncResult asyncResult) +50
   System.Web.Mvc.Async.<>c__DisplayClass2a.<BeginInvokeAction>b__20() +24
   System.Web.Mvc.Async.<>c__DisplayClass25.<BeginInvokeAction>b__22(IAsyncResult asyncResult) +126
   System.Web.Mvc.Async.WrappedAsyncResult`1.End() +57
   System.Web.Mvc.Async.AsyncControllerActionInvoker.EndInvokeAction(IAsyncResult asyncResult) +45
   System.Web.Mvc.<>c__DisplayClass1d.<BeginExecuteCore>b__18(IAsyncResult asyncResult) +14
   System.Web.Mvc.Async.<>c__DisplayClass4.<MakeVoidDelegate>b__3(IAsyncResult ar) +25
   System.Web.Mvc.Async.WrappedAsyncResult`1.End() +62
   System.Web.Mvc.Controller.EndExecuteCore(IAsyncResult asyncResult) +61
   System.Web.Mvc.Async.<>c__DisplayClass4.<MakeVoidDelegate>b__3(IAsyncResult ar) +25
   System.Web.Mvc.Async.WrappedAsyncResult`1.End() +62
   System.Web.Mvc.Controller.EndExecute(IAsyncResult asyncResult) +49
   System.Web.Mvc.Controller.System.Web.Mvc.Async.IAsyncController.EndExecute(IAsyncResult asyncResult) +10
   System.Web.Mvc.<>c__DisplayClass8.<BeginProcessRequest>b__3(IAsyncResult asyncResult) +28
   System.Web.Mvc.Async.<>c__DisplayClass4.<MakeVoidDelegate>b__3(IAsyncResult ar) +25
   System.Web.Mvc.Async.WrappedAsyncResult`1.End() +62
   System.Web.Mvc.MvcHandler.EndProcessRequest(IAsyncResult asyncResult) +49
   System.Web.Mvc.MvcHandler.System.Web.IHttpAsyncHandler.EndProcessRequest(IAsyncResult result) +9
   System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +8968077
   System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +184

The web.config (unity part) :

<unity>
<typeAliases>
  <!-- Lifetime manager types -->
  <typeAlias alias="singleton" type="Microsoft.Practices.Unity.ContainerControlledLifetimeManager,                      Microsoft.Practices.Unity" />
  <typeAlias alias="external" type="Microsoft.Practices.Unity.ExternallyControlledLifetimeManager,                      Microsoft.Practices.Unity" />
  <!-- define aliases for interfaces -->
  <typeAlias alias="IPageProvider" type="DD4T.ContentModel.Contracts.Providers.IPageProvider, DD4T.ContentModel.Contracts" />
  <typeAlias alias="IComponentProvider" type="DD4T.ContentModel.Contracts.Providers.IComponentProvider, DD4T.ContentModel.Contracts" />
  <typeAlias alias="IBinaryProvider" type="DD4T.ContentModel.Contracts.Providers.IBinaryProvider, DD4T.ContentModel.Contracts" />
  <typeAlias alias="ILinkProvider" type="DD4T.ContentModel.Contracts.Providers.ILinkProvider, DD4T.ContentModel.Contracts" />
  <typeAlias alias="ITaxonomyProvider" type="DD4T.ContentModel.Contracts.Providers.ITaxonomyProvider, DD4T.ContentModel.Contracts" />
  <typeAlias alias="IComponentPresentationRenderer" type="DD4T.Mvc.Html.IComponentPresentationRenderer, DD4T.Mvc" />
  <typeAlias alias="IPageController" type="DD4T.Mvc.Controllers.IPageController, DD4T.Mvc" />
  <typeAlias alias="IComponentController" type="DD4T.Mvc.Controllers.IComponentController, DD4T.Mvc" />
  <typeAlias alias="IPageFactory" type="DD4T.ContentModel.Factories.IPageFactory, DD4T.ContentModel.Contracts" />
  <typeAlias alias="IComponentFactory" type="DD4T.ContentModel.Factories.IComponentFactory, DD4T.ContentModel.Contracts" />
  <typeAlias alias="ILinkFactory" type="DD4T.ContentModel.Factories.ILinkFactory, DD4T.ContentModel.Contracts" />
  <!-- 
    Define aliases for implementations 
    This is where we determine which classes to use for our implementations!
  -->
  <typeAlias alias="PageProvider" type="DD4T.Providers.SDLTridion2011sp1.TridionPageProvider, DD4T.Providers.SDLTridion2011sp1" />
  <typeAlias alias="ComponentProvider" type="DD4T.Providers.SDLTridion2011sp1.TridionComponentProvider, DD4T.Providers.SDLTridion2011sp1" />
  <typeAlias alias="BinaryProvider" type="DD4T.Providers.SDLTridion2011sp1.TridionBinaryProvider, DD4T.Providers.SDLTridion2011sp1" />
  <typeAlias alias="LinkProvider" type="DD4T.Providers.SDLTridion2011sp1.TridionLinkProvider, DD4T.Providers.SDLTridion2011sp1" />
  <typeAlias alias="TaxonomyProvider" type="DD4T.Providers.SDLTridion2011sp1.TridionTaxonomyProvider, DD4T.Providers.SDLTridion2011sp1" />
  <typeAlias alias="ComponentPresentationRenderer" type="DD4T.Mvc.Html.DefaultComponentPresentationRenderer, DD4T.Mvc" />
  <typeAlias alias="PageController" type="Test.Web.DD4T.PageController, Test.Web.DD4T" />
  <typeAlias alias="ComponentController" type="Test.Web.DD4T.ComponentController, Test.Web.DD4T" />
  <typeAlias alias="PageFactory" type="DD4T.Factories.PageFactory, DD4T.Factories" />
  <typeAlias alias="ComponentFactory" type="DD4T.Factories.ComponentFactory, DD4T.Factories" />
  <typeAlias alias="LinkFactory" type="DD4T.Factories.LinkFactory, DD4T.Factories" />
</typeAliases>
<!-- Unity Configuration -->
<containers>
  <container name="main">
    <types>
      <!-- map the implementations to the interfaces -->
      <type type="IPageProvider" mapTo="PageProvider">
        <!--          <lifetime type="singleton" /> -->
        <property name="PublicationId" type="int" value="0" />
      </type>
      <type type="IPageFactory" mapTo="PageFactory">
        <property name="PageProvider" dependencyType="IPageProvider" />
        <property name="ComponentFactory" dependencyType="IComponentFactory" />
        <property name="LinkFactory" dependencyType="ILinkFactory" />
      </type>
      <type type="ILinkProvider" mapTo="LinkProvider" />
      <type type="ILinkFactory" mapTo="LinkFactory">
        <property name="LinkProvider" dependencyType="ILinkProvider" />
      </type>
      <type type="IPageController" mapTo="PageController">
        <property name="PageFactory" dependencyType="IPageFactory" />
        <property name="ComponentPresentationRenderer" dependencyType="IComponentPresentationRenderer" />
      </type>
      <type type="IComponentProvider" mapTo="ComponentProvider">
        <lifetime type="singleton" />
      </type>
      <type type="IComponentFactory" mapTo="ComponentFactory">
        <lifetime type="singleton" />
        <property name="ComponentProvider" dependencyType="IComponentProvider" />
      </type>
      <type type="IComponentController" mapTo="ComponentController">
        <property name="ComponentFactory" dependencyType="IComponentFactory" />
      </type>
      <type type="IComponentPresentationRenderer" mapTo="ComponentPresentationRenderer">
        <lifetime type="singleton" />
      </type>
    </types>
  </container>
</containers>

Do you have any idea to solve it ?

Giu Do
  • 847
  • 4
  • 12