java.lang.NumberFormatException: For input string: "#cors-filter" in camel cxfrs 2.15 version

classic Classic list List threaded Threaded
8 messages Options
Reply | Threaded
Open this post in threaded view
|

java.lang.NumberFormatException: For input string: "#cors-filter" in camel cxfrs 2.15 version

chaituu
This post was updated on .
getting below error when i used camel 2.15.2 version .

Caused by: org.apache.camel.TypeConversionException: Error during type conversion from type: java.lang.String to the required type: java.util.List with value #cors-filter due java.lang.NumberFormatException: For input string: "#cors-filter"

 <cxf:rsServer id="dsServer" address="http://0.0.0.0:10089/test"
                  serviceClass="com.xxx.xxx.xx.testservice"
                  loggingFeatureEnabled="true" loggingSizeLimit="20">
        <cxf:providers>
            <ref bean="cors-filter"/>
        </cxf:providers>
    </cxf:rsServer>
       
       
        <camel:camelContext xmlns="http://camel.apache.org/schema/spring" id="xxxx"
                        trace="true">
         <route id="test">
            <from uri="cxfrs://bean://dsServer"/>
            <setBody>
                <constant>abcd</constant>
            </setBody>
            <to uri="log:com.xxx?level=INFO"/>
        </route>
    </camel:camelContext>
Reply | Threaded
Open this post in threaded view
|

Re: getting exception for appending option providers=#cors-filter in camel cxfrs

Sergey Beryozkin
Hi

There's no need to set this provider from the uri given that it is
already registered on the rsServer bean.
However, it may be useful for simpler URI-only configurations, I'll have
a look...

Sergey
On 27/08/15 10:26, chaituu wrote:

> getting below error when i used camel 2.15.2 version .Is it required to
> append cors-filter in the from endpoint <from
> uri="cxfrs://bean://dsServer?providers=#cors-filter"/> as I have already
> referenced cors-filter in <cxf:providers> tag in the CxfRs endpoint.
>
> when i removed providers=#cors-filter option in cxfrs://bean://dsServer then
> its working fine.
>
>
> Caused by: java.lang.IllegalArgumentException: Could not find a suitable
> setter for property: providers as there isn't a setter method with same
> type: java.lang.String nor type conversion possible: No type converter
> available to convert from type: java.lang.String to the required type:
> java.util.List with value #cors-filter
>
>   <cxf:rsServer id="dsServer" address="http://0.0.0.0:10089/test"
>                    serviceClass="com.xxx.xxx.xx.testservice"
>                    loggingFeatureEnabled="true" loggingSizeLimit="20">
>          <cxf:providers>
>              <ref bean="cors-filter"/>
>          </cxf:providers>
>      </cxf:rsServer>
>
>
> <camel:camelContext xmlns="http://camel.apache.org/schema/spring" id="xxxx"
>                          trace="true">
>           <route id="test">
>              <from uri="cxfrs://bean://dsServer?providers=#cors-filter"/>
>              <setBody>
>                  <constant>abcd</constant>
>              </setBody>
>              <to uri="log:com.xxx?level=INFO"/>
>          </route>
>      </camel:camelContext>
>
>
>
> --
> View this message in context: http://camel.465427.n5.nabble.com/getting-exception-for-appending-option-providers-cors-filter-in-camel-cxfrs-tp5771009.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
>


--
Sergey Beryozkin

Talend Community Coders
http://coders.talend.com/
Reply | Threaded
Open this post in threaded view
|

Re: getting exception for appending option providers=#cors-filter in camel cxfrs

chaituu
This post was updated on .
registered cors-filter bean id like this.

<bean id="cors-filter" class="org.apache.cxf.rs.security.cors.CrossOriginResourceSharingFilter"/>


 <cxf:rsServer id="dsServer" address="http://0.0.0.0:10089/test"
                  serviceClass="com.xxx.xxx.xx.testservice"
                  loggingFeatureEnabled="true" loggingSizeLimit="20">
        <cxf:providers>
            <ref bean="cors-filter"/>
        </cxf:providers>
    </cxf:rsServer>



Path("/")
@CrossOriginResourceSharing(allowAllOrigins = true)
public class testservice{

    @GET
    @Path("/xxxx/generation")
    @Produces("application/json")
    public String test(@QueryParam("date") String date) {
        return "test";
    }
}
Reply | Threaded
Open this post in threaded view
|

Re: getting exception for appending option providers=#cors-filter in camel cxfrs

Sergey Beryozkin
Yes this should be sufficient, however it is possible to enable a cxfrs
server with a URI only without directly creating a bean, so in that case
it can be handy to refer to specific instances...

Sergey
On 27/08/15 15:25, chaituu wrote:

