Win a copy of Machine Learning with R: Expert techniques for predictive modeling this week in the Artificial Intelligence and Machine Learning forum!

Surinder Mehra

Ranch Hand
+ Follow
since Aug 06, 2013
Cows and Likes
Cows
Total received
1
In last 30 days
0
Total given
0
Likes
Total received
1
Received in last 30 days
0
Total given
4
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Surinder Mehra

I had to change the data element syntax and it worked. Just add a function to data instead of taking values directly. Here is my working code



Hi,
I have implemented server side pagination using JQuery data tables and now I want to pull records using date picker. When I select date from date picker, this value goes into search filter field not in the field  I want (dob1 in below code). How do I set value selected from date picker into ajax request after table have been initialized. I am using data-tables version 1.10

I solved it. below is my code. Note :All Objects from org.codehaus not from fasterxml except from java.time.LocalDate and Time. Hope it helps someOne





Server side configuration


Client side configarion


3 years ago
I need to convert Java 8 LocalDate in client side received from REST Service in JSON form. I read about  ParamConverterProvider, but looks like it works only for REST resource methods i.e. server side.
Is there any thing to convertt LocalDate on client side.

I tried implementing ParameterHandler<LocalDate> and registered it in jaxrs:client providers. I can see constructor is called , but not the method 'fromString'. Am I missing anything ?
Below is my implementation:

 
Client stub file:



Please note that I am able to fetch JSON string If I invoke resource directly from browser. SO only issue is my JavaLocalDateParamHandler "fromString" method is not called during conversion.

Does it work only on server side where REST resources(i.e. methods with diff annotations) are present
3 years ago
Hi All,
I am facing one very known issue yet no solution is working for me. Any quick help will be grateful
From MVC controller, I am calling REST service which returns me Model object with LocalDate as one of the fields.  JacksonJAXbJSONProvider  does not parse the Localdate object. I wrote custom Mapper as below And dependency is added in pom.xml



This was suggested in http://stackoverflow.com/questions/28802544/java-8-localdate-jackson-format/38051405#38051405

My spring.xml(contains configuration for MVC controller etc...) has already one mapper configured which does conversion automatically as below



Below is stub file which connects to REST Service



Now How do I configure my Context resolver which I just wrote so that I should be able to convert LocalDate.

Where should my custom class go, in message converter or jaxrs:providers> ?

I am getting below exception


No suitable constructor found for type [simple type, class java.time.LocalDate]: can not instantiate from JSON object (need to add/enable type information?)
3 years ago
I updated the eclipse m2e plugin and it worked.



Thanks for concern. Cheers!
3 years ago
Unfortunately, POM.xml is confidential to organization and hence I will not be able to show its contents. But this error is common with maven. I saw it even in eclipse.org (https://www.eclipse.org/m2e/documentation/m2e-execution-not-covered.html) . This link explain it, but I did not get much from it, how do we solve it.
3 years ago

Description Resource Path Location Type
Plugin execution not covered by lifecycle configuration: ***************:jpublisher-maven-plugin:1.6:jpublisher (execution: jpublisher-generate, phase: generate-sources) pom.xml /*******-jpublisher line 54 Maven Project Build Lifecycle Mapping Problem




Guys, I am struggling with above error in eclipse. pom,xml has this error. maven build is successful. but eclipse shows erros in code. Any one has idea how to fix this without effecting maven build.

I have searched it in different forums but could not find any clear solution.

Will appreciate any help.

Thanks
3 years ago
Below code throw outofBound Exception on arraylist if executed continuously(immediately)2-3 times.
I am aware that this exception can be avoided by synchronizing alterlist() methods or synchronized bocks using different objectslock1 and lock2 I have created. I want to understand why this exception is thrown. Arraylist auto increase its size when needed.

Can anyone explain what is happening behind the scene







Exception:

Starting...
Exception in thread "Thread-1" java.lang.ArrayIndexOutOfBoundsException: 25
at java.util.ArrayList.add(ArrayList.java:352)
at com.suri.threads.MultipleLocks.alterList2(MultipleLocks.java:75)
at com.suri.threads.MultipleLocks.process(MultipleLocks.java:56)
at com.suri.threads.MultipleLocks$2.run(MultipleLocks.java:36)
at java.lang.Thread.run(Thread.java:662)
Time taken : 2067
List 1 size : 1013 List 2 Size : 1013
I was just going through java questions in Facebook group for Java and found below code throwing null pointer Exception. I gave an explanation below. However i want to make sure i have given correct explaination. So please review it and let me know so that i can convey the same




can anyone explain
why jvm throw NullPointerException?



My Explaination:

That is because you are recraeting instance of class A and this is not set to reference of A in class B. here is the flow of your program
1. Created instance of A in main()
2. call m1();
3. Inside m1(), created instance of Class B.
4. call m2(CURRENT instance of A)
5. set this insatnce of A to A's reference valraible a
6. Sysout and exit m2.
7. sysut in m1() and exit m1() and come back to main method
8. Create instance of B( which calls uper class constructoer and create new instance of A)
9. call m3();
10. Now m3 dont have instance of A set in a, a is null, so throw Null Pointer Exception.
11. Now how do we solve it: just call m3 with refernce var a holding instanceof A actualy,
This can be done by calling m3("msg") from m2(); and comment b.m3("prince") from main method or pass instance of A to m3() and set it to ref variable a in m3() body

Changes req any one of below:
1. comment b.m3("prince"); in main() and call from m2();
2. pass instance of A to m3() ns et it there to a e.g
b.m3("prince", newA());

Just want to make sure my explaination is correct.
4 years ago
Hi,
Can anyone help me with this?
I installed glassfish server and plugin to eclipse. But when i select the server directory, its says Missing classpath entry C:\glassfish3\install\lib\appserv-rt.jar. I found the instructions on below website but all in vain
https://glassfish.java.net/downloads/v2ur1-b09d.html

I have jdk6 installed in my system and JAVA_HOME set to C:\Program Files\Java\jdk1.6.0_29
when i run below command
java -Xmx256m -jar filename.jar

i get the error:

C:\glassfish3\glassfish\lib> java -Xmx256m -jar appserv-rt.jar
Failed to load Main-Class manifest attribute from
appserv-rt.jar

Please share your thoughts or link to the configuration steps would be helpful
thanks

Hi,
sorry for waking the zombie, but i am little mystified of explanation of intern() quoted below ,
In the article its mentioned that "Invoking two.intern() will look for a String object referenced from the String Literal Pool that has the same value as the one you invoked the intern method upon. If one is found, a reference to that String is returned and can be assigned to your local variable.".
What if String Literal Pool does not have the same reference/value as the one we invoked on intern ???
I am trying to match the input string with range of values and getting PatternSyntaxException. below is my code




output: true

But when i try to give range in double digits, it throws exception. What if i have to match a number(as string) between 10 to 25 or like that.





Output:

Exception in thread "main" java.util.regex.PatternSyntaxException: Illegal character range near index 5
0[14-16]
^
5 years ago