{"action":"created","issue":{"url":"https://api.github.com/repos/javers/javers/issues/146","labels_url":"https://api.github.com/repos/javers/javers/issues/146/labels{/name}","comments_url":"https://api.github.com/repos/javers/javers/issues/146/comments","events_url":"https://api.github.com/repos/javers/javers/issues/146/events","html_url":"https://github.com/javers/javers/issues/146","id":73209086,"number":146,"title":"Problems with Version 1.2 - support for Mongo 3.0","user":{"login":"mantithetical","id":1190391,"avatar_url":"https://avatars.githubusercontent.com/u/1190391?v=3","gravatar_id":"","url":"https://api.github.com/users/mantithetical","html_url":"https://github.com/mantithetical","followers_url":"https://api.github.com/users/mantithetical/followers","following_url":"https://api.github.com/users/mantithetical/following{/other_user}","gists_url":"https://api.github.com/users/mantithetical/gists{/gist_id}","starred_url":"https://api.github.com/users/mantithetical/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mantithetical/subscriptions","organizations_url":"https://api.github.com/users/mantithetical/orgs","repos_url":"https://api.github.com/users/mantithetical/repos","events_url":"https://api.github.com/users/mantithetical/events{/privacy}","received_events_url":"https://api.github.com/users/mantithetical/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/javers/javers/labels/question","name":"question","color":"cc317c"}],"state":"open","locked":false,"assignee":{"login":"bartoszwalacik","id":2511028,"avatar_url":"https://avatars.githubusercontent.com/u/2511028?v=3","gravatar_id":"","url":"https://api.github.com/users/bartoszwalacik","html_url":"https://github.com/bartoszwalacik","followers_url":"https://api.github.com/users/bartoszwalacik/followers","following_url":"https://api.github.com/users/bartoszwalacik/following{/other_user}","gists_url":"https://api.github.com/users/bartoszwalacik/gists{/gist_id}","starred_url":"https://api.github.com/users/bartoszwalacik/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bartoszwalacik/subscriptions","organizations_url":"https://api.github.com/users/bartoszwalacik/orgs","repos_url":"https://api.github.com/users/bartoszwalacik/repos","events_url":"https://api.github.com/users/bartoszwalacik/events{/privacy}","received_events_url":"https://api.github.com/users/bartoszwalacik/received_events","type":"User","site_admin":false},"milestone":null,"comments":7,"created_at":"2015-05-05T05:00:16Z","updated_at":"2015-05-12T22:08:37Z","closed_at":null,"body":"JaversBuilder.javers().registerJaversRepository(mongoRepo).build() throws\r\n\r\n```java\r\ncom.mongodb.CommandFailureException: { \"serverUsed\" : \"myDb:27017\" , \"ok\" : 0.0 , \"errmsg\" : \"unauthorized\"}\r\n\tat com.mongodb.CommandResult.getException(CommandResult.java:76)\r\n\tat com.mongodb.CommandResult.throwOnError(CommandResult.java:140)\r\n\tat com.mongodb.DB.eval(DB.java:464)\r\n\tat org.javers.repository.mongo.MongoRepository.ensureSchema(MongoRepository.java:139)\r\n\tat org.javers.core.JaversBuilder.build(JaversBuilder.java:90)\r\n```\r\n\r\nThe root cause appears to be the unauthorized migration in ensureSchema:\r\n```java\r\n//schema migration script from 1.1 to 1.2\r\n        BSONObject doc = snapshots.findOne();\r\n        if (doc != null) {\r\n            Object stringCommitId = ((Map)doc.get(\"commitMetadata\")).get(\"id\");\r\n            if (stringCommitId instanceof String) {\r\n                mongo.eval(\"db.jv_snapshots.find().forEach(function(snapshot){snapshot.commitMetadata.id = Number(snapshot.commitMetadata.id);db.jv_snapshots.save(snapshot);});\");\r\n            }\r\n        }\r\n```\r\nThe eval method has been deprecated as of mongodb version 3.0\r\n\r\nI bypassed this issue by running the migration manually. However, after the first commit, subsequents commits throw a class cast exception.\r\n\r\njavers.commit(username, myObject) throws\r\n\r\n```java\r\nCaused by: java.lang.ClassCastException: java.lang.Object cannot be cast to java.lang.String\r\n\tat org.javers.core.metamodel.object.CdoSnapshotBuilder.withChangedProperties(CdoSnapshotBuilder.java:92)\r\n\tat org.javers.core.json.typeadapter.commit.CdoSnapshotTypeAdapter.deserializeChangedProperties(CdoSnapshotTypeAdapter.java:68)\r\n\tat org.javers.core.json.typeadapter.commit.CdoSnapshotTypeAdapter.fromJson(CdoSnapshotTypeAdapter.java:53)\r\n\tat org.javers.core.json.typeadapter.commit.CdoSnapshotTypeAdapter.fromJson(CdoSnapshotTypeAdapter.java:22)\r\n\tat org.javers.core.json.JsonConverterBuilder$2.deserialize(JsonConverterBuilder.java:139)\r\n```"},"comment":{"url":"https://api.github.com/repos/javers/javers/issues/comments/101437149","html_url":"https://github.com/javers/javers/issues/146#issuecomment-101437149","issue_url":"https://api.github.com/repos/javers/javers/issues/146","id":101437149,"user":{"login":"mantithetical","id":1190391,"avatar_url":"https://avatars.githubusercontent.com/u/1190391?v=3","gravatar_id":"","url":"https://api.github.com/users/mantithetical","html_url":"https://github.com/mantithetical","followers_url":"https://api.github.com/users/mantithetical/followers","following_url":"https://api.github.com/users/mantithetical/following{/other_user}","gists_url":"https://api.github.com/users/mantithetical/gists{/gist_id}","starred_url":"https://api.github.com/users/mantithetical/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mantithetical/subscriptions","organizations_url":"https://api.github.com/users/mantithetical/orgs","repos_url":"https://api.github.com/users/mantithetical/repos","events_url":"https://api.github.com/users/mantithetical/events{/privacy}","received_events_url":"https://api.github.com/users/mantithetical/received_events","type":"User","site_admin":false},"created_at":"2015-05-12T22:08:37Z","updated_at":"2015-05-12T22:08:37Z","body":"I am using Mongo 2.6 locally. I dropped both javers collections, so it's a fresh start. The first javers commit works fine as one would expect. Any  subsequent commit fails with the ClassCastException. The problem is with javers 1.2.0 only."}}