I have a problem when running OH in a 2.5 dev environment (Eclipse 09/2020). Maybe someone can help - it worked in the past, but now I can’t get it working to debug the code
I’m adding a new servlet to the Shelly binding, which registers the URI /shelly/manager
public static final String SHELLY_MANAGER_URI = "/shelly/manager";
private static final String SERVLET_URI = SHELLY_MANAGER_URI;
@Activate
public ShellyManagerServlet(@Reference HttpService httpService, @Reference ShellyHandlerFactory handlerFactory,
Map<String, Object> config) {
className = substringAfterLast(getClass().toString(), ".");
this.httpService = httpService;
this.handlerFactory = handlerFactory;
try {
httpService.registerServlet(SERVLET_URI, this, null, httpService.createDefaultHttpContext());
logger.debug("{} started at '{}'", className, SERVLET_URI);
} catch (NamespaceException | ServletException | IllegalArgumentException e) {
logger.warn("Could not start {}", className, e);
}
manager = new ShellyManager(handlerFactory.getThingHandlers());
}
which is performed without errors (same I do with /shelly/event to get the event callbacks from the device).
Now I want to debug the new servlet, but I can’t access it from the browser nor with curl. Instead of getting the page the browser prompts we for credentials, which is unusual. Also when I use the default ones openhab:habopen I’m not able to complete the request - the browser brings up the popup again.
curl -v http://127.0.0.1:8080/shelly/manager
* Trying 127.0.0.1...
* TCP_NODELAY set
* Connected to 127.0.0.1 (127.0.0.1) port 8080 (#0)
> GET /shelly/manager HTTP/1.1
> Host: 127.0.0.1:8080
> User-Agent: curl/7.64.1
> Accept: */*
>
< HTTP/1.1 401 Unauthorized
< Date: Tue, 29 Dec 2020 18:25:29 GMT
< WWW-Authenticate: Basic realm="OSGi Management Console"
< Content-Length: 0
< Server: Jetty(9.4.20.v20190813)
<
* Connection #0 to host 127.0.0.1 left intact
* Closing connection 0
I also used the regular network ip instead of 127.0.0.1 with the same result.
When I build the jar with mvn and put this on a “regular” OH instance the servlet works as expected and the code is executed.
http://127.0.0.1:8080/paperui/index.html#/control works as expected
http://127.0.0.1:8080/shelly/manager nor
http://127.0.0.1:8080/shelly/event does not.
I see no request nor any debug output from my servlet in the log.
I did not any changes to the jetty config nor user.properties
openhab = habopen,_g_:admingroup
_g_\:admingroup = group,admin,manager,viewer,systembundles
@hilbrand Any idea how to authorizes access to /shelly/*?