You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by Christian Müller <ch...@gmail.com> on 2011/04/08 23:32:28 UTC

Re: Problem with multiple CXF services using the same https port

Hello Ade, Willem, Charles,

I updated https://issues.apache.org/jira/browse/CAMEL-3756. May be you could
have a look on it. I have a problem with deploying it into ServiceMix
4.3.1-fuse-01-09. With ServiceMix 4.2.0-fuse-02-00 everything works as
expected.

Cheers,
Christian

Re: Problem with multiple CXF services using the same https port

Posted by ychawla <pr...@gmail.com>.
Hello all,
I got a little further with my configuration and think I got it working.  I
looked at the camel-example-cxf-osgi and it looks like all you really have
to do is remove the standalone jetty HTTP(s) listener and then provide your
address as a relative path in your Camel CXF bean.  Just remove the protocol
and host.

Here are a few observations.  It seems like you need to have a Jetty bean
set up to perform unit tests or have a ServiceMix instance running with the
jetty port running.  The jetty bean looks like:

	<httpj:engine-factory id="httpsSettings"
		bus="cxf">
		<httpj:engine port="8888">
			<httpj:tlsServerParameters>
				<sec:keyManagers keyPassword="password">
					<sec:keyStore type="jks" password="password" file="keystore.jks" />
				</sec:keyManagers>
				<sec:cipherSuitesFilter>
					    <sec:include>TLS_DHE_RSA_WITH_AES_128_CBC_SHA</sec:include>
					    <sec:include>SSL_DHE_RSA_WITH_3DES_EDE_CBC_SHA</sec:include>
					    <sec:include>TLS_RSA_WITH_AES_128_CBC_SHA</sec:include>
					    <sec:include>SSL_RSA_WITH_3DES_EDE_CBC_SHA</sec:include>
				</sec:cipherSuitesFilter>
				<sec:clientAuthentication want="false"
					required="false" />
			</httpj:tlsServerParameters>
		</httpj:engine>
	</httpj:engine-factory> 

You can include this jetty bean under src/test/resources as your build
process allows.

It also appears as if all urls require 'cxf' in the path.  For the camel
example, the URL is:

http://localhost:8181/cxf/camel-example-cxf-osgi/webservices/incident?wsdl

There is a reference in the documentation to editing this so you can set
your own property:

Changing /cxf servlet alias
---------------------------
By default CXF Servlet is assigned a '/cxf' alias. You can
change it in a couple of ways

a. Add org.apache.cxf.osgi.cfg to the /etc directory and set
   the 'org.apache.cxf.servlet.context' property, for example:
   
     org.apache.cxf.servlet.context=/custom
   
b. Use shell config commands, for example :
   
     config:edit org.apache.cxf.osgi   
     config:propset org.apache.cxf.servlet.context /super
     config:update

To remove 'http' and only provide a secure port, comment out this line:

#org.osgi.service.http.port=8181

Hopefully this is helpful to someone who visits this thread later.

Thanks!
Yogesh





--
View this message in context: http://camel.465427.n5.nabble.com/Problem-with-multiple-CXF-services-using-the-same-https-port-tp3379301p5762271.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Problem with multiple CXF services using the same https port

Posted by ychawla <pr...@gmail.com>.
Hi Christian,
Can you provide an example of how to set this up?  The situation I have is
this, which I think is the exact same as you describe.

I have a central broker server on it with many different bundles:

bundle A
bundle B
bundle C

Each bundle hosts a web service with a distinct WSDL and schema.  Rather
than host each bundle on a different port which creates a firewall
nightmare, we want to set up a single port and host all service on it.

I updated my pax config file like this:

org.osgi.service.http.secure.enabled=true
org.ops4j.pax.web.ssl.keystore=etc/my-keystore.jks
org.ops4j.pax.web.ssl.password=my-keystore
org.ops4j.pax.web.ssl.keypassword=my-key
org.osgi.service.http.port.secure=8443
org.ops4j.pax.web.config.file=etc/jetty.xml
org.osgi.service.http.port=8181
javax.servlet.context.tempdir=data/pax-web-jsp

