Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8822735
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T06:10:41+00:00 2026-06-14T06:10:41+00:00

You don’t need to know CXF to answer this question. Suppose I have the

  • 0

You don’t need to know CXF to answer this question.

Suppose I have the following XML declaration which creates a JAXRS server using CXF

  <jaxrs:server id="customerService" address="/service1">
    <jaxrs:serviceBeans>
      <ref bean="serviceBean1" />
      <ref bean="serviceBean2" />
      <ref bean="serviceBean3" />
    </jaxrs:serviceBeans>
  </jaxrs:server>

Now I need to find a way to customize this JAXRS server per environment, using Spring profiles mechanism. I could do something like:

 <beans profile="dev">
    <jaxrs:server id="jaxrsServer" address="/service1">
      <jaxrs:serviceBeans>
        <ref bean="serviceBean2" />
        <ref bean="serviceBean3" />
      </jaxrs:serviceBeans>
    </jaxrs:server>
  </beans>

  <beans profile="prod">
    <jaxrs:server id="jaxrsServer" address="/service1">
      <jaxrs:serviceBeans>
        <ref bean="serviceBean1" />
        <ref bean="serviceBean2" />
      </jaxrs:serviceBeans>
    </jaxrs:server>
  </beans>

But it is not what I would like to have, because my real-world JAXRS server is a bit more complicated than in my exemple.

What I am looking for is something like that:

<jaxrs:server id="jaxrsServer" address="/service1">
  <jaxrs:serviceBeans>
    <beans profile="dev">
      <ref bean="serviceBean1" />
      <ref bean="serviceBean2" />
    </beans>
    <beans profile="dev">
      <ref bean="serviceBean2" />
      <ref bean="serviceBean3" />
    </beans>
  </jaxrs:serviceBeans>
</jaxrs:server>

But it doesn’t work.


I tried to externalize my list creation:

  <bean id="serviceBeansList" class="java.util.ArrayList">
    <constructor-arg>
      <list>
        <ref bean="serviceBean1"/>
        <ref bean="serviceBean2"/>
      </list>
    </constructor-arg>
  </bean>

<jaxrs:server id="jaxrsServer" address="/service1">
  <jaxrs:serviceBeans>
      <ref bean="serviceBeansList" />
  </jaxrs:serviceBeans>
</jaxrs:server>

It still doesn’t work because CXF namespace handler does not “flatten” the list, so instead of dealing with a list of 2 serviceBeans objects, it deals with a list of 1 ArrayList, which is not a type handled by CXF.

The Spring XML parsing tries to get a list. I found that in CXF namespace handling code:

if ( "serviceBeans".equals(name) ) {
            List<?> list = ctx.getDelegate().parseListElement(el, bean.getBeanDefinition());
            bean.addPropertyValue(name, list);
}

Instead of referencing a bean, isn’t it possible to reference a “xml declaration fragment” with Spring or something else that could work?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T06:10:42+00:00Added an answer on June 14, 2026 at 6:10 am

    Have you tried using aliases + profiles

    <jaxrs:server id="jaxrsServer" address="/service1">
      <jaxrs:serviceBeans>
        <ref bean="serviceBeanA" />
        <ref bean="serviceBeanB" />
      </jaxrs:serviceBeans>
    </jaxrs:server>
    
    <beans profile="profile1">
      <alias name="serviceBean1" alias="serviceBeanA"/>
      <alias name="serviceBean2" alias="serviceBeanB" />
    </beans>
    <beans profile="profile2">
      <alias name="serviceBean3" alias="serviceBeanA"/>
      <alias name="serviceBean4" alias="serviceBeanB" />
    </beans>
    

    disclaimer: this answer is a pure fantasy, but the comments are somewhat limited – I’ll remove if it won’t work

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Don't know how to phrase this question but I need to modify the child
Don't know if this has been asked before, so point me to another question
Don't know if this has been answered before. Have custom routes to users. If
Don't know why but I can't find a solution to this. I have 3
don't know better title for this, but here's my code. I have class user
Don't dismiss this as a newbie question! It's not, I'm not, I've tried everything,
Don't ask me why but I need to do the following: string ClassName =
I don't know why, but this code worked for me a month ago... maybe
Don't know if anyone can help me with this or if it's even possible.
I don't know: if this works. if it's a good idea. what it is

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.