Discussion:
"No bean named 'cxf' is defined" when trying to configure Jetty
James Talbut
2012-08-20 14:41:33 UTC
Permalink
Hi,

I'm getting the "No bean named 'cxf' is defined" error when trying to configure Jetty for my CXF service using a named bus.
The Spring config file (trimmed to what I hope is relevant parts is):
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:aop="http://www.springframework.org/schema/aop"
xmlns:tx="http://www.springframework.org/schema/tx"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:osgi="http://www.springframework.org/schema/osgi"
xmlns:cxf="http://cxf.apache.org/core"
xmlns:jaxws="http://cxf.apache.org/jaxws"
xmlns:jee="http://www.springframework.org/schema/jee"
xmlns:camel="http://camel.apache.org/schema/spring"
xmlns:camel-cxf="http://camel.apache.org/schema/cxf"
xmlns:http="http://cxf.apache.org/transports/http/configuration"
xmlns:httpj="http://cxf.apache.org/transports/http-jetty/configuration"
xmlns:sec="http://cxf.apache.org/configuration/security"
xsi:schemaLocation="
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.5.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.0.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-2.5.xsd
http://www.springframework.org/schema/jee http://www.springframework.org/schema/jee/spring-jee-2.5.xsd
http://www.springframework.org/schema/osgi http://www.springframework.org/schema/osgi/spring-osgi.xsd
http://cxf.apache.org/core http://cxf.apache.org/schemas/core.xsd
http://cxf.apache.org/jaxws http://cxf.apache.org/schemas/jaxws.xsd
http://cxf.apache.org/configuration/security http://cxf.apache.org/schemas/configuration/security.xsd
http://cxf.apache.org/transports/http/configuration http://cxf.apache.org/schemas/configuration/http-conf.xsd
http://cxf.apache.org/transports/http-jetty/configuration http://cxf.apache.org/schemas/configuration/http-jetty.xsd
http://cxf.apache.org/configuration/security http://cxf.apache.org/schemas/configuration/security.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
">

...

<bean id="CounterRepository" class="org.apache.cxf.management.counters.CounterRepository">
<property name="bus" ref="online-tests" />
</bean>

<cxf:bus name="online-tests" id="online-tests" >
<cxf:inInterceptors>
<ref bean="cxfInboundLoggingInterceptor" />
</cxf:inInterceptors>
<cxf:outInterceptors>
<ref bean="cxfOutboundLoggingInterceptor" />
</cxf:outInterceptors>
<cxf:outFaultInterceptors>
<ref bean="cxfOutboundLoggingInterceptor" />
</cxf:outFaultInterceptors>
</cxf:bus>

<httpj:engine-factory bus="online-tests" >
<httpj:engine port="8017" >
<httpj:threadingParameters minThreads="10" maxThreads="50" />
</httpj:engine>
</httpj:engine-factory>

<jaxws:endpoint id="targetProxy" implementor="#coreService" address="http://0.0.0.0:12345/OnlineTests" bus="online-tests">
<jaxws:properties>
</jaxws:properties>
</jaxws:endpoint>

<jaxws:client id="clientTest"
serviceClass="net.groupgti.olt._1_0.OnlineTestsPortType"
address="http://127.0.0.1:12345/OnlineTests"
bus="online-tests" />

</beans>


I've tried playing around with the bus name, id and "bus" attribute, but I can't get rid of the error (except by removing the engine-factory element).
Interestingly if I change the bus attribute on the engine-factory element to something that doesn't exist I get the nonexistent name in the error message.

How can I configure the maximum thread pool size?

Thanks

Jim
James Talbut
2012-08-21 08:18:55 UTC
Permalink
Hi Again,

I have a theory, based on an incomplete understanding of how Spring extensions work :)

The bus attribute on the JettyHTTPServerEngineFactoryConfigType complex type is defined as:
<xs:attribute name="bus" type="xs:string" default="cxf"/>

