1

I am updating an existing deployer extension to implement Akamai fast purge. before my implementation, it was working perfectly fine. post-deployment of new deployer extension it was started showing following error whenever any binary/component presentation has been published.

Following is stack trace for binary:

org.hibernate.LazyInitializationException: failed to lazily initialize a collection of role: com.tridion.storage.BinaryMeta.binaryVariants, no session or session was closed
    at org.hibernate.collection.internal.AbstractPersistentCollection.throwLazyInitializationException(AbstractPersistentCollection.java:393) ~[hibernate-core-4.0.1.final.jar:4.0.1.Final]
    at org.hibernate.collection.internal.AbstractPersistentCollection.throwLazyInitializationExceptionIfNotConnected(AbstractPersistentCollection.java:385) ~[hibernate-core-4.0.1.final.jar:4.0.1.Final]
    at org.hibernate.collection.internal.AbstractPersistentCollection.initialize(AbstractPersistentCollection.java:378) ~[hibernate-core-4.0.1.final.jar:4.0.1.Final]
    at org.hibernate.collection.internal.AbstractPersistentCollection.read(AbstractPersistentCollection.java:112) ~[hibernate-core-4.0.1.final.jar:4.0.1.Final]
    at org.hibernate.collection.internal.PersistentBag.iterator(PersistentBag.java:266) ~[hibernate-core-4.0.1.final.jar:4.0.1.Final]
    at com.metlife.deployer.extensions.akamai.AkamaiDeployProcessor.postProcessComponentPresentation(AkamaiDeployProcessor.java:109) ~[metlife-add-marketing-deployer-india.jar:na]
    at com.metlife.deployer.extensions.AkamaiDeployProcessorBase.processComponentPresentation(AkamaiDeployProcessorBase.java:33) [metlife-add-marketing-deployer-india.jar:na]
    at com.tridion.deployer.modules.ComponentPresentationDeploy.processItem(ComponentPresentationDeploy.java:105) [cd_deployer-7.0.0.jar:na]
    at com.tridion.deployer.SectionVisitor.processSection(SectionVisitor.java:83) [cd_deployer-7.0.0.jar:na]
    at com.tridion.deployer.SectionVisitor.process(SectionVisitor.java:60) [cd_deployer-7.0.0.jar:na]
    at com.tridion.deployer.Processor.process(Processor.java:109) [cd_deployer-7.0.0.jar:na]
    at com.tridion.deployer.workers.ProcessorWorker.doWork(ProcessorWorker.java:77) [cd_deployer-7.0.0.jar:na]
    at com.tridion.deployer.phases.ProcessingPhase.execute(ProcessingPhase.java:73) [cd_deployer-7.0.0.jar:na]
    at com.tridion.deployer.phases.DeployPipelineExecutor.runMainExecutePhase(DeployPipelineExecutor.java:198) [cd_deployer-7.0.0.jar:na]
    at com.tridion.deployer.phases.DeployPipelineExecutor.doExecute(DeployPipelineExecutor.java:100) [cd_deployer-7.0.0.jar:na]
    at com.tridion.deployer.phases.DeployPipelineExecutor.execute(DeployPipelineExecutor.java:64) [cd_deployer-7.0.0.jar:na]
    at com.tridion.deployer.TransactionManager.handleDeployPackage(TransactionManager.java:82) [cd_deployer-7.0.0.jar:na]
    at com.tridion.deployer.queue.QueueLocationHandler$1.run(QueueLocationHandler.java:180) [cd_deployer-7.0.0.jar:na]
    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471) [na:1.7.0_80]
    at java.util.concurrent.FutureTask.run(FutureTask.java:262) [na:1.7.0_80]
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145) [na:1.7.0_80]
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615) [na:1.7.0_80]
    at java.lang.Thread.run(Thread.java:745) [na:1.7.0_80]

Following is the code segment from where this error has been generated:

package com.metlife.deployer.extensions.akamai;

import java.io.File;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.metlife.deployer.extensions.AkamaiDeployProcessorBase;
import com.metlife.deployer.extensions.constants.Constants;
import com.metlife.deployer.extensions.restclient.AkamaiRestClient;
import com.metlife.deployer.extensions.restclient.impl.AkamaiRestClientImpl;
import com.metlife.deployer.extensions.util.URLCreator;
import com.tridion.broker.StorageException;
import com.tridion.configuration.Configuration;
import com.tridion.configuration.ConfigurationException;
import com.tridion.deployer.Processor;
import com.tridion.storage.BinaryContent;
import com.tridion.storage.BinaryMeta;
import com.tridion.storage.BinaryVariant;
import com.tridion.storage.StorageManagerFactory;
import com.tridion.storage.StorageTypeMapping;
import com.tridion.storage.dao.ItemDAO;
import com.tridion.transport.transportpackage.BinaryKey;
import com.tridion.transport.transportpackage.ComponentPresentation;

