Re: Java object binding not working

2019-02-12 Thread Swapnil Katkar
Hi,

Do you need any input from me to resolve this issue?

Regards,
Swapnil Katkar

On Fri, Feb 8, 2019 at 10:30 AM Swapnil Katkar  wrote:

> Hi,
>
> It would be beneficial to me if you provide me at least some hint to
> resolve this problem. Thanks in advance!
>
> Regards,
> Swapnil Katkar
>
>
>
> -- Forwarded message -
> From: Swapnil Katkar 
> Date: Tue, Feb 5, 2019 at 10:58 PM
> Subject: Fwd: Java object binding not working
> To: 
>
>
> Hello,
>
> Could you please let me know how can I get the resolution of the mentioned
> issue?
>
> Regards,
> Swapnil Katkar
>
> -- Forwarded message -----
> From: Swapnil Katkar 
> Date: Sun, Feb 3, 2019, 17:31
> Subject: Java object binding not working
> To: 
>
>
> Greetings!
>
> I am working on a requirement where I want to query the data and want to
> do the object mapping for the retrieved result using Solrj. For this, I am
> referring to the official document at 
> *https://lucene.apache.org/solr/guide/7_6/using-solrj.html#java-object-binding
> <https://lucene.apache.org/solr/guide/7_6/using-solrj.html#java-object-binding>.*
>  I
> set-up the necessary class files and the collections.
>
> With the help of this document, I can create the documents in the Solr DB,
> but it is not working for fetching and mapping the fields to the Java POJO
> class. To do the mapping, I used @Field annotation.
>
> Details are as below:
> *1)* Solrj version: 7.6.0
> *2)* The line of code which is not working: *List employees =
> response.getBeans(Employee.class);*
> *3)* Exception stack trace:
> *Caused by: java.lang.IllegalArgumentException: Can not set
> java.lang.String field demo.apache.solr.vo.Employee.name
> <http://demo.apache.solr.vo.Employee.name> to java.util.ArrayList*
> * at
> sun.reflect.UnsafeFieldAccessorImpl.throwSetIllegalArgumentException(Unknown
> Source)*
> * at
> sun.reflect.UnsafeFieldAccessorImpl.throwSetIllegalArgumentException(Unknown
> Source)*
> * at sun.reflect.UnsafeObjectFieldAccessorImpl.set(Unknown Source)*
> * at java.lang.reflect.Field.set(Unknown Source)*
> *4)* Collection was created using
> *solr.cmd create -c employees -s 2 -rf 2*
>
> Please find the attached source code files. Also, I attached the stack
> trace file. Can you please help me on how to resolve them?
>
> Regards,
> Swapnil Katkar
>
>
> --
> Hello,
>
>
> Regards,
> Swapnil Katkar
>


-- 
Hello,


Regards,
Swapnil Katkar


Re: Java object binding not working

2019-02-08 Thread Jason Gerlowski
Hi Swapnil,

Ray did suggest a potential cause.  Your Java object has "name" as a
String, but Solr returns the "name" value as an ArrayList.
Usually Solr returns ArrayLists when the field in question is
multivalued, so it's a safe bet that Solr is treating your "name"
field as multivalued.

You can check this by opening Solr's admin UI, selecting your
collection from the collection dropdown menu, and clicking on the
Schema tab.  In the "Schema" window you can select your "name" field
from the dropdown and see if the table that appears shows it as
"multivalued".

If the field is multivalued, you've got a few options:
- you can start fresh with a new collection, and modify your schema so
that "name" is single-valued
- you can try to change the field-definition in place.  I'm not sure
whether Solr will allow this, but the API to try is here:
https://lucene.apache.org/solr/guide/7_6/schema-api.html#replace-a-field
- you can just change your Java object to represent "name" as a
List instead of a String.

If the field _isn't_ multivalued, then I'm not sure what's going on.

Best,

Jason

