Saturday, July 6, 2019

Add MySQL Driver in JBoss Server

Hello Everyone,

In the previous blog, you have already gone through a sample application of spring
boot to be deployed in JBoss container.

Now in this blog, we will see how to add mysql driver in JBoss and through JNDI URL,
how Spring boot gets connected with database.

Before going to coding part, we need few prerequisites to set up database with JBOSS.
Here we don’t directly put database configurations in spring boot
So we create JNDI configuration in JBoss and add that configuration in spring boot
properties file to connect to database.
How to add  mysql driver in JBOSS and create a JNDI URL:
Out of the box, JBoss only comes with an H2 JDBC driver. Most likely, you have a different
database such as Oracle, MS SQL or MySQL. As long as you have access to JBoss,
installing the appropriate JDBC driver is fairly straightforward.
The advantage of installing it into JBoss itself is:
  • You can enforce a specific JDBC driver version for all of your deployed applications.
  • If any changes required in database configurations, no need to change in code base.
  • If different environments are connected to different databases, still you can manage the same JNDI URL for all the environments. So environment specific configurations are not needed.
  • Multiple applications can also share the same JNDI URL.
So below are the steps to install MySQL drivers in JBoss.
  • Navigate to the directory $JBOSS_HOME/modules/system/layers/base
  • Create com/mysql/main directory.
  • Navigate to main directory and save MySQL JDBC driver's jar there.
Fig 1: Main Directory
  • Create a module.xml file with the content below inside the main directory.
  • <?xml version="1.0" encoding="UTF-8"?>
    <module xmlns="urn:jboss:module:1.1" name="com.mysql">
            <resource-root path="mysql-connector-java-[VERSION]-bin.jar"/>
            <module name="javax.api"/>
            <module name="javax.transaction.api"/>
            <module name="javax.servlet.api" optional="true"/>
  • Access directory $JBOSS_HOME/standalone/configuration and open the file standalone.xml.Till mysql-connector-java-5.1.47-bin.jar,add the driver like this:
    <driver name="mysql" module="com.mysql">
From mysql-connector-java-6.0.2-bin.jar, the hierarchy of driver classes has been changed
and for those versions you need to add the below mentioned configurations in
standalone.xml to add a driver.
<driver name="mysql" module="com.mysql">
After all the above steps, a new driver will get added in the JBoss Server and need to restart the JBoss Server to see the newly added driver.

Create JDBC DataSource in JBoss Server.

  • Go to JBoss Server Datasources .
  • Fig 2: Add a new JDBC DataSource Attributes
  • Click on Add to create a new Datasource.
  • It has 3 steps configurations shown below.
    • Step1/3 :DataSource Attributes
      • Name: any Name.
      • JNDI Name: The jndi name must start with “java:jboss/” and after that you can put anything like java:jboss/test
Fig 3: DataSource Attributes
    • Step 2/3: JDBC Driver
Fig 4: JDBC Driver
    • Step 3/3 Connection Settings
      • Connection URL:jdbc:mysql://localhost:3306/sys[here sys is the database name.]
      • Username: the username of the database.
      • Password: the password of the database
Fig 5: Connection Settings

You can Test the connection by clicking on “Test the connection” button after filling all the above configurations  and verify that the database is connected correctly or not.

Demonstration Video On Add MySQL Driver in JBoss Server:

If you have any query or suggestion then kindly comment or mail us at

Hope it will help you guys !!
Thanks and Happy Learning.

Sunday, June 30, 2019

Preparing your Spring Boot app to deploy it to JBoss EAP 6.3

Hello Everyone,

Being an AEM Developer. You are supposed to know how to use java frameworks. So
in my industry experience I got an opportunity to work with spring boot many times. Working with spring boot framework is one of the easiest things to do because spring
boot applications runs on its own tomcat server and you don't need to have a big setup for

But sometimes clients want to deploy spring boot applications in JBoss server and if
JBoss server is quite legacy like JBoss EAP 6.3 or older than this then the actual problem

So my requirement was client wants me to make a spring boot application which can run on
java 7 and 8 and can be deployed over JBoss EAP 6.3.

As spring boot 2 needs java 8 to run so I am not able to use that so I decided to use spring
boot version 1.5.21.RELEASE as it works on both java 7 and 8.

Let’s create a basic Application with spring boot and deploy it in JBoss 6.3.
  1. Install JBoss EAP 6.3 : You can download JBoss 6.3 installer from here. For step by step procedure to install it in windows, please go through with this video.
  2. Create a sample spring boot project: To create a sample spring boot project, you need to create a project from here. You can see the whole video to how to create a spring project and deploy it in JBoss container.