/**
 * This is subclass of MetlifeDeployProcessorBase.
 * 
 * @author sgup42
 * 
 */
@SuppressWarnings("deprecation")
public class AkamaiDeployProcessor extends AkamaiDeployProcessorBase {
    /** Instance of URLCreator. */
    private URLCreator urlCreator = null;

    /** Instance of AkamaiRestClient. */
    private AkamaiRestClient akamaiRestClient = null;

    /** LOGGER Instance */
    private static final Logger LOGGER = LoggerFactory
            .getLogger(AkamaiDeployProcessor.class);

    /**
     * Constructor for AkamaiDeployProcessor.
     * 
     * @param config
     *            - Instance of Configuration
     * @param processor
     *            - Instance of Processor
     * @throws ConfigurationException
     *             - Instance of ConfigurationException.
     */
    public AkamaiDeployProcessor(Configuration config, Processor processor)
            throws ConfigurationException {
        super(config, processor);
    }

    /**
     * This is an overridden implementation for
     * "postProcessComponentPresentation",it captures the "publicationId" and
     * "itemId" of the binary component. It gets the path of all the published
     * multimedia components and sends the list to Akamai.
     */
    @Override
    public void postProcessComponentPresentation(
            ComponentPresentation componentPresentation,
            File comPresentationFile) {
        LOGGER.debug(Constants.METHOD_START);

        try {
            LOGGER.debug("AkamaiDeployProcessor.java | postProcessComponentPresentation()| method start");
            int publicationId = componentPresentation.getComponentKey().getId()
                    .getPublicationId();
            BinaryKey binaryKey = null;
            LOGGER.debug("AkamaiDeployProcessor.java | postProcessComponentPresentation()| publication_id :" + publicationId);
            List urlList = new ArrayList();
            for (Iterator binaryKeysIterator = componentPresentation
                    .getBinaryKeys(); binaryKeysIterator.hasNext();) {
                LOGGER.debug("AkamaiDeployProcessor.java | postProcessComponentPresentation()| publication_id : 83");

                binaryKey = (BinaryKey) binaryKeysIterator.next();
                LOGGER.debug("AkamaiDeployProcessor.java | postProcessComponentPresentation()| publication_id : 86");

                byte[] content = {};
                BinaryContent binaryContent = new BinaryContent(publicationId,
                        binaryKey.getId().getItemId(),
                        binaryKey.getVariantId(), content);
                LOGGER.debug("AkamaiDeployProcessor.java | postProcessComponentPresentation()| publication_id : 92");

                ItemDAO item = (ItemDAO) StorageManagerFactory.getDAO(
                        publicationId, StorageTypeMapping.BINARY_META);
                LOGGER.debug("AkamaiDeployProcessor.java | postProcessComponentPresentation()| publication_id : 96");

                BinaryMeta binaryMeta = (BinaryMeta) item
                        .findBinaryByPrimaryKey(
                                binaryContent.getPublicationId(),
                                binaryContent.getBinaryId());
                LOGGER.debug("AkamaiDeployProcessor.java | postProcessComponentPresentation()| publication_id : 102");

                if (binaryMeta != null) {
                    List BinaryVariantList = binaryMeta
                            .getBinaryVariants();
                    LOGGER.debug("AkamaiDeployProcessor.java | postProcessComponentPresentation()| publication_id : 107");

                    **for (Iterator iterator2 = BinaryVariantList.iterator(); iterator2
                            .hasNext();) {
                        BinaryVariant binaryVariant = (BinaryVariant) iterator2
                                .next();**
                        LOGGER.debug("AkamaiDeployProcessor.java | postProcessComponentPresentation()| URL is :" + binaryVariant.getPath()
                                + " for Binary type :"
                                + binaryVariant.getBinaryType());
                        LOGGER.debug("AkamaiDeployProcessor.java | postProcessComponentPresentation()| publication_id : 116");

                        urlList.add(binaryVariant.getPath());
                    }
                }
            }
            if (!urlList.isEmpty()) {
                LOGGER.debug("AkamaiDeployProcessor.java | postProcessComponentPresentation()| Calling AkamaiRestClient to create purge request. 123");
                List purgeUrls = new ArrayList();
                urlCreator = new URLCreator();
                purgeUrls = urlCreator.createPurgeURL(urlList);
                this.akamaiRestClient = new AkamaiRestClientImpl();
                this.akamaiRestClient.purgeResources(purgeUrls);

            }
        } catch (StorageException e) {
            LOGGER.error(
                    "AkamaiDeployProcessor.java | postProcessComponentPresentation()| Error occured while postProcessComponentPresentation: storage", e);
        }
        catch (Exception e) {
            LOGGER.error(
                    "AkamaiDeployProcessor.java | postProcessComponentPresentation()| Error occured while postProcessComponentPresentation: ", e);
        }
        LOGGER.debug(Constants.METHOD_END);
    }

}