On Fri, Feb 8, 2019 at 1:40 PM Swapnil Katkar  wrote:
>
> Hi,
>
> It would be beneficial to me if you provide me at least some hint to
> resolve this problem. Thanks in advance!
>
> Regards,
> Swapnil Katkar
>
>
>
> -- Forwarded message -
> From: Swapnil Katkar 
> Date: Tue, Feb 5, 2019 at 10:58 PM
> Subject: Fwd: Java object binding not working
> To: 
>
>
> Hello,
>
> Could you please let me know how can I get the resolution of the mentioned
> issue?
>
> Regards,
> Swapnil Katkar
>
> -- Forwarded message -
> From: Swapnil Katkar 
> Date: Sun, Feb 3, 2019, 17:31
> Subject: Java object binding not working
> To: 
>
>
> Greetings!
>
> I am working on a requirement where I want to query the data and want to do
> the object mapping for the retrieved result using Solrj. For this, I am
> referring to the official document at
> *https://lucene.apache.org/solr/guide/7_6/using-solrj.html#java-object-binding
> <https://lucene.apache.org/solr/guide/7_6/using-solrj.html#java-object-binding>.*
> I
> set-up the necessary class files and the collections.
>
> With the help of this document, I can create the documents in the Solr DB,
> but it is not working for fetching and mapping the fields to the Java POJO
> class. To do the mapping, I used @Field annotation.
>
> Details are as below:
> *1)* Solrj version: 7.6.0
> *2)* The line of code which is not working: *List employees =
> response.getBeans(Employee.class);*
> *3)* Exception stack trace:
> *Caused by: java.lang.IllegalArgumentException: Can not set
> java.lang.String field demo.apache.solr.vo.Employee.name
> <http://demo.apache.solr.vo.Employee.name> to java.util.ArrayList*
> * at
> sun.reflect.UnsafeFieldAccessorImpl.throwSetIllegalArgumentException(Unknown
> Source)*
> * at
> sun.reflect.UnsafeFieldAccessorImpl.throwSetIllegalArgumentException(Unknown
> Source)*
> * at sun.reflect.UnsafeObjectFieldAccessorImpl.set(Unknown Source)*
> * at java.lang.reflect.Field.set(Unknown Source)*
> *4)* Collection was created using
> *solr.cmd create -c employees -s 2 -rf 2*
>
> Please find the attached source code files. Also, I attached the stack
> trace file. Can you please help me on how to resolve them?
>
> Regards,
> Swapnil Katkar
>
>
> --
> Hello,
>
>
> Regards,
> Swapnil Katkar


Fwd: Java object binding not working

2019-02-08 Thread Swapnil Katkar
Hi,

It would be beneficial to me if you provide me at least some hint to
resolve this problem. Thanks in advance!

Regards,
Swapnil Katkar



-- Forwarded message -
From: Swapnil Katkar 
Date: Tue, Feb 5, 2019 at 10:58 PM
Subject: Fwd: Java object binding not working
To: 


Hello,

Could you please let me know how can I get the resolution of the mentioned
issue?

Regards,
Swapnil Katkar

-- Forwarded message -
From: Swapnil Katkar 
Date: Sun, Feb 3, 2019, 17:31
Subject: Java object binding not working
To: 


Greetings!

I am working on a requirement where I want to query the data and want to do
the object mapping for the retrieved result using Solrj. For this, I am
referring to the official document at
*https://lucene.apache.org/solr/guide/7_6/using-solrj.html#java-object-binding
<https://lucene.apache.org/solr/guide/7_6/using-solrj.html#java-object-binding>.*
I
set-up the necessary class files and the collections.

With the help of this document, I can create the documents in the Solr DB,
but it is not working for fetching and mapping the fields to the Java POJO
class. To do the mapping, I used @Field annotation.

Details are as below:
*1)* Solrj version: 7.6.0
*2)* The line of code which is not working: *List employees =
response.getBeans(Employee.class);*
*3)* Exception stack trace:
*Caused by: java.lang.IllegalArgumentException: Can not set
java.lang.String field demo.apache.solr.vo.Employee.name
<http://demo.apache.solr.vo.Employee.name> to java.util.ArrayList*
* at
sun.reflect.UnsafeFieldAccessorImpl.throwSetIllegalArgumentException(Unknown
Source)*
* at
sun.reflect.UnsafeFieldAccessorImpl.throwSetIllegalArgumentException(Unknown
Source)*
* at sun.reflect.UnsafeObjectFieldAccessorImpl.set(Unknown Source)*
* at java.lang.reflect.Field.set(Unknown Source)*
*4)* Collection was created using
*solr.cmd create -c employees -s 2 -rf 2*

Please find the attached source code files. Also, I attached the stack
trace file. Can you please help me on how to resolve them?

Regards,
Swapnil Katkar


-- 
Hello,


Regards,
Swapnil Katkar


Re: Java object binding not working

2019-02-03 Thread Ray Niu
did you use multi values field?

On Sun, Feb 3, 2019 at 8:22 PM Swapnil Katkar  wrote:

