Problem with HttpSolrClient.Builder on Windows with tomcat

2020-12-09 Thread Raivo Rebane

Hello

I have problem with HttpSolrClient.Builder on Windows with tomcat

I have follwing code lines in my programm:
System.out.println("Trying HttpSolrClient = " + url );
LibraryServlet.solrClientClient = new 
HttpSolrClient.Builder(url).withConnectionTimeout(5000).withSocketTimeout(3000).build();

System.out.println("Trying HttpSolrClient sucessfull ");

and project WEB-INF/lib contains following jars:
commons-codec-1.15.jar*
commons-httpclient-3.1.jar*
commons-io-1.4.jar*
httpclient5-5.0.3.jar
slf4j-api-1.8.0-beta4.jar
slf4j-log4j12.jar*
solr-solrj-8.6.3.jar*

On Ubuntu I have following tomcat output
Trying HttpSolrClient = http://localhost:8983/solr/clients
SLF4J: No SLF4J providers were found.
SLF4J: Defaulting to no-operation (NOP) logger implementation
SLF4J: See http://www.slf4j.org/codes.html#noProviders for further details.
SLF4J: Class path contains SLF4J bindings targeting slf4j-api versions 
prior to 1.8.
SLF4J: Ignoring binding found at 
[jar:file:/home/hydra/Librarian/target/Librarian/WEB-INF/lib/slf4j-log4j12.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Ignoring binding found at 
[jar:file:/opt/tomcat/apache-tomcat-9.0.38/lib/nlog4j-1.2.19.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Ignoring binding found at 
[jar:file:/opt/tomcat/apache-tomcat-9.0.38/lib/logback-classic-1.1.3.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: See http://www.slf4j.org/codes.html#ignoredBindings for an 
explanation.

Trying HttpSolrClient sucessfull

But on Windows tomcat I have only one line:
Trying HttpSolrClient = http://localhost:8983/solr/clients

and it's hangs !!!

What is the reason ?

Regards
Raivo



Re: getFirstValue problem with solrj

2020-11-05 Thread Raivo Rebane

Heloo

I found mistake

Thanks

Raivo

On 05.11.20 17:08, Raivo Rebane wrote:

Hello

I have one problem

I made a query as foollws :

                    System.out.println("Querying by using SolrQuery...");
                    SolrQuery solrQuery = new SolrQuery("Name:" + 
Pattern);

                    solrQuery.addField("id");
                    solrQuery.addField("App_code");
                    solrQuery.setSort("App_code", ORDER.asc);
                    solrQuery.setRows(10);
                QueryResponse response = null;
                try {
                response = 
AppServServlet.solrClientApps.query(solrQuery);

                } catch (SolrServerException | IOException e) {
                System.err.printf("\nFailed to search 
articles: %s", e.getMessage());

                }

and got response as follows :

                SolrDocumentList documents = null;
                    if (response != null) {
                    documents = response.getResults();
                    System.out.printf("Found %d documents\n", 
documents.getNumFound());

                    for (SolrDocument document : documents) {
                    String id = (String) 
document.getFirstValue("id");
                    String name = (String) 
document.getFirstValue("Name");
                    long App_code1 = (long) 
document.getFirstValue("App_code");
                    System.out.printf("id=%s, App_code=%s, 
name=%s\n", id, App_code1, name);

                    }
                 }

Found 1 document but name = (String) document.getFirstValue("Name"); 
returns null


Console looks like :

Querying by using SolrQuery...
Found 1 documents
id=92, App_code=2, name=null

What is wrong ?

Please somebody helps me !

Regards

Raivo

PS. Collection is like :

57 0  HIS
45 1  RAN/AEGIR
92 2  PIT2
*



getFirstValue problem with solrj

2020-11-05 Thread Raivo Rebane

Hello

I have one problem

I made a query as foollws :

                    System.out.println("Querying by using SolrQuery...");
                    SolrQuery solrQuery = new SolrQuery("Name:" + Pattern);
                    solrQuery.addField("id");
                    solrQuery.addField("App_code");
                    solrQuery.setSort("App_code", ORDER.asc);
                    solrQuery.setRows(10);
                QueryResponse response = null;
                try {
                response = 
AppServServlet.solrClientApps.query(solrQuery);

                } catch (SolrServerException | IOException e) {
                System.err.printf("\nFailed to search articles: 
%s", e.getMessage());

                }

and got response as follows :

                SolrDocumentList documents = null;
                    if (response != null) {
                    documents = response.getResults();
                    System.out.printf("Found %d documents\n", 
documents.getNumFound());

                    for (SolrDocument document : documents) {
                    String id = (String) 
document.getFirstValue("id");
                    String name = (String) 
document.getFirstValue("Name");
                    long App_code1 = (long) 
document.getFirstValue("App_code");
                    System.out.printf("id=%s, App_code=%s, 
name=%s\n", id, App_code1, name);

                    }
                 }

Found 1 document but name = (String) document.getFirstValue("Name"); 
returns null


Console looks like :

Querying by using SolrQuery...
Found 1 documents
id=92, App_code=2, name=null

What is wrong ?

Please somebody helps me !

Regards

Raivo

PS. Collection is like :

57 0  HIS
45 1  RAN/AEGIR
92 2  PIT2
*



httpclient gives error

2020-10-31 Thread Raivo Rebane

Hello

I try to use solrj in web application with eclipse tomcat but I get 
following errors


java.lang.NoSuchFieldError: INSTANCE
    at 
org.apache.http.impl.io.DefaultHttpRequestWriterFactory.(DefaultHttpRequestWriterFactory.java:52)
    at 
org.apache.http.impl.io.DefaultHttpRequestWriterFactory.(DefaultHttpRequestWriterFactory.java:56)
    at 
org.apache.http.impl.io.DefaultHttpRequestWriterFactory.(DefaultHttpRequestWriterFactory.java:46)
    at 
org.apache.http.impl.conn.ManagedHttpClientConnectionFactory.(ManagedHttpClientConnectionFactory.java:82)
    at 
org.apache.http.impl.conn.ManagedHttpClientConnectionFactory.(ManagedHttpClientConnectionFactory.java:95)
    at 
org.apache.http.impl.conn.ManagedHttpClientConnectionFactory.(ManagedHttpClientConnectionFactory.java:104)
    at 
org.apache.http.impl.conn.ManagedHttpClientConnectionFactory.(ManagedHttpClientConnectionFactory.java:62)
    at 
org.apache.http.impl.conn.PoolingHttpClientConnectionManager$InternalConnectionFactory.(PoolingHttpClientConnectionManager.java:572)
    at 
org.apache.http.impl.conn.PoolingHttpClientConnectionManager.(PoolingHttpClientConnectionManager.java:174)
    at 
org.apache.http.impl.conn.PoolingHttpClientConnectionManager.(PoolingHttpClientConnectionManager.java:158)
    at 
org.apache.http.impl.conn.PoolingHttpClientConnectionManager.(PoolingHttpClientConnectionManager.java:149)
    at 
org.apache.http.impl.conn.PoolingHttpClientConnectionManager.(PoolingHttpClientConnectionManager.java:125)
    at 
org.apache.solr.client.solrj.impl.HttpClientUtil.createPoolingConnectionManager(HttpClientUtil.java:278)
    at 
org.apache.solr.client.solrj.impl.HttpClientUtil.createClient(HttpClientUtil.java:273)
    at 
org.apache.solr.client.solrj.impl.HttpSolrClient.(HttpSolrClient.java:204)
    at 
org.apache.solr.client.solrj.impl.HttpSolrClient$Builder.build(HttpSolrClient.java:968)

    at AppServServlet.init(AppServServlet.java:63)


Tomcat lib contains following http jars:

-rw-rw-rw- 1 hydra hydra 326724 sept   6 21:33 httpcore-4.4.4.jar
-rw-rw-rw- 1 hydra hydra 736658 sept   6 21:33 httpclient-4.5.2.jar
-rwxrwxr-x 1 hydra hydra  21544 sept   9 11:17 httpcore5-reactive-5.0.2.jar*
-rwxrwxr-x 1 hydra hydra 809733 sept   9 12:26 httpcore5-5.0.2.jar*
-rwxrwxr-x 1 hydra hydra 225863 sept   9 12:27 httpcore5-h2-5.0.2.jar*
-rwxrwxr-x 1 hydra hydra 145492 sept   9 12:30 httpcore5-testing-5.0.2.jar*
-rwxrwxr-x 1 hydra hydra 775798 okt    3 18:53 httpclient5-5.0.3.jar*
-rwxrwxr-x 1 hydra hydra  24047 okt    3 18:54 httpclient5-fluent-5.0.3.jar*
-rwxrwxr-x 1 hydra hydra 259199 okt    3 18:54 httpclient5-cache-5.0.3.jar*
-rwxrwxr-x 1 hydra hydra  15576 okt    3 18:54 httpclient5-win-5.0.3.jar*
-rwxrwxr-x 1 hydra hydra  38022 okt    3 18:55 
httpclient5-testing-5.0.3.jar*

-rw-rw-r-- 1 hydra hydra  37068 okt   31 19:50 httpmime-4.3.jar

 which is accesible for tomcat.

What is wrong with my application ?

Please somebody help me

Regards

Raivo




I can cannot execute my SolrJ application

2020-10-21 Thread Raivo Rebane
:290)
    at java.base/java.lang.Thread.run(Thread.java:834)
Caused by: java.lang.Error: Unresolved compilation problem:

    at SolrJExample.main(SolrJExample.java:41)
    ... 6 more
[ERROR]
[ERROR]
[ERROR] For more information about the errors and possible solutions, 
please read the following articles:
[ERROR] [Help 1] 
http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException


My pom.xml looks like:

http://maven.apache.org/POM/4.0.0"; 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"; 
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 
https://maven.apache.org/xsd/maven-4.0.0.xsd";>

  4.0.0
  test
  test
  0.0.1-SNAPSHOT
  
   
   solr-solrj
   org.apache.solr
   1.4.0
   jar
   compile
    
  
  
    src
    
   
    org.apache.maven.plugins
    maven-surefire-plugin
    3.0.0-M5
        
        
         test
     
  SolrJExample
  
       arg0
           arg1
       
     
        
           
    
false
    
  
  
    maven-compiler-plugin
    3.8.1
    
  11
    
  
   
org.codehaus.mojo
exec-maven-plugin
    1.1
    
 
        
    
  


How to fix that problem ?

Looking forward

Raivo Rebane



SolrJ doesn't find symbol

2020-10-20 Thread Raivo Rebane

Hello

I want to use solrj in Maven project, but I got errors:

[ERROR] 
/home/hydra/workspace1/kaks/src/main/java/solr/SolrJExample.java:[9,36] 
cannot find symbol

[ERROR]   symbol:   class SolrClient
[ERROR]   location: package org.apache.solr.client.solrj
[ERROR] 
/home/hydra/workspace1/kaks/src/main/java/solr/SolrJExample.java:[14,41] 
cannot find symbol

[ERROR]   symbol:   class HttpSolrClient
[ERROR]   location: package org.apache.solr.client.solrj.impl
[ERROR] 
/home/hydra/workspace1/kaks/src/main/java/solr/SolrJExample.java:[32,26] 
cannot find symbol

[ERROR]   symbol:   class SolrClient
[ERROR]   location: class solr.SolrJExample
[ERROR] 
/home/hydra/workspace1/kaks/src/main/java/solr/SolrJExample.java:[32,68] 
package HttpSolrClient does not exist
[ERROR] 
/home/hydra/workspace1/kaks/src/main/java/solr/SolrJExample.java:[133,18] 
cannot find symbol
[ERROR]   symbol:   method 
setSort(java.lang.String,org.apache.solr.client.solrj.SolrQuery.ORDER)
[ERROR]   location: variable solrQuery of type 
org.apache.solr.client.solrj.SolrQuery
[ERROR] 
/home/hydra/workspace1/kaks/src/main/java/solr/SolrJExample.java:[161,18] 
cannot find symbol
[ERROR]   symbol:   method 
setSort(java.lang.String,org.apache.solr.client.solrj.SolrQuery.ORDER)
[ERROR]   location: variable solrQuery of type 
org.apache.solr.client.solrj.SolrQuery


My .classpath looks like:



    path="TOMCAT_HOME/solr/httpclient5-5.0.3.jar"/>
    path="TOMCAT_HOME/solr/solr-solrj-8.6.3.jar"/>
    path="TOMCAT_HOME/solr/commons-codec-1.15.jar"/>
    path="TOMCAT_HOME/solr/commons-httpclient-3.1.jar"/>

    
    path="TOMCAT_HOME/solr/jcl-over-slf4j-1.5.5.jar"/>
    path="src/main/java">

        
            
            
        
    
    path="src/main/resources">

        
            
        
    
    path="src/test/java">

        
            
            
            
        
    
    output="target/test-classes" path="src/test/resources">

        
            
            
        
    
    path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.5">

        
            
        
    
    path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER">

        
            
        
    
    


Hope that anybody helps me

I Can't udrestand where is mistake ?

Looking forward

Raivo Rebane

I add my pomxml


http://maven.apache.org/POM/4.0.0";
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd";>
 
4.0.0
 
com.illucit
illucit-solr
0.0.1-SNAPSHOT
war
 

1.8
1.8
 

UTF-8
 

3.2
2.4
2.10.1
 

2.6
 

   
   
   solr-solrj
   org.apache.solr
   1.4.0
   jar
   compile

  
 

${project.artifactId}
src
test


resources




testresources




maven-war-plugin

illucit-solr



maven-source-plugin


maven-javadoc-plugin





maven-compiler-plugin
${version.compiler.plugin}

${maven.compiler.source}
${maven.compiler.target}



maven-source-plugin
${version.source.plugin}


attach-sources

jar-no-fork





maven-javadoc-plugin
${version.javadoc.plugin}


attach-javadocs

jar





maven-war-plugin
${version.war.plugin}

false
true
WebContent