from multiple log statements i can see that following log statement was last executed: LOGGER.debug("AkamaiDeployProcessor.java | postProcessComponentPresentation()| publication_id : 107");

I have updated following jar files as old jar files are not working with current implementation:

  1. hibernate-core-4.0.1.final.jar
  2. slf4j-api-1.7.5.jar
  3. httpcore-4.4.4.jar
  4. httpclient-4.5.8.jar
  5. commons-logging-1.2.jar
  6. commons-lang3-3.4.jar
  7. commons-configuration2-2.1.jar
  8. commons-codec-1.11.jar
  9. cd_model-7.0.0.jar
  10. cd_deployer-7.0.0.jar
  11. cd_datalayer-7.0.0.jar

I am using Tridion 2013 SP1 and JDK 1.7

following is cd_deployer config

    <!-- <Processor Action="Deploy" Class="com.tridion.deployer.Processor" Phase="post-transaction"> -->

    <Processor Action="Deploy" Class="com.tridion.deployer.Processor">
        <!-- A Module is triggered by a Processor to process incoming instructions.
                The 'Type' attribute needs to be unique within a Processor and serves
                as a symbolic identifier. The 'Class' attribute defines the
                implementation used for any type of Module. Replace or add modules to
                implement custom Deployer behavior. -->
        <Module Type="ApplicationCacheFlushForComponentPresentation" Class="com.******.deployer.extensions.ehcache.ApplicationCacheFlushForComponentPresentation" />
        <Module Type="ApplicationCacheFlushForTaxonomy" Class="com.******.deployer.extensions.ehcache.ApplicationCacheFlushForTaxonomy" />
        <Module Type="AkamaiDeploy" Class="com.******.deployer.extensions.akamai.AkamaiDeployProcessor" />
        <Module Type="SchemaDeploy" Class="com.tridion.deployer.modules.SchemaDeploy"/>
        <Module Type="PageDeploy" Class="com.tridion.deployer.modules.PageDeploy">
            <!-- The transformer enables the TCDL Engine -->
            <Transformer Class="com.tridion.deployer.TCDLTransformer"/>
        </Module>
        <Module Type="BinaryDeploy" Class="com.tridion.deployer.modules.BinaryDeploy"/>
        <Module Type="ComponentDeploy" Class="com.tridion.deployer.modules.ComponentDeploy"/>
        <Module Type="TemplateDeploy" Class="com.tridion.deployer.modules.TemplateDeploy"/>
        <Module Type="PublicationDeploy" Class="com.tridion.deployer.modules.PublicationDeploy"/>

        <!-- This module enables deployment of taxonomies -->
        <Module Type="TaxonomyDeploy" Class="com.tridion.deployer.modules.TaxonomyDeploy"/>

        <Module Type="ComponentPresentationDeploy" Class="com.tridion.deployer.modules.ComponentPresentationDeploy">
            <!-- The transformer enables the TCDL Engine -->
            <Transformer Class="com.tridion.deployer.TCDLTransformer"/>
        </Module>

        <!-- This module enables deployment of structure groups -->
        <Module Type="StructureGroupDeploy" Class="com.tridion.deployer.modules.StructureGroupDeploy"/>
        <!-- This module enables the deploy of extension data. This module should be enabled if you are using UNDO -->
        <!-- <Module Type="ExtensionDataDeploy" Class="com.tridion.deployer.modules.ExtensionDataDeploy"/> -->
    </Processor>
    <Processor Action="Undeploy" Class="com.tridion.deployer.Processor">
        <Module Type="PageUndeploy" Class="com.tridion.deployer.modules.PageUndeploy"/>
        <Module Type="ComponentPresentationUndeploy"
                Class="com.tridion.deployer.modules.ComponentPresentationUndeploy"/>

        <!-- This module enables the undeploy of taxonomies -->
        <Module Type="TaxonomyUndeploy" Class="com.tridion.deployer.modules.TaxonomyUndeploy"/>

        <!-- This module enables the undeploy of structure groups -->
        <Module Type="StructureGroupUndeploy" Class="com.tridion.deployer.modules.StructureGroupUndeploy"/>

        <!-- This module enables the undeploy of extension data. This module should be enabled if you are using UNDO -->
        <!-- <Module Type="ExtensionDataUndeploy" Class="com.tridion.deployer.modules.ExtensionDataUndeploy"/> -->
    </Processor>

    <!-- Undo Deployer modules.-->
    <!--
    <Processor Action="Undo" Class="com.tridion.deployer.Processor">
      <Module Type="UndoModule" Class="com.tridion.deployer.UndoDeploy"/>
    </Processor>
    -->
    <!-- Undo Deployer module for post-transaction should be enabled only if there are any deployer post-transaction modules configured.-->
    <!--
    <Processor Action="Undo" Class="com.tridion.deployer.Processor" Phase="post-transaction">
      <Module Type="UndoModule" Class="com.tridion.deployer.UndoPostTransactionDeploy"/>
    </Processor>
    -->
    <!-- Undo Deployer module for pre-transaction should be enabled only if there are any deployer pre-transaction modules configured.-->
    <!--
    <Processor Action="Undo" Class="com.tridion.deployer.Processor" Phase="pre-transaction">
      <Module Type="UndoModule" Class="com.tridion.deployer.UndoPreTransactionDeploy"/>
    </Processor>
    -->

