Skip to content

Quick Start guide for DD4T 2 Java

RaimondKempees edited this page Dec 30, 2017 · 9 revisions

Setting up a Tridion > DD4T 2 stack can be done pretty quick. You need three things before you start:

  1. A Tridion environment setup and configured
  2. Maven
  3. The Tridion and other dependencies in your local repository.

If that's all there, follow the steps below to get started:

1. Installing the DD4T templates

Downloading and running the installer

  • Download the zip package from here and unpack it.
  • Run the install-templates.bat and follow the steps.

It couldn't be easier!

Creating your first Page Template

Open the SDL Tridion Template Builder (if you don't have it installed, start Internet Explorer and browse to any Tridion CME, then click on the Tools ribbon and download the template builder from there).

Create a page template, give it any name you like, and add the 'Generate dynamic page' DD4T template building block to it. Save and close the template.

Creating your first Component Template

Create a component template, give it any name you like, and add the 'Generate dynamic component presentation' DD4T template building block to it. Save and close the template. Open the component template again, but this time from the CME. Link it to one ore more schemas.

You are now ready to publish pages.

2. Creating a bare dd4t-2-java Spring MVC web application based on the DD4T Archetype

To create a complete, but minimal Spring MVC web application to develop with, create a new project based on a Maven archetype:

Command Line:

  1. Create an empty directory where you want to develop the web application in
  2. Execute the following command after replacing the parameters in between the brackets ([com.example] and [mywebapp]):

For Web 8: mvn archetype:generate -DgroupId=[com.example] -DartifactId=[mywebapp] -DarchetypeGroupId=org.dd4t -DarchetypeArtifactId=dd4t-web8-archetype -DarchetypeVersion=1.1 -DarchetypeCatalog=remote

For Tridion 2011 / 2013:

	mvn archetype:generate -DgroupId=[com.example] -DartifactId=[testapp] -DarchetypeGroupId=org.dd4t -DarchetypeArtifactId=dd4t-spring-mvc-archetype -DarchetypeVersion=1.6 -DarchetypeCatalog=remote
  1. If you are on SDL Tridion 2013, use this command instead:

     mvn archetype:generate -DgroupId=[com.example] -DartifactId=[mywebapp] -DarchetypeGroupId=org.dd4t -DarchetypeArtifactId=dd4t-spring-mvc-archetype -DarchetypeVersion=1.5 -DarchetypeCatalog=remote 
    
  2. Enter the requested information. Maven will ask you to specify a version (defaults to 1.0-SNAPSHOT) and will then ask you to confirm the settings.

  3. The web application project is created if you see the following Maven output:

     $ mvn archetype:generate -DgroupId=com.example -DartifactId=mywebapp -DarchetypeGroupId=org.dd4t -DarchetypeArtifactId=dd4t-spring-mvc-archetype -DarchetypeVersion=1.5  -DarchetypeCatalog=remote -DarchetypeCatalog=http://repo1.maven.org/maven2
     [INFO] Scanning for projects...
     [INFO] Using the builder org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder with a thread count of 1
                                                                      
     [INFO]  ------------------------------------------------------------------------
     [INFO] Building Maven Stub Project (No POM) 1
     [INFO] ------------------------------------------------------------------------
     [INFO] 
     [INFO] >>> maven-archetype-plugin:2.3:generate (default-cli) @ standalone-pom >>>
     [INFO] 
     [INFO] <<< maven-archetype-plugin:2.3:generate (default-cli) @ standalone-pom <<<
     [INFO] 
     [INFO] --- maven-archetype-plugin:2.3:generate (default-cli) @ standalone-pom ---
     [INFO] Generating project in Interactive mode
     [INFO] Using property: groupId = com.example
     [INFO] Using property: artifactId = mywebapp
     Define value for property 'version':  1.0-SNAPSHOT: : 
     [INFO] Using property: package = com.example
     Confirm properties configuration:
     groupId: com.example
     artifactId: mywebapp
     version: 1.0-SNAPSHOT
     package: com.example
     Y: : Y
     [INFO] ----------------------------------------------------------------------------
     [INFO] Using following parameters for creating project from Archetype: dd4t-spring-mvc-archetype:1.4
     [INFO] ----------------------------------------------------------------------------
     [INFO] Parameter: groupId, Value: com.example
     [INFO] Parameter: artifactId, Value: mywebapp
     [INFO] Parameter: version, Value: 1.0-SNAPSHOT
     [INFO] Parameter: package, Value: com.example
     [INFO] Parameter: packageInPathFormat, Value: com/example
     [INFO] Parameter: version, Value: 1.0-SNAPSHOT
     [INFO] Parameter: package, Value: com.example
     [INFO] Parameter: groupId, Value: com.example
     [INFO] Parameter: artifactId, Value: mywebapp
     [INFO] project created from Archetype in dir: /your-dir/mywebapp
     [INFO] ------------------------------------------------------------------------
     [INFO] BUILD SUCCESS
     [INFO] ------------------------------------------------------------------------
    
  4. You can now open the project using your favourite IDE.

IDE

For setting up a webapp based on the dd4t-2-java through your IDE, you will need to enter the following information:

  1. Archetype GroupId=org.dd4t

  2. Archetype ArtifactId=dd4t-web8-archetype

  3. ArchetypeVersion=1.1

(note, for Tridion 2013 / 2011 use 'dd4t-spring-mvc-archetype' with version 1.6

-- Alternatively, you can create an Eclipse project from the command line and import it as an existing project:

           mvn eclipse:eclipse

3. Configure cd_storage_conf.xml, logback.xml, dd4t.properties and cd_dynamic.conf.xml

Navigate to src/main/resources/WEB-INF/classes of your created webapp and configure the Tridion configuration files like you normally would.

In addition, configure the dd4t.properties file. The properties are self-explanatory.

4 Using JMS cache invalidation

If you do not want to use cache invalidation, open up src/main/resources/WEB-INF/classes/dispatcher-servlet.xml and change the following line:

<bean id="cacheProvider" class="org.dd4t.core.providers.EHCacheProvider" />

in to:

<bean id="cacheProvider" class="org.dd4t.providers.impl.NoCacheProvider" />

Next, comment out the entire following section:

	    <bean id="cacheMessageListener" class="org.dd4t.core.caching.jms.impl.JMSCacheMessageListener"/>
	    <bean id="jmsExceptionListener" class="org.dd4t.core.caching.jms.impl.JMSExceptionListener"/>
	    <bean id="jmsCacheMonitor" class="org.dd4t.core.caching.jms.impl.JMSCacheMonitor" />
	    <bean id="jmsTransportListener" class="org.dd4t.core.caching.jms.impl.JMSTransportListener"/>

	    <bean id="connectionFactory" class="org.apache.activemq.ActiveMQConnectionFactory">
	        <property name="brokerURL" value="${jms.brokerUrl}"/>
	        <property name="userName" value="${jms.userName}"/>
	        <property name="password" value="${jms.password}"/>
	        <property name="exceptionListener" ref="jmsExceptionListener"/>
	        <property name="transportListener" ref="jmsTransportListener"/>
	    </bean>

	    <jms:listener-container container-type="default" destination-type="topic" connection-factory="connectionFactory" acknowledge="auto">
	        <jms:listener destination="${jms.topicName}" ref="cacheMessageListener" method="onMessage"/>
	    </jms:listener-container>

5. That's all folks!

Your next step should be to create a normal web app run configuration in your IDE to run the application.