javaee-samples / javaee7-hol

Java EE 7 Hands-on Lab
http://htmlpreview.github.io/?https://github.com/javaee-samples/javaee7-hol/blob/master/docs/javaee7-hol.html
Other
136 stars 92 forks source link

Exceptions with add movie #14

Closed martin-welss closed 10 years ago

martin-welss commented 10 years ago

In Section 7 of the HOL "Add Movie" I get the following exceptions:

1. javax.json.JsonException: Cannot auto-detect encoding, not enough chars t org.javaee7.movieplex7.json.MovieReader.readFrom(MovieReader.java:31) [classes:] at org.javaee7.movieplex7.json.MovieReader.readFrom(MovieReader.java:19) [classes:]

2. java.lang.IllegalStateException: Invalid use of BasicClientConnManager: connection still allocated. at org.javaee7.movieplex7.client.MovieClientBean.getMovies(MovieClientBean.java:52) [classes:]

This happens both with wildfly 8.0.0.Final as well as with 8.1.0.CR1

arun-gupta commented 10 years ago

Are you seeing this error every time ?

Can you try the solution at https://github.com/javaee-samples/javaee7-hol/tree/master/solution ?

martin-welss commented 10 years ago

The solution works fine, so I tracked my bug down in my code: It was a problem with imports and parameter names in MovieReader.readFrom(). I copied only the implementation from your text leaving the signature as it was generated by netbeans "implement all abstract methods". But I did not notice that the parameter names were not the same and "fix imports" fixed the "InputStream in" to be "static import java.lang.System.in". So the method tried to read from stdin which of course had zero chars and thus explaining the first exception.

Thank you very much for your hint!