MANAGED_CLASS_MAPPING_ERROR: for 'class java.util.Comparators$NaturalOrderComparator' - javers

I am using Javers 2.9.2. When comparing two object getting this exception- MANAGED_CLASS_MAPPING_ERROR: given javaClass 'class java.util.Comparators$NaturalOrderComparator' is mapped to PrimitiveType, expected ManagedType

Related

Xamarin Android Native binding for Android Plugin SDK

I am trying to create xamarin wrapper for Plugin SDK built in Native Android (built using kotlin language).
I am getting below log.
obj/Debug/api.xml.class-parse : warning BG8605: The Java type '$' could not be found (are you missing a Java reference jar/aar or a Java binding library NuGet?)
/Library/Frameworks/Mono.framework/External/xbuild/Xamarin/Android/Xamarin.Android.Bindings.ClassParse.targets(36,5): obj/Debug/api.xml.class-parse warning BG8605: The Java type '$' could not be found (are you missing a Java reference jar/aar or a Java binding library NuGet?)
obj/Debug/api.xml.class-parse : warning BG8605: The Java type 'kotlin.jvm.internal.FunctionReferenceImpl' could not be found (are you missing a Java reference jar/aar or a Java binding library NuGet?)
/Library/Frameworks/Mono.framework/External/xbuild/Xamarin/Android/Xamarin.Android.Bindings.ClassParse.targets(36,5): obj/Debug/api.xml.class-parse warning BG8605: The Java type 'kotlin.jvm.internal.FunctionReferenceImpl' could not be found (are you missing a Java reference jar/aar or a Java binding library NuGet?)
The method '[Method] com.*.blesdk.manager.BluetoothLeService access$getMBluetoothLeService$p(com.*.blesdk.manager.BLEConnectionManager $this)' was removed because its name contains a dollar sign.
The method '[Method] java.lang.String access$getMDeviceAddress$p(com.*.blesdk.manager.BLEConnectionManager $this)' was removed because its name contains a dollar sign.
The method '[Method] com.*.blesdk.manager.BLEConnectionManager.BLEConnectionListener access$getUser$p(com.*.blesdk.manager.BLEConnectionManager $this)' was removed because its name contains a dollar sign.
The method '[Method] void access$setMBluetoothLeService$p(com.*.blesdk.manager.BLEConnectionManager $this, com.*.blesdk.manager.BluetoothLeService <set-?>)' was removed because its name contains a dollar sign.
The method '[Method] boolean connectDevice$default(com.*.blesdk.manager.BLEConnectionManager p0, java.lang.String p1, int p2, java.lang.Object p3)' was removed because its name contains a dollar sign.
The class '[Class] com.*.blesdk.manager.BLEConnectionManager.Companion.1' was removed because the Java base type 'kotlin.jvm.internal.FunctionReferenceImpl' could not be found.
The class '[Class] com.*.blesdk.manager.BLEScanManager.Companion.1' was removed because the Java base type 'kotlin.jvm.internal.FunctionReferenceImpl' could not be found.
The method '[Method] void access$broadcastUpdate(com.*.blesdk.manager.BluetoothLeService $this, java.lang.String action)' was removed because its name contains a dollar sign.
The method '[Method] void access$broadcastUpdate(com.*.blesdk.manager.BluetoothLeService $this, java.lang.String action, android.bluetooth.BluetoothGattCharacteristic characteristic)' was removed because its name contains a dollar sign.
The method '[Method] android.bluetooth.BluetoothGatt access$getMBluetoothGatt$p(com.*.blesdk.manager.BluetoothLeService $this)' was removed because its name contains a dollar sign.
The method '[Method] java.lang.String access$getTAG$cp()' was removed because its name contains a dollar sign.
The method '[Method] java.util.UUID access$getUUID_HEART_RATE_MEASUREMENT$cp()' was removed because its name contains a dollar sign.
The method '[Method] void access$setMConnectionState$p(com.*.blesdk.manager.BluetoothLeService $this, int <set-?>)' was removed because its name contains a dollar sign.
The method '[Method] void logd$default(com.*.blesdk.utility.Loggers p0, java.lang.String p1, java.lang.Throwable p2, int p3, java.lang.Object p4)' was removed because its name contains a dollar sign.
The method '[Method] void loge$default(com.*.blesdk.utility.Loggers p0, java.lang.String p1, java.lang.Throwable p2, int p3, java.lang.Object p4)' was removed because its name contains a dollar sign.
The method '[Method] void logi$default(com.*.blesdk.utility.Loggers p0, java.lang.String p1, java.lang.Throwable p2, int p3, java.lang.Object p4)' was removed because its name contains a dollar sign.
The method '[Method] void logv$default(com.*.blesdk.utility.Loggers p0, java.lang.String p1, java.lang.Throwable p2, int p3, java.lang.Object p4)' was removed because its name contains a dollar sign.
The method '[Method] void logw$default(com.*.blesdk.utility.Loggers p0, java.lang.String p1, java.lang.Throwable p2, int p3, java.lang.Object p4)' was removed because its name contains a dollar sign.
obj/Debug/java-resolution-report.log : warning BG8606: Some types or members could not be bound because referenced Java types could not be found. See the 'java-resolution-report.log' file for details.
/Library/Frameworks/Mono.framework/External/xbuild/Xamarin/Android/Xamarin.Android.Bindings.ClassParse.targets(36,5): obj/Debug/java-resolution-report.log warning BG8606: Some types or members could not be bound because referenced Java types could not be found. See the 'java-resolution-report.log' file for details.
Errors you encounter during the initial phase of Java type resolution are emitted as warnings. These are missing external Java types and generally indicate the user is missing a reference .jar or binding NuGet.
The class '[Class] com.*.blesdk.manager.BLEConnectionManager.Companion.1' was removed because the Java base type 'kotlin.jvm.internal.FunctionReferenceImpl' could not be found.
The class '[Class] com.*.blesdk.manager.BLEScanManager.Companion.1' was removed because the Java base type 'kotlin.jvm.internal.FunctionReferenceImpl' could not be found.
remaining resolution errors are generally the fallout from those missing external types. For example: 'androidx.appcompat.widget.AppCompatTextView', if the above missing type caused us to remove com.example.MyTextView, then that may result in us removing class GetMyTextView() due to a missing return type.
it is recommended to carefully check java-resolution-report.log, that display a warning notifying the user that some types could not be bound.
because i noticed that this problem has different variants and causes you could change the accessibility of the class given the following Kotlin code:
internal Class {
public interface { }
}
// The default Java representation
public Class {
public interface { }
}
// In order to prevent this being bound, our Kotlin fixups instead change it to
private Class {
private interface { }
}
this might help you eliminate or reduce the warnings, since you have to navigate between classes and methods in the log file.
Also check:
ApiXmlAdjuster removes required methods from interfaces #814
Remove API adjuster #789
Better surface class-parse Java resolve errors to users

