Thanks Shalin,

I am now trying to use MiniSolrCloudCluster to create mini cluster in solr 6/7 
as below:
 
MiniSolrCloudCluster miniCluster = new MiniSolrCloudCluster(1, 
temp_folder_path, path_to_solr.xml, null);


It throws the following exception:

org.apache.zookeeper.KeeperException$NodeExistsException: KeeperErrorCode = 
NodeExists for /solr/solr.xml
        at org.apache.zookeeper.KeeperException.create(KeeperException.java:119)
        at org.apache.zookeeper.KeeperException.create(KeeperException.java:51)
        at org.apache.zookeeper.ZooKeeper.create(ZooKeeper.java:783)
        at 
org.apache.solr.common.cloud.SolrZkClient$10.execute(SolrZkClient.java:503)
        at 
org.apache.solr.common.cloud.ZkCmdExecutor.retryOperation(ZkCmdExecutor.java:60)
        at 
org.apache.solr.common.cloud.SolrZkClient.makePath(SolrZkClient.java:500)
        at 
org.apache.solr.common.cloud.SolrZkClient.makePath(SolrZkClient.java:458)
        at 
org.apache.solr.common.cloud.SolrZkClient.makePath(SolrZkClient.java:445)
        at 
org.apache.solr.common.cloud.SolrZkClient.makePath(SolrZkClient.java:432)
        at 
org.apache.solr.cloud.MiniSolrCloudCluster.<init>(MiniSolrCloudCluster.java:199)
        at 
org.apache.solr.cloud.MiniSolrCloudCluster.<init>(MiniSolrCloudCluster.java:168)
        at 
com.gossinteractive.solr.TestMiniSolrCloudCluster.setup(TestMiniSolrCloudCluster.java:52)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at 
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
        at 
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:497)
        at 
org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:45)
        at 
org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15)
        at 
org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:42)
        at 
org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:27)
        at 
org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:30)
        at org.junit.runners.ParentRunner.run(ParentRunner.java:300)
        at 
org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50)
        at 
org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
        at 
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467)
        at 
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
        at 
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)
        at 
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)


This is a Zookeeper exception and I cannot figure out what is wrong. Can 
someone shed some light please?

Rohana


-----Original Message-----
From: Shalin Shekhar Mangar [mailto:shalinman...@gmail.com] 
Sent: 12 April 2016 13:19
To: solr-user@lucene.apache.org
Subject: Re: EmbeddedSolr for unit tests in Solr 6

Rohana, as I said earlier, the MiniSolrCloudCluster is specifically made for 
your use-case i.e. where you want to quickly setup a SolrCloud cluster in your 
own application for testing. It is available in the solr-test-framework 
artifact.

On Tue, Apr 12, 2016 at 4:31 PM, Rohana Rajapakse < 
rohana.rajapa...@gossinteractive.com> wrote:

