Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
BedrockMission!

Learn More

View all

Sign in to view all badges

all servlets always called twice!

Avatar

Avatar
Ignite 10
Level 4
TB3dock
Level 4

Likes

34 likes

Total Posts

203 posts

Correct Reply

4 solutions
Top badges earned
Ignite 10
Boost 25
Give Back 25
Validate 10
Validate 1
View profile

Avatar
Ignite 10
Level 4
TB3dock
Level 4

Likes

34 likes

Total Posts

203 posts

Correct Reply

4 solutions
Top badges earned
Ignite 10
Boost 25
Give Back 25
Validate 10
Validate 1
View profile
TB3dock
Level 4

21-04-2021

We have had this issue since the beginning.

All servlets, no matter how configured, always get run twice, even though they are only called once.  We have the same problem with servlets in wknd, or in our own, completely different project, or in an empty project.

We are hitting the local aem sdk author instance on a mac

e.g this servlet:

 

(service = { Servlet.class })
@SlingServletPaths(value="/bin/test/2")
@ServiceDescription("Simple Demo Servlet 2")
public class MyServlet extends SlingAllMethodsServlet {
	private static final long serialVersionUID = 1L;
	final static Logger log = LoggerFactory.getLogger(MyServlet.class);
	@Override
	protected void doGet(SlingHttpServletRequest request, SlingHttpServletResponse response) {
		try {
			log.info("doGet() called");
			response.getWriter().println("hello 1");
		} catch (IOException e) {
			e.printStackTrace();
		}
	}
	
	@Override
	protected void doPost(SlingHttpServletRequest request, SlingHttpServletResponse response) {
		try {
			log.info("doPost() called");
			response.getWriter().println("hello 2");
		} catch (IOException e) {
			e.printStackTrace();
		}
	}
}

 

When called a single time, either via postman, or via browser, we always see two calls run.  See error.log below:

 

2021-04-21 11:45:29.112 DEBUG [com.xx.core.filters.LoggingFilter] request for /bin/test/2, with selector null
2021-04-21 11:45:29.112 DEBUG [com.xx.core.filters.LoggingFilter] request for /bin/test/2, with selector null
2021-04-21 11:45:29.112 INFO [com.xx.core.servlets.MyServlet] doGet() called
2021-04-21 11:45:29.112 INFO [com.xx.core.servlets.MyServlet] doGet() called

 

in the access log, we only see one call:

 

[0:0:0:0:0:0:0:1] - admin 21/Apr/2021:11:51:33 +0200 "GET /bin/test/2 HTTP/1.1" 200 8 "-" "Mozilla/5.0 (Macintosh; Intel Mac OS X 11_2_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/89.0.4389.128 Safari/537.36"

 

Replies

Avatar

Avatar
Give Back 100
Level 10
asutosh_jena
Level 10

Likes

560 likes

Total Posts

677 posts

Correct Reply

194 solutions
Top badges earned
Give Back 100
Boost 500
Affirm 100
Ignite 1
Establish
View profile

Avatar
Give Back 100
Level 10
asutosh_jena
Level 10

Likes

560 likes

Total Posts

677 posts

Correct Reply

194 solutions
Top badges earned
Give Back 100
Boost 500
Affirm 100
Ignite 1
Establish
View profile
asutosh_jena
Level 10

21-04-2021

Hi @TB3dock 

 

I am tried the same on AEM as Cloud and it seems to be an issue. For me also it's executing twice.

But the same code when I try to run it on AEM 6.5 instance it works perfectly fine and executes only once.

 

We might need to reach out to Adobe Support and they will need to look into this issue.

 

Thanks!

Avatar

Avatar
Coach
MVP
Arun_Patidar
MVP

Likes

1,356 likes

Total Posts

3,228 posts

Correct Reply

917 solutions
Top badges earned
Coach
Contributor 2
Ignite 10
Give Back 700
Boost 1000
View profile

Avatar
Coach
MVP
Arun_Patidar
MVP

Likes

1,356 likes

Total Posts

3,228 posts

Correct Reply

917 solutions
Top badges earned
Coach
Contributor 2
Ignite 10
Give Back 700
Boost 1000
View profile
Arun_Patidar
MVP

21-04-2021

It looks like the log messages are getting printed twice but the execution is happening once.

I tried to call a service from servlet that has a static variable as a counter and the counter does not increase twice, only increases once but in logs, there are 2 entries with the same message.

 

 

 

2021-04-21 16:00:13.973 INFO [com.community.aemlab.core.servlets.SampleOsgiServlet] sampleOsgiService STARTED......
2021-04-21 16:00:13.973 INFO [com.community.aemlab.core.servlets.SampleOsgiServlet] sampleOsgiService STARTED......
2021-04-21 16:00:13.973 INFO [com.community.aemlab.core.services.impl.SampleOsgiServiceImpl] SampleOsgiService#getSettings : 3
2021-04-21 16:00:13.973 INFO [com.community.aemlab.core.services.impl.SampleOsgiServiceImpl] SampleOsgiService#getSettings : 3
2021-04-21 16:00:13.973 INFO [com.community.aemlab.core.servlets.SampleOsgiServlet] sampleOsgiService END......
2021-04-21 16:00:13.973 INFO [com.community.aemlab.core.servlets.SampleOsgiServlet] sampleOsgiService END......

