Every property is present in the model. But still getting error:
An exception of type 'System.NullReferenceException' occurred in App_Web_vzy5d524.dll but was not handled in user code
I am not getting why this error is occuring. Things were working fine not started getting error.
Please guide if any idea.
It indicates that your model value is NULL
Related
A method which was working for a long time in Grails 2.2.5 has broken after moving to 4.0.11 with a validation error on saving, and the error is a puzzle to me. I have a domain class 'Decline' which has one of its properties 'user', which is of domain class user. As part of the save process I assign the currently logged in user to this property:
Decline decline = new Decline()
decline.policy = policy
decline.declineTime = new Date()
decline.field = field
decline.cause = reason
decline.user = User.getUser()
decline.save(flush:true)
This was working fine in 2.2.5 but now I get the following validation error:
Field error in object 'myapp.pei.Decline' on field 'user.userType': rejected value [DIRECT_CLIENT]; codes [myapp.User.userType.nullable.error.myapp.pei.Decline.user.userType,myapp.User.userType.nullable.error.user.userType,myapp.User.userType.nullable.error.userType,myapp.User.userType.nullable.error.myapp.UserType,myapp.User.userType.nullable.error,user.userType.nullable.error.myapp.pei.Decline.user.userType,user.userType.nullable.error.user.userType,user.userType.nullable.error.userType,user.userType.nullable.error.myapp.UserType,user.userType.nullable.error,myapp.User.userType.nullable.myapp.pei.Decline.user.userType,myapp.User.userType.nullable.user.userType,myapp.User.userType.nullable.userType,myapp.User.userType.nullable.myapp.UserType,myapp.User.userType.nullable,user.userType.nullable.myapp.pei.Decline.user.userType,user.userType.nullable.user.userType,user.userType.nullable.userType,user.userType.nullable.myapp.UserType,user.userType.nullable,nullable.myapp.pei.Decline.user.userType,nullable.user.userType,nullable.userType,nullable.myapp.UserType,nullable]; arguments [userType,class myapp.User]; default message [Property [{0}] of class [{1}] cannot be null]
There are two things which are puzzling about this. Firstly, and more importantly, this appears to be an error saving the User object. But why is it even trying to save the User object? I have assigned an existing User object which it should be using. Secondly, the specific error is 'rejected value [DIRECT_CLIENT]' for field 'user.userType', but the error message is that this field cannot be null. So it's rejecting a value but telling me it cannot be null! The value, incidentally, is of a UserType enum defined thus:
public enum UserType {
ADMIN_USER,ADMIN_OWNER_USER,SUPER_USER,BROKER,DIRECT_CLIENT
}
I wonder what change from version 2.2.5 to 4 (or maybe 3) could have caused this?
It seems there was some change in behaviour of deepValidate between Grails 2.x and 4.x which is causing this, although I don't see why validation of the associated User object should be failing when it can actually be saved OK separately. But what got me past this issue was to set the following in the mapping block for Decline:
user cascadeValidate: 'none'
This ensures that when the Decline object is saved it does not attempt to validate the User as well.
Does anyone know why this error occurs?
'Validation failed for one or more entities. See 'EntityValidationErrors' property for more details.'
I am getting this error when I am trying to update a bool value in my database. Please see the picture for get clear idea.
Following code solve my issue. Thanks for all comments
db.Configuration.ValidateOnSaveEnabled = false;
I am using Umbraco version 7.4.3 assembly: 1.0.5948.18141
I am getting intermittent exceptions during fetch and query operations. I have scoured the web for answers and am coming up empty. This is what shows up in my umbraco log file when I get these errors. I have validated that with the same query that works over and over again, that occasionally I get this error. I have added retry logic with garbage collection in the exception handlers and sleep statements, but to no avail. Anything anyone could suggest to shed light on this would be extremely helpful. I am desperate. :)
2016-11-03 10:49:12,240 [P2872/D6/T1120] ERROR
Umbraco.Core.Persistence.UmbracoDatabase - Database exception occurred
System.NullReferenceException: Object reference not set to an instance
of an object. at Umbraco.Core.Persistence.Database.d71.MoveNext()
2016-11-03 10:49:13,442 [P2872/D6/T1120] ERROR
Umbraco.Core.Persistence.UmbracoDatabase - Database exception occurred
System.NullReferenceException: Object reference not set to an instance
of an object. at
Umbraco.Core.Persistence.Database.d__71.MoveNext() 2016-11-03
10:49:14,518 [P2872/D6/T1120] ERROR
Umbraco.Core.Persistence.UmbracoDatabase - Database exception occurred
System.NullReferenceException: Object reference not set to an instance
of an object. at Umbraco.Core.Persistence.Database.d7`1.MoveNext()
I am trying to determine what the Error Code is from an exception that is thrown when interacting with a domain object in Grails.
I have a database that has some field validations, and one of the validations is that a specific column must be unique. According to the docs it will give an Error Code of className.propertyName.unique(http://grails.org/doc/latest/ref/Constraints/unique.html). When I wrap my controller in a try catch block like. I can catch all kinds of validation exceptions this:
catch (grails.validation.ValidationException e) {
exception handling code here
}
How do I access the Error Code? I would like to do something like If the Error Code = className1.propertyName2.unique, then respond propertyName2 is not unique.
I do have "failOnError: true" set as a parameter when I do my save operation.
Thanks!
The Error Code is burried deep within the object. It will be one of the items in the list that is returned by calling the following code, where 'e' is the exception object.
e.getErrors().getFieldError()
You can also get just the code ("unique" in this case) from the exception by calling the following:
e.getErrors().getFieldError().getCode()
I have an error (see below). At first glance it seems obvious to me, however. I've checked everything: the MODEL is ok; metadata class set ok and i've checked my controller and at the time 'TryUpdateMOdel' is called all is well and the object is as i expect it to be. I'm thinking this will be something silly but been stuck all day, anyone recommend anything?
The associated metadata type for type 'Lms.Model.PaymentFrequency' contains the following unknown properties or fields: SiteAgreementId, PaymentTypeId, PaymentCategoryId, ObligationStartDate, TerminationDate, Comments. Please make sure that the names of these members match the names of the properties on the main type.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.InvalidOperationException: The associated metadata type for type 'Lms.Model.PaymentFrequency' contains the following unknown properties or fields: SiteAgreementId, PaymentTypeId, PaymentCategoryId, ObligationStartDate, TerminationDate, Comments. Please make sure that the names of these members match the names of the properties on the main type.
Source Error:
Line 120: PaymentFrequency paymentFrequency = this._siteRepository.GetPayment(Convert.ToInt16(collection["PaymentId"])).PaymentFrequency;
Line 121:
Line 122: TryUpdateModel(paymentFrequency);
Line 123:
Line 124: if (!ModelState.IsValid)
It sounds like the metadata class you have attached to your PaymentFrequency model may have properties the model itself doesn't.