Thanks for the responses! Shawn you are right, I'm using Solr 5.2.1 not 5.2.3. 
In the main code I am using the HttpSolrClient  (we are calling it the 
SolrCatalogClient) and an EmbeddedSolrServer in the JUnit Tests that we use the 
SolrCatalogClient to query:

private static SolrCatalogClient testSolrClient;
private static EmbeddedSolrServer embeddedServer;

@BeforeClass
public static void setUpBeforeClass() throws Exception {
        System.setProperty("solr.solr.home", "solr/conf");
        System.setProperty("solr.data.dir", new 
File("target/solr-embedded-data").getAbsolutePath());
        CoreContainer coreContainer = new CoreContainer("solr/conf");
        coreContainer.load();
                
        CoreDescriptor cd = new CoreDescriptor(coreContainer, " ourSolrCore ", 
new File("solr").getAbsolutePath());
        coreContainer.create(cd);
                
        LOGGER.info("Printing all Core Names: " + 
coreContainer.getAllCoreNames());
        embeddedServer = new EmbeddedSolrServer(coreContainer, "ourSolrCore");
                
        LOGGER.info("Initializing Solr Client for JUnit tests");

        testSolrClient = new SolrCatalogClient(embeddedServer);

        //Create test objects
        TestObject testObject1 = new TestObject(...);

        testSolrClient.addObject(testObject1);
}

@Test
public void testIdDoesNotExistQuery() {
        String json = testSolrClient.getQueryResponseAsJson("1111");
        LOGGER.info("Solrj does not exist response = " + json);
        assert(json.equalsIgnoreCase("[]"));
}

If I extend the SolrJettyTestBase can I still specify the schema that I want to 
use for the tests?

-Jennifer

-----Original Message-----
From: Shawn Heisey [mailto:apa...@elyograg.org] 
Sent: Tuesday, January 03, 2017 2:31 PM
To: solr-user@lucene.apache.org
Subject: Re: Can I use SolrJ 6.3.0 to talk to a Solr 5.2.3 server?

On 1/3/2017 10:35 AM, Jennifer Coston wrote:
> I am running into a conflict with Solr and ElasticSearch. We are trying to 
> add support for Elastic Search 5.1.1 which requires Lucene 6.3.0 to an 
> existing system that uses Solr 5.2.3. At the moment I am using SolrJ 5.3.1 to 
> talk to the 5.2.3 Server. I was hoping I could just update the SolrJ 
> libraries to 6.3.0 so the Lucene conflict goes away, but when I try to run my 
> unit tests I'm seeing this error:

There is no 5.2.3 version of Solr.  The 5.2.x line ended with 5.2.1. 
There is a 5.3.2 version.

If you're using HttpSolrClient, mixing a 5.x server and a 6.x client will be no 
problem at all.  If you're using CloudSolrClient you may run into issues 
because of the very rapid pace of change in SolrCloud -- mixing major versions 
is not recommended.  If you're using EmbeddedSolrServer, then the client and 
the server are not separate, so upgrading both at once is probably OK, but the 
code and the core config might require changes.

> java.util.ServiceConfigurationError: Cannot instantiate SPI class: 
> org.apache.lucene.codecs.simpletext.SimpleTextPostingsFormat

This is an error from a Solr *server*, not a client.  Are you using 
EmbeddedSolrServer?

> Here are the Solr Dependencies I have in my pom.xml:

You've got a solr-core dependency here.  That is not at all necessary for a 
SolrJ client, *unless* you are using EmbeddedSolrServer.  If you are using the 
embedded server, then things are much more complicated, and your code may 
require changes before it will work correctly with a new major version.  The 
embedded server is NOT recommended unless you have no other choice.  The unit 
tests included with Solr are able to fire up Solr with Jetty for tests, just 
like a real separate Solr server.  Your tests can also do this.  Look for tests 
in the Lucene/Solr codebase that extend SolrJettyTestBase, and use those as a 
guide.

Thanks,
Shawn

Reply via email to