You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@camel.apache.org by "Gerald Kallas (Jira)" <ji...@apache.org> on 2020/05/02 19:26:00 UTC

[jira] [Created] (CAMEL-15000) Using a registered ConstraintSecurityHandler in another Blueprint file causes an java.lang.IllegalStateException: STARTED

Gerald Kallas created CAMEL-15000:
-------------------------------------

             Summary: Using a registered ConstraintSecurityHandler in another Blueprint file causes an java.lang.IllegalStateException: STARTED
                 Key: CAMEL-15000
                 URL: https://issues.apache.org/jira/browse/CAMEL-15000
             Project: Camel
          Issue Type: Bug
          Components: camel-jetty
    Affects Versions: 3.0.1
            Reporter: Gerald Kallas


I've defined a Blueprint DSL file with a securityHandler configuration for multiple paths as following
{code:java}
<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0"
   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
   xsi:schemaLocation="http://www.osgi.org/xmlns/blueprint/v1.0.0 https://www.osgi.org/xmlns/blueprint/v1.0.0/blueprint.xsd">

   <bean id="constraint_TSTISP001" class="org.eclipse.jetty.util.security.Constraint">
      <property name="name" value="BASIC" />
      <property name="authenticate" value="true" />
      <property name="roles">
         <list>
            <value>TSTISP001</value>
         </list>
      </property>
   </bean>

   <bean id="constraintMapping_TSTISP001" class="org.eclipse.jetty.security.ConstraintMapping">
      <property name="constraint" ref="constraint_TSTISP001" />
      <property name="pathSpec" value="/hello1" />
   </bean>

   <bean id="constraint_TSTISP002" class="org.eclipse.jetty.util.security.Constraint">
      <property name="name" value="BASIC" />
      <property name="authenticate" value="true" />
      <property name="roles">
         <list>
            <value>TSTISP002</value>
         </list>
      </property>
   </bean>

   <bean id="constraintMapping_TSTISP002" class="org.eclipse.jetty.security.ConstraintMapping">
      <property name="constraint" ref="constraint_TSTISP002" />
      <property name="pathSpec" value="/hello2" />
   </bean>

   <bean id="securityHandlerImpl" class="org.eclipse.jetty.security.ConstraintSecurityHandler">
      <property name="loginService">
         <bean class="org.eclipse.jetty.security.HashLoginService">
            <property name="config" value="/opt/apache-karaf/etc/users.properties" />
         </bean>
      </property>
      <property name="authenticator">
         <bean class="org.eclipse.jetty.security.authentication.BasicAuthenticator" />
      </property>
      <property name="constraintMappings">
         <list>
            <ref component-id="constraintMapping_TSTISP001" />
            <ref component-id="constraintMapping_TSTISP002" />
         </list>
      </property>
   </bean>

   <service id="securityHandlerIsp" ref="securityHandlerImpl" interface="org.eclipse.jetty.server.Handler" />

   <sslContextParameters id="sslContextParameters" xmlns="http://camel.apache.org/schema/blueprint">
      ...
   </sslContextParameters>

   <service ref="sslContextParameters" auto-export="all-classes" />
</blueprint>
{code}
The use in another Blueprint DSL file as attached
{code:java}
<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0"
         xmlns:ext="http://aries.apache.org/blueprint/xmlns/blueprint-ext/v1.0.0"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xmlns:cm="http://aries.apache.org/blueprint/xmlns/blueprint-cm/v1.1.0"
         xsi:schemaLocation="http://www.osgi.org/xmlns/blueprint/v1.0.0 https://www.osgi.org/xmlns/blueprint/v1.0.0/blueprint.xsd">

   <!-- set reference to the SSLContextParameters -->
   <reference id="sslContextParameters" interface="org.apache.camel.support.jsse.SSLContextParameters" ext:proxy-method="classes" />

   <!-- set reference to the securityHandler -->
   <reference id="securityHandlerIsp" interface="org.eclipse.jetty.server.Handler" />

   <camelContext id="isp.context.user.TSTISP001" xmlns="http://camel.apache.org/schema/blueprint" streamCache="true" useBreadcrumb="true">

      <route id="isp.route.user.TSTISP001">
         <from uri="jetty:https://0.0.0.0:8444/hello1?sslContextParameters=#sslContextParameters&amp;handlers=securityHandlerIsp" />
         <setBody><constant>Hello 1</constant></setBody>
      </route>

   </camelContext>