> registered cors-filter bean id like this.
>
> <bean id="cors-filter"
> class="org.apache.cxf.rs.security.cors.CrossOriginResourceSharingFilter"/>
>
>
>   <cxf:rsServer id="dsServer" address="http://0.0.0.0:10089/test"
>                    serviceClass="com.xxx.xxx.xx.testservice"
>                    loggingFeatureEnabled="true" loggingSizeLimit="20">
>          <cxf:providers>
>              <ref bean="cors-filter"/>
>          </cxf:providers>
>      </cxf:rsServer>
>
>
>
> --
> View this message in context: http://camel.465427.n5.nabble.com/java-lang-NumberFormatException-For-input-string-cors-filter-in-camel-cxfrs-2-15-version-tp5771009p5771019.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
>


--
Sergey Beryozkin

Talend Community Coders
http://coders.talend.com/
Reply | Threaded
Open this post in threaded view
|

Re: getting exception for appending option providers=#cors-filter in camel cxfrs

chaituu
defined like above in the config like but getting the error.do i need change anything?its working in camel 2.9 version but not working in 2.15 version & cxf version is 3.0.4.
Reply | Threaded
Open this post in threaded view
|

Re: getting exception for appending option providers=#cors-filter in camel cxfrs

Sergey Beryozkin
Sorry, may be I got confused.
The whole issue is about referring to a cors-filter instance from the
URI, right ?
You said if you remove it from the route URI then it is fine, and I also
said you do not need if you have a cxfrs server bean where you do
reference the same cors-filter anyway.

So, does it work for you if you remove it from the URI ?
I agree it has to work when it is linked from URI when a cxfrs server is
not created from a bean, which is something I'll look into. If you said
it did work then I guess there might be some regression...

Sergey



On 27/08/15 15:55, chaituu wrote:

> defined like above in the config like but getting the error.do i need change
> anything?its working in camel 2.9 version but not working in 2.15 version &
> cxf version is 3.0.4.
>
>
>
> --
> View this message in context: http://camel.465427.n5.nabble.com/java-lang-NumberFormatException-For-input-string-cors-filter-in-camel-cxfrs-2-15-version-tp5771009p5771022.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
>

Reply | Threaded
Open this post in threaded view
|

Re: getting exception for appending option providers=#cors-filter in camel cxfrs

chaituu
even if i remove it from the route URI also its not working.can you check from your side once.as per doc

http://camel.apache.org/cxfrs.html

providers Since Camel 2.12.2 set custom JAX-RS providers list to the CxfRs endpoint.
providers=#MyProviders

initially i didn't checked the logs properly so thought its working even if i removed from the route URI.

Reply | Threaded
Open this post in threaded view
|

Re: getting exception for appending option providers=#cors-filter in camel cxfrs

Sergey Beryozkin
Right, I checked this test:

https://github.com/apache/camel/blob/master/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/jaxrs/CxfRsSpringConsumerTest.java

which uses this resource:

https://github.com/apache/camel/blob/master/components/camel-cxf/src/test/resources/org/apache/camel/component/cxf/jaxrs/CxfRsSpringConsumer.xml

If I update CxfRsSpringConsumer.xml and remove for example a reference
to the exceptionMapper then the test starts failing, which proves the
provider registration works.

Perhaps you mean the actual CORS filter is not returning the right CORS
headers ? Typically you'd need to tune it or add Cors annotations to the
resource class for the filter to figure out what to do.

Next, re http://camel.apache.org/cxfrs.html using this "#" notation for
a number of properties such as providers=#MyProviders.

This is misleading and probably never worked as far as the assumption
that a '#' implies a reference to an instance as opposed to a class when
using it from a route cxfrs URI.

I've checked CXFRsComponent source - it pre-processes 'resourceClass' or
'resourceClasses' uri parameters *only* and it assumes the parsed values
represent classes as opposed to instances of specific classes.

CXFRsComponent does do something around #prefixed properties when a bean
is an instance of Blueprint or Spring Support but in this case these
properties are bean properties as opposed to the properties extracted
from a route cxfrs URI.

So, a summary:
- If you have a CXFRS bean then set all the providers/features/resource
classes/etc on that bean, do not overload a cxfrs URI. IMHO it does not
make sense to start over-complicating the URI if the bean is there which
is meant to support all sort of CXFRS properties.

- If one sets these parameters in URI then the only non-primitive
property which currently works is 'resourceClass(es)' whose values are
expected to be class names. I'll open a JIRA to make sure other
parameters are supported when using a URI only form, though will
probably keep the current restriction that such parameters refer to
classes only.

Cheers, Sergey





On 28/08/15 06:05, chaituu wrote:

> even if i remove it from the route URI also its not working.can you check
> from your side once.as per doc
>
> http://camel.apache.org/cxfrs.html
>
> providers Since Camel 2.12.2 set custom JAX-RS providers list to the CxfRs
> endpoint.
> providers=#MyProviders
>
> initially i didn't checked the logs properly so thought its working even if
> i removed from the route URI.
>
>
>
>
>
> --
> View this message in context: http://camel.465427.n5.nabble.com/java-lang-NumberFormatException-For-input-string-cors-filter-in-camel-cxfrs-2-15-version-tp5771009p5771046.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
>


--
Sergey Beryozkin

Talend Community Coders
http://coders.talend.com/