> Greetings!
>
> I am working on a requirement where I want to query the data and want to
> do the object mapping for the retrieved result using Solrj. For this, I am
> referring to the official document at 
> *https://lucene.apache.org/solr/guide/7_6/using-solrj.html#java-object-binding
> .*
>  I
> set-up the necessary class files and the collections.
>
> With the help of this document, I can create the documents in the Solr DB,
> but it is not working for fetching and mapping the fields to the Java POJO
> class. To do the mapping, I used @Field annotation.
>
> Details are as below:
> *1)* Solrj version: 7.6.0
> *2)* The line of code which is not working: *List employees =
> response.getBeans(Employee.class);*
> *3)* Exception stack trace:
> *Caused by: java.lang.IllegalArgumentException: Can not set
> java.lang.String field demo.apache.solr.vo.Employee.name
>  to java.util.ArrayList*
> * at
> sun.reflect.UnsafeFieldAccessorImpl.throwSetIllegalArgumentException(Unknown
> Source)*
> * at
> sun.reflect.UnsafeFieldAccessorImpl.throwSetIllegalArgumentException(Unknown
> Source)*
> * at sun.reflect.UnsafeObjectFieldAccessorImpl.set(Unknown Source)*
> * at java.lang.reflect.Field.set(Unknown Source)*
> *4)* Collection was created using
> *solr.cmd create -c employees -s 2 -rf 2*
>
> Please find the attached source code files. Also, I attached the stack
> trace file. Can you please help me on how to resolve them?
>
> Regards,
> Swapnil Katkar
>


Java object binding not working

2019-02-03 Thread Swapnil Katkar
Greetings!

I am working on a requirement where I want to query the data and want to do
the object mapping for the retrieved result using Solrj. For this, I am
referring to the official document at
*https://lucene.apache.org/solr/guide/7_6/using-solrj.html#java-object-binding
.*
I
set-up the necessary class files and the collections.

With the help of this document, I can create the documents in the Solr DB,
but it is not working for fetching and mapping the fields to the Java POJO
class. To do the mapping, I used @Field annotation.

Details are as below:
*1)* Solrj version: 7.6.0
*2)* The line of code which is not working: *List employees =
response.getBeans(Employee.class);*
*3)* Exception stack trace:
*Caused by: java.lang.IllegalArgumentException: Can not set
java.lang.String field demo.apache.solr.vo.Employee.name
 to java.util.ArrayList*
* at
sun.reflect.UnsafeFieldAccessorImpl.throwSetIllegalArgumentException(Unknown
Source)*
* at
sun.reflect.UnsafeFieldAccessorImpl.throwSetIllegalArgumentException(Unknown
Source)*
* at sun.reflect.UnsafeObjectFieldAccessorImpl.set(Unknown Source)*
* at java.lang.reflect.Field.set(Unknown Source)*
*4)* Collection was created using
*solr.cmd create -c employees -s 2 -rf 2*

Please find the attached source code files. Also, I attached the stack
trace file. Can you please help me on how to resolve them?

Regards,
Swapnil Katkar
SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
SLF4J: Defaulting to no-operation (NOP) logger implementation
SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further 
details.
Exception in thread "main" org.apache.solr.client.solrj.beans.BindingException: 
Could not instantiate object of class demo.apache.solr.vo.Employee
at 
org.apache.solr.client.solrj.beans.DocumentObjectBinder.getBean(DocumentObjectBinder.java:71)
at 
org.apache.solr.client.solrj.beans.DocumentObjectBinder.getBeans(DocumentObjectBinder.java:50)
at 
org.apache.solr.client.solrj.response.QueryResponse.getBeans(QueryResponse.java:628)
at 
demo.apache.solr.SolrObjMapper.retrieveDocuments(SolrObjMapper.java:60)
at demo.apache.solr.SolrObjMapper.main(SolrObjMapper.java:27)
Caused by: org.apache.solr.client.solrj.beans.BindingException: Exception while 
setting value : [Sam Martin] on public java.lang.String 
demo.apache.solr.vo.Employee.name
at 
org.apache.solr.client.solrj.beans.DocumentObjectBinder$DocField.set(DocumentObjectBinder.java:455)
at 
org.apache.solr.client.solrj.beans.DocumentObjectBinder$DocField.inject(DocumentObjectBinder.java:438)
at 
org.apache.solr.client.solrj.beans.DocumentObjectBinder.getBean(DocumentObjectBinder.java:67)
... 4 more
Caused by: java.lang.IllegalArgumentException: Can not set java.lang.String 
field demo.apache.solr.vo.Employee.name to java.util.ArrayList
at 
sun.reflect.UnsafeFieldAccessorImpl.throwSetIllegalArgumentException(Unknown 
Source)
at 
sun.reflect.UnsafeFieldAccessorImpl.throwSetIllegalArgumentException(Unknown 
Source)
at sun.reflect.UnsafeObjectFieldAccessorImpl.set(Unknown Source)
at java.lang.reflect.Field.set(Unknown Source)
at 
org.apache.solr.client.solrj.beans.DocumentObjectBinder$DocField.set(DocumentObjectBinder.java:449)
... 6 more