</Processors>
<!-- Configure the Queue locations the deployer checks for incoming deployment packages -->
<Queue>
    <Location Path="/opt/adam/tridion/cda-india/incoming" WindowSize="20" Workers="10" Cleanup="false" Interval="2s"/>
    <!--<Location Path="c:\tridion\work\http" WindowSize="10" Workers="10" Cleanup="true" Interval="30s"/> -->
</Queue>
<!-- Configure the HTTPSReceiver to store incoming package in specified location, and configure if deployer should run in process -->
<HTTPSReceiver MaxSize="209715200" Location="/opt/adam/tridion/cda-india/incoming" InProcessDeploy="true"/>
<!--
 Specifies the location of the license file.
 -->
<!--
 <License Location="c:/Tridion/config/cd_licenses.xml"/>
 -->

<TCDLEngine>
    <Properties>
        <!-- Default code generation will always be targetted towards the use of tag libraries and
              server controls. Uncomment these lines to drop that behaviour -->
        <Property Name="tcdl.dotnet.style" Value="controls"/>
        <Property Name="tcdl.jsp.style" Value="tags"/>

        <!-- Since R5.4 another interop mechanism for ASP.NET has been introduced this setting
           will allow code generation into that new Interop model. -->
        <!-- <Property Name="tcdl.dotnet.style" Value="native_interop" /> -->

        <!-- To use the deprecated R5.3 code generation enable this line -->
        <!-- <Property Name="tcdl.dotnet.style" Value="com_interop" /> -->

        <!--To fix the target language to a specific language uncomment any of the following lines -->
        <!--<Property Name="tcdl.target.language" Value="jsp" />-->
        <!--<Property Name="tcdl.target.language" Value="dotnet" />-->
        <!--<Property Name="tcdl.target.language" Value="rel" />-->
        <!--Deprecated: <Property Name="tcdl.target.language" Value="vbscript" />-->
        <!--Deprecated: <Property Name="tcdl.target.language" Value="jscript" />-->
    </Properties>
    <!--
    Optional configuration needed in case of using the UGC TCDL transformers
    -->
    <!--
    <TagBundle Resource="ugc_tag_bundle.xml"/>
    -->
</TCDLEngine>

<!--
 Specify RMI listening port
 -->
<!--
 <RMIChannel ListenerPort="1050"/>
 -->

Regards, Soumava

2
  • Can you please edit your question to update the full class source? also, update the cd_deployer_conf.xml of Processor tag?
    – Velmurugan
    Apr 17, 2019 at 21:01
  • Hi @Velmurugan, due to character limitation posting class file as part of original question. Apr 18, 2019 at 10:19

0

Your Answer

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

Browse other questions tagged or ask your own question.