Hi Shani, What version of Solr are you using? The instructions you quote look like they are for something like <4.4 from what you have written below.
The below is cloned from one of my projects, and hacked without testing, but I hope it gives you the idea of how it can be done. public SolrServer getEmbeddedServer(String solrHome, String solrConfigurationPath, String myCore) { // Create solr_home directory with solr.xml new File(solrHome).mkdirs(); FileUtils.copyFile(new File(config.getSolrXmlPath()), new File(solrHome, "solr.xml")); // Create config dir for my new core File myCoreConfig = new File(solrHome + "/" + myCore + "/conf"); myCoreConfig.mkdirs(); FileUtils.copyDirectory(new File(solrConfigurationPath), myCoreConfig); // Create core.properties file FileUtils.write(new File(core, "core.properties"), "name=" + coreName); // Create CoreContainer and EmbeddedSolrServer File solrXml = new File(solrHome, "solr.xml"); CoreContainer coreContainer = CoreContainer.createAndLoad(solrHome, solrXml); EmbeddedSolrServer newServer = new EmbeddedSolrServer(coreContainer, myCore); } Upayavira On Sun, Jul 5, 2015, at 01:17 PM, Chaushu, Shani wrote: > Hi, > I'm using EmbeddedSolrServer for testing the solr. > I went step by step in this instuctions (for solr 4) > https://wiki.searchtechnologies.com/index.php/Unit_Testing_with_Embedded_Solr > I can see that the config loaded, but when I try to put document, the > error I get is: > org.apache.solr.common.SolrException: No such core: collection1 > > I'm sure it's something in the solr.xml, but I couldn't find the issue, > Any thought? > > in the solr.xml I have: > <solr> > > <solrcloud> > <str name="host">${host:}</str> > <int name="hostPort">${jetty.port:8983}</int> > <str name="hostContext">${hostContext:solr}</str> > <int name="zkClientTimeout">${zkClientTimeout:30000}</int> > <bool > name="genericCoreNodeNames">${genericCoreNodeNames:true}</bool> > </solrcloud> > > <solr persistent="true"> > <cores adminPath="collection1" defaultCoreName="collection1"> > <core name="collection1" instanceDir="collection1" /> > </cores> > </solr> > > > <shardHandlerFactory name="shardHandlerFactory" > class="HttpShardHandlerFactory"> > <int name="socketTimeout">${socketTimeout:0}</int> > <int name="connTimeout">${connTimeout:0}</int> > </shardHandlerFactory> > > </solr> > > Thanks, > Shani > > > --------------------------------------------------------------------- > Intel Electronics Ltd. > > This e-mail and any attachments may contain confidential material for > the sole use of the intended recipient(s). Any review or distribution > by others is strictly prohibited. If you are not the intended > recipient, please contact the sender and delete all copies.