UnsupportedTypeExceptions on latest 3.5 build

51 views
Skip to first unread message

Nick

unread,
Jun 25, 2016, 6:56:07 AM6/25/16
to RavenDB - 2nd generation document database
I am taking RavenDB 3.5 for a test run and have upgraded a 3.0 server to 3.5 and upgraded the app to use the 3.5 client (latest build as of today), I now keep getting UnsupportedTypeExceptions when saving changes on this line, let me know if you want the full stack trace

Raven.Imports.Newtonsoft.Json.JsonWriter.CreateUnsupportedTypeException(JsonWriter writer, Object value) in C:\Builds\RavenDB-3.5-Unstable\Imports\Newtonsoft.Json\Src\Newtonsoft.Json\JsonWriter.cs:line 1436 

Its worth noting if I use 3.0 client against 3.5 server I don't get these errors.

Also couple of questions on 3 and 3.5 compatibility

> Should I be able to just upgrade a 3.0 database or do I need to start with a clean DB and replicate from a 3.0 database
> Can I use the 3.0 client against a 3.5 server?
> Can i use a 3.5 client against a 3.0 server?

Thanks



Grisha Kotler

unread,
Jun 25, 2016, 7:23:29 AM6/25/16
to rav...@googlegroups.com
Can you share the full stack trace?

