1

I am trying to setup a new project using DD4T 2.0 .Net Solution with SDL Web 8.5. Here I have not used any micro services in web application to fetch the data. I am using cd_storage_config to connect to Broker Database.

When I run the application I encounter the below error in the code level :

An exception of type 'System.Web.HttpException' occurred in DD4T.MVC.dll but was not handled in user code Additional information: Page cannot be found

I have followed this link while creating the DD4T solution. Below I am adding the basic information I have used in the solution

cd_storage_config :

  <?xml version="1.0" encoding="UTF-8"?>
 <Configuration xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" Version="6.1" xsi:noNamespaceSchemaLocation="schemas/cd_storage_conf.xsd">              
 <Global>       
    <Storages>

        <Storage Class="com.tridion.storage.persistence.JPADAOFactory" Id="defaultdb" Type="persistence" dialect="MSSQL">
            <Pool CheckoutTimeout="120" IdleTimeout="120" MonitorInterval="60" Size="10" Type="jdbc"/>
            <DataSource Class="com.microsoft.sqlserver.jdbc.SQLServerDataSource">
                <Property Name="serverName" Value="<DB_Instance>"/>
                <Property Name="portNumber" Value="1433"/>
                <Property Name="databaseName" Value="Tridion_Broker_Staging"/>
                <Property Name="user" Value="TridionBrokerUser"/>
                <Property Name="password" Value="********"/>
            </DataSource>
        </Storage>

        <!--            
            Configuration example for using filesystem as data storage. 
        -->
        <Storage Class="com.tridion.storage.filesystem.FSDAOFactory" Id="defaultFile" Type="filesystem" defaultFilesystem="false">
            <Root Path="D:\websites\staging"/>
        </Storage>

      </Storages>

</Global>
<!-- If no item type mappings are defined within ItemTypes or if storages on a lower level do not exist then the storage defined by defaultStorageId attribute will be used.
     If storage defined by defaultStorageId does not exist then exception will be thrown. -->
<ItemTypes cached="true" defaultStorageId="defaultdb">       
      <Item typeMapping="Query" storageId="defaultdb"/>
  <Publication Id="157" cached="false" defaultStorageId="defaultdb">
    <Item cached="false" storageId="defaultdb" typeMapping="Page"/>
    <Item cached="false" storageId="defaultdb" typeMapping="Binary"/>
  </Publication>
</ItemTypes>
<!-- Specifies the location of the license file. -->
<License Location="D:/SDL/license/cd_licenses.xml"/>
</Configuration>

App setting Entry :

  <!-- Basic DD4T Configuration Settings-->
<add key="DD4T.ComponentPresentationController" value="Component" />
<add key="DD4T.ComponentPresentationAction" value="ComponentPresentation" />
<add key="DD4T.PublicationId" value="157" />
<add key="DD4T.ProviderVersion" value="SDLWeb85" />
<add key="DD4T.DefaultPage" value="index.html" />

Global.ascx.cs:

public class MvcApplication : System.Web.HttpApplication
{

    ILifetimeScope BuildContainer()
    {
        var builder = new ContainerBuilder();
        builder.RegisterControllers(typeof(MvcApplication).Assembly);
        builder.UseDD4T();
        return builder.Build();
    }
    protected void Application_Start()
    {
        var builder = BuildContainer();
        DependencyResolver.SetResolver(new AutofacDependencyResolver(builder));

        AreaRegistration.RegisterAllAreas();
        RouteConfig.RegisterRoutes(RouteTable.Routes);
    }
}

Page Controller :

public class PageController : TridionControllerBase
{
    public PageController(IPageFactory pageFactor,
                   IComponentPresentationFactory 
                   componentPresentationFactory,
                   ILogger logger,
                   IDD4TConfiguration configuration) :
                   base(pageFactor, componentPresentationFactory, logger, configuration)
    { }

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

}

Below are the framework/Templates I have used in my solution

  • DD4T.MVC5
  • DD4T.Providers.SDLWeb85
  • DD4T.DI.Autofac

Here is the debug Log of my solution

In the log file I see the below text saying something is wrong with cd_Storage_confg file

      2019-08-13 08:12:10,899 DEBUG ConfigurationRepositoryMonitor - Monitor is not initialized. Attempt:2
      2019-08-13 08:12:10,899 INFO  ConfigurationRepositoryMonitor - Configuration Repository Monitor setting up. Getting settings from 'cd_storage_conf.xml'
      2019-08-13 08:12:10,899 DEBUG XMLConfigurationReaderImpl - Reading configuration from: 'cd_storage_conf.xml'
     2019-08-13 08:12:10,899 DEBUG XMLConfigurationReaderImpl - Reading configuration from source: 'null'
     2019-08-13 08:12:10,902 INFO  ConfigurationRepositoryMonitorUtil - Configuration Repository not configured

Also I dont see any entry of Publication ID in the log. Am I passing the correct Key in the app settings for Publication details?

Can some one assist me here.

Update 1:

I can fetch the page meta data using the below code

var pageMetaFactory = new Tridion.ContentDelivery.Meta.PageMetaFactory(pubId);
var pageMeta = pageMetaFactory.GetMetaByUrl(pubId, pageId);

Also using the PageFactory I can fetch the Page content and Page Object . But the base.Page(pageuri) is always throwing exception saying "Page Cannot be found". I am using DD4T.MVC (version 2.2.6.0).

Also in the view when I am trying to use DD4T Html I am getting the below warning and at run time it fails to execute. enter image description here

1 Answer 1

2

I see no reason to assume there is anything wrong with your cd_storage_conf.xml, that logging looks normal to me. I did notice a couple of other things.

First of all, the blog you are referring to is quite old, and is meant for Tridion 2013 sp1 as you probably noticed. Please make sure that you add the jars and config files for SDL Web 8.5 instead of the ones mentioned in the blog.

Are you sure that the page really exists? Could it perhaps have something to do with the publication URL? To check if the page really exists with the URL you believe should work, try the following code (e.g. in a custom controller / action):

var pageMetaFactory = new Tridion.ContentDelivery.Meta.PageMetaFactory(157);
var pageMeta = pageMetaFactory.GetMetaByUrl(157, "/the/correct/url.html");

This uses out of the box Tridion functionality to retrieve the metadata of the page. Does the pageMeta object have a value?

Also, I would recommend to install DD4T.Logging.Log4Net and start checking the DD4T log file. This Nuget package automatically installs Log4net, and configures itself in your Web.config. You can change the details (like log level and log file location) there.

4
  • Hi Quirijn, I have added the above fix, still I am getting the same error. I tried to remove all the lib,config and CD Dlls from the bin folder. But now it throws the generic error of not having the CD assembly in the Bin folder. I tried to get the Page content response using content service from broker, over there it is working fine. And the page format is also in json format.
    – Manas.p
    Commented Aug 13, 2019 at 20:13
  • As I mentioned above in the test and Prod environment we do not want to use any Micro services to fetch web content as any issue with the micro service will break the web page. Can you help me with any sample DD4T 2.0 solution which should connect to Broker DB using the cd_storage config file only, like the old dd4t architecture.
    – Manas.p
    Commented Aug 13, 2019 at 20:17
  • I didn't catch that you don't want to use the microservices. I will update my answer.
    – Quirijn
    Commented Aug 15, 2019 at 19:24
  • Hi Quirijn,I have updated my post. I am getting the output but not able use the DD4T.Mvc model. Also can you please let me know where can I add the logs to catch the exact issue as I am using DD4T assemblies in my project.
    – Manas.p
    Commented Aug 16, 2019 at 19:56

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.