Sunday, August 19, 2012

Common issues while installing UGC

I wanted to share with you the issues that I encountered while installing and configuring SDL Tridion UGC. They seem to occur often, and I hope this speeds up the process when you encounter them as well.


Setting up the Content Delivery Web services

One Content Delivery Web service is setup for the content manager, and one for the websites visitors, and both have a storage configuration setup solely for the UGC database:

<?xml version="1.0" encoding="UTF-8"?>
<Configuration Version="6.1"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:noNamespaceSchemaLocation="schemas/cd_storage_conf.xsd">
    <Global>
        <ObjectCache Enabled="false">
            <Policy Type="LRU" Class="com.tridion.cache.LRUPolicy">
                <Param Name="MemSize" Value="16mb"/>
            </Policy>
            <Features>
                <Feature Type="DependencyTracker" Class="com.tridion.cache.DependencyTracker"/>
            </Features>
        </ObjectCache>
        <Storages>
            <StorageBindings>
                <Bundle src="ugc_dao_bundle.xml"/>
            </StorageBindings>
            <Storage Type="persistence" Id="ugcdb" dialect="MSSQL" Class="com.tridion.storage.persistence.JPADAOFactory">
                <Pool Type="jdbc" Size="5" MonitorInterval="60" IdleTimeout="120" CheckoutTimeout="120" />
                <DataSource Class="com.microsoft.sqlserver.jdbc.SQLServerDataSource">
                    <Property Name="serverName" Value="[Server Address]" />
                    <Property Name="portNumber" Value="1433" />
                    <Property Name="databaseName" Value="Tridion_Ugc" />
                    <Property Name="user" Value="[Username]" />
                    <Property Name="password" Value="[Password]" />
                </DataSource>
            </Storage>
        </Storages>
    </Global>
    <ItemTypes defaultStorageId="ugcdb" cached="false"/>
    <!-- Specifies the location of the license file. -->
    <!-- License Location="c:/Tridion/config/cd_licenses.xml"/ -->
</Configuration>

When you encounter problems with POST requests to the UGC CD Web service from the content manager, then enable tracing in the Tridion.UGC.Model, by replacing the assembly with the assembly from the trace folder:

Tridion\web\WebUI\WebRoot\bin\Tridion.UGC.Model.dll

The Trace log can be found at the same location in the Tridion.Web.Trace logfile and shows you the exact response from the CD Web service and a possible exception stack trace.

Also enable exception details and service metadata on http get for the UGC CD Webservices (system.serviceModel/behaviors) to allow easier debugging:


<serviceBehaviors>
    <behavior name="ODataServiceBehaviors" >
        <!-- Add the following element to your service behavior configuration. -->
        <serviceMetadata httpGetEnabled="true" />
        <serviceDebug includeExceptionDetailInFaults="true"/>
    </behavior>
</serviceBehaviors>


Storage Type Exceptions

When you receive exceptions that are related to the storage configuration, the problem is most likely a malformed cd_storage_config.xml file, but it can also be a problem with your license.

To ensure that the right licenses file is used you can configure the location of the license file in the License element, or exclude this element and place the cd_licenses.xml file in the config folder.

When there is a licenses problem it will show up in the cd.core log file, when the log level is set to WARN.


NB: To easy debugging issues it is recommended to temporarily set the log level to DEBUG/TRACE.


Couldn't retrieve data from 1 datasources

When you get a “Couldn’t retrieve data from 1 datasources” exception when switching to the Comments tab in the Page or Component edit forms then you most probably have a problem in the Content Delivery Web service endpoint configuration.

This is configured in: Tridion\web\WebUI\Models\UGC\Configuration\DataSources.xml

<DataSource>
    <Key>1</Key>
    <Match>^(ugc:|oe:|tcm:)+</Match>
    <Url>[URL to UGC CD Webservice configured for the CM]</Url>
    <TimeOut>100000</TimeOut>
    <Threshold>0</Threshold>
    <RatingMinimum>-1</RatingMinimum>
    <RatingMaximum>5</RatingMaximum>
    <OAuthEnabled>false</OAuthEnabled>
    <Locale>en-us</Locale>
    <ClientId></ClientId>
    <ClientSecret></ClientSecret>
    <EventSystemClientId></EventSystemClientId>
    <EventSystemClientSecret></EventSystemClientSecret>
    <AccessTokenUrl></AccessTokenUrl>
</DataSource>

When you cannot post any messages

At one point I was able to query the OData web services using Linqpad, and I was able to access the comments tabs through the content manager explorer. However, I was not able to post any new messages. When this is the case verify that you configured the Ambient Data Http Module in the Content Delivery Web services web configuration.

<system.webServer>
    <modules>
        <add type="Tridion.ContentDelivery.AmbientData.HttpModule" name="AmbientFrameworkModule" preCondition="managedHandler" />
    </modules>
</system.webServer>

Users registered with ID null

Make sure that the UGC ambient cartridge is configured on both the UGC CD Webservice as the (staging or live) website. If this is not done users will be registered with ID null.


Using the ItemStats object


The ItemStats object (Tridion.ContentDelivery.UGC.Web.Model.ItemStats) allows you to access statistics on user generated content for a specific component or page. But using this object is not as clear as it seems.

When rendered, the UGC ItemStats User Control (<ugc:ItemStats />) adds the ItemStats object to an Item of the HttpContext.Current.Items collection using the name set in the Var attribute.

When you want to use this object you have to retrieve if from the context variable first. The UGC Item Stats control does not give you access to it.

NB: The Var attribute is optional, and defaults to ugcItemStats.

1 comment:

Rache said...

Hi Arjen,

Can you help me out. I have a jsp website and have done everything to configure UGC. The component published doesn't seem to print the value for ugcComment.content on the jsp. The visitor side webservice works because I was able to see the comments I entered through CME appear on the browser. Can you please help me debug this.
Do I have to code the call to the webservice on the component source. This component actually calls a .net class