If this default is applied by Spring before it applies my custom value it would explain the behaviour I'm seeing:
If I just have the engine-factory config I get a "No bean named 'cxf'" error.
If I add the import for "classpath:META-INF/cxf/cxf.xml" I get an assertion from setBus: assert this.bus == null || this.bus == bus;

Which means it's impossible to use a custom bus with the JettyHTTPServerEngineFactoryConfigType.



Secondary question: do I need to have a custom bus?
I have an OSGi container that has many different CXF buses in it, but not usually more than one per bundle.
What is the scope of a bus?
Can I just use the normal "cxf" bus with a custom "id" to differentiate them?

Jim
Post by James Talbut
Hi,
I'm getting the "No bean named 'cxf' is defined" error when trying to configure Jetty for my CXF service using a named bus.
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:aop="http://www.springframework.org/schema/aop"
xmlns:tx="http://www.springframework.org/schema/tx"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:osgi="http://www.springframework.org/schema/osgi"
xmlns:cxf="http://cxf.apache.org/core"
xmlns:jaxws="http://cxf.apache.org/jaxws"
xmlns:jee="http://www.springframework.org/schema/jee"
xmlns:camel="http://camel.apache.org/schema/spring"
xmlns:camel-cxf="http://camel.apache.org/schema/cxf"
xmlns:http="http://cxf.apache.org/transports/http/configuration"
xmlns:httpj="http://cxf.apache.org/transports/http-jetty/configuration"
xmlns:sec="http://cxf.apache.org/configuration/security"
xsi:schemaLocation="
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.5.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.0.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-2.5.xsd
http://www.springframework.org/schema/jee http://www.springframework.org/schema/jee/spring-jee-2.5.xsd
http://www.springframework.org/schema/osgi http://www.springframework.org/schema/osgi/spring-osgi.xsd
http://cxf.apache.org/core http://cxf.apache.org/schemas/core.xsd
http://cxf.apache.org/jaxws http://cxf.apache.org/schemas/jaxws.xsd
http://cxf.apache.org/configuration/security http://cxf.apache.org/schemas/configuration/security.xsd
http://cxf.apache.org/transports/http/configuration http://cxf.apache.org/schemas/configuration/http-conf.xsd
http://cxf.apache.org/transports/http-jetty/configuration http://cxf.apache.org/schemas/configuration/http-jetty.xsd
http://cxf.apache.org/configuration/security http://cxf.apache.org/schemas/configuration/security.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
">
...
<bean id="CounterRepository" class="org.apache.cxf.management.counters.CounterRepository">
<property name="bus" ref="online-tests" />
</bean>
<cxf:bus name="online-tests" id="online-tests" >
<cxf:inInterceptors>
<ref bean="cxfInboundLoggingInterceptor" />
</cxf:inInterceptors>
<cxf:outInterceptors>
<ref bean="cxfOutboundLoggingInterceptor" />
</cxf:outInterceptors>
<cxf:outFaultInterceptors>
<ref bean="cxfOutboundLoggingInterceptor" />
</cxf:outFaultInterceptors>
</cxf:bus>
<httpj:engine-factory bus="online-tests" >
<httpj:engine port="8017" >
<httpj:threadingParameters minThreads="10" maxThreads="50" />
</httpj:engine>
</httpj:engine-factory>
<jaxws:endpoint id="targetProxy" implementor="#coreService" address="http://0.0.0.0:12345/OnlineTests" bus="online-tests">
<jaxws:properties>
</jaxws:properties>
</jaxws:endpoint>
<jaxws:client id="clientTest"
serviceClass="net.groupgti.olt._1_0.OnlineTestsPortType"
address="http://127.0.0.1:12345/OnlineTests"
bus="online-tests" />
</beans>
I've tried playing around with the bus name, id and "bus" attribute, but I can't get rid of the error (except by removing the engine-factory element).
Interestingly if I change the bus attribute on the engine-factory element to something that doesn't exist I get the nonexistent name in the error message.
How can I configure the maximum thread pool size?
Thanks
Jim
Daniel Kulp
2012-08-21 18:13:43 UTC
Permalink
This sounds like a bug in the spring code. I was going to suggest trying blueprint, but that code doesn't look like it's setting the bus at all on the JettyServerEngineFactory. :-(

That said, I'm not even sure the Bus is needed in this case as the individual ports are held in a static since they have to be shared.

Finally, if using OSGi and CXF 2.6.x, it might be better to remove these configs from the app bundles and use config:admin/files in etc to configure these. Since the port numbers are "shared", it would be whichever bundle starts something on that port first is the one that has the configuration that would "win". Removing that configuration from the apps and allowing the administrator to configure that may make some sense.

Assuming Karaf style etc dir and file based config:admin, create a file like:
etc/org.apache.cxf.http.jetty-8017.cfg

port=8017
threadingParameters.minThreads=10
threadingParameters.maxThreads=50


Dan
Post by James Talbut
Hi Again,
I have a theory, based on an incomplete understanding of how Spring extensions work :)
<xs:attribute name="bus" type="xs:string" default="cxf"/>
If I just have the engine-factory config I get a "No bean named 'cxf'" error.
If I add the import for "classpath:META-INF/cxf/cxf.xml" I get an assertion from setBus: assert this.bus == null || this.bus == bus;
Which means it's impossible to use a custom bus with the JettyHTTPServerEngineFactoryConfigType.
Secondary question: do I need to have a custom bus?
I have an OSGi container that has many different CXF buses in it, but not usually more than one per bundle.
What is the scope of a bus?
Can I just use the normal "cxf" bus with a custom "id" to differentiate them?
Jim
Post by James Talbut
Hi,
I'm getting the "No bean named 'cxf' is defined" error when trying to configure Jetty for my CXF service using a named bus.
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:aop="http://www.springframework.org/schema/aop"
xmlns:tx="http://www.springframework.org/schema/tx"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:osgi="http://www.springframework.org/schema/osgi"
xmlns:cxf="http://cxf.apache.org/core"
xmlns:jaxws="http://cxf.apache.org/jaxws"
xmlns:jee="http://www.springframework.org/schema/jee"
xmlns:camel="http://camel.apache.org/schema/spring"
xmlns:camel-cxf="http://camel.apache.org/schema/cxf"
xmlns:http="http://cxf.apache.org/transports/http/configuration"
xmlns:httpj="http://cxf.apache.org/transports/http-jetty/configuration"
xmlns:sec="http://cxf.apache.org/configuration/security"
xsi:schemaLocation="
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.5.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.0.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-2.5.xsd
http://www.springframework.org/schema/jee http://www.springframework.org/schema/jee/spring-jee-2.5.xsd
http://www.springframework.org/schema/osgi http://www.springframework.org/schema/osgi/spring-osgi.xsd
http://cxf.apache.org/core http://cxf.apache.org/schemas/core.xsd
http://cxf.apache.org/jaxws http://cxf.apache.org/schemas/jaxws.xsd
http://cxf.apache.org/configuration/security http://cxf.apache.org/schemas/configuration/security.xsd
http://cxf.apache.org/transports/http/configuration http://cxf.apache.org/schemas/configuration/http-conf.xsd
http://cxf.apache.org/transports/http-jetty/configuration http://cxf.apache.org/schemas/configuration/http-jetty.xsd
http://cxf.apache.org/configuration/security http://cxf.apache.org/schemas/configuration/security.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
">
...
<bean id="CounterRepository" class="org.apache.cxf.management.counters.CounterRepository">
<property name="bus" ref="online-tests" />
</bean>
<cxf:bus name="online-tests" id="online-tests" >
<cxf:inInterceptors>
<ref bean="cxfInboundLoggingInterceptor" />
</cxf:inInterceptors>
<cxf:outInterceptors>
<ref bean="cxfOutboundLoggingInterceptor" />
</cxf:outInterceptors>
<cxf:outFaultInterceptors>
<ref bean="cxfOutboundLoggingInterceptor" />
</cxf:outFaultInterceptors>
</cxf:bus>
<httpj:engine-factory bus="online-tests" >
<httpj:engine port="8017" >
<httpj:threadingParameters minThreads="10" maxThreads="50" />
</httpj:engine>
</httpj:engine-factory>
<jaxws:endpoint id="targetProxy" implementor="#coreService" address="http://0.0.0.0:12345/OnlineTests" bus="online-tests">
<jaxws:properties>
</jaxws:properties>
</jaxws:endpoint>
<jaxws:client id="clientTest"
serviceClass="net.groupgti.olt._1_0.OnlineTestsPortType"
address="http://127.0.0.1:12345/OnlineTests"
bus="online-tests" />
</beans>
I've tried playing around with the bus name, id and "bus" attribute, but I can't get rid of the error (except by removing the engine-factory element).
Interestingly if I change the bus attribute on the engine-factory element to something that doesn't exist I get the nonexistent name in the error message.
How can I configure the maximum thread pool size?
Thanks
Jim
--
Daniel Kulp
dkulp-1oDqGaOF3Lkdnm+***@public.gmane.org - http://dankulp.com/blog
Talend Community Coder - http://coders.talend.com
Jim Talbut
2012-08-21 19:29:52 UTC
Permalink
Post by Daniel Kulp
etc/org.apache.cxf.http.jetty-8017.cfg
port=8017
threadingParameters.minThreads=10
threadingParameters.maxThreads=50
Ooh, I didn't know I could do that!
Specifically I didn't know Jetty would pick up OSGi config properties
and I didn't know I could just create property files with any old subname.

Is there any way to work around the bug from the CXF side? Is it so bad
if the bus is set more than once (before some other event takes place)?

Thanks.

What I've done in the mean time is to revert to having a bus named cxf
but with a custom ID, which works.

Jim
Daniel Kulp
2012-08-21 19:58:46 UTC
Permalink
Post by Jim Talbut
Post by Daniel Kulp
etc/org.apache.cxf.http.jetty-8017.cfg
port=8017
threadingParameters.minThreads=10
threadingParameters.maxThreads=50
Ooh, I didn't know I could do that!
Specifically I didn't know Jetty would pick up OSGi config properties and I didn't know I could just create property files with any old sub name.
Well, it's not quite THAT simpleā€¦. :-)

This is a feature I added to the CXF Jetty transport (2.6.x) to benefit the Talend ESB users around configuring the Jetty stuff. (there is a similar thing for the http-conduits BTW). It's not really looking for files. It's asking the config:admin service for stuff for the "org.apache.cxf.http.jetty" service. It's a factory based service to the file based admin stuff has the filename of "org.apache.cxf.http.jetty-SOMETHING.cfg" where SOMETHING really could be anything. I like to use either the port name (in this case) or the host name (like localhost) for the conduit cases. If you use the config:admin commands from the Karaf command line, it would name it something completely different. In any case, the config:admin service will hand us a Properties object of the properties in that file. We then loop through the properties and set the various config items. You can look at the code at:

http://svn.apache.org/repos/asf/cxf/trunk/rt/transports/http-jetty/src/main/java/org/apache/cxf/transport/http_jetty/osgi/HTTPJettyTransportActivator.java

if you want. You should be able to set the same things via normal config:admin commands as well.
Post by Jim Talbut
Is there any way to work around the bug from the CXF side? Is it so bad if the bus is set more than once (before some other event takes place)?
Since these things are static, having any bus (even the "cxf" bus) would be fine. The config should be set up front and used by all the users of that since you can only have a single Jetty service per port.

Dan
Post by Jim Talbut
Thanks.
What I've done in the mean time is to revert to having a bus named cxf but with a custom ID, which works.
Jim
--
Daniel Kulp
dkulp-1oDqGaOF3Lkdnm+***@public.gmane.org - http://dankulp.com/blog
Talend Community Coder - http://coders.talend.com
James Talbut
2012-09-03 10:07:25 UTC
Permalink
Post by Daniel Kulp
This is a feature I added to the CXF Jetty transport (2.6.x) to benefit the Talend ESB users around configuring the Jetty stuff. (there is a similar thing for the http-conduits BTW). It's not really looking for files. It's asking the config:admin service for stuff for the "org.apache.cxf.http.jetty" service. It's a factory based service to the file based admin stuff has the filename of "org.apache.cxf.http.jetty-SOMETHING.cfg" where SOMETHING really could be anything. I like to use either the port name (in this case) or the host name (like localhost) for the conduit cases. If you use the config:admin commands from the Karaf command line, it would name it something completely different. In any case, the config:admin service will hand us a Properties object of the properties i
http://svn.apache.org/repos/asf/cxf/trunk/rt/transports/http-jetty/src/main/java/org/apache/cxf/transport/http_jetty/osgi/HTTPJettyTransportActivator.java
if you want. You should be able to set the same things via normal config:admin commands as well.
From looking at that there doesn't seem to be any way to set up Jetty handlers in an external file.
Is that true or have I missed something?

What I'd like to be able to do is set up the security configuration for a port in a single place.

Thanks

Jim
Daniel Kulp
2012-09-04 19:45:09 UTC
Permalink
Post by James Talbut
Post by Daniel Kulp
http://svn.apache.org/repos/asf/cxf/trunk/rt/transports/http-jetty/src/main/java/org/apache/cxf/transport/http_jetty/osgi/HTTPJettyTransportActivator.java
if you want. You should be able to set the same things via normal config:admin commands as well.
From looking at that there doesn't seem to be any way to set up Jetty handlers in an external file.
Is that true or have I missed something?
Not at this time, no. The major part of the problem involves the entire "class loading" issue in OSGi. If you stick a class name in the config file, we likely wouldn't be able to load it anyway since the CXF bundles wouldn't be importing the package of the handler. Christian and I tossed around some ideas of having an OSGi service name or something stuck in the config file and we grab the handler from the OSGi service registry that way, but that would require a little more work in CXF that we haven't had time for.

I'd certainly welcome any patches (likely to the above mentioned class as a starting point) to get that working.

Dan
Post by James Talbut
What I'd like to be able to do is set up the security configuration for a port in a single place.
Thanks
Jim
--
Daniel Kulp
dkulp-1oDqGaOF3Lkdnm+***@public.gmane.org - http://dankulp.com/blog
Talend Community Coder - http://coders.talend.com
Jim Talbut
2012-09-04 19:50:33 UTC
Permalink
Post by Daniel Kulp
Not at this time, no. The major part of the problem involves the entire "class loading" issue in OSGi. If you stick a class name in the config file, we likely wouldn't be able to load it anyway since the CXF bundles wouldn't be importing the package of the handler. Christian and I tossed around some ideas of having an OSGi service name or something stuck in the config file and we grab the handler from the OSGi service registry that way, but that would require a little more work in CXF that we haven't had time for.
I'd certainly welcome any patches (likely to the above mentioned class as a starting point) to get that working.
Dan
One option would be to define a CXF Jetty Handler Factory OSGi Service,
then the config file would just have to provide references to existing
services.
It's a bit irritating that Jetty handlers (though understandable) can
only be used in one context, so you can't just have the handler as a
service - and the factory would need some way to pass arguments to the
factory (we've found that all our handlers actually need some
configuration that is specific to the port they are handling).
That's essentially what we've done, but it's not generic and it wouldn't
be very easy to make it so :(

Jim

Loading...