DD4T is a web app for the Tridion Content Delivery system that provides an MVC layer on top of the Broker, created by the SDL Tridion community and used by a variety of large companies and organizations, including SDL themselves, to serve millions of pages per month. SDL Tridion ships with a set of Broker and OData APIs that we can use to retrieve dynamic content, links, metadata and keywords – but DD4T pulls all of this together under a nice MVC architecture to allow us to build modern MVC applications with the latest .Net and Spring frameworks.

However, when starting a new DD4T project, the setup and configuration a DD4T Web Application is a bit more challenging than the simple static setup of a new IIS site and Tridion Content Delivery instance. For example, in DD4T we create an instance of Content Delivery within our web app, running on our local dev box. In this article I describe some frequent errors while getting started with DD4T, how to solve them, and finally some useful tips. Thanks to the SDL Tridion community for their support and help, for without them this article would not be possible.  I used the Tridion 2013 MVC 4 Visual Studio Template from Rob Stevenson-Leggett for this article.  https://code.google.com/p/dynamic-delivery-4-tridion/downloads/detail?name=DD4T.1.31-MVC4-Tridion2013-VS2012-VS2013.vsix

Trivident offers in-person DD4T training and this is the fastest way to get up and running, and answer your most complex questions. See my review of the Training here.

1. Page cannot be found. Error: 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

return base.Page(pageId);

PageController.cs, Line 16

About: This is a good error message. It means that DD4T cannot find a page with the URL in the Page table of the Broker DB.

Solution: Type the correct URL to a published page. The page should use the DD4T Template Building Blocks to publish DD4T XML to the Broker. Also, a great idea is to set the startup page in Visual Studio project properties, Web, Start Action setting to be a working URL so you never see this again. 🙂

2. HTTP Error 404.0 – Not FoundThe resource you are looking for has been removed, had its name changed, or is temporarily unavailable. Handler, StaticFile

About: This is another good error message. Most likely that the page has an .html extension and MVC is treatign it like a static file and not processing it with the .Net DD4T framework. For example, placing a breakpoint in the Page Controller will not be hit.

Solution: Update the web.config <modules /> node and add the following info: <modules runAllManagedModulesForAllRequests=”true” >

3. An attempt was made to load a program with an incorrect format. (Exception from HRESULT: 0x8007000B)

About: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.BadImageFormatException: An attempt was made to load a program with an incorrect format. (Exception from HRESULT: 0x8007000B)

Line 16: return base.Page(pageId);

About:  This is about running the project using the built-in Visual Studio webserver or IIS Express with 64 bit DLLs. I also saw this many many times.

Solution: Open the project properties in Visual Studio, Web, Servers and choose ‘Local IIS’.

4. Object reference not set to an instance of an object.

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.NullReferenceException: Object reference not set to an instance of an object.

Source Error:

