So far I have not been able to get the logging to work - here is what I get in the console prior to the exception:

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.
db
/Users/carlroberts/dev/solr-4.10.3/
false
{}
[]
/Users/carlroberts/dev/solr-4.10.3/


On 1/21/15, 11:50 AM, Alan Woodward wrote:
That certainly looks like it ought to work.  Is there log output that you could 
show us as well?

Alan Woodward
www.flax.co.uk


On 21 Jan 2015, at 16:09, Carl Roberts wrote:

Hi,

I have downloaded the code and documentation for Solr version 4.10.3.

I am trying to follow SolrJ Wiki guide and I am running into errors.  The 
latest error is this one:

Exception in thread "main" org.apache.solr.common.SolrException: No such core: 
db
    at 
org.apache.solr.client.solrj.embedded.EmbeddedSolrServer.request(EmbeddedSolrServer.java:112)
    at 
org.apache.solr.client.solrj.request.AbstractUpdateRequest.process(AbstractUpdateRequest.java:124)
    at org.apache.solr.client.solrj.SolrServer.add(SolrServer.java:68)
    at org.apache.solr.client.solrj.SolrServer.add(SolrServer.java:54)
    at solr.Test.main(Test.java:39)

My code is this:

package solr;

import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Collection;

import org.apache.solr.client.solrj.SolrServerException;
import org.apache.solr.client.solrj.embedded.EmbeddedSolrServer;
import org.apache.solr.common.SolrInputDocument;
import org.apache.solr.core.CoreContainer;
import org.apache.solr.core.SolrCore;


public class Test {
    public static void main(String [] args){
        CoreContainer container = new 
CoreContainer("/Users/carlroberts/dev/solr-4.10.3");
        System.out.println(container.getDefaultCoreName());
        System.out.println(container.getSolrHome());
        container.load();
        System.out.println(container.isLoaded("db"));
        System.out.println(container.getCoreInitFailures());
        Collection<SolrCore> cores = container.getCores();
        System.out.println(cores);
        EmbeddedSolrServer server = new EmbeddedSolrServer( container, "db" );
        SolrInputDocument doc1 = new SolrInputDocument();
        doc1.addField( "id", "id1", 1.0f );
        doc1.addField( "name", "doc1", 1.0f );
        doc1.addField( "price", 10 );
        SolrInputDocument doc2 = new SolrInputDocument();
        doc2.addField( "id", "id2", 1.0f );
        doc2.addField( "name", "doc2", 1.0f );
        doc2.addField( "price", 20 );
        Collection<SolrInputDocument> docs = new
        ArrayList<SolrInputDocument>();
        docs.add( doc1 );
        docs.add( doc2 );
        try{
            server.add( docs );
            server.commit();
            server.deleteByQuery( "*:*" );
        }catch(IOException e){
            e.printStackTrace();
        }catch(SolrServerException e){
            e.printStackTrace();
        }
    }
}


My solr.xml file is this:

<?xml version="1.0" encoding="UTF-8" ?>
<!--
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements.  See the NOTICE file distributed with
this work for additional information regarding copyright ownership.
The ASF licenses this file to You under the Apache License, Version 2.0
(the "License"); you may not use this file except in compliance with
the License.  You may obtain a copy of the License at

     http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->

<!--
   This is an example of a simple "solr.xml" file for configuring one or
   more Solr Cores, as well as allowing Cores to be added, removed, and
   reloaded via HTTP requests.

   More information about options available in this configuration file,
   and Solr Core administration can be found online:
   http://wiki.apache.org/solr/CoreAdmin
-->

<solr>
  <cores adminPath="/admin/cores" defaultCoreName="db">
        <core default="true" instanceDir="db/" name="db"/>
  </cores>
</solr>

And my db/conf directory was copied from example/solr/collection/conf directory 
and it contains the solrconfig.xml file and schema.xml file.

I have noticed that the documentation that shows how to use the 
EmbeddedSolarServer is outdated as it indicates I should use 
CoreContainer.Initializer class which doesn't exist, and container.load(path, 
file) which also doesn't exist.

At this point I have no idea why I am getting the No such core error and I have 
googled it and there seems to be tons of threads showing this error but for 
different reasons, and I have tried all the suggested resolutions and get 
nowhere with this.

Can you please help?

Regards,

Joe


Reply via email to