MythTV-Clients / MythTV-Android-Frontend

Implementation of MythTV .25+ Services API for Android
GNU General Public License v3.0
66 stars 16 forks source link

1.20.0 beta: NumberFormatException #227

Closed MaEngelhard closed 11 years ago

MaEngelhard commented 11 years ago

I'm running the current beta on a 0.27 backend. The frontent can't connect to the bakend. The reason is a NumberFormatException as followed:

10-13 13:12:21.063: E/BackendStatusHelperV27(12840): org.mythtv.services.api.MythServiceApiRuntimeException: org.springframework.http.converter.HttpMessageNotReadableException: Could not read [class org.mythtv.services.api.v027.status.beans.BackendStatus]; nested exception is java.lang.NumberFormatException: Invalid float: "0,15"; nested exception is org.springframework.http.converter.HttpMessageNotReadableException: Could not read [class org.mythtv.services.api.v027.status.beans.BackendStatus]; nested exception is java.lang.NumberFormatException: Invalid float: "0,15" 10-13 13:12:21.063: E/BackendStatusHelperV27(12840): at org.mythtv.services.api.v027.impl.StatusTemplate.getStatus(StatusTemplate.java:56) 10-13 13:12:21.063: E/BackendStatusHelperV27(12840): at org.mythtv.service.status.v27.BackendStatusHelperV27.downloadBackendStatus(BackendStatusHelperV27.java:149) 10-13 13:12:21.063: E/BackendStatusHelperV27(12840): at org.mythtv.service.status.v27.BackendStatusHelperV27.process(BackendStatusHelperV27.java:135) 10-13 13:12:21.063: E/BackendStatusHelperV27(12840): at org.mythtv.service.status.BackendStatusService.onHandleIntent(BackendStatusService.java:94) 10-13 13:12:21.063: E/BackendStatusHelperV27(12840): at android.app.IntentService$ServiceHandler.handleMessage(IntentService.java:65) 10-13 13:12:21.063: E/BackendStatusHelperV27(12840): at android.os.Handler.dispatchMessage(Handler.java:99) 10-13 13:12:21.063: E/BackendStatusHelperV27(12840): at android.os.Looper.loop(Looper.java:137) 10-13 13:12:21.063: E/BackendStatusHelperV27(12840): at android.os.HandlerThread.run(HandlerThread.java:61) 10-13 13:12:21.063: E/BackendStatusHelperV27(12840): Caused by: org.springframework.http.converter.HttpMessageNotReadableException: Could not read [class org.mythtv.services.api.v027.status.beans.BackendStatus]; nested exception is java.lang.NumberFormatException: Invalid float: "0,15" 10-13 13:12:21.063: E/BackendStatusHelperV27(12840): at org.springframework.http.converter.xml.SimpleXmlHttpMessageConverter.readInternal(SimpleXmlHttpMessageConverter.java:115) 10-13 13:12:21.063: E/BackendStatusHelperV27(12840): at org.springframework.http.converter.AbstractHttpMessageConverter.read(AbstractHttpMessageConverter.java:147) 10-13 13:12:21.063: E/BackendStatusHelperV27(12840): at org.springframework.web.client.HttpMessageConverterExtractor.extractData(HttpMessageConverterExtractor.java:76) 10-13 13:12:21.063: E/BackendStatusHelperV27(12840): at org.springframework.web.client.RestTemplate$ResponseEntityResponseExtractor.extractData(RestTemplate.java:655) 10-13 13:12:21.063: E/BackendStatusHelperV27(12840): at org.springframework.web.client.RestTemplate$ResponseEntityResponseExtractor.extractData(RestTemplate.java:641) 10-13 13:12:21.063: E/BackendStatusHelperV27(12840): at org.springframework.web.client.RestTemplate.doExecute(RestTemplate.java:484) 10-13 13:12:21.063: E/BackendStatusHelperV27(12840): at org.springframework.web.client.RestTemplate.execute(RestTemplate.java:453) 10-13 13:12:21.063: E/BackendStatusHelperV27(12840): at org.springframework.web.client.RestTemplate.exchange(RestTemplate.java:429) 10-13 13:12:21.063: E/BackendStatusHelperV27(12840): at org.mythtv.services.api.v027.impl.StatusTemplate.getStatus(StatusTemplate.java:52) 10-13 13:12:21.063: E/BackendStatusHelperV27(12840): ... 7 more 10-13 13:12:21.063: E/BackendStatusHelperV27(12840): Caused by: java.lang.NumberFormatException: Invalid float: "0,15" 10-13 13:12:21.063: E/BackendStatusHelperV27(12840): at java.lang.StringToReal.invalidReal(StringToReal.java:63) 10-13 13:12:21.063: E/BackendStatusHelperV27(12840): at java.lang.StringToReal.parseFloat(StringToReal.java:310) 10-13 13:12:21.063: E/BackendStatusHelperV27(12840): at java.lang.Float.parseFloat(Float.java:300) 10-13 13:12:21.063: E/BackendStatusHelperV27(12840): at java.lang.Float.valueOf(Float.java:337) 10-13 13:12:21.063: E/BackendStatusHelperV27(12840): at org.simpleframework.xml.transform.FloatTransform.read(FloatTransform.java:55) 10-13 13:12:21.063: E/BackendStatusHelperV27(12840): at org.simpleframework.xml.transform.FloatTransform.read(FloatTransform.java:42) 10-13 13:12:21.063: E/BackendStatusHelperV27(12840): at org.simpleframework.xml.transform.Transformer.read(Transformer.java:106) 10-13 13:12:21.063: E/BackendStatusHelperV27(12840): at org.simpleframework.xml.core.Support.read(Support.java:372) 10-13 13:12:21.063: E/BackendStatusHelperV27(12840): at org.simpleframework.xml.core.PrimitiveFactory.getInstance(PrimitiveFactory.java:105) 10-13 13:12:21.063: E/BackendStatusHelperV27(12840): at org.simpleframework.xml.core.Primitive.readTemplate(Primitive.java:231) 10-13 13:12:21.063: E/BackendStatusHelperV27(12840): at org.simpleframework.xml.core.Primitive.read(Primitive.java:171) 10-13 13:12:21.063: E/BackendStatusHelperV27(12840): at org.simpleframework.xml.core.Primitive.read(Primitive.java:126) 10-13 13:12:21.063: E/BackendStatusHelperV27(12840): at org.simpleframework.xml.core.Composite.readVariable(Composite.java:623) 10-13 13:12:21.063: E/BackendStatusHelperV27(12840): at org.simpleframework.xml.core.Composite.readInstance(Composite.java:573) 10-13 13:12:21.063: E/BackendStatusHelperV27(12840): at org.simpleframework.xml.core.Composite.readAttribute(Composite.java:497) 10-13 13:12:21.063: E/BackendStatusHelperV27(12840): at org.simpleframework.xml.core.Composite.readAttributes(Composite.java:413) 10-13 13:12:21.063: E/BackendStatusHelperV27(12840): at org.simpleframework.xml.core.Composite.access$300(Composite.java:59) 10-13 13:12:21.063: E/BackendStatusHelperV27(12840): at org.simpleframework.xml.core.Composite$Builder.read(Composite.java:1382) 10-13 13:12:21.063: E/BackendStatusHelperV27(12840): at org.simpleframework.xml.core.Composite.read(Composite.java:201) 10-13 13:12:21.063: E/BackendStatusHelperV27(12840): at org.simpleframework.xml.core.Composite.read(Composite.java:148) 10-13 13:12:21.063: E/BackendStatusHelperV27(12840): at org.simpleframework.xml.core.Composite.readVariable(Composite.java:623) 10-13 13:12:21.063: E/BackendStatusHelperV27(12840): at org.simpleframework.xml.core.Composite.readInstance(Composite.java:573) 10-13 13:12:21.063: E/BackendStatusHelperV27(12840): at org.simpleframework.xml.core.Composite.readUnion(Composite.java:549) 10-13 13:12:21.063: E/BackendStatusHelperV27(12840): at org.simpleframewo 10-13 13:12:21.063: D/BackendStatusHelperV27(12840): process : exit

