OK - I figured out the logging. Here is the logging output plus the
console output and the stack trace:
main] INFO org.apache.solr.core.SolrResourceLoader - new
SolrResourceLoader for directory: '/Users/carlroberts/dev/solr-4.10.3/'
[main] INFO org.apache.solr.core.SolrResourceLoader - Adding
'file:/Users/carlroberts/dev/solr-4.10.3/lib/commons-logging-1.2.jar' to
classloader
[main] INFO org.apache.solr.core.SolrResourceLoader - Adding
'file:/Users/carlroberts/dev/solr-4.10.3/lib/servlet-api.jar' to classloader
[main] INFO org.apache.solr.core.SolrResourceLoader - Adding
'file:/Users/carlroberts/dev/solr-4.10.3/lib/slf4j-simple-1.7.5.jar' to
classloader
[main] INFO org.apache.solr.core.ConfigSolr - Loading container
configuration from /Users/carlroberts/dev/solr-4.10.3/solr.xml
[main] INFO org.apache.solr.core.CoreContainer - New CoreContainer
2050551931
db
/Users/carlroberts/dev/solr-4.10.3/[main] INFO
org.apache.solr.core.CoreContainer - Loading cores into CoreContainer
[instanceDir=/Users/carlroberts/dev/solr-4.10.3/]
[main] INFO org.apache.solr.handler.component.HttpShardHandlerFactory -
Setting socketTimeout to: 0
[main] INFO org.apache.solr.handler.component.HttpShardHandlerFactory -
Setting urlScheme to: null
[main] INFO org.apache.solr.handler.component.HttpShardHandlerFactory -
Setting connTimeout to: 0
[main] INFO org.apache.solr.handler.component.HttpShardHandlerFactory -
Setting maxConnectionsPerHost to: 20
[main] INFO org.apache.solr.handler.component.HttpShardHandlerFactory -
Setting corePoolSize to: 0
[main] INFO org.apache.solr.handler.component.HttpShardHandlerFactory -
Setting maximumPoolSize to: 2147483647
[main] INFO org.apache.solr.handler.component.HttpShardHandlerFactory -
Setting maxThreadIdleTime to: 5
[main] INFO org.apache.solr.handler.component.HttpShardHandlerFactory -
Setting sizeOfQueue to: -1
[main] INFO org.apache.solr.handler.component.HttpShardHandlerFactory -
Setting fairnessPolicy to: false
[main] INFO org.apache.solr.update.UpdateShardHandler - Creating
UpdateShardHandler HTTP client with params:
socketTimeout=0&connTimeout=0&retry=false
[main] INFO org.apache.solr.logging.LogWatcher - SLF4J impl is
org.slf4j.impl.SimpleLoggerFactory
[main] INFO org.apache.solr.logging.LogWatcher - No LogWatcher configured
[main] INFO org.apache.solr.core.CoreContainer - Host Name: null
[coreLoadExecutor-5-thread-1] INFO
org.apache.solr.core.SolrResourceLoader - new SolrResourceLoader for
directory: '/Users/carlroberts/dev/solr-4.10.3/db/'
[coreLoadExecutor-5-thread-1] INFO org.apache.solr.core.SolrConfig -
Adding specified lib dirs to ClassLoader
[coreLoadExecutor-5-thread-1] WARN
org.apache.solr.core.SolrResourceLoader - Can't find (or read) directory
to add to classloader: ../../../contrib/extraction/lib (resolved as:
/Users/carlroberts/dev/solr-4.10.3/db/../../../contrib/extraction/lib).
[coreLoadExecutor-5-thread-1] WARN
org.apache.solr.core.SolrResourceLoader - Can't find (or read) directory
to add to classloader: ../../../dist/ (resolved as:
/Users/carlroberts/dev/solr-4.10.3/db/../../../dist).
[coreLoadExecutor-5-thread-1] WARN
org.apache.solr.core.SolrResourceLoader - Can't find (or read) directory
to add to classloader: ../../../contrib/clustering/lib/ (resolved as:
/Users/carlroberts/dev/solr-4.10.3/db/../../../contrib/clustering/lib).
[coreLoadExecutor-5-thread-1] WARN
org.apache.solr.core.SolrResourceLoader - Can't find (or read) directory
to add to classloader: ../../../dist/ (resolved as:
/Users/carlroberts/dev/solr-4.10.3/db/../../../dist).
[coreLoadExecutor-5-thread-1] WARN
org.apache.solr.core.SolrResourceLoader - Can't find (or read) directory
to add to classloader: ../../../contrib/langid/lib/ (resolved as:
/Users/carlroberts/dev/solr-4.10.3/db/../../../contrib/langid/lib).
[coreLoadExecutor-5-thread-1] WARN
org.apache.solr.core.SolrResourceLoader - Can't find (or read) directory
to add to classloader: ../../../dist/ (resolved as:
/Users/carlroberts/dev/solr-4.10.3/db/../../../dist).
[coreLoadExecutor-5-thread-1] WARN
org.apache.solr.core.SolrResourceLoader - Can't find (or read) directory
to add to classloader: ../../../contrib/velocity/lib (resolved as:
/Users/carlroberts/dev/solr-4.10.3/db/../../../contrib/velocity/lib).
[coreLoadExecutor-5-thread-1] WARN
org.apache.solr.core.SolrResourceLoader - Can't find (or read) directory
to add to classloader: ../../../dist/ (resolved as:
/Users/carlroberts/dev/solr-4.10.3/db/../../../dist).
[coreLoadExecutor-5-thread-1] INFO
org.apache.solr.update.SolrIndexConfig - IndexWriter infoStream solr
logging is enabled
[coreLoadExecutor-5-thread-1] INFO org.apache.solr.core.SolrConfig -
Using Lucene MatchVersion: 4.10.3
[coreLoadExecutor-5-thread-1] INFO org.apache.solr.core.Config - Loaded
SolrConfig: solrconfig.xml
[coreLoadExecutor-5-thread-1] INFO org.apache.solr.schema.IndexSchema -
Reading Solr Schema from
/Users/carlroberts/dev/solr-4.10.3/db/conf/schema.xml
[coreLoadExecutor-5-thread-1] INFO org.apache.solr.schema.IndexSchema -
[db] Schema name=example
false
{}
[]
/Users/carlroberts/dev/solr-4.10.3/
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:40)
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