How to put a default value in an object with Annotation? (#RequestParam)

Is it possible to give an object a default value using #RequestParam?
When I name the form tag the same as the field in the object
I know that it automatically assigns a value to an object.
But if the object's field is an int, null value is entered, an error occurs.
★ Plant_list2VO class
★ form
★ controller:
public String reg4(HttpServletRequest request, HttpServletResponse response,
Plant_list2VO plant_list2VO,
#RequestParam(name="inv_count", defaultValue="0") int inv_count,
#RequestParam(name="inv_count_disable", defaultValue="2") int inv_count_disable,
Model model) {
}
★ console:
WARN : org.springframework.web.servlet.mvc.support.DefaultHandlerExceptionResolver - Resolved [org.springframework.validation.BindException: org.springframework.validation.BeanPropertyBindingResult: 2 errors
Field error in object 'plant_list2VO' on field 'inv_count': rejected value [];
codes [typeMismatch.plant_list2VO.inv_count,typeMismatch.inv_count,typeMismatch.int,typeMismatch];
arguments [org.springframework.context.support.DefaultMessageSourceResolvable: codes [plant_list2VO.inv_count,inv_count]; arguments [];
default message [inv_count]]; default message [Failed to convert property value of type 'java.lang.String' to required type 'int' for property 'inv_count'; nested exception is java.lang.NumberFormatException: For input string: ""]
Field error in object 'plant_list2VO' on field 'inv_count_disable': rejected value [];
codes [typeMismatch.plant_list2VO.inv_count_disable,typeMismatch.inv_count_disable,typeMismatch.int,typeMismatch];
arguments [org.springframework.context.support.DefaultMessageSourceResolvable: codes [plant_list2VO.inv_count_disable,inv_count_disable]; arguments []; default message [inv_count_disable]];
default message [Failed to convert property value of type 'java.lang.String' to required type 'int' for property 'inv_count_disable'; nested exception is java.lang.NumberFormatException: For input string: ""]]
I see you define inv_count and inv_count_disable are int attributes. So, you should change values of defaultValue to a number to resolve java.lang.NumberFormatException
Judging by the console log, the inv_count and inv_count_disable values passed to your controller are not null, but empty Strings.
I can assume you use an old version of Spring, because before 3.2.x version empty String values were accepted by AbstractNamedValueMethodArgumentResolver as actual values (see method resolveArgument here), and defaultValue wasn't used in that case, resulting in conversion exception, because empty String cannot be converted to an integer.
In 3.2.x and later versions of Spring empty String is considered as there were no value passed, and defaultValue is used in case it's present (see method resolveArgument here).
So, if you want to stick to an older version of Spring, you may want to change your form to send some default number if the field is empty, or create a DTO, where these fields are of type String with some logic in setters.
Also this may help: Is it possible to have empty RequestParam values use the defaultValue?

How many "AND" can you have on a SpringData query?

I've created this method:
Long getAttributesAfterTimeSent(String x, String y, Long timeSent) {
return repository.countByXAndYAndZTypesAndTimeSentGreaterThanEqual(
x,
y,
new ArrayList<String>() {{ add("attribute1"); add("attribute2"); }},
timeSent);
}
The signature of this method in the repository is as follows:
Long countByXAndYAndZTypesAndTimeSentGreaterThanEqual(String x, String y, Collection<String> attributeTypes, timeSent);
When I run it, i get the following error:
13:18:40.784 [main] INFO o.h.h.i.QueryTranslatorFactoryInitiator - HHH000397: Using ASTQueryTranslatorFactory
13:18:41.014 [main] WARN o.h.e.jdbc.spi.SqlExceptionHelper - SQL Error: 1797, SQLState: 42000
13:18:41.014 [main] ERROR o.h.e.jdbc.spi.SqlExceptionHelper - SQL error: 1797 ORA-01797: this operator must be followed by ANY or ALL
javax.persistence.PersistenceException: org.hibernate.exception.SQLGrammarException: could not extract ResultSet
Any pointers?
Figured out the answer.
One of my types was a non-scalar type the: ArrayList.
For cases like this we need to use the IN keyword in the JPA method.
So when changing the method from
countByXAndYAndZTypesAndTimeSentGreaterThanEqual
to
countByXAndYAndZTypesInAndTimeSentGreaterThanEqual
it worked like charm.
This almost certainly has nothing to do with the number of AND phrases in your method.
The limit is only implicit through something like maximum method name length, maximum query length, maximum number of parameters.
It will be way higher than anything any sane person will try to cram in a single method name.
The cause of the exception you are seeing is:
CAUSE:
equal operator = followed by multiple value like (1,2)
This probably means: one of the parameters or maybe some of the attributes is not of scalar type, but some kind of collection or array.
If these leads you toward something you can't easily express through a method name use a #Query annotation and provide the exact query you need to execute.

Spring MVC - Throws exception when the int value of ModelAttribute is null

I'm building an web application using Spring 3.0 MVC.
I have a method which has prototype below.
#RequestMapping(value = "/blahblah/blah.do", method=RequestMethod.GET)
public void searchData(#RequestParam(value="uniqOid", required=false) String uniqOid, #ModelAttribute("MasterVo") MasterVo searchVo,
ModelMap model, HttpServletResponse response, HttpServletRequest request)
The problem is that, the view (jsp) contains inputs that matches to searchVo(ModelAttribute).
When the int or long value of searchVo didn't come from the jsp, the server throws 404 page not found exception.
If the type of value is "String", it has no problem.
In my opinion, it is the problem of type casting.
How could I solve this problem, and which part of the server code that I have to check?
Thanks in advance.
I will go ahead and assume a few things about your problem.
It is not a type-cast problem. Spring has default converters that can easily convert from a String to some primitive type.
Now what you are facing is I think a null assigment to primitive type problem. Suppose the name of the property that's causing the problem is named primitiveProperty. Now, the request-paramters could include a parameter named primitiveProperty with an empty-String value, or some value that cannot be converted to a number. If the type of the primitiveProperty is String, it can assign the value of that parameter to it without any problem.
If the type of the primitiveProperty is int, long or some other primitive type that cannot have a null value, a problem occurs. When Spring converts the empty-string or a non-numeric string valued request-param named primitiveProperty, it cannot do so since that string can't be converted to a valid int or long value. So it is converted to null. Now, when Spring tries to assign that null value to a property that cannot have a null value (any primitve type), you get an Exception. If you are getting an empty-string as your request-param, you can replace the troublesome property in your domain object with its equivalent wrapper class (int with Integer, long with Long and so on). If you are getting a non-numeric value from your view, well, make sure that you don't get a non-numeric value.
You need to check the setter of the fields that are giving the typecast problem, in your case MasterVo .
The Spring will call the setter of the property to bind the value, where i presume you will see the error coming.
Just add a debug point to this setter and you will see the problem.

while inserting it show type converting error

i am calling the validator method in Insert to check for empty text box...and print msg
it prints the msg but Show this msg i.e
Failed to convert property value of type java.lang.String to required type float for property advance; nested exception is java.lang.NumberFormatException: empty String
the text box field which i am validating is float type...
can any body tell me how to remove this error.
this is the form tag
[form:input path="advance" id="addpa"]
..>> enttiy
class name is order
private float advance ;
getter and setter method

Resources