MySQL and REST API issue

2 views
Skip to first unread message

neyric

unread,
Jul 31, 2008, 9:17:50 AM7/31/08
to Persevere
Hi Kris,

Thanks for the 0.9.12 version. That was quick !
I keep on complaning about things that doesn't work, and I forgot to
thank you for persevere.
You've done an amazing job and I hope it'll soon be my favorite
framework :)

I re-wrote a classMapping method that adds client methods into the
class and server methods as JSON-RPC calls, but I have some issues
with the REST POST or PUT methods (to add new items or update a
record).

I set up a datasource that uses a MySql table.

When I do those queries :

PUT /Customer/1
{"id":"1",
"lastName":"new last name",
...
}

POST /Customer/
{
"lastName":"new last name",
...
}

the server answers a 500 http code "Can't call commit when
autocommit=true"

I tried to do a "SET autocommit=0;" on my database, but it is still
the same.

Here is the trace:

com.mysql.jdbc.exceptions.MySQLNonTransientConnectionException: Can't
call rollback when autocommit=true
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:
980)
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:
956)
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:
926)
at com.mysql.jdbc.ConnectionImpl.rollback(ConnectionImpl.java:
4586)
at
org.persvr.datasource.DatabaseDataSource.abortTransaction(DatabaseDataSource.java:
271)
at org.persvr.data.Transaction.commit(Transaction.java:234)
at
org.persvr.remote.ClientConnection.commitTransaction(ClientConnection.java:
69)
at
org.persvr.remote.PersevereFilter.doFilter(PersevereFilter.java:535)
at org.mortbay.jetty.servlet.ServletHandler
$CachedChain.doFilter(ServletHandler.java:1084)
at
org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:
360)
at
org.mortbay.jetty.security.SecurityHandler.handle(SecurityHandler.java:
216)
at
org.mortbay.jetty.servlet.SessionHandler.handle(SessionHandler.java:
181)
at
org.mortbay.jetty.handler.ContextHandler.handle(ContextHandler.java:
726)
at
org.mortbay.jetty.webapp.WebAppContext.handle(WebAppContext.java:405)
at
org.mortbay.jetty.handler.ContextHandlerCollection.handle(ContextHandlerCollection.java:
206)
at
org.mortbay.jetty.handler.HandlerCollection.handle(HandlerCollection.java:
114)
at
org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:
152)
at org.mortbay.jetty.Server.handle(Server.java:324)
at
org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:
505)
at org.mortbay.jetty.HttpConnection
$RequestHandler.content(HttpConnection.java:842)
at org.mortbay.jetty.HttpParser.parseNext(HttpParser.java:648)
at org.mortbay.jetty.HttpParser.parseAvailable(HttpParser.java:
211)
at org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:
380)
at
org.mortbay.io.nio.SelectChannelEndPoint.run(SelectChannelEndPoint.java:
395)
at org.mortbay.thread.BoundedThreadPool
$PoolThread.run(BoundedThreadPool.java:450)
java.lang.RuntimeException: java.sql.SQLException: Can't call commit
when autocommit=true
at org.persvr.data.Transaction.commit(Transaction.java:240)
at
org.persvr.remote.ClientConnection.commitTransaction(ClientConnection.java:
69)
at
org.persvr.remote.PersevereFilter.doFilter(PersevereFilter.java:535)
at org.mortbay.jetty.servlet.ServletHandler
$CachedChain.doFilter(ServletHandler.java:1084)
at
org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:
360)
at
org.mortbay.jetty.security.SecurityHandler.handle(SecurityHandler.java:
216)
at
org.mortbay.jetty.servlet.SessionHandler.handle(SessionHandler.java:
181)
at
org.mortbay.jetty.handler.ContextHandler.handle(ContextHandler.java:
726)
at
org.mortbay.jetty.webapp.WebAppContext.handle(WebAppContext.java:405)
at
org.mortbay.jetty.handler.ContextHandlerCollection.handle(ContextHandlerCollection.java:
206)
at
org.mortbay.jetty.handler.HandlerCollection.handle(HandlerCollection.java:
114)
at
org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:
152)
at org.mortbay.jetty.Server.handle(Server.java:324)
at
org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:
505)
at org.mortbay.jetty.HttpConnection
$RequestHandler.content(HttpConnection.java:842)
at org.mortbay.jetty.HttpParser.parseNext(HttpParser.java:648)
at org.mortbay.jetty.HttpParser.parseAvailable(HttpParser.java:
211)
at org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:
380)
at
org.mortbay.io.nio.SelectChannelEndPoint.run(SelectChannelEndPoint.java:
395)
at org.mortbay.thread.BoundedThreadPool
$PoolThread.run(BoundedThreadPool.java:450)
Caused by: java.sql.SQLException: Can't call commit when
autocommit=true
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:
930)
at com.mysql.jdbc.ConnectionImpl.commit(ConnectionImpl.java:
1535)
at
org.persvr.datasource.DatabaseDataSource.startTransaction(DatabaseDataSource.java:
265)
at
org.persvr.data.Transaction.addAffectedSource(Transaction.java:106)
at
org.persvr.data.PersistableObject.commitPut(PersistableObject.java:
249)
at org.persvr.data.Transaction.commit(Transaction.java:190)
... 19 more

I'll test the same methods with other DataSources...

neyric

unread,
Jul 31, 2008, 9:43:02 AM7/31/08
to Persevere
It works with a DynaObjectDBSource sourceClass.

This issue only appears when we use a DatabaseTableDataSource
sourceClass.

Kris Zyp

unread,
Jul 31, 2008, 10:23:47 AM7/31/08
to persevere...@googlegroups.com
I just uploaded a new copy of version 0.9.12 (didn't increment the version
you are the only one that has downloaded it) that upgrades to Jetty 6.1.11
and should fix the autocommit error. Let me know if you still have issues
with the autocommit error. It would also be great if you could see if
symbolic links work now, if not we will probably want to file a bug with
Jetty.
Thanks,
Kris
Reply all
Reply to author
Forward
0 new messages