> Please note that I am not writing unit tests for testing classes in Solr.
> I need a temporary Solr index to test classes in my own application 
> that needs a Solr index. I would like to use classes that are 
> available in solr-core and solr-solrj jars. I could do this easily in 
> solr-4.x versions using EmbeddedSolrServer. I prefer not to extend 
> SolrTestCaseJ4 class. Also MiniSolrCloudCluster is not available in solr-core 
> or solr-solrj jar.
>
> What is the best way of doing this in Solr-6.x / Solr-7.0  ?
>
> -----Original Message-----
> From: Joe Lawson [mailto:jlaw...@opensourceconnections.com]
> Sent: 11 April 2016 17:31
> To: solr-user@lucene.apache.org
> Subject: Re: EmbeddedSolr for unit tests in Solr 6
>
> Check for example tests here too:
>
> https://github.com/apache/lucene-solr/tree/master/solr/core/src/test/o
> rg/apache/solr
>
> On Mon, Apr 11, 2016 at 12:24 PM, Shalin Shekhar Mangar < 
> shalinman...@gmail.com> wrote:
>
> > Please use MiniSolrCloudCluster instead of EmbeddedSolrServer for 
> > unit/integration tests.
> >
> > On Mon, Apr 11, 2016 at 2:26 PM, Rohana Rajapakse < 
> > rohana.rajapa...@gossinteractive.com> wrote:
> >
> > > Thanks Shawn,
> > >
> > > I am now pointing solrHomeFolder to 
> > > lucene-solr-master\solr\server\solr
> > > which contains the correct solr.xml file.
> > > Tried the following two ways to create an EmbeddedSolrServer:
> > >
> > >
> > > 1.         CoreContainer corecon =
> > > CoreContainer.createAndLoad(Paths.get(solrHomeFolder));
> > >            corecon.load();
> > >            SolrClient svr = new EmbeddedSolrServer(corecon, 
> > > corename);
> > >
> > >
> > > 2.   SolrClient svr = new EmbeddedSolrServer(Paths.get(solrHomeFolder),
> > > corename);
> > >
> > >
> > > They both throws the same exception  (java.lang.NoClassDefFoundError:
> > > Could not initialize class org.apache.solr.servlet.SolrRequestParsers).
> > > org.apache.solr.servlet.SolrRequestParsers class is present in the 
> > > solr-core-7.0.0-SNAPSHOT.jar and this jar is present in the 
> > > WEB-INF\lib folder (in solr server) and also included as a 
> > > dependency jar in the pom.xml of the test project.
> > >
> > > Here is the full stack trace of the exception:
> > >
> > > java.lang.NoClassDefFoundError: Could not initialize class 
> > > org.apache.solr.servlet.SolrRequestParsers
> > >         at
> > >
> > org.apache.solr.client.solrj.embedded.EmbeddedSolrServer.<init>(Embe
> > dd
> > edSolrServer.java:112)
> > >         at
> > >
> > org.apache.solr.client.solrj.embedded.EmbeddedSolrServer.<init>(Embe
> > dd
> > edSolrServer.java:70)
> > >         at
> > >
> > com.gossinteractive.solr.DocPhraseUpdateProcessorTest.createEmbedded
> > So
> > lrServer(DocPhraseUpdateProcessorTest.java:141)
> > >         at
> > >
> > com.gossinteractive.solr.DocPhraseUpdateProcessorTest.setUp(DocPhras
> > eU
> > pdateProcessorTest.java:99)
> > >         at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> > >         at
> > >
> > sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl
> > .j
> > ava:62)
> > >         at
> > >
> > sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcce
> > ss
> > orImpl.java:43)
> > >         at java.lang.reflect.Method.invoke(Method.java:497)
> > >         at
> > >
> > org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(Framewor
> > kM
> > ethod.java:44)
> > >         at
> > >
> > org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCa
> > ll
> > able.java:15)
> > >         at
> > >
> > org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkM
> > et
> > hod.java:41)
> > >         at
> > >
> > org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores
> > .j
> > ava:27)
> > >         at
> > >
> > org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.j
> > av
> > a:31)
> > >         at
> > >
> > org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRu
> > nn
> > er.java:73)
> > >         at
> > >
> > org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRu
> > nn
> > er.java:46)
> > >         at
> > > org.junit.runners.ParentRunner.runChildren(ParentRunner.java:180)
> > >         at
> > org.junit.runners.ParentRunner.access$000(ParentRunner.java:41)
> > >         at
> > org.junit.runners.ParentRunner$1.evaluate(ParentRunner.java:173)
> > >         at
> > >
> > org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores
> > .j
> > ava:28)
> > >         at
> > >
> > org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.j
> > av
> > a:31)
> > >         at org.junit.runners.ParentRunner.run(ParentRunner.java:220)
> > >         at
> > >
> > org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit
> > 4T
> > estReference.java:50)
> > >         at
> > >
> > org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.
> > java:38)
> > >         at
> > >
> > org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(Remo
> > te
> > TestRunner.java:467)
> > >         at
> > >
> > org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(Remo
> > te
> > TestRunner.java:683)
> > >         at
> > >
> > org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTes
> > tR
> > unner.java:390)
> > >         at
> > >
> > org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTe
> > st
> > Runner.java:197)
> > >
> > >
> > > I have debugged this a bit and found that this exception is thrown 
> > > on the following line in EmbeddedServer.class
> > >
> > > _parser = new SolrRequestParsers(null);
> > >
> > > Also, the coreContainer object has no cores at this point.
> > >
> > >
> > > Wonder if I should update my code from master (it is now about two 
> > > weeks old).
> > >
> > > Thanks for any help.
> > >
> > > Rohana
> > >
> > >
> > > -----Original Message-----
> > > From: Shawn Heisey [mailto:apa...@elyograg.org]
> > > Sent: 08 April 2016 16:46
> > > To: solr-user@lucene.apache.org
> > > Subject: Re: EmbeddedSolr for unit tests in Solr 6
> > >
> > > On 4/8/2016 7:51 AM, Rohana Rajapakse wrote:
> > > > Thanks. I know it exists, but don't know how to use it.
> > > >
> > > > I am trying to use EmbeddedSolrServer(Path solrHome, String
> > > > defaultCoreName)
> > > >
> > > > What should be the "solrHome"? Should it be the actual solr home
> (i.e.
> > > lucene-solr-master\solr\server\solr) in the solr server, or can it 
> > > be any temporary folder?
> > > >
> > > > I create it with:  new EmbeddedSolrServer((new
> > > File("testdata/solr")).toPath(), "tmpcore");  and get the 
> > > following Exception (I use solr-Solr-7.0.0):
> > > >
> > > > org.apache.solr.common.SolrException: Should not have found 
> > > > solr/@persistent . Please upgrade your solr.xml:
> > > https://cwiki.apache.org/confluence/display/solr/Format+of+solr.xm
> > > l
> > > >       at
> > > org.apache.solr.core.SolrXmlConfig.failIfFound(SolrXmlConfig.java:
> > > 16
> > > 7)
> > > >       at
> > >
> > org.apache.solr.core.SolrXmlConfig.checkForIllegalConfig(SolrXmlConf
> > ig
> > .java:149)
> > > >       at
> > > org.apache.solr.core.SolrXmlConfig.fromConfig(SolrXmlConfig.java:6
> > > 1)
> > > >       at
> > >
> > org.apache.solr.core.SolrXmlConfig.fromInputStream(SolrXmlConfig.java:
> > 129)
> > > >       at
> > > org.apache.solr.core.SolrXmlConfig.fromFile(SolrXmlConfig.java:111
> > > )
> > > >       at
> > > org.apache.solr.core.SolrXmlConfig.fromSolrHome(SolrXmlConfig.java
> > > :1
> > > 39)
> > > >       at
> > > org.apache.solr.core.SolrXmlConfig.fromSolrHome(SolrXmlConfig.java
> > > :1
> > > 44)
> > > >       at
> > >
> > org.apache.solr.client.solrj.embedded.EmbeddedSolrServer.<init>(Embe
> > dd
> > edSolrServer.java:70)
> > > >       at
> > >
> > com.gossinteractive.solr.DocPhraseUpdateProcessorTest.createEmbedded
> > So
> > lrServer(DocPhraseUpdateProcessorTest.java:140)
> > > >       at
> > > > com.gossinteractive.solr.DocPhraseUpdateProcessorTest.setUp(DocP
> > > > hr
> > > > aseU
> > > > pdateProcessorTest.java:98)
> > >
> > > You said you were using EmbeddedSolrServer with 4.x, so I assumed 
> > > you
> > knew
> > > what you were doing.
> > >
> > > You are getting that Exception because the solr home you pointed 
> > > to contains a solr.xml file in the old solr.xml format.  This 
> > > format is supported by all of 4.x, but support was dropped in 5.0.  
> > > The message is pretty clear -- it says that you need to upgrade 
> > > your solr.xml, and even points at some documentation.  Here's a 
> > > wiki page about the old format, with a link to another page about the new 
> > > format:
> > >
> > > http://wiki.apache.org/solr/Solr.xml%20%28supported%20through%204.
> > > x%
> > > 29
> > >
> > > Suggestion: Rather than create a File object and convert it to a 
> > > Path,
> > use
> > > NIO2 methods directly:
> > >
> > > Paths.get("testdata/solr")
> > >
> > > Thanks,
> > > Shawn
> > >
> > >
> > >
> > > Registered Office: 24 Darklake View, Estover, Plymouth, PL6 7TL.
> > > Company Registration No: 3553908
> > >
> > > This email contains proprietary information, some or all of which 
> > > may be legally privileged. It is for the intended recipient only. 
> > > If an
> > addressing
> > > or transmission error has misdirected this email, please notify 
> > > the
> > author
> > > by replying to this email. If you are not the intended recipient 
> > > you may not use, disclose, distribute, copy, print or rely on this email.
> > >
> > > Email transmission cannot be guaranteed to be secure or error 
> > > free, as information may be intercepted, corrupted, lost, 
> > > destroyed, arrive late
> > or
> > > incomplete or contain viruses. This email and any files attached 
> > > to it
> > have
> > > been checked with virus detection software before transmission. 
> > > You
> > should
> > > nonetheless carry out your own virus check before opening any
> attachment.
> > > GOSS Interactive Ltd accepts no liability for any loss or damage 
> > > that may be caused by software viruses.
> > >
> > >
> > >
> >
> >
> > --
> > Regards,
> > Shalin Shekhar Mangar.
> >
>



--
Regards,
Shalin Shekhar Mangar.

Reply via email to