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

Problem with add movie : connection still allocated. #21

Closed bdepaz80 closed 8 years ago

bdepaz80 commented 8 years ago

Hello, In the section to add the movie via json, I'm still stumbling upon an exception and I can't seem to find what the problem is.

Upon adding a movie:

Caused by: java.lang.IllegalStateException: Invalid use of BasicClientConnManager: connection still allocated.
Make sure to release the connection before allocating another one.

I saw in an earlier issue, this same problem was already reported, but not mentioned in the solution. I already tried fetching the complete solution project, but even after clean, reinstall of the solution project, I'm still getting the same error.

This was the only glitch I encountered, so I'm keen to find out what I'm bumping against here, so any advice appreciated ;-)

I'm on wildfly-8.2.1.Final, java version "1.7.0_71" OSX, NetBeans 8.1.

arun-gupta commented 8 years ago

Can you try asking your question on WildFly forum? https://developer.jboss.org/en/wildfly

bdepaz80 commented 8 years ago

Ok, I think I located the real problem.

For the record : I was trying with any other version of Wildfly, resulted in the same error. Then I noticed in the wildfly server logs a sql exception :

Caused by: org.h2.jdbc.JdbcSQLException: Unique index or primary key violation: "PRIMARY_KEY_4 ON PUBLIC.MOVIE(ID) VALUES ( /* key:20 */ 20, 'Skyfall', 'Daniel Craig')"; SQL statement:
insert into MOVIE (actors, name, id) values (?, ?, ?) [23505-173]

I've always tried adding a movie as shown in the screenshot in the tutorial (with id=20), never noticed it already existed in my local db. Any other id, the add movie works just fine.

So bottomline, I suppose the "real" sql exception is not returned because it's not translated into a JSON response to the client. I was too much focussing on the stacktrace shown on screen, which is a bit misleading in this case. Lesson learned, thanks! :-)