Issue with a custom built servlet | Community
Skip to main content
Nitesh-Chavan
Level 3
June 6, 2025

Issue with a custom built servlet

  • June 6, 2025
  • 5 replies
  • 880 views

Hi, 

Good Day!

I have a question, in our AEM as a Managed Service instance we have 2 Create Asset Servlet. which are interfering with each other. Basically if both of the servlets are in running condition, we are not able to upload any asset.

 

AEM default Asset upload servlet ----> com.day.cq.dam.core.impl.servlet.CreateAssetServlet

Custom built servlet -----> com.custombuilt.aem.servlets.CreateAssetServlet

 

The mentioned custom built servlet for asset upload is interfering with the default servlet. We have to disable it whenever our author server is getting restarted. 

For some reason we cannot remove the mentioned servlet in a new AEM build, is there a way to permanently disable the custom built servlet without removing it.

Thank You in advance.

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.

5 replies

TarunKumar
Community Advisor
Community Advisor
June 6, 2025

HI @nitesh-chavan ,

 It seems you want to trigger the custom servlet when your instance is completely up, AEM is built on OSGi, and you can listen to lifecycle events to determine when the instance is active. Implement an OSGi component that listens for the FrameworkEvent.STARTED event, which indicates that the OSGi framework has started.

Sample code:

import org.osgi.framework.BundleContext; import org.osgi.framework.FrameworkEvent; import org.osgi.framework.FrameworkListener; import org.osgi.service.component.annotations.Activate; import org.osgi.service.component.annotations.Component; @Component(immediate = true) public class InstanceActiveListener implements FrameworkListener { @Activate protected void activate(BundleContext bundleContext) { bundleContext.addFrameworkListener(this); } @Override public void frameworkEvent(FrameworkEvent event) { if (event.getType() == FrameworkEvent.STARTED) { // Trigger your servlet logic here triggerServlet(); } } private void triggerServlet() { // Logic to trigger the servlet } }

 

 

-Tarun

arunpatidar
Community Advisor
Community Advisor
June 6, 2025

Hi @nitesh-chavan 

Can you share the use case of Custom built servlet? When is it needed? Why It can't be deleted? Is it in use somewhere?

Arun Patidar
lukasz-m
Community Advisor
Community Advisor
June 6, 2025

Hi @nitesh-chavan,

You can consider to use OSGi Component Disabler from ACS Commons, to disable CreateAssetServlet or any other OSGi component.

In case you can not use ACS Commons, you can implement similar mechanism in your project base on ACS Commons implementation:

Nitesh-Chavan
Level 3
June 9, 2025

We have ACS Commons in our environment, But I was not aware that we can disable the OSGi Component using it.

I will check these blog, and I will get back to you if I have any questions. 

Thank You.

aanchal-sikka
Community Advisor
Community Advisor
June 7, 2025

@nitesh-chavan 

 

Define a lower service ranking for the Custom Servlet. It would assure that the OOTB one is prioritized by OSGi . Example:

 

@Component(service = Servlet.class,
property = { Constants.SERVICE_DESCRIPTION + "=Custom Asset Create servlet"Constants.SERVICE_RANKING+ ":Integer=-700"
"sling.servlet.methods=" + HttpConstants.METHOD_GET, "sling.servlet.paths=" + "/bin/createpage" })

 

If you want to learn more about Service Ranking, visit https://sling.apache.org/documentation/the-sling-engine/servlets.html#servlet-resolution-order-1

Aanchal Sikka
Nitesh-Chavan
Level 3
June 9, 2025

I will check service ranking blog, and I will get back to you if I have any questions. 

kautuk_sahni
Community Manager
Community Manager
June 23, 2025

@nitesh-chavan Did you find the suggestions helpful? If you need more information, please let us know. If a response resolved your issue, kindly mark it as correct to help others in the future. Alternatively, if you discovered a solution on your own, we'd appreciate it if you could share it with the community. Thank you.

Kautuk Sahni