分析:
应该是官方的update策略有变化,3.0以前,使用updateOne,3.0以后使用replaceOne
解决办法:
将updateOne替换为replaceOne即可
完整错误栈:
java.lang.IllegalArgumentException: Invalid BSON field name _id
at org.bson.AbstractBsonWriter.writeName(AbstractBsonWriter.java:494) ~[bson-3.2.2.jar:na]
at org.bson.codecs.DocumentCodec.writeMap(DocumentCodec.java:188) ~[bson-3.2.2.jar:na]
at org.bson.codecs.DocumentCodec.encode(DocumentCodec.java:131) ~[bson-3.2.2.jar:na]
at org.bson.codecs.DocumentCodec.encode(DocumentCodec.java:45) ~[bson-3.2.2.jar:na]
at org.bson.codecs.BsonDocumentWrapperCodec.encode(BsonDocumentWrapperCodec.java:63) ~[bson-3.2.2.jar:na]
at org.bson.codecs.BsonDocumentWrapperCodec.encode(BsonDocumentWrapperCodec.java:29) ~[bson-3.2.2.jar:na]
at com.mongodb.connection.UpdateCommandMessage.writeTheWrites(UpdateCommandMessage.java:84) ~[mongodb-driver-core-3.2.2.jar:na]
at com.mongodb.connection.UpdateCommandMessage.writeTheWrites(UpdateCommandMessage.java:42) ~[mongodb-driver-core-3.2.2.jar:na]
at com.mongodb.connection.BaseWriteCommandMessage.encodeMessageBodyWithMetadata(BaseWriteCommandMessage.java:129) ~[mongodb-driver-core-3.2.2.jar:na]
at com.mongodb.connection.RequestMessage.encodeWithMetadata(RequestMessage.java:160) ~[mongodb-driver-core-3.2.2.jar:na]
at com.mongodb.connection.WriteCommandProtocol.sendMessage(WriteCommandProtocol.java:212) ~[mongodb-driver-core-3.2.2.jar:na]
at com.mongodb.connection.WriteCommandProtocol.execute(WriteCommandProtocol.java:101) ~[mongodb-driver-core-3.2.2.jar:na]
at com.mongodb.connection.UpdateCommandProtocol.execute(UpdateCommandProtocol.java:64) ~[mongodb-driver-core-3.2.2.jar:na]
at com.mongodb.connection.UpdateCommandProtocol.execute(UpdateCommandProtocol.java:37) ~[mongodb-driver-core-3.2.2.jar:na]
at com.mongodb.connection.DefaultServer$DefaultServerProtocolExecutor.execute(DefaultServer.java:159) ~[mongodb-driver-core-3.2.2.jar:na]
at com.mongodb.connection.DefaultServerConnection.executeProtocol(DefaultServerConnection.java:286) ~[mongodb-driver-core-3.2.2.jar:na]
at com.mongodb.connection.DefaultServerConnection.updateCommand(DefaultServerConnection.java:140) ~[mongodb-driver-core-3.2.2.jar:na]
at com.mongodb.operation.MixedBulkWriteOperation$Run$3.executeWriteCommandProtocol(MixedBulkWriteOperation.java:480) ~[mongodb-driver-core-3.2.2.jar:na]
at com.mongodb.operation.MixedBulkWriteOperation$Run$RunExecutor.execute(MixedBulkWriteOperation.java:646) ~[mongodb-driver-core-3.2.2.jar:na]
at com.mongodb.operation.MixedBulkWriteOperation$Run.execute(MixedBulkWriteOperation.java:399) ~[mongodb-driver-core-3.2.2.jar:na]
at com.mongodb.operation.MixedBulkWriteOperation$1.call(MixedBulkWriteOperation.java:179) ~[mongodb-driver-core-3.2.2.jar:na]
at com.mongodb.operation.MixedBulkWriteOperation$1.call(MixedBulkWriteOperation.java:168) ~[mongodb-driver-core-3.2.2.jar:na]
at com.mongodb.operation.OperationHelper.withConnectionSource(OperationHelper.java:230) ~[mongodb-driver-core-3.2.2.jar:na]
at com.mongodb.operation.OperationHelper.withConnection(OperationHelper.java:221) ~[mongodb-driver-core-3.2.2.jar:na]
at com.mongodb.operation.MixedBulkWriteOperation.execute(MixedBulkWriteOperation.java:168) ~[mongodb-driver-core-3.2.2.jar:na]
at com.mongodb.operation.MixedBulkWriteOperation.execute(MixedBulkWriteOperation.java:74) ~[mongodb-driver-core-3.2.2.jar:na]
at com.mongodb.Mongo.execute(Mongo.java:781) ~[mongodb-driver-3.2.2.jar:na]
at com.mongodb.Mongo$2.execute(Mongo.java:764) ~[mongodb-driver-3.2.2.jar:na]
at com.mongodb.MongoCollectionImpl.executeSingleWriteRequest(MongoCollectionImpl.java:515) ~[mongodb-driver-3.2.2.jar:na]
at com.mongodb.MongoCollectionImpl.update(MongoCollectionImpl.java:508) ~[mongodb-driver-3.2.2.jar:na]
at com.mongodb.MongoCollectionImpl.updateOne(MongoCollectionImpl.java:355) ~[mongodb-driver-3.2.2.jar:na]
at com.mongodb.MongoCollectionImpl.updateOne(MongoCollectionImpl.java:350) ~[mongodb-driver-3.2.2.jar:na]
at app.saas.SaasSettings.dao.TicketTypeDao.updateTicketType(TicketTypeDao.java:53) ~[classes/:na]
at app.saas.SaasSettings.service.TicketTypeServiceImpl.updateTicketType(TicketTypeServiceImpl.java:47) ~[classes/:na]
at app.saas.SaasSettings.rest.TicketTypeSettingRest.updateTicketType(TicketTypeSettingRest.java:89) ~[classes/:na]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.7.0_67]
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) ~[na:1.7.0_67]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.7.0_67]
at java.lang.reflect.Method.invoke(Method.java:606) ~[na:1.7.0_67]
at com.sun.jersey.spi.container.JavaMethodInvokerFactory$1.invoke(JavaMethodInvokerFactory.java:60) [jersey-server-1.19.jar:1.19]
at com.sun.jersey.server.impl.model.method.dispatch.AbstractResourceMethodDispatchProvider$ResponseOutInvoker._dispatch(AbstractResourceMethodDispatchProvider.java:205) [jersey-server-1.19.jar:1.19]
at com.sun.jersey.server.impl.model.method.dispatch.ResourceJavaMethodDispatcher.dispatch(ResourceJavaMethodDispatcher.java:75) [jersey-server-1.19.jar:1.19]
at com.sun.jersey.server.impl.uri.rules.HttpMethodRule.accept(HttpMethodRule.java:302) [jersey-server-1.19.jar:1.19]
at com.sun.jersey.server.impl.uri.rules.ResourceClassRule.accept(ResourceClassRule.java:108) [jersey-server-1.19.jar:1.19]
at com.sun.jersey.server.impl.uri.rules.RightHandPathRule.accept(RightHandPathRule.java:147) [jersey-server-1.19.jar:1.19]
at com.sun.jersey.server.impl.uri.rules.RootResourceClassesRule.accept(RootResourceClassesRule.java:84) [jersey-server-1.19.jar:1.19]
at com.sun.jersey.server.impl.application.WebApplicationImpl._handleRequest(WebApplicationImpl.java:1542) [jersey-server-1.19.jar:1.19]
at com.sun.jersey.server.impl.application.WebApplicationImpl._handleRequest(WebApplicationImpl.java:1473) [jersey-server-1.19.jar:1.19]
at com.sun.jersey.server.impl.application.WebApplicationImpl.handleRequest(WebApplicationImpl.java:1419) [jersey-server-1.19.jar:1.19]
at com.sun.jersey.server.impl.application.WebApplicationImpl.handleRequest(WebApplicationImpl.java:1409) [jersey-server-1.19.jar:1.19]
at com.sun.jersey.spi.container.servlet.WebComponent.service(WebComponent.java:409) [jersey-bundle-1.19.jar:1.19]
at com.sun.jersey.spi.container.servlet.ServletContainer.service(ServletContainer.java:558) [jersey-bundle-1.19.jar:1.19]
at com.sun.jersey.spi.container.servlet.ServletContainer.service(ServletContainer.java:733) [jersey-bundle-1.19.jar:1.19]
at javax.servlet.http.HttpServlet.service(HttpServlet.java:848) [javax.servlet-3.0.0.v201112011016.jar:na]
at org.eclipse.jetty.servlet.ServletHolder.handle(ServletHolder.java:670) [jetty-servlet-9.0.0.M4.jar:9.0.0.M4]
at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1318) [jetty-servlet-9.0.0.M4.jar:9.0.0.M4]
at com.thetransactioncompany.cors.CORSFilter.doFilter(CORSFilter.java:158) [cors-filter-1.9.1.jar:1.9.1]
at com.thetransactioncompany.cors.CORSFilter.doFilter(CORSFilter.java:232) [cors-filter-1.9.1.jar:1.9.1]
at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1289) [jetty-servlet-9.0.0.M4.jar:9.0.0.M4]
at org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:442) [jetty-servlet-9.0.0.M4.jar:9.0.0.M4]
at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:138) [jetty-server-9.0.0.M4.jar:9.0.0.M4]
at org.eclipse.jetty.security.SecurityHandler.handle(SecurityHandler.java:564) [jetty-security-9.0.0.M4.jar:9.0.0.M4]
at org.eclipse.jetty.server.session.SessionHandler.doHandle(SessionHandler.java:213) [jetty-server-9.0.0.M4.jar:9.0.0.M4]
at org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1067) [jetty-server-9.0.0.M4.jar:9.0.0.M4]
at org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:371) [jetty-servlet-9.0.0.M4.jar:9.0.0.M4]
at org.eclipse.jetty.server.session.SessionHandler.doScope(SessionHandler.java:175) [jetty-server-9.0.0.M4.jar:9.0.0.M4]
at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:1001) [jetty-server-9.0.0.M4.jar:9.0.0.M4]
at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:136) [jetty-server-9.0.0.M4.jar:9.0.0.M4]
at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:97) [jetty-server-9.0.0.M4.jar:9.0.0.M4]
at org.eclipse.jetty.server.Server.handle(Server.java:437) [jetty-server-9.0.0.M4.jar:9.0.0.M4]
at org.eclipse.jetty.server.HttpChannel.run(HttpChannel.java:246) [jetty-server-9.0.0.M4.jar:9.0.0.M4]
at org.eclipse.jetty.server.HttpConnection.onFillable(HttpConnection.java:265) [jetty-server-9.0.0.M4.jar:9.0.0.M4]
at org.eclipse.jetty.io.AbstractConnection$ReadCallback.run(AbstractConnection.java:240) [jetty-io-9.0.0.M4.jar:9.0.0.M4]
at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:589) [jetty-util-9.0.0.M4.jar:9.0.0.M4]
at org.eclipse.jetty.util.thread.QueuedThreadPool$3.run(QueuedThreadPool.java:520) [jetty-util-9.0.0.M4.jar:9.0.0.M4]
at java.lang.Thread.run(Thread.java:745) [na:1.7.0_67]
by 刘迎光@萤火虫工作室
OpenBI交流群:495266201
MicroService 微服务交流群:217722918
mail: liuyg#liuyingguang.cn
博主首页(防止爬虫):http://blog.liuyingguang.cn
OpenBI问答社区:http://openbi.liuyingguang.cn/