I'm Posting the following to the Solr Server:
<add>
<doc>
<field name="uniqueid">5453543</field>
<field name="modifieddate">2008-12-03T15:49:00Z</field>
<field name="title">My Record</field>
<field name="description">Descirption
Details
</field>
<field name="startdate">2009-01-21T15:26:05.680Z</field>
<field name="enddate">2009-01-21T15:26:05.697Z</field>
<field name="Telephone_number">11111 111 111(text phone)</field>
<field name="Telephone_number">11111 111 111</field>
<field name="Mobile_number">1111111111</field>
</doc>
</add>
I'm using SolrNet to send the documents here's an extract from the code (s is the above xml):
public string Post(string relativeUrl, string s)
{
var u = new UriBuilder(serverURL);
u.Path += relativeUrl;
var request = httpWebRequestFactory.Create(u.Uri);
request.Method = HttpWebRequestMethod.POST;
request.KeepAlive = false;
if (Timeout > 0)
request.Timeout = Timeout;
request.ContentType = "text/xml; charset=utf-8";
request.ContentLength = s.Length;
request.ProtocolVersion = HttpVersion.Version10;
try
{
using (var postParams = request.GetRequestStream())
{
postParams.Write(xmlEncoding.GetBytes(s), 0, s.Length);
using (var response = request.GetResponse())
{
using (var rStream = response.GetResponseStream())
{
string r = xmlEncoding.GetString(ReadFully(rStream));
//Console.WriteLine(r);
return r;
}
}
}
}
catch (WebException e)
{
throw new SolrConnectionException(e);
}
}
When it gets to request.GetResponse it failed with this error:
base {System.InvalidOperationException} = {"The remote server returned an error: (500) Internal Server Error."}
When i look on the server in the Logs for apache it gives the following reason:
Unexpected end of input block in end
Here's the full stack trace:
Sep 17, 2009 10:13:53 AM org.apache.solr.common.SolrException log SEVERE: com.ctc.wstx.exc.WstxEOFException: Unexpected end of input block in end tag at [row,col {unknown-source}]: [26,1266] at com.ctc.wstx.sr.StreamScanner.throwUnexpectedEOB(StreamScanner.java:700) at com.ctc.wstx.sr.StreamScanner.loadMoreFromCurrent(StreamScanner.java:1054) at com.ctc.wstx.sr.StreamScanner.getNextCharFromCurrent(StreamScanner.java:811) at com.ctc.wstx.sr.BasicStreamReader.readEndElem(BasicStreamReader.java:3211) at com.ctc.wstx.sr.BasicStreamReader.nextFromTree(BasicStreamReader.java:2832) at com.ctc.wstx.sr.BasicStreamReader.next(BasicStreamReader.java:1019) at org.apache.solr.handler.XmlUpdateRequestHandler.processUpdate(XmlUpdateRequestHandler.java:148) at org.apache.solr.handler.XmlUpdateRequestHandler.handleRequestBody(XmlUpdateRequestHandler.java:123) at org.apache.solr.handler.RequestHandlerBase.handleRequest(RequestHandlerBase.java:131) at org.apache.solr.core.SolrCore.execute(SolrCore.java:1204) at org.apache.solr.servlet.SolrDispatchFilter.execute(SolrDispatchFilter.java:303) at org.apache.solr.servlet.SolrDispatchFilter.doFilter(SolrDispatchFilter.java:232) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233) at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191) at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128) at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102) at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109) at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:293) at org.apache.coyote.http11.Http11AprProcessor.process(Http11AprProcessor.java:859) at org.apache.coyote.http11.Http11AprProtocol$Http11ConnectionHandler.process(Http11AprProtocol.java:574) at org.apache.tomcat.util.net.AprEndpoint$Worker.run(AprEndpoint.java:1527) at java.lang.Thread.run(Thread.java:619)
Please note the Solr server is running on the following system:
Microsoft Windows Server 2003 R2 Apache Tomcat 6
Finally here's my question:
The Xml i'm sending looks ok to me.. Does anyone have an ideas as to why Solr is throwing this exception?
Thanks
Dave
Edit Answer is as follows:
public string Post(string relativeUrl, string s)
{
var u = new UriBuilder(serverURL);
u.Path += relativeUrl;
var request = httpWebRequestFactory.Create(u.Uri);
request.Method = HttpWebRequestMethod.POST;
request.KeepAlive = false;
if (Timeout > 0)
request.Timeout = Timeout;
request.ContentType = "text/xml; charset=utf-8";
request.ProtocolVersion = HttpVersion.Version10;
try
{
// Set the Content length after the size of the byte array has been calculated.
byte[] data = xmlEncoding.GetBytes(s);
request.ContentLength = s.Length;
using (var postParams = request.GetRequestStream())
{
postParams.Write(data, 0, data.Length);
using (var response = request.GetResponse())
{
using (var rStream = response.GetResponseStream())
{
string r = xmlEncoding.GetString(ReadFully(rStream));
//Console.WriteLine(r);
return r;
}
}
}
}
catch (WebException e)
{
throw new SolrConnectionException(e);
}
}