Using and debugging DXA (Java) with Web 8.5 on Amazon

Datetime:2017-03-22 05:29:09         Topic: Tomcat          Share        Original >>
Here to See The Original Article!!!

So I finally got around to having enough time to set up a Java-based DXA connecting to a Content Service in the Amazon cloud.

It was a fun adventure, to say the least, and most of it is due to my rustiness in Java. I have tried with both Eclipse and IntelliJ Idea, and definitely IntelliJ made it a lot simpler by detecting project dependencies and installing them for me – which actually made it harder to get Eclipse to work, as I hadn’t noticed what it had done.

Anyway – below are the steps I followed to get a local instance of DXA running within Eclipse. As with the.NET install, you need to make sure you have a proper firewall configuration allowing communication between your machine and the CIS, as well as having the right mappings set in Topology Manager (I used the default of “localhost:8080″ for this). I will not cover those steps in this post.


In order to get this to work, you need to:

  • Install a Java SDK
  • Install Maven
  • Install Eclipse
  • Install Tomcat
  • Install lombok

Installing Java

Download a standard JDK from Oracle’s website – I went with whatever was the latest version, 64 bit.

Once it’s installed, make sure you set the JAVA_HOME environment variable in your machine, as Maven will need this.

Test that java is installed by running “java -version”

Installing Maven

Head over to Maven’s download page and download the latest one for windows, unzip it to a location you will remember  and then make sure to add “maven\bin” to your path environment variable.

You can test it by running “mvn -v”

Installing Eclipse

Oddly enough, this was what took me the longest, as for some reason was super slow today. Eventually, this mirror worked the best for me, but YMMV.


You need an app server to run your application, so we’ll be using Tomcat for this. Head over to Tomcat’s download page and get Tomcat 8.5x (I used 8.5.12). Unzip it somewhere you will remember!

Install Lombok

Don’t ask me what it is, I didn’t bother checking that other than noticing it was needed (thanks to Alexey Zarakovskiy from SDL’s DXA team for pointing me in this direction).

Download lombok.jar from here , and then run java -jar lombok.jar

A simple wizard will ask you to identify where your IDE is, enter the path to eclipse, and click “Install/Update”.

Getting the DXA

Now that we’re done with the prerequisites, let’s get our DXA going.

The first thing we need to do is to download it, and we will use maven to do this for us. Below are the steps I followed, if you know what you’re doing, feel free to improvise – if you don’t know what you’re doing, do exactly as I did .

  1. Create a folder, for instance c:\dev\java-dxa
  2. In a command prompt or PS shell, go to this folder and type “mvn archetype:generate” (without the quotes, of course)
    1. On the next prompt, enter “dxa” (again, no quotes!)
    2. Enter “1”
    3. Press Enter to accept the default (latest DXA version)
    4. Enter “com.sdl.dxa” as groupId
    5. Enter “dxawebapp” as artifactId
    6. Press Enter to accept the default version
    7. Press Enter to accept the default package
    8. Enter Y to confirm

Now you should have a set of subfolders created under c:\dev\java-dxa, and one of them (dxawebapp) will have a pom.xml, which we will need soon.

Let’s get into Eclipse

Open Eclipse and configure Tomcat as a Server:

  1. Click File -> New -> Other

  2. Type “server” to filter and click Next
  3. (You may have to expand this window), select Tomcat v8.5 server and click Next

  4. Specify the location where Tomcat is installed then click on “Installed JREs”
    Click on “Add…”

  6. Select “Standard VM” and click Next
  7. Set the path to the folder where the JDK is installed and click Finish
  8. Optionally, set this new JRE as the default.

Quick recap: we now have the DXA’s maven pom.xml, we have Eclipse and we have Tomcat installed as a server in Eclipse. Time to import the DXA into Eclipse:

  1. Select File -> Import

  2. Type maven in the filter window and select “Existing Maven Project”

  3. Browse to the location where you downladed the POM to (c:\dev\Java-DXA\dxawebapp in my case) and click Finish.

Wait a few minutes for the import to finish. You now should be able to see in your workspace a “DxaWebApp” project. Let’s add the core module to it.

Right-click the dxawebapp project and select Maven -> Select Maven Profiles

In the window that shows the available profiles, check the box next to “core-module” and click OK.

Next, let’s change the DXA’s context root to be / instead of the default of /dxawebapp. Right click the DXA Web App project again and select Properties (all the way at the end of that menu)

Find the “Web Project Settings” and modify the “Context Root” to /

Last step… you’re almost there!

Edit the cd_client_conf.xml file and enter the URL to your discovery service, as well as the cduser and password to use.

Once that’s done, just right-click the project, select “Run As -> Run On Server”, select the tomcat server that you configured earlier… and wait.

You may see an error on the first attempt, as apparently Eclipse expects Tomcat to be able to launch fully in 45 seconds, and this may not be enough the first time. Just do it again, and you’ll finally see this screen: