Hi,
The more I think about it, this is likely a CXF question not a Camel
question. However, I am not a member of the CXF list and I suspect when
I say I am using the CXF version in Camel 2.12.3, I would end up here.
Apologies if I should not have posted here.
That being said, I have created several blueprint REST services that
respond with JSON using the default JSONProvider. I noticed one
response, a single item list, was not serialized as an array. Googling
this led me down the path of trying to configure the JSONProvider
directly which didn't work and several search results suggested that the
bug was already fixed back in 2009 in Jettison, but my results appear
different.
Here's what I have configured in my blueprint.xml:
<cxf:bus>
<cxf:features>
<cxf:logging/>
</cxf:features>
</cxf:bus>
<bean id="jsonProvider"
class="org.apache.cxf.jaxrs.provider.json.JSONProvider">
<property name="serializeAsArray" value="true"/>
<property name="arrayKeys">
<list>
<value>steps</value>
</list>
</property>
</bean>
<!-- Exported REST Services -->
<jaxrs:server address="/cdw/services/api/v2" id="servicesBeans">
<jaxrs:serviceBeans>
... (services)
</jaxrs:serviceBeans>
<jaxrs:providers>
<ref bean="jsonProvider"/>
</jaxrs:providers>
</jaxrs:server>
This produces the following error:
org.osgi.service.blueprint.container.ComponentDefinitionException:
Element ref must have a valid component-id attribute
at org.apache.aries.blueprint.parser.Parser.parseRef(Parser.java:1217)
at
org.apache.aries.blueprint.parser.Parser.parseValueGroup(Parser.java:1183)
at
org.apache.aries.blueprint.parser.Parser.parseCollection(Parser.java:740)
at org.apache.aries.blueprint.parser.Parser.parseElement(Parser.java:363)
at
org.apache.aries.blueprint.parser.ParserContextImpl.parseElement(ParserContextImpl.java:69)
at
org.apache.cxf.configuration.blueprint.AbstractBPBeanDefinitionParser.parseListData(AbstractBPBeanDefinitionParser.java:84)
at
org.apache.cxf.jaxrs.blueprint.JAXRSServerFactoryBeanDefinitionParser.mapElement(JAXRSServerFactoryBeanDefinitionParser.java:99)
at
org.apache.cxf.configuration.blueprint.AbstractBPBeanDefinitionParser.parseChildElements(AbstractBPBeanDefinitionParser.java:307)
at
org.apache.cxf.configuration.blueprint.SimpleBPBeanDefinitionParser.parse(SimpleBPBeanDefinitionParser.java:61)
at
org.apache.cxf.jaxrs.blueprint.JAXRSServerFactoryBeanDefinitionParser.parse(JAXRSServerFactoryBeanDefinitionParser.java:133)
at
org.apache.cxf.jaxrs.blueprint.JAXRSBPNamespaceHandler.parse(JAXRSBPNamespaceHandler.java:51)
at
org.apache.aries.blueprint.parser.Parser.parseCustomElement(Parser.java:1279)
at org.apache.aries.blueprint.parser.Parser.loadComponents(Parser.java:337)
at org.apache.aries.blueprint.parser.Parser.populate(Parser.java:277)
What is the correct way, using ServiceMix (5.0.0), Camel 2.12.3 and the
CXF version that is included in the Camel distribution, to configure the
JSONProvider to produce JSON of a single item list as an array?
I appreciate any input.
Thanks,
John
The more I think about it, this is likely a CXF question not a Camel
question. However, I am not a member of the CXF list and I suspect when
I say I am using the CXF version in Camel 2.12.3, I would end up here.
Apologies if I should not have posted here.
That being said, I have created several blueprint REST services that
respond with JSON using the default JSONProvider. I noticed one
response, a single item list, was not serialized as an array. Googling
this led me down the path of trying to configure the JSONProvider
directly which didn't work and several search results suggested that the
bug was already fixed back in 2009 in Jettison, but my results appear
different.
Here's what I have configured in my blueprint.xml:
<cxf:bus>
<cxf:features>
<cxf:logging/>
</cxf:features>
</cxf:bus>
<bean id="jsonProvider"
class="org.apache.cxf.jaxrs.provider.json.JSONProvider">
<property name="serializeAsArray" value="true"/>
<property name="arrayKeys">
<list>
<value>steps</value>
</list>
</property>
</bean>
<!-- Exported REST Services -->
<jaxrs:server address="/cdw/services/api/v2" id="servicesBeans">
<jaxrs:serviceBeans>
... (services)
</jaxrs:serviceBeans>
<jaxrs:providers>
<ref bean="jsonProvider"/>
</jaxrs:providers>
</jaxrs:server>
This produces the following error:
org.osgi.service.blueprint.container.ComponentDefinitionException:
Element ref must have a valid component-id attribute
at org.apache.aries.blueprint.parser.Parser.parseRef(Parser.java:1217)
at
org.apache.aries.blueprint.parser.Parser.parseValueGroup(Parser.java:1183)
at
org.apache.aries.blueprint.parser.Parser.parseCollection(Parser.java:740)
at org.apache.aries.blueprint.parser.Parser.parseElement(Parser.java:363)
at
org.apache.aries.blueprint.parser.ParserContextImpl.parseElement(ParserContextImpl.java:69)
at
org.apache.cxf.configuration.blueprint.AbstractBPBeanDefinitionParser.parseListData(AbstractBPBeanDefinitionParser.java:84)
at
org.apache.cxf.jaxrs.blueprint.JAXRSServerFactoryBeanDefinitionParser.mapElement(JAXRSServerFactoryBeanDefinitionParser.java:99)
at
org.apache.cxf.configuration.blueprint.AbstractBPBeanDefinitionParser.parseChildElements(AbstractBPBeanDefinitionParser.java:307)
at
org.apache.cxf.configuration.blueprint.SimpleBPBeanDefinitionParser.parse(SimpleBPBeanDefinitionParser.java:61)
at
org.apache.cxf.jaxrs.blueprint.JAXRSServerFactoryBeanDefinitionParser.parse(JAXRSServerFactoryBeanDefinitionParser.java:133)
at
org.apache.cxf.jaxrs.blueprint.JAXRSBPNamespaceHandler.parse(JAXRSBPNamespaceHandler.java:51)
at
org.apache.aries.blueprint.parser.Parser.parseCustomElement(Parser.java:1279)
at org.apache.aries.blueprint.parser.Parser.loadComponents(Parser.java:337)
at org.apache.aries.blueprint.parser.Parser.populate(Parser.java:277)
What is the correct way, using ServiceMix (5.0.0), Camel 2.12.3 and the
CXF version that is included in the Camel distribution, to configure the
JSONProvider to produce JSON of a single item list as an array?
I appreciate any input.
Thanks,
John