2021-04-21 16:03:40.767 INFO [com.community.aemlab.core.servlets.SampleOsgiServlet] sampleOsgiService STARTED......
2021-04-21 16:03:40.767 INFO [com.community.aemlab.core.servlets.SampleOsgiServlet] sampleOsgiService STARTED......
2021-04-21 16:03:40.768 INFO [com.community.aemlab.core.services.impl.SampleOsgiServiceImpl] SampleOsgiService#getSettings : 4
2021-04-21 16:03:40.768 INFO [com.community.aemlab.core.services.impl.SampleOsgiServiceImpl] SampleOsgiService#getSettings : 4
2021-04-21 16:03:40.768 INFO [com.community.aemlab.core.servlets.SampleOsgiServlet] sampleOsgiService END......
2021-04-21 16:03:40.768 INFO [com.community.aemlab.core.servlets.SampleOsgiServlet] sampleOsgiService END......

 

 

Avatar

Avatar
Give Back 100
Level 10
asutosh_jena
Level 10

Likes

560 likes

Total Posts

677 posts

Correct Reply

194 solutions
Top badges earned
Give Back 100
Boost 500
Affirm 100
Ignite 1
Establish
View profile

Avatar
Give Back 100
Level 10
asutosh_jena
Level 10

Likes

560 likes

Total Posts

677 posts

Correct Reply

194 solutions
Top badges earned
Give Back 100
Boost 500
Affirm 100
Ignite 1
Establish
View profile
asutosh_jena
Level 10

21-04-2021

That's strange. Log also should not be printed twice!

Avatar

Avatar
Ignite 10
Level 4
TB3dock
Level 4

Likes

34 likes

Total Posts

203 posts

Correct Reply

4 solutions
Top badges earned
Ignite 10
Boost 25
Give Back 25
Validate 10
Validate 1
View profile

Avatar
Ignite 10
Level 4
TB3dock
Level 4

Likes

34 likes

Total Posts

203 posts

Correct Reply

4 solutions
Top badges earned
Ignite 10
Boost 25
Give Back 25
Validate 10
Validate 1
View profile
TB3dock
Level 4

21-04-2021

That doesnt seem possible?

Avatar

Avatar
Validate 1
MVP
Nikhil-Kumar
MVP

Likes

243 likes

Total Posts

256 posts

Correct Reply

38 solutions
Top badges earned
Validate 1
Ignite 3
Ignite 1
Give Back 5
Give Back 3
View profile

Avatar
Validate 1
MVP
Nikhil-Kumar
MVP

Likes

243 likes

Total Posts

256 posts

Correct Reply

38 solutions
Top badges earned
Validate 1
Ignite 3
Ignite 1
Give Back 5
Give Back 3
View profile
Nikhil-Kumar
MVP

21-04-2021

@TB3dock - Which version of AEM are you using ? I have tested it out on 6.5.5 and it worked fine. I suspect you are using AEMaaCs, raise a day care support ticket if it's an issue with the AEM version.

Avatar

Avatar
Ignite 10
Level 4
TB3dock
Level 4

Likes

34 likes

Total Posts

203 posts

Correct Reply

4 solutions
Top badges earned
Ignite 10
Boost 25
Give Back 25
Validate 10
Validate 1
View profile

Avatar
Ignite 10
Level 4
TB3dock
Level 4

Likes

34 likes

Total Posts

203 posts

Correct Reply

4 solutions
Top badges earned
Ignite 10
Boost 25
Give Back 25
Validate 10
Validate 1
View profile
TB3dock
Level 4

22-04-2021

I have tested this, and my service is called twice from the servlet. So this is not just logging, this is 2 complete calls.

Avatar

Avatar
Ignite 10
Level 4
TB3dock
Level 4

Likes

34 likes

Total Posts

203 posts

Correct Reply

4 solutions
Top badges earned
Ignite 10
Boost 25
Give Back 25
Validate 10
Validate 1
View profile

Avatar
Ignite 10
Level 4
TB3dock
Level 4

Likes

34 likes

Total Posts

203 posts

Correct Reply

4 solutions
Top badges earned
Ignite 10
Boost 25
Give Back 25
Validate 10
Validate 1
View profile
TB3dock
Level 4

22-04-2021

Im using the absolute latest cloud SDK on a mac.

Avatar

Avatar
Coach
Employee
Jörg_Hoh
Employee

Likes

1,115 likes

Total Posts

3,149 posts

Correct Reply

1,072 solutions
Top badges earned
Coach
Give back 600
Ignite 5
Ignite 3
Ignite 1
View profile

Avatar
Coach
Employee
Jörg_Hoh
Employee

Likes

1,115 likes

Total Posts

3,149 posts

Correct Reply

1,072 solutions
Top badges earned
Coach
Give back 600
Ignite 5
Ignite 3
Ignite 1
View profile
Jörg_Hoh
Employee

23-04-2021

Can you check in the OSGI webconsole under "recent requests", that this request is actually showing up twice? And is this behavior consistent between the SDK and the actual AEM CS instances (in the cloud)?

 

Logging would be indeed my first assumption, too.

Avatar

Avatar
Ignite 10
Level 4
TB3dock
Level 4

Likes

34 likes

Total Posts

203 posts

Correct Reply

4 solutions
Top badges earned
Ignite 10
Boost 25
Give Back 25
Validate 10
Validate 1
View profile

Avatar
Ignite 10
Level 4
TB3dock
Level 4

Likes

34 likes

Total Posts

203 posts

Correct Reply

4 solutions
Top badges earned
Ignite 10
Boost 25
Give Back 25
Validate 10
Validate 1
View profile
TB3dock
Level 4

24-04-2021

The servlet is calling my service twice - so its not just logging, the servlet is being executed twice.  My code wont go onto the actual cloud for some time unfortunately.  In the osgi config stuff, under web console tab, are only 3 options: license, memory usage and system information.  Where do i see recent requests?  The access log only shows a single hit.  There is a sling recent requests, but this is always empty.