I installed the 'http' feature in ServiceMix and can see this page in a
browser served up by Jetty:

https://localhost:8443/

In my camel bundle, I set up a CXF endpoint with a URL like this:

https://localhost:8443/MyService

However, I can not start up my service in a simple Camel Context in a unit
test and I get an error like this:

java.lang.IllegalStateException: Port 8443 is configured with wrong protocol
"http" for "https://localhost:8443/MyService"

My understanding is that I should set up my CXF endpoint as usual and then
remove the embedded Jetty instance.   That way the bundle doesn't attempt to
start a standalone instance of Jetty.  Originally in standalone mode i used
a bean like this:

	<httpj:engine-factory id="MyHttpsSettings"
		bus="cxf">

Any ideas of how I can set up multiple bundles in the same SMX instance that
use different WSDLs / schemas on the same port?

Thanks!
Yogesh



--
View this message in context: http://camel.465427.n5.nabble.com/Problem-with-multiple-CXF-services-using-the-same-https-port-tp3379301p5762264.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Problem with multiple CXF services using the same https port

Posted by Daniel Kulp <dk...@apache.org>.
On Thursday, February 09, 2012 5:47:09 AM snatera wrote:
> Hello Dan!
> 
> Thanks for taking your time to reply to me.
> 
> In this link Fuse Source explains the way that I implemented:
> http://fusesource.com/docs/esb/4.3/cxf_security/HTTPCompatible.html#i488847