Till here, I assume that you are already done with prerequisites and now you need to make a few changes in your spring boot project.
  1. Let’s create a sample main class and a very basic hello world API here.
  2. First change the artifact “spring-boot-starter” to “spring-boot-starter-web”, because to create API we need “spring-boot-starter-web” dependency and web jar also contain the “spring-boot-starter jar in itself.So to avoid duplicacy we need to do it. You need to deploy this application in JBoss container so you need to exclude tomcat dependency from your main spring boot starter web jar.
  3. As javax.servlet dependency was the part of tomcat API and in step 2 we have already excluded tomcat dependency, so we need to add this dependency externally only for compile time as JBoss also has this dependency so at run-time JBoss will take care of it.
  4. <dependency>
  5. Add server.servlet-path=/* in file.
  6. To deploy it in JBoss container, we need to make a war for the project. To do that we need to add :<packaging>war</packaging>
  7. Define context root:There are many ways to decide the context root of application in JBoss container.
    • Add <finalName> xyz</finalName> in pom.xml inside <build> tag.
    • Add jboss-web.xml inside project directory/webapp/WEB-INF/jboss-web.xml and add this line in the xml file.
That’s all you need to do after that just run the maven command “mvn clean package” and deploy it in the JBoss container.
After you follow the above steps and deploy the application in JBoss, the very first issue comes to you which is:
Caused by: JBAS018104: Deployment error processing SCI for jar: logback-classic-1.1.11.jar

To solve this issue, you need to exclude the logback dependency from spring boot starter web dependency. Add this exclusion also in step 2 exclusions list.

After this you again deploy the application in JBoss container and hit the servlet to see the result.
Fig 1: Test your sample API

Note: To see the admin console, JBoss Default Port is 9990 but to view the application the default port is 8080. So you will be able to see the API when you hit localhost:8080/context-root/API_URL
Note: The location of server.log file is JBOSS_HOME/standalone/log/server.log.

If you have any query or suggestion then kindly comment or mail us at

Hope it will help you guys !!
Thanks and Happy Learning.

Thursday, May 30, 2019

Export Experience Fragments to Adobe Target with AEM 6.3

** Still in Progress but publishing it if just write up can help"**

Hello Everyone.

Recently I have gone through one use case of XF with adobe target. The problem statement
was I was having one component which is having three variations. And I want to show
different variations of the component to different audience using adobe Target.

So when i start implementing, I came to know that one way to achieve this is to create an XF
and make three variations of that and Export it to Adobe Target.

So This blog only talks about how to Export the Experience Fragment  to adobe target.

1. AEM needs to be successfully connected to “Adobe Target”.
2. In the cloud configurations of XF (in page properties), need to configure adobe target.

In the previous blog we have already created an XF and in AEM 6.4 there is already
a button available in the XF Console and it will directly publish the XF to target.

But My project is using AEM Version, I was not able to find the option of "Export to
Target".But when I upgraded my system to AEM 6.3.3 then I got the option.But the client was not always ready about this upgrade so how can we do it with minimal things done on production.

While debugging this problem, I have gone through few documents that says different things and really a bit mislead me.

1. One document says that the prerequisite for this option need to be “Adobe Experience Manager 6.3 SP2 (or later)”.
2. Someone also face the same issue and raise it to adobe forum then they ask to update the instance (AEM 6.3.2) with one pack “” and in the forum they mentioned also that “Open a daycare ticket to get access to it. It's not yet available at Adobe Package share cloud”.
3. Other document says that “This functionality requires the application of AEM 6.3 Service Pack 3 (

Now the actual things which I figured out are:
1. AEM don’t support XF "Export to Adobe Target" option.
2.“” package is a very small bug fix package and can solve the problem but it is available in packageshare. No need to raise a ticket to adobe.
3. AEM 6.3.3+ versions supports the option but you can make it available in AEM 6.3.2 with a very small(2 MB) Bug fix package but your client doesn't want to go for the big upgrade.

If you have any query or suggestion then kindly comment or mail us at

Hope it will help you guys !!
Thanks and Happy Learning.

Experience Fragments in AEM 6.4

** Still in Progress as package and videos are not attached but publishing it if just write up can help"

Hello Everyone,

A lot of people asked me to write upon experience fragments since so long but I couldn’t
write over it because before this I have not worked on it.
By writing something after reading from google doesn’t experience you the real time problems
you may face.So finally as I am using this feature in my projects and understand the
technical challenge also, So for your reference I am writing down this article on experience

What are Experience Fragments?
An Experience Fragment is a set of content that grouped forms an experience that should
make sense on its own.
We will not do our hands on we-retail because that won’t really help you to create your
XF so let’s see how you can do initial set up for XF in your own projects.

  1. Page Component of Experience fragments
  2. Creating Dynamic Template for Experience fragments
How to create a Page Component for XF: Copy the we-retail page Component “weretail/components/structure/xfpage” in your own project  and change the clientlibs in “customfooterlibs.html” and “customheaderlibs.html”,and include your own clientlibs.It is important because if you create an XF for your project and use the components you want to see  the same look and feel of the actual website in XF pages also.

Dynamic Templates for Experience Fragments:

If you are already using dynamic templates,  you must be aware about it so create a new template-types with your xf resourcetype.

If in your project you are using static templates, still you need to create a dynamic template for XF. To check the  steps of creating a dynamic template you can check this link out from here or no need to understand the dynamic templates in so deep just take the package from here and update the name and path as per your needs.

Note: One important thing to highlight here is you need to add one more property in the “jcr:content” of “initial” node of your template-type manually which is


If you don’t add this property you won’t able to see your XF Variant in the
experience fragment component to select it over a page.

So my assumption till here is that you have created a template-types and page component.
It's time to create a template from template-types and allow the components in parsys by
adding policy and unlock the parsys.

If you are completely unaware of dynamic templates you can follow the video for more
clarity if the terminologies (policy, template-types) are not clear to you.

Allow the template for Experience Fragment: You need to add your template
manually in XF path(“/content/experience-fragments”) property allowedTemplates,
so that template can be visible to create XF.

Now it’s time to create Experience Fragments:
1. Go to AEM Start Console and go to “Experience Fragments”.
2. Create a folder for your project.
3. Under that click on Create-> Experience Fragment and choose the template for your project.
4. When you open the template you will be able to see a parsys in which you can drag and drop the components.Only those components can be dropped here which you configured in the policy of parsys at the time of template creation.
5.You can create different variation of the XF also.

Now your Experience Fragment is ready, you can use it in your page.Drag and drop the Component named “experience Fragment” from "General" group on a page and choose the variation which you want to use on a page.

If you have any query or suggestion then kindly comment or mail us at

Hope it will help you guys !!
Thanks and Happy Learning.