</blueprint>
{code}
causes an error
{code:java}
2020-05-02T19:15:46,202 | ERROR | Blueprint Event Dispatcher: 1 | BlueprintCamelContext            | 92 - org.apache.camel.camel-api - 3.0.0 | Error starting CamelContext (isp.context.user.TSTISP001) due to exception thrown: STARTED
java.lang.IllegalStateException: STARTED
        at org.eclipse.jetty.server.handler.AbstractHandlerContainer.setServer(AbstractHandlerContainer.java:131) ~[!/:9.4.20.v20190813]
        at Proxyb4d61c20_c161_4396_a800_1fa982bbaaea.setServer(Unknown Source) ~[?:?]
        at org.eclipse.jetty.server.handler.HandlerCollection.updateHandlers(HandlerCollection.java:117) ~[!/:9.4.20.v20190813]
        at org.eclipse.jetty.server.handler.HandlerCollection.addHandler(HandlerCollection.java:180) ~[!/:9.4.20.v20190813]
        at org.apache.camel.component.jetty.JettyHttpComponent.addJettyHandlers(JettyHttpComponent.java:1182) ~[!/:3.0.0]
        at org.apache.camel.component.jetty.JettyHttpComponent.createServletForConnector(JettyHttpComponent.java:1145) ~[!/:3.0.0]
        at org.apache.camel.component.jetty.JettyHttpComponent.connect(JettyHttpComponent.java:329) ~[!/:3.0.0]
        at org.apache.camel.http.common.HttpCommonEndpoint.connect(HttpCommonEndpoint.java:177) ~[!/:3.0.0]
        at org.apache.camel.http.common.HttpConsumer.doStart(HttpConsumer.java:58) ~[!/:3.0.0]
        at org.apache.camel.component.jetty.JettyHttpConsumer.doStart(JettyHttpConsumer.java:31) ~[!/:3.0.0]
        at org.apache.camel.support.service.ServiceSupport.start(ServiceSupport.java:117) ~[!/:3.0.0]
        at org.apache.camel.impl.engine.AbstractCamelContext.startService(AbstractCamelContext.java:2900) ~[!/:3.0.0]
        at org.apache.camel.impl.engine.AbstractCamelContext.doStartOrResumeRouteConsumers(AbstractCamelContext.java:3227) ~[!/:3.0.0]
        at org.apache.camel.impl.engine.AbstractCamelContext.doStartRouteConsumers(AbstractCamelContext.java:3161) ~[!/:3.0.0]
        at org.apache.camel.impl.engine.AbstractCamelContext.safelyStartRouteServices(AbstractCamelContext.java:3071) ~[!/:3.0.0]
        at org.apache.camel.impl.engine.AbstractCamelContext.doStartOrResumeRoutes(AbstractCamelContext.java:2836) ~[!/:3.0.0]
        at org.apache.camel.impl.engine.AbstractCamelContext.doStartCamel(AbstractCamelContext.java:2640) ~[!/:3.0.0]
        at org.apache.camel.impl.engine.AbstractCamelContext.lambda$doStart$2(AbstractCamelContext.java:2445) ~[!/:3.0.0]
        at org.apache.camel.impl.engine.AbstractCamelContext.doWithDefinedClassLoader(AbstractCamelContext.java:2462) ~[!/:3.0.0]
        at org.apache.camel.impl.engine.AbstractCamelContext.doStart(AbstractCamelContext.java:2443) ~[!/:3.0.0]
        at org.apache.camel.support.service.ServiceSupport.start(ServiceSupport.java:117) ~[!/:3.0.0]
        at org.apache.camel.impl.engine.AbstractCamelContext.start(AbstractCamelContext.java:2352) [!/:3.0.0]
        at org.apache.camel.blueprint.BlueprintCamelContext.start(BlueprintCamelContext.java:244) [!/:3.0.0]
        at org.apache.camel.blueprint.BlueprintCamelContext.maybeStart(BlueprintCamelContext.java:286) [!/:3.0.0]
        at org.apache.camel.blueprint.BlueprintCamelContext.blueprintEvent(BlueprintCamelContext.java:183) [!/:3.0.0]
        at org.apache.aries.blueprint.container.BlueprintEventDispatcher$3.call(BlueprintEventDispatcher.java:190) [!/:1.10.2]
        at org.apache.aries.blueprint.container.BlueprintEventDispatcher$3.call(BlueprintEventDispatcher.java:188) [!/:1.10.2]
        at java.util.concurrent.FutureTask.run(Unknown Source) [?:?]
        at java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source) [?:?]
        at java.util.concurrent.FutureTask.run(Unknown Source) [?:?]
        at java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source) [?:?]
        at java.util.concurrent.FutureTask.run(Unknown Source) [?:?]
        at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(Unknown Source) [?:?]
        at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source) [?:?]
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source) [?:?]
        at java.lang.Thread.run(Unknown Source) [?:?]
{code}
A similar approach with the definition of the securityHandler and the route using this in one Blueprint DSL is working.



--
This message was sent by Atlassian Jira
(v8.3.4#803005)