2つのCamelサーブレットベースのAPI(2つのOSGiバンドル)を作成しようとしています。私はthis exampleのようにブループリントXMLを使用しています。Apache CamelブループリントベースのOSGiバンドルでDuplicate ServletNameが検出されました
これらの2つの青写真XMLS、
<?xml version="1.0" encoding="UTF-8"?>
<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">
<reference id="httpService" interface="org.osgi.service.http.HttpService"/>
<bean class="org.apache.camel.component.servlet.osgi.OsgiServletRegisterer"
init-method="register"
destroy-method="unregister">
<property name="alias" value="/digital"/>
<property name="httpService" ref="httpService"/>
<property name="servlet" ref="teamCamelServlet"/>
</bean>
<bean id="teamCamelServlet" class="org.apache.camel.component.servlet.CamelHttpTransportServlet"/>
<bean id="teamService" class="com.test.TeamService"/>
<camelContext xmlns="http://camel.apache.org/schema/blueprint">
<restConfiguration component="servlet" bindingMode="json" contextPath="/digital"
port="8181">
<dataFormatProperty key="prettyPrint" value="true"/>
</restConfiguration>
<rest path="/team" consumes="application/json" produces="application/json">
..content omitted
</rest>
</camelContext>
</blueprint>
他blueprint.xml
です:
<?xml version="1.0" encoding="UTF-8"?>
<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">
<reference id="httpService" interface="org.osgi.service.http.HttpService"/>
<bean class="org.apache.camel.component.servlet.osgi.OsgiServletRegisterer"
init-method="register"
destroy-method="unregister">
<property name="alias" value="/api"/>
<property name="httpService" ref="httpService"/>
<property name="servlet" ref="camelServlet"/>
</bean>
<bean id="camelServlet" class="org.apache.camel.component.servlet.CamelHttpTransportServlet"/>
<bean id="helloService" class="com.test.HelloService"/>
<camelContext xmlns="http://camel.apache.org/schema/blueprint">
<restConfiguration component="servlet" bindingMode="json" contextPath="/api"
port="8181">
<dataFormatProperty key="prettyPrint" value="true"/>
</restConfiguration>
<!-- defines the rest services using the context-path /user -->
<rest path="/hello" consumes="application/json" produces="application/json">
..content omitted
</rest>
</camelContext>
</blueprint>
しかし、私は、このエラーメッセージが表示されます:私はここで間違って何を
javax.servlet.ServletException: Duplicate ServletName detected: CamelServlet. Existing: CamelHttpTransportServlet[name=CamelServlet] This: CamelHttpTransportServlet[name=CamelServlet]. Its advised to use unique ServletName per Camel application.
をやっていますか?私はこれら2つのOSGiバンドルをApache ServiceMixで実行しようとしています。そのうちの1つが展開されていれば、正常に動作しています。両方が展開されている場合、最初のものだけが動作しています。私はApache Camelを初めて使用しています。私はServiceMixを再起動しようとしましたが、運はありません。また、バンドルキャッシュをクリアして試しました。
両方のバンドルに完全なblueprint.xmlを追加できますか? – stringy05
私はあなたが両方のサーブレット定義でポートを宣言したかもしれないと思います。 pax webサーブレットを使用する方が良いです(cxfservletでポートを削除するだけですが、残りの構成コンポーネントでこれを行う方法がわかりません) – stringy05
@ stringy05ありがとうございます。ところで、ポートバインディングの問題については不平を言っていません。他のサーブレットコンポーネントと何が起こるか –