lucene-solr-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jeff Schmidt <>
Subject Re: Which version of Solr?
Date Mon, 14 Feb 2011 04:15:17 GMT
Hello again:

Back to the javabin iissue:

On Feb 12, 2011, at 6:07 PM, Lance Norskog wrote:

> --- But I'm unable to get SolrJ to work due to the 'javabin' version
> mismatch. I'm using the 1.4.1 version of SolrJ, but I always get an
> HTTP response code of 200, but the return entity is simply a null
> byte, which does not match the version number of 1 defined in Solr
> common.  ---
> I've never seen this problem. At this point you are better off
> starting with 3.x instead of chasing this problem down.

I'm now using the latest branch_3x built Solr and SolrJ.  Other places I've seen the message:

Caused by: java.lang.RuntimeException: Invalid version (expected 2, but 0) or the data in
not in 'javabin' format at org.apache.solr.common.util.JavaBinCodec.unmarshal(
at org.apache.solr.client.solrj.impl.BinaryResponseParser.processResponse(

One was told to make sure the version of Solr and SolrJ are compatible, and that the schema
is valid. Unlike 1.4, I see 3.1 actually outputs the expected and received version numbers,
which is helpful. You can see the invalid version of 0 is indicated which is the zero byte
I receive in response.

I have Solr running within Tomcat by following the wiki.  I have the conf/Catalina/localhost/solr.xml
file set as:

<?xml version="1.0" encoding="utf-8"?>
<Context docBase="/usr/local/ingenuity/isec/solr/apache-solr-3.1-SNAPSHOT.war" debug="0"
  <Environment name="solr/home" type="java.lang.String"

 With that, I'm able to use my browser to index some content (DIH, curl etc.) and issue queries,
so it seems Solr is running okay in tomcat (apache-tomcat-6.0.30). To index some Products,
I have this simple method:

	public void addProducts(final Collection<Product> products, final String indexName)
{"addProducts - indexing %d products to Solr core: %s",
				products.size(), indexName));
		final Collection<SolrInputDocument> docs = new ArrayList<SolrInputDocument>();
		for (Product product : products) {
			final SolrInputDocument doc = createDocumentForProduct(product);
			docs.add(doc);"addProduct: document to index: " + doc);
		final SolrServer solrServer = getSolrServer(indexName);
		try {
			solrServer.commit(commitWaitFlush, commitWaitSearcher);
		} catch (Exception ex) {
			final String msg = String.format("Unable to add and commit %d documents to core: %s",
					products.size(), indexName);
			throw new ServiceException(msg, ex);

And I have:

	protected SolrServer getSolrServer(final String indexName) {

		final String url = solrServerBaseUrl + indexName;"getSolrServer - construct server for url: " + url);
		try {
			final CommonsHttpSolrServer solrServer = new CommonsHttpSolrServer(solrServerBaseUrl +
			//solrServer.setParser(new BinaryResponseParser());
			//solrServer.setParser(new XMLResponseParser());
			solrServer.setRequestWriter(new BinaryRequestWriter());
			return solrServer;
		} catch (Exception ex) {
			final String msg = String.format("Unable to create Solr server for url: %s", url);
			throw new ServiceException(msg, ex);			

Note that this is code for prototyping. :)

As you can see, in getSolrServer() I'm trying various settings.
is tagged Solr 1.4, but I'm assuming it's at least very similar in 3.1. For the core in question,
solrconfig.xml does have:

  <requestHandler name="/update" class="solr.XmlUpdateRequestHandler" />
  <requestHandler name="/update/javabin" class="solr.BinaryUpdateRequestHandler" />

I can see in the Solr log:

Feb 13, 2011 3:35:14 PM org.apache.solr.core.RequestHandlers initHandlersFromConfig
INFO: created /update/javabin: solr.BinaryUpdateRequestHandler

Running this through the burp proxy to try to see what's going on, I can see my application
making the following request to Solr via SolrJ:

POST /solr/partner-tmo/update/javabin?wt=javabin&version=2 HTTP/1.1
User-Agent: Solr[org.apache.solr.client.solrj.impl.CommonsHttpSolrServer] 1.0
Host: localhost:8090
Content-Type: application/octet-stream
Content-Length: 543

View raw message