I had a look and this is due to a bug I think. The issue is that when you
create Consumer it is for a specific media type which is a simple String.
This is then compared to the Content-Type of the request. To verify this
you should be able to create a Consumer, which can extend the JsonConsumer,
in the demo, that returns the media type with the property 'charset=utf-8'
for the mediaType() method. I'm not saying that this is how it should be
but it might be a quicker way to move forward than to fix it in the
controller.
Let me know what you think
On 18 June 2013 11:19, Daniel Bevenius <daniel.bevenius(a)gmail.com> wrote:
I'll take a look at what is going on. Can't tell from just
reading the
emails here.
Regarding using JAX-RS I would say that sounds like a better option moving
forward, as the future of the controller is uncertain.
On 18 June 2013 11:02, Matthias Wessendorf <matzew(a)apache.org> wrote:
> Perhaps, we change to backend to use only JAX-RS ?
> I do that for the PushEE Server (using AeroGear-Security in there as
> well, with JAX-RS)
>
> -Matthias
>
>
> On Tue, Jun 18, 2013 at 10:53 AM, Corinne Krych <corinnekrych(a)gmail.com>wrote:
>
>> If I patch controller-aerogear with some code like
>>
>> org.jboss.aerogear.controller.util.ParameterExtractor.getConsumer(....)
>> with snippet below:
>>
>> if (contentType.contains("application/json")) {
>> contentType = "application/json";
>> }
>>
>>
>> I think that for the similar to
>>
https://issues.jboss.org/browse/AEROGEAR-1085
>> we should ignore subtype in content-type
>>
>>
>> I go a step further in my login request but now I get this exception
>> from server:
>>
>> 10:43:42,379 ERROR [org.jboss.aerogear.controller.log]
>> (http--127.0.0.1-8080-1) AG_CONTROLLER000005: Exception Message: 'User id
>> can not be null.': java.lang.IllegalArgumentException: User id can not be
>> null.
>> at
>>
org.picketlink.credential.DefaultLoginCredentials.setUserId(DefaultLoginCredentials.java:44)
>> [picketlink-api-2.5.0.Beta4.jar:]
>> at
>>
org.picketlink.credential.DefaultLoginCredentials$Proxy$_$$_WeldClientProxy.setUserId(DefaultLoginCredentials$Proxy$_$$_WeldClientProxy.java)
>> [picketlink-api-2.5.0.Beta4.jar:]
>> at
>>
org.jboss.aerogear.security.picketlink.auth.AuthenticationManagerImpl.login(AuthenticationManagerImpl.java:52)
>> [aerogear-security-picketlink-1.0.1.jar:1.0.1]
>> at
>>
org.jboss.aerogear.security.picketlink.auth.AuthenticationManagerImpl.login(AuthenticationManagerImpl.java:34)
>> [aerogear-security-picketlink-1.0.1.jar:1.0.1]
>> at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>> [rt.jar:1.7.0_15]
>> at
>> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
>> [rt.jar:1.7.0_15]
>> at
>>
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
>> [rt.jar:1.7.0_15]
>> at java.lang.reflect.Method.invoke(Method.java:601) [rt.jar:1.7.0_15]
>> at
>>
org.jboss.weld.bean.proxy.AbstractBeanInstance.invoke(AbstractBeanInstance.java:44)
>> [weld-core-1.1.5.AS71.Final.jar:2012-02-10 15:31]
>> at
>> org.jboss.weld.bean.proxy.ProxyMethodHandler.invoke(ProxyMethodHandler.java:105)
>> [weld-core-1.1.5.AS71.Final.jar:2012-02-10 15:31]
>>
>>
>> Any idea?
>>
>>
>>
>>
>>
>>
>>
>> On 18 June 2013 10:44, Matthias Wessendorf <matzew(a)apache.org> wrote:
>>
>>> This works:
>>>
>>>
>>> curl -v -b cookies.txt -c cookies.txt -H "Accept: application/json;
>>> charset=utf-8" -H "Content-type: application/json" -X POST -d
>>> '{"loginName": "john",
"password":"123"}'
>>>
http://localhost:8080/prodoctor/login
>>>
>>>
>>> (accept header)
>>>
>>>
>>>
>>>
>>> On Tue, Jun 18, 2013 at 10:35 AM, Matthias Wessendorf <
>>> matzew(a)apache.org> wrote:
>>>
>>>>
>>>>
>>>>
>>>> On Tue, Jun 18, 2013 at 10:03 AM, Corinne Krych <
>>>> corinnekrych(a)gmail.com> wrote:
>>>>
>>>>> Seb,
>>>>>
>>>>> When debugging with a breakpoint
>>>>> on org.jboss.aerogear.controller.util.ParameterExtractor.java line
139, I
>>>>> still get consumers map containing only "application/json"
and then
>>>>> exception get throw line l152.
>>>>>
>>>>> contentType holds "application/json; charset=utf-8"
>>>>>
>>>>> Server side issue to me.
>>>>>
>>>>> Any more idea?
>>>>>
>>>>
>>>>
>>>> Doing this CUR:
>>>> curl -v -b cookies.txt -c cookies.txt -H "Accept:
application/json" -H
>>>> "Content-type: application/json; charset=utf-8" -X POST -d
'{"loginName":
>>>> "john", "password":"123"}'
http://localhost:8080/prodoctor/login
>>>>
>>>>
>>>> same issue (=> same exception)
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>>
>>>>>
>>>>> On 18 June 2013 09:53, Matthias Wessendorf <matzew(a)apache.org>
wrote:
>>>>>
>>>>>> can you debug and see what's actually hitting the server?
The
>>>>>> Exception is, to be honest, not meaningful :)
>>>>>>
>>>>>> -M
>>>>>>
>>>>>>
>>>>>> On Tue, Jun 18, 2013 at 9:19 AM, Sebastien Blanc <
>>>>>> scm.blanc(a)gmail.com> wrote:
>>>>>>
>>>>>>> Sorry I though you were talking about Travis ... Hum, okay so
the
>>>>>>> workaround don't work ... but the curl was, maybe
lowercase issue, I see
>>>>>>> now "utf-8" and iOs maybe send "UTF-8"
and controller match also the case ?
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>> On Tue, Jun 18, 2013 at 9:14 AM, Matthias Wessendorf <
>>>>>>> matzew(a)apache.org> wrote:
>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>> On Tue, Jun 18, 2013 at 9:01 AM, Matthias Wessendorf
<
>>>>>>>> matzew(a)apache.org> wrote:
>>>>>>>>
>>>>>>>>> still the failure, (both: AeroGear-iOS 1.0.1 (AFN
1.0.RC1) + the
>>>>>>>>> branch going to AFN 1.2.1
>>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>> ==> same exception (see my different testing iOS
environments
>>>>>>>> above)
>>>>>>>>
>>>>>>>> -Matthias
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>> On Tue, Jun 18, 2013 at 8:50 AM, Sebastien Blanc
<
>>>>>>>>> scm.blanc(a)gmail.com> wrote:
>>>>>>>>>
>>>>>>>>>> Oups,
>>>>>>>>>> I should not push code at 1 am ;)
>>>>>>>>>> Should be okay now
>>>>>>>>>> Seb
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>> On Tue, Jun 18, 2013 at 8:30 AM, Matthias
Wessendorf <
>>>>>>>>>> matzew(a)apache.org> wrote:
>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>> On Tue, Jun 18, 2013 at 12:56 AM, Sebastien
Blanc <
>>>>>>>>>>> scm.blanc(a)gmail.com> wrote:
>>>>>>>>>>>
>>>>>>>>>>>> Hi Corinne,
>>>>>>>>>>>> On a route you can set different
consumers (
>>>>>>>>>>>>
http://aerogear.org/docs/guides/aerogear-controller/mediatypes.html )
>>>>>>>>>>>> , I've updated the Route on Prodoctor
and now it seems to work. I can not
>>>>>>>>>>>> reproduce your ios example here on my
fedora box but this curl works now :
>>>>>>>>>>>>
>>>>>>>>>>>> curl -v -b cookies.txt -c cookies.txt -H
"Accept:
>>>>>>>>>>>> application/json" -H
"Content-type: application/json; charset=utf-8" -X
>>>>>>>>>>>> POST -d '{"loginName":
"john", "password":"123"}'
>>>>>>>>>>>>
http://localhost:8080/prodoctor/login
>>>>>>>>>>>>
>>>>>>>>>>>> Update the repo and give it a try !
>>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>> please push this type:
>>>>>>>>>>>
>>>>>>>>>>> import
org.aerogear.prodoctor.config.CustomConsumer;
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>> it's missing and the build is failing
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>> Seb
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>> On Mon, Jun 17, 2013 at 10:47 PM, Corinne
Krych <
>>>>>>>>>>>> corinnekrych(a)gmail.com> wrote:
>>>>>>>>>>>>
>>>>>>>>>>>>> Hello Guys
>>>>>>>>>>>>>
>>>>>>>>>>>>> Writing code for ProDoctor demo, on
client side, I'm using
>>>>>>>>>>>>> Xcode template for AGPush which is
based on AFNetworking 121
>>>>>>>>>>>>>
>>>>>>>>>>>>> When doing my login request in iOS I
bumped into the issue of
>>>>>>>>>>>>> having content type set to
"application/json; charset=utf-8" whereas on
>>>>>>>>>>>>> routes (backend) only
"application/json" is set which causes this exception:
>>>>>>>>>>>>>
>>>>>>>>>>>>> [application/json].':
java.lang.RuntimeException:
>>>>>>>>>>>>> AG_CONTROLLER000012: No Consumer
found for Parameter:
>>>>>>>>>>>>> 'Parameter[type=ENTITY,
type=class
>>>>>>>>>>>>>
org.aerogear.prodoctor.model.SaleAgent]'. The registered Consumers were:
>>>>>>>>>>>>>
'[JsonConsumer[mediaType=application/json]]'. Please add a Consumer for one
>>>>>>>>>>>>> the media types supported by the
route: [application/json].
>>>>>>>>>>>>>
>>>>>>>>>>>>> at
>>>>>>>>>>>>>
org.jboss.aerogear.controller.util.ParameterExtractor.getConsumer(ParameterExtractor.java:152)
>>>>>>>>>>>>>
[aerogear-controller-1.0.1.jar:1.0.1]
>>>>>>>>>>>>>
>>>>>>>>>>>>> at
>>>>>>>>>>>>>
org.jboss.aerogear.controller.util.ParameterExtractor.extractArguments(ParameterExtractor.java:70)
>>>>>>>>>>>>>
[aerogear-controller-1.0.1.jar:1.0.1]
>>>>>>>>>>>>>
>>>>>>>>>>>>>
>>>>>>>>>>>>> I think we should support both
"application/json;
>>>>>>>>>>>>> charset=utf-8" and
"application/json". /shall we open a JIRA on AeroGear
>>>>>>>>>>>>> Controller to support both?
>>>>>>>>>>>>>
>>>>>>>>>>>>>
>>>>>>>>>>>>> wdyt?
>>>>>>>>>>>>>
>>>>>>>>>>>>>
>>>>>>>>>>>>> Corinne
>>>>>>>>>>>>>
>>>>>>>>>>>>>
>>>>>>>>>>>>>
>>>>>>>>>>>>>
_______________________________________________
>>>>>>>>>>>>> aerogear-dev mailing list
>>>>>>>>>>>>> aerogear-dev(a)lists.jboss.org
>>>>>>>>>>>>>
https://lists.jboss.org/mailman/listinfo/aerogear-dev
>>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>>
_______________________________________________
>>>>>>>>>>>> aerogear-dev mailing list
>>>>>>>>>>>> aerogear-dev(a)lists.jboss.org
>>>>>>>>>>>>
https://lists.jboss.org/mailman/listinfo/aerogear-dev
>>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>> --
>>>>>>>>>>> Matthias Wessendorf
>>>>>>>>>>>
>>>>>>>>>>> blog:
http://matthiaswessendorf.wordpress.com/
>>>>>>>>>>> sessions:
http://www.slideshare.net/mwessendorf
>>>>>>>>>>> twitter:
http://twitter.com/mwessendorf
>>>>>>>>>>>
>>>>>>>>>>>
_______________________________________________
>>>>>>>>>>> aerogear-dev mailing list
>>>>>>>>>>> aerogear-dev(a)lists.jboss.org
>>>>>>>>>>>
https://lists.jboss.org/mailman/listinfo/aerogear-dev
>>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>> _______________________________________________
>>>>>>>>>> aerogear-dev mailing list
>>>>>>>>>> aerogear-dev(a)lists.jboss.org
>>>>>>>>>>
https://lists.jboss.org/mailman/listinfo/aerogear-dev
>>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>> --
>>>>>>>>> Matthias Wessendorf
>>>>>>>>>
>>>>>>>>> blog:
http://matthiaswessendorf.wordpress.com/
>>>>>>>>> sessions:
http://www.slideshare.net/mwessendorf
>>>>>>>>> twitter:
http://twitter.com/mwessendorf
>>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>> --
>>>>>>>> Matthias Wessendorf
>>>>>>>>
>>>>>>>> blog:
http://matthiaswessendorf.wordpress.com/
>>>>>>>> sessions:
http://www.slideshare.net/mwessendorf
>>>>>>>> twitter:
http://twitter.com/mwessendorf
>>>>>>>>
>>>>>>>> _______________________________________________
>>>>>>>> aerogear-dev mailing list
>>>>>>>> aerogear-dev(a)lists.jboss.org
>>>>>>>>
https://lists.jboss.org/mailman/listinfo/aerogear-dev
>>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>> _______________________________________________
>>>>>>> aerogear-dev mailing list
>>>>>>> aerogear-dev(a)lists.jboss.org
>>>>>>>
https://lists.jboss.org/mailman/listinfo/aerogear-dev
>>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>> --
>>>>>> Matthias Wessendorf
>>>>>>
>>>>>> blog:
http://matthiaswessendorf.wordpress.com/
>>>>>> sessions:
http://www.slideshare.net/mwessendorf
>>>>>> twitter:
http://twitter.com/mwessendorf
>>>>>>
>>>>>> _______________________________________________
>>>>>> aerogear-dev mailing list
>>>>>> aerogear-dev(a)lists.jboss.org
>>>>>>
https://lists.jboss.org/mailman/listinfo/aerogear-dev
>>>>>>
>>>>>
>>>>>
>>>>> _______________________________________________
>>>>> aerogear-dev mailing list
>>>>> aerogear-dev(a)lists.jboss.org
>>>>>
https://lists.jboss.org/mailman/listinfo/aerogear-dev
>>>>>
>>>>
>>>>
>>>>
>>>> --
>>>> Matthias Wessendorf
>>>>
>>>> blog:
http://matthiaswessendorf.wordpress.com/
>>>> sessions:
http://www.slideshare.net/mwessendorf
>>>> twitter:
http://twitter.com/mwessendorf
>>>>
>>>
>>>
>>>
>>> --
>>> Matthias Wessendorf
>>>
>>> blog:
http://matthiaswessendorf.wordpress.com/
>>> sessions:
http://www.slideshare.net/mwessendorf
>>> twitter:
http://twitter.com/mwessendorf
>>>
>>> _______________________________________________
>>> aerogear-dev mailing list
>>> aerogear-dev(a)lists.jboss.org
>>>
https://lists.jboss.org/mailman/listinfo/aerogear-dev
>>>
>>
>>
>> _______________________________________________
>> aerogear-dev mailing list
>> aerogear-dev(a)lists.jboss.org
>>
https://lists.jboss.org/mailman/listinfo/aerogear-dev
>>
>
>
>
> --
> Matthias Wessendorf
>
> blog:
http://matthiaswessendorf.wordpress.com/
> sessions:
http://www.slideshare.net/mwessendorf
> twitter:
http://twitter.com/mwessendorf
>
> _______________________________________________
> aerogear-dev mailing list
> aerogear-dev(a)lists.jboss.org
>
https://lists.jboss.org/mailman/listinfo/aerogear-dev
>