[ 
https://issues.apache.org/jira/browse/KARAF-7804?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17831791#comment-17831791
 ] 

ASF subversion and git services commented on KARAF-7804:
--------------------------------------------------------

Commit d111ee4b8b9eee395208bb14e8b48ee00ceb9a07 in karaf's branch 
refs/heads/main from JB Onofré
[ https://gitbox.apache.org/repos/asf?p=karaf.git;h=d111ee4b8b ]

Merge pull request #1822 from awrb/KARAF-7804

KARAF-7804 - provide unique servlet-name when registering http proxy servlets

> Cannot register more than one HTTP proxy
> ----------------------------------------
>
>                 Key: KARAF-7804
>                 URL: https://issues.apache.org/jira/browse/KARAF-7804
>             Project: Karaf
>          Issue Type: Bug
>          Components: karaf
>            Reporter: Aleksy Wróblewski
>            Assignee: Jean-Baptiste Onofré
>            Priority: Major
>
> When you register more than one proxy into ProxyService, it crashes with the 
> following exception:
>  
> {code:java}
> org.osgi.service.http.NamespaceException: 
> ServletModel{id=ServletModel-49,name='org.apache.karaf.http.core.internal.proxy.ProxyServlet',alias='/kb',urlPatterns=[/kb/*],servlet=org.apache.karaf.http.core.internal.proxy.ProxyServlet@6bad2ac1,contexts=[
> {HS,OCM-48,default,/}]} can't be registered. 
> ServletContextModel\{id=ServletContextModel-2,contextPath='/'} already 
> contains servlet named 
> org.apache.karaf.http.core.internal.proxy.ProxyServlet: 
> ServletModel{id=ServletModel-47,name='org.apache.karaf.http.core.internal.proxy.ProxyServlet',alias='/webconsole',urlPatterns=[/webconsole/*],servlet=org.apache.karaf.http.core.internal.proxy.ProxyServlet@4ce53d9c,contexts=[\{HS,OCM-48,default,/}
> ]}
> {code}
>  
> The important part: *already* *contains servlet named 
> org.apache.karaf.http.core.internal.proxy.ProxyServlet*
>  
> This is because servlet-name is not specified when registering a new 
> ProxyServlet into HttpService. So PAX-WEB defaults to the fully qualified 
> class name, as specified in HTTP whiteboard spec section 140.4. 
> ([https://docs.osgi.org/specification/osgi.cmpn/7.0.0/service.http.whiteboard.html#service.http.whiteboard-i21223311).]
>  But the class name is the same for subsequent Servlets, so there is a 
> conflict.
> This is also easy to see when you modify 
> org.apache.karaf.itests.HttpTest.testProxy to register two proxies and check 
> if both are registered:
> {code:java}
> @Test
> public void testProxy() throws Exception {
> executeCommand("http:proxy-add /test1 http://karaf.apache.org";);
> executeCommand("http:proxy-add /test2 http://karaf.apache.org";); // not added
> String output = executeCommand("http:proxy-balancing-list");
> System.out.println(output);
> assertContains("random", output);
> assertContains("round-robin", output);
> output = executeCommand("http:proxy-list");
> System.out.println(output);
> assertContains("/test1", output);
> assertContains("/test2", output); // fails
> }
> {code}
>  



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to