Nice of them to promote the use of generally bad ideas...   :-(


> I was trying to use <import resource="classpath:META-INF/cxf/cxf.xml" />
> before, but I had this Exception:
> 
> -- Exception in thread "SpringOsgiExtenderThread-29"
> org.springframework.beans.factory.CannotLoadBeanClassException: Cannot find
> class [org.apache.cxf.bus.spring.SpringBus] for bean with name 'cxf' defined
> in OSGi
> resource[classpath:META-INF/cxf/cxf.xml|bnd.id=219|bnd.sym=cnti-sw-dev-https
> ]; nested exception is java.lang.ClassNotFoundException:
> org.apache.cxf.bus.spring.SpringBus not found from bundle [my-bundle] --

You likely need to either add some imports (org.apache.cxf.bus.spring) or add 
a "Require-Bundle: org.apache.cxf.bundle" header to the manifest.    
Definitely one of the more annoying things about spring-dm.

 
> And.. if I do this <cxf:bus name="cxf"/> I get this Exception:
> 
>  --  org.springframework.beans.factory.xml.XmlBeanDefinitionStoreException:
> Line 24 in XML document from URL
> [bundle://219.29:0/META-INF/spring/beans.xml] is invalid; nested exception
> is org.xml.sax.SAXParseException: cvc-complex-type.2.4.c: The matching
> wildcard is strict, but no declaration can be found for element 'cxf:bus'.

This is easier....  You need to update the schemaLocation attribute on the 
root beans to add 

"http://cxf.apache.org/core http://cxf.apache.org/schemas/core.xsd"

to the list of namespaces to map to a schema for validation purposes.

Dan



> --
> 
> What can I do to solve this?
> Thanks a lot,
> 
> --
> View this message in context:
> http://camel.465427.n5.nabble.com/Problem-with-multiple-CXF-services-using-
> the-same-https-port-tp3379301p5469462.html Sent from the Camel - Users
> mailing list archive at Nabble.com.
-- 
Daniel Kulp
dkulp@apache.org - http://dankulp.com/blog
Talend Community Coder - http://coders.talend.com

Re: Problem with multiple CXF services using the same https port

Posted by Willem Jiang <wi...@gmail.com>.
As Dan suggested, CXF already does some hacking itself to setup a right 
class loader.
You don't need to import lots of CXF related package in your bundle.

On Thu Feb  9 03:25:38 2012, Daniel Kulp wrote:
> On Wednesday, February 08, 2012 11:10:35 AM snatera wrote:
>>   I could solve the last post, where I mention the Exception about 'cxf'
>> bean.
>>
>> In your beans.xml or camel-config.xml you have to put this source:
>>
>>          <bean id="cxf" class="org.apache.cxf.bus.CXFBusImpl"/>
>
> Please do not do that.   That's a surefire way to make sure you'll have
> configuration issues, strange errors, and issues upgrading to newer versions
> of CXF.
>
> Just import:
> <import resource="classpath:META-INF/cxf/cxf.xml" />
>
> or do a:
>
> <cxf:bus name="cxf"/>
>
> And let CXF setup the bus.  CXFBusImpl is not spring aware and is also not
> even CXF extension aware.  Thus, it's quite likely that nothing using that bus
> will even work.
>
>
> Dan
>
>
>
>>
>> Then, go to pom.xml and put this dependendy and this import:
>>
>> Dependency:
>>
>>          <dependency>
>>              <groupId>org.apache.camel</groupId>
>>              <artifactId>camel-cxf</artifactId>
>>              <version>${camel.version}</version>
>>          </dependency>
>>
>> Import:
>>
>>          <Import-Package>
>>                  ...,
>>                  org.apache.cxf.bus
>>          </Import-Package>
>>
>>
>> This way I could solve it.
>>
>> --
>> View this message in context:
>> http://camel.465427.n5.nabble.com/Problem-with-multiple-CXF-services-using-
>> the-same-https-port-tp3379301p5467423.html Sent from the Camel - Users
>> mailing list archive at Nabble.com.



-- 
Willem
----------------------------------
FuseSource
Web: http://www.fusesource.com
Blog:    http://willemjiang.blogspot.com (English)
         http://jnn.javaeye.com (Chinese)
Twitter: willemjiang 
Weibo: willemjiang 


Re: Problem with multiple CXF services using the same https port

Posted by snatera <sn...@divux.com>.
Hello Dan!

Thanks for taking your time to reply to me.

In this link Fuse Source explains the way that I implemented:
http://fusesource.com/docs/esb/4.3/cxf_security/HTTPCompatible.html#i488847

I was trying to use <import resource="classpath:META-INF/cxf/cxf.xml" />
before, but I had this Exception: 

-- Exception in thread "SpringOsgiExtenderThread-29"
org.springframework.beans.factory.CannotLoadBeanClassException: Cannot find
class [org.apache.cxf.bus.spring.SpringBus] for bean with name 'cxf' defined
in OSGi
resource[classpath:META-INF/cxf/cxf.xml|bnd.id=219|bnd.sym=cnti-sw-dev-https];
nested exception is java.lang.ClassNotFoundException:
org.apache.cxf.bus.spring.SpringBus not found from bundle [my-bundle] --

And.. if I do this <cxf:bus name="cxf"/> I get this Exception:

 --  org.springframework.beans.factory.xml.XmlBeanDefinitionStoreException:
Line 24 in XML document from URL
[bundle://219.29:0/META-INF/spring/beans.xml] is invalid; nested exception
is org.xml.sax.SAXParseException: cvc-complex-type.2.4.c: The matching
wildcard is strict, but no declaration can be found for element 'cxf:bus'.
--

What can I do to solve this? 
Thanks a lot,

--
View this message in context: http://camel.465427.n5.nabble.com/Problem-with-multiple-CXF-services-using-the-same-https-port-tp3379301p5469462.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Problem with multiple CXF services using the same https port

Posted by Daniel Kulp <dk...@apache.org>.
On Wednesday, February 08, 2012 11:10:35 AM snatera wrote:
>  I could solve the last post, where I mention the Exception about 'cxf'
> bean.
> 
> In your beans.xml or camel-config.xml you have to put this source:
> 
>         <bean id="cxf" class="org.apache.cxf.bus.CXFBusImpl"/>

Please do not do that.   That's a surefire way to make sure you'll have 
configuration issues, strange errors, and issues upgrading to newer versions 
of CXF.

Just import:
<import resource="classpath:META-INF/cxf/cxf.xml" />

or do a:

<cxf:bus name="cxf"/>

And let CXF setup the bus.  CXFBusImpl is not spring aware and is also not 
even CXF extension aware.  Thus, it's quite likely that nothing using that bus 
will even work.   


Dan



> 
> Then, go to pom.xml and put this dependendy and this import:
> 
> Dependency:
> 
>         <dependency>
>             <groupId>org.apache.camel</groupId>
>             <artifactId>camel-cxf</artifactId>
>             <version>${camel.version}</version>
>         </dependency>
> 
> Import:
> 
>         <Import-Package>
>                 ...,
>                 org.apache.cxf.bus
>         </Import-Package>
> 
> 
> This way I could solve it.
> 
> --
> View this message in context:
> http://camel.465427.n5.nabble.com/Problem-with-multiple-CXF-services-using-
> the-same-https-port-tp3379301p5467423.html Sent from the Camel - Users
> mailing list archive at Nabble.com.
-- 
Daniel Kulp
dkulp@apache.org - http://dankulp.com/blog
Talend Community Coder - http://coders.talend.com

Re: Problem with multiple CXF services using the same https port

Posted by snatera <sn...@divux.com>.
 I could solve the last post, where I mention the Exception about 'cxf' bean.

In your beans.xml or camel-config.xml you have to put this source:

        <bean id="cxf" class="org.apache.cxf.bus.CXFBusImpl"/>

Then, go to pom.xml and put this dependendy and this import:

Dependency:

        <dependency>
            <groupId>org.apache.camel</groupId>
            <artifactId>camel-cxf</artifactId>
            <version>${camel.version}</version>
        </dependency>

Import:

        <Import-Package>
                ...,
                org.apache.cxf.bus
        </Import-Package>


This way I could solve it.

--
View this message in context: http://camel.465427.n5.nabble.com/Problem-with-multiple-CXF-services-using-the-same-https-port-tp3379301p5467423.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Problem with multiple CXF services using the same https port

Posted by snatera <sn...@divux.com>.
 Thank you for share this link.

I have a Exception with this example, it's about Bus attribute in
httpj:engine-factory element, the example defined it this way
httpj:engine-factory bus="cxf", but when I install this bundle in
fuse-esb-servicemix I have this exception:

-- Error creating bean with name
'org.apache.cxf.transport.http_jetty.JettyHTTPServerEngineFactory': Cannot
resolve reference to bean 'cxf' while setting constructor argument; nested
exception is
org.springframework.beans.factory.NoSuchBeanDefinitionException: No bean
named 'cxf' is defined --

This exception has some logic, but in the example, they don't define a 'cxf'
bean. 
Could you help me what do I have to do in this case?

--
View this message in context: http://camel.465427.n5.nabble.com/Problem-with-multiple-CXF-services-using-the-same-https-port-tp3379301p5466997.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Problem with multiple CXF services using the same https port

Posted by "Moulliard, Charles" <cm...@fusesource.com>.
Hi,

You can follow instructions explained here :

http://fusesource.com/docs/esb/4.4.1/esb_security/CamelCXF-SecureProxy.html

Regards,

Charles

On Mon, Feb 6, 2012 at 8:31 PM, snatera <sn...@divux.com> wrote:

> Hi cristian,
>
> I am working with apache camel and i would like to configure https in the
> route.
> can you help me with this?
>
> This is my beans.xml:
>
> <beans xmlns="http://www.springframework.org/schema/beans"
>    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
>    xmlns:cxf="http://camel.apache.org/schema/cxf"
>
> xmlns:cc="
> http://www.cnti.gob.ve/servicio/ServicioDirectorioEstadoVenezolano"
>     xsi:schemaLocation="
>        http://www.springframework.org/schema/beans
>        http://www.springframework.org/schema/beans/spring-beans.xsd
>         http://camel.apache.org/schema/spring
>        http://camel.apache.org/schema/spring/camel-spring.xsd
>        http://camel.apache.org/schema/cxf
>        http://camel.apache.org/schema/cxf/camel-cxf.xsd
>    ">
>
>    <cxf:cxfEndpoint id="servicio_web_bus"
> address="http://localhost:9003/servicios"
>        wsdlURL="ServicioDirectorioEstadoVenezolano.wsdl"
>        serviceName="cc:ServicioDirectorioEstadoVenezolano"
> endpointName="cc:ServicioDirectorioEstadoVenezolanoUbicacion">
>         <cxf:properties>
>                      <entry key="dataFormat" value="MESSAGE"/>
>             </cxf:properties>
>    </cxf:cxfEndpoint>
>
>    <cxf:cxfEndpoint id="servicio_web"
> address="
> http://192.168.0.128:8080/cnti_servicios/ServicioDirectorioEstadoVenezolano
> "
>         wsdlURL="ServicioDirectorioEstadoVenezolano.wsdl"
>         serviceName="cc:ServicioDirectorioEstadoVenezolano"
> endpointName="cc:ServicioDirectorioEstadoVenezolanoUbicacion">
>          <cxf:properties>
>                      <entry key="dataFormat" value="MESSAGE"/>
>              </cxf:properties>
>    </cxf:cxfEndpoint>
>
>    <camelContext id="converter"
> xmlns="http://camel.apache.org/schema/spring" >
>        <route streamCache="true">
>            <from uri="cxf:bean:servicio_web_bus" />
>            <to uri="cxf:bean:servicio_web" />
>        </route>
>    </camelContext>
>
> </beans>
>
> I hope for your response.
>
> Thank you
>
>
>
> --
> View this message in context:
> http://camel.465427.n5.nabble.com/Problem-with-multiple-CXF-services-using-the-same-https-port-tp3379301p5461039.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
>



-- 
-- 
*Charles Moulliard*
Sr. Principal Consultant  | *FuseSource Corp.*
cmoulliard@fusesource.com | fusesource.com
*mobile: *+32 473 604 014
skype: cmoulliard | twitter: @cmoulliard
blog:  cmoulliard.blogspot.com


 <http://www.progress.com/>

Re: Problem with multiple CXF services using the same https port

Posted by snatera <sn...@divux.com>.
Hi cristian,

I am working with apache camel and i would like to configure https in the
route.
can you help me with this?

This is my beans.xml:

<beans xmlns="http://www.springframework.org/schema/beans"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns:cxf="http://camel.apache.org/schema/cxf"
   
xmlns:cc="http://www.cnti.gob.ve/servicio/ServicioDirectorioEstadoVenezolano"
    xsi:schemaLocation="
        http://www.springframework.org/schema/beans
        http://www.springframework.org/schema/beans/spring-beans.xsd
        http://camel.apache.org/schema/spring
        http://camel.apache.org/schema/spring/camel-spring.xsd
        http://camel.apache.org/schema/cxf
        http://camel.apache.org/schema/cxf/camel-cxf.xsd
    ">

    <cxf:cxfEndpoint id="servicio_web_bus"
address="http://localhost:9003/servicios"
        wsdlURL="ServicioDirectorioEstadoVenezolano.wsdl"
        serviceName="cc:ServicioDirectorioEstadoVenezolano"
endpointName="cc:ServicioDirectorioEstadoVenezolanoUbicacion">
         <cxf:properties>
		      <entry key="dataFormat" value="MESSAGE"/>
  	     </cxf:properties> 
    </cxf:cxfEndpoint> 

    <cxf:cxfEndpoint id="servicio_web"
address="http://192.168.0.128:8080/cnti_servicios/ServicioDirectorioEstadoVenezolano"
         wsdlURL="ServicioDirectorioEstadoVenezolano.wsdl"
         serviceName="cc:ServicioDirectorioEstadoVenezolano"
endpointName="cc:ServicioDirectorioEstadoVenezolanoUbicacion">
          <cxf:properties>
		      <entry key="dataFormat" value="MESSAGE"/>
	      </cxf:properties>
    </cxf:cxfEndpoint>
	
    <camelContext id="converter"
xmlns="http://camel.apache.org/schema/spring" >
        <route streamCache="true">
            <from uri="cxf:bean:servicio_web_bus" />
            <to uri="cxf:bean:servicio_web" /> 
        </route>
    </camelContext>

</beans>

I hope for your response.

Thank you



--
View this message in context: http://camel.465427.n5.nabble.com/Problem-with-multiple-CXF-services-using-the-same-https-port-tp3379301p5461039.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Problem with multiple CXF services using the same https port

Posted by Christian Mueller <ch...@gmail.com>.
Thank you all for your help on this example.
I think this is a very useful feature for all people which use excessive
camel-cxf in multiple different bundles (like we). Without this (and we did
it in the past), we have to choose a different port for each web service we
provided and we had to duplicate the SSL configuration for each service.
Now, it's much more easier to configure and maintain. We only have to
configure PAX WEB in org.ops4j.pax.web.cfg and everything is done.

Thank you again,
Christian

P.S.: Ade, may be a good topic for a further webinar about CXF? ;o)


--
View this message in context: http://camel.465427.n5.nabble.com/Problem-with-multiple-CXF-services-using-the-same-https-port-tp3379301p4296566.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Problem with multiple CXF services using the same https port

Posted by Willem Jiang <wi...@gmail.com>.
Hi Charles,

You can use patch -p1 < patch to apply the patch which is generated by git.
BTW, I'm working on the patch now.

Willem

On 4/11/11 2:46 PM, Moulliard, Charles wrote:
> Hi Christian,
>
> Can you send us your maven project as I do not use now GIT repo for camel
> and cannot apply your patch to build the project using subversion ?
>
> Regards,
>
> Charles
>
> On Fri, Apr 8, 2011 at 11:32 PM, Christian Müller<
> christian.mueller@gmail.com>  wrote:
>
>> Hello Ade, Willem, Charles,
>>
>> I updated https://issues.apache.org/jira/browse/CAMEL-3756. May be you
>> could
>> have a look on it. I have a problem with deploying it into ServiceMix
>> 4.3.1-fuse-01-09. With ServiceMix 4.2.0-fuse-02-00 everything works as
>> expected.
>>
>> Cheers,
>> Christian
>>
>
>
>


-- 
Willem
----------------------------------
FuseSource
Web: http://www.fusesource.com
Blog:    http://willemjiang.blogspot.com (English)
          http://jnn.javaeye.com (Chinese)
Twitter: willemjiang

Connect at CamelOne May 24-26
The Open Source Integration Conference
http://camelone.com

Re: Problem with multiple CXF services using the same https port

Posted by "Moulliard, Charles" <cm...@fusesource.com>.
Hi Christian,

Can you send us your maven project as I do not use now GIT repo for camel
and cannot apply your patch to build the project using subversion ?

Regards,

Charles

On Fri, Apr 8, 2011 at 11:32 PM, Christian Müller <
christian.mueller@gmail.com> wrote:

> Hello Ade, Willem, Charles,
>
> I updated https://issues.apache.org/jira/browse/CAMEL-3756. May be you
> could
> have a look on it. I have a problem with deploying it into ServiceMix
> 4.3.1-fuse-01-09. With ServiceMix 4.2.0-fuse-02-00 everything works as
> expected.
>
> Cheers,
> Christian
>



-- 
-- 
Charles Moulliard - Sr. Principal Solution Architect
FuseSource
Phone: +32 473 604 014
Email: cmoulliard@fusesource.com
Web: http://cmoulliard.blogspot.com, http://fusesource.com
Twitter: cmoulliard


 <http://www.progress.com/>