servlet only working on cloud author, not publish instance?

Avatar

Avatar
Affirm 5
Level 4
TB3dock
Level 4

Likes

37 likes

Total Posts

223 posts

Correct reply

5 solutions
Top badges earned
Affirm 5
Ignite 10
Boost 25
Give Back 25
Validate 10
View profile

Avatar
Affirm 5
Level 4
TB3dock
Level 4

Likes

37 likes

Total Posts

223 posts

Correct reply

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

10-05-2021

We created a simple servlet with a fixed path of /bin/demo/querybuilder.

 

 

 

 

 

(service = Servlet.class, property = { Constants.SERVICE_DESCRIPTION + "=Query Builder servlet",
		"sling.servlet.methods=" + HttpConstants.METHOD_GET, "sling.servlet.paths=" + "/bin/demo/querybuilder" })
public class SimonServlet extends SlingSafeMethodsServlet {

 

 

 

 

 

This works great on local sdk, and works hitting the cloud author instance.  However, when we hit the corresponding publish instance, we get:

 

 

 

 

 

<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<html>
<head>
	<title>404 Not Found</title>
</head>
<body>
	<h1>Not Found</h1>
	<p>The requested URL was not found on this server.</p>
</body>
</html>

 

 

 

 

 

Any ideas how we get them onto publish? Our content gets pushed onto the publish instance automatically.   A servlet which can't be published is of no use.

 

Update:

added the following line:

 

 

/005 { /type "allow" /url "/bin/myapi/*"    }

 

 

to 

 

 

myapp.dispatcher.cloud/src/conf.dispatcher.d/filters/filters.any

 

 

and deployed to dev cloud instance.  This seems to work, EXCEPT its stripping all the request headers. even things like X-Correlation-Token. 

 

How to get AEM to not remove the request headers for serlvets?

Replies

Avatar

Avatar
Applaud 25
Level 10
asutosh_jena
Level 10

Likes

593 likes

Total Posts

705 posts

Correct reply

207 solutions
Top badges earned
Applaud 25
Give Back 100
Boost 500
Affirm 100
Ignite 1
View profile

Avatar
Applaud 25
Level 10
asutosh_jena
Level 10

Likes

593 likes

Total Posts

705 posts

Correct reply

207 solutions
Top badges earned
Applaud 25
Give Back 100
Boost 500
Affirm 100
Ignite 1
View profile
asutosh_jena
Level 10

10-05-2021

Hi @TB3dock 

 

You are trying to access the end user URL which is behind the dispatcher and in dispatcher /bin/*

/bin/demo/querybuilder

the above path will be blocked.

 

You need to allow the above path in filter section in dispatcher config and it will allow you to access the servlet.

 

You can look for ams_publish_filters.any file in your code base under dispatcher folder.

 

# allow non-public content directories if this isn't a production environment by uncommenting the next few lines
# /005 { /type "allow" /url "/bin/*" } # allow bin path access

asutosh_jena_0-1620652545527.png

 

Thanks!

Avatar

Avatar
Validate 25
MVP
PuzanovsP
MVP

Likes

140 likes

Total Posts

543 posts

Correct reply

165 solutions
Top badges earned
Validate 25
Validate 10
Validate 1
Contributor 2
Ignite 10
View profile

Avatar
Validate 25
MVP
PuzanovsP
MVP

Likes

140 likes

Total Posts

543 posts

Correct reply

165 solutions
Top badges earned
Validate 25
Validate 10
Validate 1
Contributor 2
Ignite 10
View profile
PuzanovsP
MVP

10-05-2021

Hey TB3dock,

 

Are you sure, you have allowed your url in the AEM as a Cloud Dispatcher, so that you're not blocked there?

 

Regards,

Peter

Avatar

Avatar
Affirm 5
Level 4
TB3dock
Level 4

Likes

37 likes

Total Posts

223 posts

Correct reply

5 solutions
Top badges earned
Affirm 5
Ignite 10
Boost 25
Give Back 25
Validate 10
View profile

Avatar
Affirm 5
Level 4
TB3dock
Level 4

Likes

37 likes

Total Posts

223 posts

Correct reply

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

10-05-2021

Thanks for the helpful reply. Where is the dispatcher folder? We dont see it in ui.config for core?

Avatar

Avatar
Applaud 25
Level 10
asutosh_jena
Level 10

Likes

593 likes

Total Posts

705 posts

Correct reply

207 solutions
Top badges earned
Applaud 25
Give Back 100
Boost 500
Affirm 100
Ignite 1
View profile

Avatar
Applaud 25
Level 10
asutosh_jena
Level 10

Likes

593 likes

Total Posts

705 posts

Correct reply

207 solutions
Top badges earned
Applaud 25
Give Back 100
Boost 500
Affirm 100
Ignite 1
View profile
asutosh_jena
Level 10

10-05-2021

Hi @TB3dock 

It will not be part of ui.config. It's a separate folder parallel to ui.config in codebase named as "dispatcher".

 

asutosh_jena_0-1620652514971.png

 

Avatar

Avatar
Affirm 5
Level 4
TB3dock
Level 4

Likes

37 likes

Total Posts

223 posts

Correct reply

5 solutions
Top badges earned
Affirm 5
Ignite 10
Boost 25
Give Back 25
Validate 10
View profile

Avatar
Affirm 5
Level 4
TB3dock
Level 4

Likes

37 likes

Total Posts

223 posts

Correct reply

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

10-05-2021

great, found it. for us its dispatcher.cloud. There are two sub dirs, conf.d and conf.dispatcher.d. We are guessing the latter. In conf.dispatcher.d, is a dir call filters with a) default_filters.any and b) filters.any. I guess we could just add it to "filters.any"?

Avatar

Avatar
Applaud 25
Level 10
asutosh_jena
Level 10

Likes

593 likes

Total Posts

705 posts

Correct reply

207 solutions
Top badges earned
Applaud 25
Give Back 100
Boost 500
Affirm 100
Ignite 1
View profile

Avatar
Applaud 25
Level 10
asutosh_jena
Level 10

Likes

593 likes

Total Posts

705 posts

Correct reply

207 solutions
Top badges earned
Applaud 25
Give Back 100
Boost 500
Affirm 100
Ignite 1
View profile
asutosh_jena
Level 10

10-05-2021

You are absolutely right!

You need to add to the filter.any which is inside the conf.dispatcher.d folder.

 

Thanks!

Avatar

Avatar
Affirm 5
Level 4
TB3dock
Level 4

Likes

37 likes

Total Posts

223 posts

Correct reply

5 solutions
Top badges earned
Affirm 5
Ignite 10
Boost 25
Give Back 25
Validate 10
View profile

Avatar
Affirm 5
Level 4
TB3dock
Level 4

Likes

37 likes

Total Posts

223 posts

Correct reply

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

10-05-2021

out of interest, does the number at the start have any meaning?

Avatar

Avatar
Applaud 25
Level 10
asutosh_jena
Level 10

Likes

593 likes

Total Posts

705 posts

Correct reply

207 solutions
Top badges earned
Applaud 25
Give Back 100
Boost 500
Affirm 100
Ignite 1
View profile

Avatar
Applaud 25
Level 10
asutosh_jena
Level 10

Likes

593 likes

Total Posts

705 posts

Correct reply

207 solutions
Top badges earned
Applaud 25
Give Back 100
Boost 500
Affirm 100
Ignite 1
View profile
asutosh_jena
Level 10

10-05-2021

Yes. It's the sequence in which the rules will be executed/evaluated on dispatcher.

Avatar

Avatar
Boost 5
Level 7
Ritesh_M
Level 7

Likes

179 likes

Total Posts

142 posts

Correct reply

44 solutions
Top badges earned
Boost 5
Boost 3
Boost 1
Applaud 5
Affirm 1
View profile

Avatar
Boost 5
Level 7
Ritesh_M
Level 7

Likes

179 likes

Total Posts

142 posts

Correct reply

44 solutions
Top badges earned
Boost 5
Boost 3
Boost 1
Applaud 5
Affirm 1
View profile
Ritesh_M
Level 7

10-05-2021

Hi @TB3dock ,

 

Steps given by @asutosh_jena  should resolve your issue. Also, please consider using resource type based servlets, they are

 

1. More secure

2. You get ACLs with the resource node assigned

3. Avoids the headache of adding custom paths to dispatcher.