- You can just upgrade a 3.0 database to 3.5.
- Yes.
- No. (this might work but it's not supported).

Hibernating Rhinos Ltd  cid:image001.png@01CF95E2.8ED1B7D0

Grisha Kotler l RavenDB Core Team Developer Mobile: +972-54-586-8647

Office: +972-4-622-7811 l Fax: +972-153-4-622-7811

RavenDB paving the way to "Data Made Simplehttp://ravendb.net/


--
You received this message because you are subscribed to the Google Groups "RavenDB - 2nd generation document database" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ravendb+u...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Nick

unread,
Jun 25, 2016, 7:30:45 AM6/25/16
to RavenDB - 2nd generation document database
Here you go

[NullReferenceException: Object reference not set to an instance of an object.]
   System.Object.GetType() +0
   Raven.Imports.Newtonsoft.Json.JsonWriter.CreateUnsupportedTypeException(JsonWriter writer, Object value) in C:\Builds\RavenDB-3.5-Unstable\Imports\Newtonsoft.Json\Src\Newtonsoft.Json\JsonWriter.cs:1436
   Raven.Imports.Newtonsoft.Json.JsonWriter.WriteValue(JsonWriter writer, PrimitiveTypeCode typeCode, Object value) in C:\Builds\RavenDB-3.5-Unstable\Imports\Newtonsoft.Json\Src\Newtonsoft.Json\JsonWriter.cs:1424
   Raven.Imports.Newtonsoft.Json.JsonWriter.WriteValue(JsonWriter writer, PrimitiveTypeCode typeCode, Object value) in C:\Builds\RavenDB-3.5-Unstable\Imports\Newtonsoft.Json\Src\Newtonsoft.Json\JsonWriter.cs:1424
   Raven.Imports.Newtonsoft.Json.JsonWriter.WriteValue(Object value) in C:\Builds\RavenDB-3.5-Unstable\Imports\Newtonsoft.Json\Src\Newtonsoft.Json\JsonWriter.cs:1243
   Raven.Client.Document.EntityToJson.<GetObjectAsJson>b__12_0(Object o, JsonWriter writer) in C:\Builds\RavenDB-3.5-Unstable\Raven.Client.Lightweight\Document\EntityToJson.cs:81
   Raven.Imports.Newtonsoft.Json.Serialization.JsonSerializerInternalWriter.SerializeObject(JsonWriter writer, Object value, JsonObjectContract contract, JsonProperty member, JsonContainerContract collectionContract, JsonProperty containerProperty) in C:\Builds\RavenDB-3.5-Unstable\Imports\Newtonsoft.Json\Src\Newtonsoft.Json\Serialization\JsonSerializerInternalWriter.cs:466
   Raven.Imports.Newtonsoft.Json.Serialization.JsonSerializerInternalWriter.Serialize(JsonWriter jsonWriter, Object value, Type objectType) in C:\Builds\RavenDB-3.5-Unstable\Imports\Newtonsoft.Json\Src\Newtonsoft.Json\Serialization\JsonSerializerInternalWriter.cs:101
   Raven.Imports.Newtonsoft.Json.JsonSerializer.SerializeInternal(JsonWriter jsonWriter, Object value, Type objectType) in C:\Builds\RavenDB-3.5-Unstable\Imports\Newtonsoft.Json\Src\Newtonsoft.Json\JsonSerializer.cs:949
   Raven.Json.Linq.RavenJToken.FromObjectInternal(Object o, JsonSerializer jsonSerializer) in C:\Builds\RavenDB-3.5-Unstable\Raven.Abstractions\Json\Linq\RavenJToken.cs:91
   Raven.Json.Linq.RavenJObject.FromObject(Object o, JsonSerializer jsonSerializer) in C:\Builds\RavenDB-3.5-Unstable\Raven.Abstractions\Json\Linq\RavenJObject.cs:174
   Raven.Client.Document.EntityToJson.GetObjectAsJson(Object entity) in C:\Builds\RavenDB-3.5-Unstable\Raven.Client.Lightweight\Document\EntityToJson.cs:72
   Raven.Client.Document.EntityToJson.ConvertEntityToJson(String key, Object entity, RavenJObject metadata) in C:\Builds\RavenDB-3.5-Unstable\Raven.Client.Lightweight\Document\EntityToJson.cs:44
   Raven.Client.Document.InMemoryDocumentSessionOperations.EntityChanged(Object entity, DocumentMetadata documentMetadata, IDictionary`2 changes) in C:\Builds\RavenDB-3.5-Unstable\Raven.Client.Lightweight\Document\InMemoryDocumentSessionOperations.cs:1187
   Raven.Client.Document.InMemoryDocumentSessionOperations.<PrepareForEntitiesPuts>b__108_0(KeyValuePair`2 pair) in C:\Builds\RavenDB-3.5-Unstable\Raven.Client.Lightweight\Document\InMemoryDocumentSessionOperations.cs:1002
   System.Linq.WhereEnumerableIterator`1.MoveNext() +222
   System.Linq.Buffer`1..ctor(IEnumerable`1 source) +176
   System.Linq.Enumerable.ToArray(IEnumerable`1 source) +106
   Raven.Client.Document.InMemoryDocumentSessionOperations.PrepareForEntitiesPuts(SaveChangesData result) in C:\Builds\RavenDB-3.5-Unstable\Raven.Client.Lightweight\Document\InMemoryDocumentSessionOperations.cs:1002
   Raven.Client.Document.InMemoryDocumentSessionOperations.PrepareForSaveChanges() in C:\Builds\RavenDB-3.5-Unstable\Raven.Client.Lightweight\Document\InMemoryDocumentSessionOperations.cs:986
   Raven.Client.Document.DocumentSession.SaveChanges() in C:\Builds\RavenDB-3.5-Unstable\Raven.Client.Lightweight\Document\DocumentSession.cs:740
   Marketplace.Core.Session.AppSession.Commit() in C:\Dev\Repositories\Marketplace\src\Marketplace.Core\Session\AppSession.cs:163
   Marketplace.Web.ActionFilters.SessionActionFilterAttribute.OnResultExecuted(ResultExecutedContext filterContext) in C:\Dev\Repositories\Marketplace\src\Marketplace.Web\ActionFilters\SessionActionFilterAttribute.cs:38
   System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilterRecursive(IList`1 filters, Int32 filterIndex, ResultExecutingContext preContext, ControllerContext controllerContext, ActionResult actionResult) +444
   System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilterRecursive(IList`1 filters, Int32 filterIndex, ResultExecutingContext preContext, ControllerContext controllerContext, ActionResult actionResult) +833
   System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilterRecursive(IList`1 filters, Int32 filterIndex, ResultExecutingContext preContext, ControllerContext controllerContext, ActionResult actionResult) +833
   System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilterRecursive(IList`1 filters, Int32 filterIndex, ResultExecutingContext preContext, ControllerContext controllerContext, ActionResult actionResult) +833
   System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilterRecursive(IList`1 filters, Int32 filterIndex, ResultExecutingContext preContext, ControllerContext controllerContext, ActionResult actionResult) +833
   System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilterRecursive(IList`1 filters, Int32 filterIndex, ResultExecutingContext preContext, ControllerContext controllerContext, ActionResult actionResult) +833
   System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilterRecursive(IList`1 filters, Int32 filterIndex, ResultExecutingContext preContext, ControllerContext controllerContext, ActionResult actionResult) +833
   System.Web.Mvc.ControllerActionInvoker.InvokeActionResultWithFilters(ControllerContext controllerContext, IList`1 filters, ActionResult actionResult) +81
   System.Web.Mvc.Async.<>c__DisplayClass21.<BeginInvokeAction>b__1e(IAsyncResult asyncResult) +186
   System.Web.Mvc.Async.AsyncControllerActionInvoker.EndInvokeAction(IAsyncResult asyncResult) +38
   System.Web.Mvc.Controller.<BeginExecuteCore>b__1d(IAsyncResult asyncResult, ExecuteCoreState innerState) +29
   System.Web.Mvc.Async.WrappedAsyncVoid`1.CallEndDelegate(IAsyncResult asyncResult) +67
   System.Web.Mvc.Controller.EndExecuteCore(IAsyncResult asyncResult) +53
   System.Web.Mvc.Async.WrappedAsyncVoid`1.CallEndDelegate(IAsyncResult asyncResult) +36
   System.Web.Mvc.Controller.EndExecute(IAsyncResult asyncResult) +38
   System.Web.Mvc.MvcHandler.<BeginProcessRequest>b__5(IAsyncResult asyncResult, ProcessRequestState innerState) +44
   System.Web.Mvc.Async.WrappedAsyncVoid`1.CallEndDelegate(IAsyncResult asyncResult) +67
   System.Web.Mvc.MvcHandler.EndProcessRequest(IAsyncResult asyncResult) +38
   System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +399
   System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +137

Oren Eini (Ayende Rahien)

unread,
Jun 25, 2016, 11:59:01 AM6/25/16
to ravendb
Can you send a failing test? This is very strange.

Hibernating Rhinos Ltd  

Oren Eini l CEO Mobile: + 972-52-548-6969

Nick

unread,
Jun 26, 2016, 5:36:34 AM6/26/16
to RavenDB - 2nd generation document database
Well I cant reproduce this with an embedded document store, but I do have some steps for you which will hopefully allow you to reproduce the issue.

The problem seems to arise when saving changes on documents that were not created via the client API, so if I replicate documents into a server or just create them manually on the server I am having trouble subsequently saving changes after loading those documents. So to reproduce.
  1. Create a new database called "Test"
  2. Manually create a new document in the database with Id = "users/1" and the following content
{
    "FirstName": "Nick",
    "LastName": "Champion",
    "Email": "ni...@test.com",
    "ExternalId": "3500031",
    "Password": "fdsfdsf",
    "PasswordToken": "fb980637-d95c-4d9d-b706-2a21146bc62c",
    "UserType": "User",
    "MerchantId": null,
    "CreatedAt": "2015-02-09T14:11:28.5684161+00:00",
    "LastLogin": "2016-06-25T05:43:02.4338434+01:00",
    "CreatedByUserId": null,
    "Source": "SignUp",
    "Country2LetterISOCode": "SG",
    "Timezone": "Morocco Standard Time",
    "Language": "en",
    "Gender": null,
    "Avatar": null,
    "SsoToken": "21fcbd0450820b85bb8dd",
    "ApiToken": {
        "CreatedAt": "2016-06-17T14:20:49.5049868+01:00",
        "Token": "15a9"
    },
    "ContactNumber": {
        "CountryCode": 65,
        "Number": "789456123"
    },
    "Preferences": {
        "DefaultShippingAddressId": 1,
        "DefaultBillingAddressId": 1,
        "DefaultPaymentMethodId": "ep"
    },
    "DateOfBirth": null,
    "ThirdPartyConnections": [],
    "Merchants": [],
    "Roles": [
        "User"
    ],
    "Countries": [],
    "RegisteredAt": "2015-02-09T14:11:28.5684161+00:00",
    "CurrencyIsoCode": null
}

Then run the test in the following Gist (you will need to set the URL for the document store beforehand obviously)


I'm then getting the following error

System.NullReferenceException : Object reference not set to an instance of an object.
   at System.Object.GetType()
   at Raven.Imports.Newtonsoft.Json.JsonWriter.CreateUnsupportedTypeException(JsonWriter writer, Object value) in C:\Builds\RavenDB-3.5-Unstable\Imports\Newtonsoft.Json\Src\Newtonsoft.Json\JsonWriter.cs:line 1436
   at Raven.Imports.Newtonsoft.Json.JsonWriter.WriteValue(JsonWriter writer, PrimitiveTypeCode typeCode, Object value) in C:\Builds\RavenDB-3.5-Unstable\Imports\Newtonsoft.Json\Src\Newtonsoft.Json\JsonWriter.cs:line 1424

I'm on build 3.5.35129 if it helps.

Thanks

Nick

Tal Weiss

unread,
Jun 28, 2016, 7:46:15 AM6/28/16
to RavenDB - 2nd generation document database
The underlining issue here is that the document has the property "CurrencyIsoCode" and your C# class does not.
That said, this is something that we support and should not be throwing an exception.
I'm currently working on resolving this issue, you can keep track of the issue at:

Tal Weiss l Core Team Developer Mobile:+972-54-802-4849

Office: +972-4-622-7811 l Fax: +972-153-4-622-7811l Skype: talweiss1982

Tal Weiss

unread,
Jun 28, 2016, 9:52:09 AM6/28/16
to RavenDB - 2nd generation document database
The issue was resolved, running tests at the moment to make sure nothing got broken.
I have added a test for this case so it won't break again, you can see it at:

Nick

unread,
Jun 28, 2016, 4:07:02 PM6/28/16
to RavenDB - 2nd generation document database
Ok thanks Tal, I will test this out once the build's ready
Reply all
Reply to author
Forward
0 new messages