Line 16: protected override ViewResult GetView(IComponentPresentation componentPresentation)
Line 17: {
Line 18: if (!componentPresentation.ComponentTemplate.MetadataFields.ContainsKey(“view”))
Line 19: {
Line 20: throw new ConfigurationErrorsException(“no view configured for component template ” + componentPresentation.ComponentTemplate.Id);

About: The metadata schema with the view name is not assigned to the Component Template

Solution: Create a metadata schema with a text field and XmlName of ‘view’. Then, add this schema to the Component Templates and Page Templates. Make sure the value of the ‘view’ is the same as in .Net. After updating the templates it is necessary to re-publish them.

5. Could not load file or assembly ‘Tridion.ContentDelivery, Version=7.1.0.165, Culture=neutral, PublicKeyToken=ddfc895746e5ee6b’ or one of its dependencies. The system cannot find the file specified.

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.IO.FileNotFoundException: Could not load file or assembly ‘Tridion.ContentDelivery, Version=7.1.0.165, Culture=neutral, PublicKeyToken=ddfc895746e5ee6b’ or one of its dependencies. The system cannot find the file specified.

Source Error:

Line 34: public override void Load()
Line 35: {
Line 36: Bind<IPageProvider>().ToMethod(context => new TridionPageProvider() { PublicationId = _publicationId });
Line 37: Bind<ILinkProvider>().To<TridionLinkProvider>();
Line 38:

About: The Tridion ContentDelivery DLLs are missing from the bin folder of the Visual Studio project.

Solution: Copy the Content Delivery DLLs from ‘Tridion 2013 SP1\Content Delivery\roles\api\dotNet\x86_64’ to the bin folder of the Visual Studio project. If you only copied the Content Delivery DLLs from the deployer then you might be missing some and need to copy from the original Tridion install files.

6. Unable to load DLL ‘xmogrt’: Access is denied. (Exception from HRESULT: 0x80070005 (E_ACCESSDENIED))

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.DllNotFoundException: Unable to load DLL ‘xmogrt’: Access is denied. (Exception from HRESULT: 0x80070005 (E_ACCESSDENIED))

Source Error:

Line 14: {
Line 15: pageId = UriHelper.ParseUrl(pageId);
Line 16: return base.Page(pageId);
Line 17: }
Line 18: }

About: The xmogrt.dll is responsible for providing the DLLs access to the .jar files within the app.

Solution: Give the Users group more permissions on the xmogrt.dll file
Other tips:
1. Upgrading to 2013sp1 (as of Feb, 2014)
– Get the 2013sp1 provider from NuGet, http://www.nuget.org/packages/DD4T-Tridion-2013sp1/
– Update the web.config (is using RSL’s VS Template https://code.google.com/p/dynamic-delivery-4-tridion/downloads/detail?name=DD4T.1.31-MVC4-Tridion2013-VS2012-VS2013.vsix and Ninject) -> <add key=”DD4T.ProviderVersion” value=”Tridion2013sp1″ />

2. Java versions. If using a 64 bit server, get the 64 bit JRE. From the command prompt, type ‘Java -version’. If it says 64 bit, you’re good. If it doesn’t say anything, you’ve got a problem, and I suggest to uninstall any Java versions found in the Add / Remove programs, and install the 64 bit one. And, make sure to use the 64 bit Content Delivery Dlls. There is only 1 version of the .jar files, not separate 32bit and 64 bit. See Nick’s post here for more info. Also, always use the real IIS in Visual Studio instead of the internal / IIS Express version of Visual Studio.

3. Tridion Content Delivery files.  When getting started, after downloading the NuGet package, we can quickly get the solution running by placing the Tridion .Net Content Delivery files in the same bin folder as the web app, and create a new config folder and place all Content Delivery config files there, and finally create a lib folder (within bin) and put all the Tridion and 3rd party .jar files there. Remember to also download the Microsoft SQL Server java jar file if using SQL Server – Tridion does not provide this. I usually borrow this from the Content Delivery install. I also usually copy the cd_storage configuration from the Deployer.

4. Database bindings in the cd_storage config.  In the cd_storage config file (of the deployer and also web app), all types should be stored in the Database. Using a filesystem-based Content Delivery instance is not supported for Pages and Component Presentations. It is possible to store multimedia files on the filesystem, but I will not cover that here.

5. Updating jar files.  If missing a file (such as cd_dynamic), copy it from the SDL Tridion install files and then at a command prompt, run ‘iisreset’. The updates to the jar files will not be reflected until the iisreset command is used.

6. Unblocking files.  Check that your files are not blocked, especially the xmogrt.dll file. Also, you may need to add IIS_IUsrs

Still stuck?

Contact our team at DD4T@Yabolka.com for direct support.  We can provide short term (2 hours) up to long term (2+ months) on-site and remote support for your DD4T .Net projects.

 

References:

https://code.google.com/p/dynamic-delivery-4-tridion/downloads/detail?name=DD4T.1.31-MVC4-Tridion2013-VS2012-VS2013.vsix&can=2&q=#makechanges

http://tridion.stackexchange.com/questions/4102/getting-404-error-in-dd4t

http://tridion.stackexchange.com/questions/3863/dd4t-and-tridion-2013-sp1/4401#

http://www.hanselman.com/blog/BackToBasicsDynamicImageGenerationASPNETControllersRoutingIHttpHandlersAndRunAllManagedModulesForAllRequests.aspx

http://www.building-blocks.com/thinking/sdl-tridion-2013-sp1-providers-dd4t/

 

Author: Robert Curlette

Robert organizes the Tridion Developer Summit, likes teaching workshops on SDL Tridion, and helps customers implement solutions with SDL Tridion, DD4T, and Alchemy GUI Extensions. If you would like help, please contact me.