dmfrey commented 11 years ago

Can you check and see if the locale set on your phone or tablet matches that of your backend? On Oct 13, 2013 7:20 AM, "MaEngelhard" notifications@github.com wrote:

I'm running the current beta on a 0.27 backend. The frontent can't connect to the bakend. The reason is a NumberFormatException as followed:

10-13 13:12:21.063: E/BackendStatusHelperV27(12840): org.mythtv.services.api.MythServiceApiRuntimeException: org.springframework.http.converter.HttpMessageNotReadableException: Could not read [class org.mythtv.services.api.v027.status.beans.BackendStatus]; nested exception is java.lang.NumberFormatException: Invalid float: "0,15"; nested exception is org.springframework.http.converter.HttpMessageNotReadableException: Could not read [class org.mythtv.services.api.v027.status.beans.BackendStatus]; nested exception is java.lang.NumberFormatException: Invalid float: "0,15" 10-13 13:12:21.063: E/BackendStatusHelperV27(12840): at org.mythtv.services.api.v027.impl.StatusTemplate.getStatus(StatusTemplate.java:56) 10-13 13:12:21.063: E/BackendStatusHelperV27(12840): at org.mythtv.service.status.v27.BackendStatusHelperV27.downloadBackendStatus(BackendStatusHelperV27.java:149) 10-13 13:12:21.063: E/BackendStatusHelperV27(12840): at org.mythtv.service.status.v27.BackendStatusHelperV27.process(BackendStatusHelperV27.java:135) 10-13 13:12:21.063: E/BackendStatusHelperV27(12840): at org.mythtv.service.status.BackendStatusService.onHandleIntent(BackendStatusService.java:94) 10-13 13:12:21.063: E/BackendStatusHelperV27(12840): at android.app.IntentService$ServiceHandler.handleMessage(IntentService.java:65) 10-13 13:12:21.063: E/BackendStatusHelperV27(12840): at android.os.Handler.dispatchMessage(Handler.java:99) 10-13 13:12:21.063: E/BackendStatusHelperV27(12840): at android.os.Looper.loop(Looper.java:137) 10-13 13:12:21.063: E/BackendStatusHelperV27(12840): at android.os.HandlerThread.run(HandlerThread.java:61) 10-13 13:12:21.063: E/BackendStatusHelperV27(12840): Caused by: org.springframework.http.converter.HttpMessageNotReadableException: Could not read [class org.mythtv.services.api.v027.status.beans.BackendStatus]; nested exception is java.lang.NumberFormatException: Invalid float: "0,15" 10-13 13:12:21.063: E/BackendStatusHelperV27(12840): at org.springframework.http.converter.xml.SimpleXmlHttpMessageConverter.readInternal(SimpleXmlHttpMessageConverter.java:115) 10-13 13:12:21.063: E/BackendStatusHelperV27(12840): at org.springframework.http.converter.AbstractHttpMessageConverter.read(AbstractHttpMessageConverter.java:147) 10-13 13:12:21.063: E/BackendStatusHelperV27(12840): at org.springframework.web.client.HttpMessageConverterExtractor.extractData(HttpMessageConverterExtractor.java:76) 10-13 13:12:21.063: E/BackendStatusHelperV27(12840): at org.springframework.web.client.RestTemplate$ResponseEntityResponseExtractor.extractData(RestTemplate.java:655) 10-13 13:12:21.063: E/BackendStatusHelperV27(12840): at org.springframework.web.client.RestTemplate$ResponseEntityResponseExtractor.extractData(RestTemplate.java:641) 10-13 13:12:21.063: E/BackendStatusHelperV27(12840): at org.springframework.web.client.RestTemplate.doExecute(RestTemplate.java:484) 10-13 13:12:21.063: E/BackendStatusHelperV27(12840): at org.springframework.web.client.RestTemplate.execute(RestTemplate.java:453) 10-13 13:12:21.063: E/BackendStatusHelperV27(12840): at org.springframework.web.client.RestTemplate.exchange(RestTemplate.java:429) 10-13 13:12:21.063: E/BackendStatusHelperV27(12840): at org.mythtv.services.api.v027.impl.StatusTemplate.getStatus(StatusTemplate.java:52) 10-13 13:12:21.063: E/BackendStatusHelperV27(12840): ... 7 more 10-13 13:12:21.063: E/BackendStatusHelperV27(12840): Caused by: java.lang.NumberFormatException: Invalid float: "0,15" 10-13 13:12:21.063: E/BackendStatusHelperV27(12840): at java.lang.StringToReal.invalidReal(StringToReal.java:63) 10-13 13:12:21.063: E/BackendStatusHelperV27(12840): at java.lang.StringToReal.parseFloat(StringToReal.java:310) 10-13 13:12:21.063: E/BackendStatusHelperV27(12840): at java.lang.Float.parseFloat(Float.java:300) 10-13 13:12:21.063: E/BackendStatusHelperV27(12840): at java.lang.Float.valueOf(Float.java:337) 10-13 13:12:21.063: E/BackendStatusHelperV27(12840): at org.simpleframework.xml.transform.FloatTransform.read(FloatTransform.java:55) 10-13 13:12:21.063: E/BackendStatusHelperV27(12840): at org.simpleframework.xml.transform.FloatTransform.read(FloatTransform.java:42) 10-13 13:12:21.063: E/BackendStatusHelperV27(12840): at org.simpleframework.xml.transform.Transformer.read(Transformer.java:106) 10-13 13:12:21.063: E/BackendStatusHelperV27(12840): at org.simpleframework.xml.core.Support.read(Support.java:372) 10-13 13:12:21.063: E/BackendStatusHelperV27(12840): at org.simpleframework.xml.core.PrimitiveFactory.getInstance(PrimitiveFactory.java:105) 10-13 13:12:21.063: E/BackendStatusHelperV27(12840): at org.simpleframework.xml.core.Primitive.readTemplate(Primitive.java:231) 10-13 13:12:21.063: E/BackendStatusHelperV27(12840): at org.simpleframework.xml.core.Primitive.read(Primitive.java:171) 10-13 13:12:21.063: E/BackendStatusHelperV27(12840): at org.simpleframework.xml.core.Primitive.read(Primitive.java:126) 10-13 13:12:21.063: E/BackendStatusHelperV27(12840): at org.simpleframework.xml.core.Composite.readVariable(Composite.java:623) 10-13 13:12:21.063: E/BackendStatusHelperV27(12840): at org.simpleframework.xml.core.Composite.readInstance(Composite.java:573) 10-13 13:12:21.063: E/BackendStatusHelperV27(12840): at org.simpleframework.xml.core.Composite.readAttribute(Composite.java:497) 10-13 13:12:21.063: E/BackendStatusHelperV27(12840): at org.simpleframework.xml.core.Composite.readAttributes(Composite.java:413) 10-13 13:12:21.063: E/BackendStatusHelperV27(12840): at org.simpleframework.xml.core.Composite.access$300(Composite.java:59) 10-13 13:12:21.063: E/BackendStatusHelperV27(12840): at org.simpleframework.xml.core.Composite$Builder.read(Composite.java:1382) 10-13 13:12:21.063: E/BackendStatusHelperV27(12840): at org.simpleframework.xml.core.Composite.read(Composite.java:201) 10-13 13:12:21.063: E/BackendStatusHelperV27(12840): at org.simpleframework.xml.core.Composite.read(Composite.java:148) 10-13 13:12:21.063: E/BackendStatusHelperV27(12840): at org.simpleframework.xml.core.Composite.readVariable(Composite.java:623) 10-13 13:12:21.063: E/BackendStatusHelperV27(12840): at org.simpleframework.xml.core.Composite.readInstance(Composite.java:573) 10-13 13:12:21.063: E/BackendStatusHelperV27(12840): at org.simpleframework.xml.core.Composite.readUnion(Composite.java:549) 10-13 13:12:21.063: E/BackendStatusHelperV27(12840): at org.simpleframewo 10-13 13:12:21.063: D/BackendStatusHelperV27(12840): process : exit

— Reply to this email directly or view it on GitHubhttps://github.com/MythTV-Clients/MythTV-Android-Frontend/issues/227 .

MaEngelhard commented 11 years ago

Here is the locale setting on the backend:

LANG=de_DE.UTF-8 LC_CTYPE=de_DE.UTF-8 LC_NUMERIC="de_DE.UTF-8" LC_TIME="de_DE.UTF-8" LC_COLLATE=C LC_MONETARY="de_DE.UTF-8" LC_MESSAGES="de_DE.UTF-8" LC_PAPER="de_DE.UTF-8" LC_NAME="de_DE.UTF-8" LC_ADDRESS="de_DE.UTF-8" LC_TELEPHONE="de_DE.UTF-8" LC_MEASUREMENT="de_DE.UTF-8" LC_IDENTIFICATION="de_DE.UTF-8" LC_ALL=

I don't know where i'm getting this information on android but i guess it's some kind of "de" because all is written in german ;)

MaEngelhard commented 11 years ago

The problem seems to be the load information in the received xml:

Load avg1="0,33" avg2="0,24" avg3="0,26"

dmfrey commented 11 years ago

@MaEngelhard

This is a duplicate of #163

The original problem was that @espenaf phone was not set to the same locale as the his Master Backend.

Our mythtv-services-api implementation reads your default locale and sends that along with the request to the backend. When it receives responses from the backend, it uses this information to parse out specific details (i.e. use comma as decimal separator instead of period, etc.)

billmeek commented 11 years ago

When I switch to either of the German languages on my tablet, the app works fine. But, I'd expect it to fail because my English backend is sending periods rather than commas for host:6544/Status/GetStatus

espenaf commented 11 years ago

I never retested #163 with Norwegian locale, as I just changed LC_NUMERIC to English for my backends. While using either Norwegian or English settings on phone/tablet.

MaEngelhard commented 11 years ago

The frontend can't connect even if the language of the android is English. Changing LC_NUMERIC as suggested by @espenaf works for me too but shouldn't be the solution.

billmeek commented 11 years ago

Agreed. Setting the critical label, as you can't even connect.

@dmfrey @tafypz, I don't see the load status used anywhere. Could this be read in as a string rather than a float? Or, is this auto generated code.

tafypz commented 11 years ago

@billmeek The status endpoint is not backed by a wsdl, this is the only endpoint that is not part of the services api umbrella. This is only an xml document. In terms of the java code, this is the only "endpoint" that is not autogenerated. This obviously could be changed to be read as a string.

billmeek commented 11 years ago

@tafypz, thanks, as long as those would parse OK with the commas, that says the sets/gets for 0.2[567] could be changed to strings in the API (I can do that.) Then similar changes would go into MAF. I found those too. I looks like the data doesn't go into the DB, or for that matter get displayed at this time.

@dmfrey are you OK with this?

dmfrey commented 11 years ago

I am OK with that for now. I don't have any plans to use that data off hand. On Oct 13, 2013 5:00 PM, "billmeek" notifications@github.com wrote:

@tafypz https://github.com/tafypz, thanks, as long as those would parse OK with the commas, that says the sets/gets for 0.2[567] could be changed to strings in the API (I can do that.) Then similar changes would go into MAF. I found those too. I looks like the data doesn't go into the DB, or for that matter get displayed at this time.

@dmfrey https://github.com/dmfrey are you OK with this?

— Reply to this email directly or view it on GitHubhttps://github.com/MythTV-Clients/MythTV-Android-Frontend/issues/227#issuecomment-26226996 .

billmeek commented 11 years ago

Just pushed 1.0.9. Changes complete in MAF, but I won't push them until Maven Central gets updated. Everything build OK and the Status screen loads normally. I assume there's no other testing required.

I did try setting LC_NUMERIC="de_DE.UTF-8", but it didn't take (after a restart too.) @MaEngelhard, if you have any tips on where you made that change, I'd love to test it before 1.20.2 goes out.

billmeek commented 11 years ago

Looks like stars, userRating and progress are floats too. The above may get past the GetStatus issue, but looks like it will fail afterwards.

dmfrey commented 11 years ago

These are from the generator. Is there any reason we should need these to be in there native form? Definitely not right now, but anything in the future? On Oct 13, 2013 10:16 PM, "billmeek" notifications@github.com wrote:

Looks like stars, userRating and progress are floats too. The above may get past the GetStatus issue, but looks like it will fail afterwards.

— Reply to this email directly or view it on GitHubhttps://github.com/MythTV-Clients/MythTV-Android-Frontend/issues/227#issuecomment-26232673 .

billmeek commented 11 years ago

Perhaps it would be useful to print the stars for movies in the future.

There's a userrating in mythconverg's videometadata table looks like the above.

Progress is from the new SendNotification that jya added in 0.27. Not sure MAF would ever want to send messages to the TV screen (caller ID?)

Can't see the GetNumberFormat in the API, maybe it's intended to be automatic. springworks shows it using Locale and that looks at xx, e.g. de.

billmeek commented 11 years ago

The following in prints . and , for US or , and . for DE. So we know changing the language really does choose the proper separators. Why the error is thrown... no clue.

DecimalFormatSymbols otherSymbols = new DecimalFormatSymbols( Locale.getDefault() );
Log.e( TAG, "***** decimal seperator = " + otherSymbols.getDecimalSeparator() );
Log.e( TAG, "***** grouping seperator = " + otherSymbols.getGroupingSeparator() );
MaEngelhard commented 11 years ago

@billmeek I set 'LC_NUMERIC="en_US.UTF-8"' in /etc/env.d/02locale as well in '~/.bashrc' of the myth user in my gentoo system. Afterwards i restarted the backend for the new settings.

If this isn't working for you i can test it as well.

billmeek commented 11 years ago

@MaEngelhard, Oops. It helps to have the German language pack installed!

Without the changes and with LC_NUMERIC="de_DE.UTF-8", the failure occurs as expected.

With the changes and LC_NUMERIC="de_DE.UTF-8", the Status screen loads OK.

The Recordings and Guide screens also load, and I verified that there were some stars values that had decimal values. I'll be very interested to see if this works for you.

MaEngelhard commented 11 years ago

@billmeek

Both screens load here too. Are stars-values displayed anywhere?

billmeek commented 11 years ago

No, they aren't used at this time.

However, they are returned in the XML from the Master Backend. I think I see why it's not failing. If you try:

<yourMasterBackend>:6544/Dvr/GetRecordedList

The fractional value in the Stars field doesn't respect the value of LC_NUMERIC on my host. Which could mean there's a problem waiting to bite us.

...
<Program>
<StartTime>2013-10-14T15:50:00Z</StartTime>
<EndTime>2013-10-14T18:00:00Z</EndTime>
<Title>The Matrix Revolutions</Title>
...
<Stars>0.625</Stars>
...

I don't know what your listings provider gives you. If you have a chance, could you look in your MythTV database and see if there are any fractional values for these tables?

SELECT title,starttime,stars FROM recorded WHERE stars != 0;
SELECT title,starttime,stars FROM program WHERE stars != 0;
billmeek commented 11 years ago

Found a discussion that says mysql ALWAYS inserts decimals with a period. It has to because it also accepts comma separated lists in input and couldn't tell the difference between decimal values and list entries e.g.:

VALUES( 2,2, 4,567, 345,88)

looks like 3 decimal numbers (with , as a decimal point) or 6 integers. How the values appear when output to the user should honor LC_NUMERIC, but that's not the problem here. stars, if used, would likely appear as graphics.

billmeek commented 11 years ago

@MaEngelhard, please retest. It doesn't fail on my system, but you should probably be the final judge. 1.20.2 was released 10/15/2013.

Thanks!

MaEngelhard commented 11 years ago

@billmeek retested with the released 1.20.2 in the play store but didn't work. BUT with the current git version it works?! I'm a little bit confused right now. ?!?!

MaEngelhard commented 11 years ago

I looked in my database and found only decimals as period.

billmeek commented 11 years ago

@MaEngelhard,Confusing and scary. I just tried 1.20.2 from the Play Store and it works. And, I verified that http://mc1:6544/Status/GetStatus returned the load averages with commas. Thanks for checking your MythTV DB.

To be clear, did the top of the Navigation Drawer display "MAF 1.20.2" with your most recent Play Store test? (Apologies for asking that question, but there should be exactly one 1.20.2.)

billmeek commented 11 years ago

@MaEngelhard, I'm not sure why this worked for you from git and not 1.20.2, but if it's OK in 1.20.3 I'd like to close this.

Is that OK with you?

MaEngelhard commented 11 years ago

I'm ok with that. My retest with the 1.20.3 was successful. I believe in my previous test i used an older git version instead of the released 1.20.2. At leased this would explain my results...but for now everything is working.

billmeek commented 11 years ago

Thanks for the response and testing! Closing.