How to deploy Solr 5.5 in Tomcat 8

2016-02-29 Thread Marcin T
Hi,

Since Solr 5.x there is no web archive (war) in standard distribution.
So I'm building a web archive (war) and I'm deploying it in my Tomcat
8 container. It works to Solr 5.3. Since Solr 5.4 it doesn't works
(admin's page doesn't works). A problem is with
org.apache.solr.servlet.LoadAdminUiServlet (doGet method). During
debugging this method i noticed that in Tomcat request.getRequestURI()
method returns only a context path (without admin.html). So variable
admin has a value "/" and
getServletContext().getResourceAsStream(admin) returns null. Finally
doGet method returns 404.
Following is a code

...
String admin = 
request.getRequestURI().substring(request.getContextPath().length());
 <- admin is "/"
CoreContainer cores = (CoreContainer)
request.getAttribute("org.apache.solr.CoreContainer");
InputStream in = getServletContext().getResourceAsStream(admin);
<- in is null
...

How can I solve this problem?

Best regards,


Problem enum type field

2017-09-09 Thread Marcin T
HI,

In my project i use Apache Solr version 6.2.1. A schema.xml contains
an enum field. When I try to index this field (sending a java object
with an enum via solrj) I get an exception (stacktrace below)

org.apache.solr.client.solrj.impl.HttpSolrClient$RemoteSolrException:
Error from server at http://mydomain.pl/solr/text: Unknown value for
enum field: :
at 
org.apache.solr.client.solrj.impl.HttpSolrClient.executeMethod(HttpSolrClient.java:560)
at 
org.apache.solr.client.solrj.impl.HttpSolrClient.request(HttpSolrClient.java:235)
at 
org.apache.solr.client.solrj.impl.HttpSolrClient.request(HttpSolrClient.java:227)
at 
org.apache.solr.client.solrj.impl.LBHttpSolrClient.doRequest(LBHttpSolrClient.java:376)
at 
org.apache.solr.client.solrj.impl.LBHttpSolrClient.request(LBHttpSolrClient.java:328)
at 
org.apache.solr.client.solrj.impl.CloudSolrClient.sendRequest(CloudSolrClient.java:1086)
at 
org.apache.solr.client.solrj.impl.CloudSolrClient.requestWithRetryOnStaleState(CloudSolrClient.java:856)
at 
org.apache.solr.client.solrj.impl.CloudSolrClient.request(CloudSolrClient.java:799)
at 
org.apache.solr.client.solrj.SolrRequest.process(SolrRequest.java:135)[100:org.apache.servicemix.bundles.solr-solrj:5.2.1.1]
at 
org.apache.solr.client.solrj.SolrClient.add(SolrClient.java:107)[100:org.apache.servicemix.bundles.solr-solrj:5.2.1.1]
at 
org.apache.solr.client.solrj.SolrClient.addBeans(SolrClient.java:358)[100:org.apache.servicemix.bundles.solr-solrj:5.2.1.1]
at 
org.apache.solr.client.solrj.SolrClient.addBeans(SolrClient.java:330)[100:org.apache.servicemix.bundles.solr-solrj:5.2.1.1]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native
Method)[:1.8.0_51]
at 
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)[:1.8.0_51]
at 
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)[:1.8.0_51]
at java.lang.reflect.Method.invoke(Method.java:497)[:1.8.0_51]

It looks like solrj cannot properly handle an enum field. While code
debugging I have noticed that there is a writeVal(Object) method in
org.apache.solr.common.util.JavaBinCodec class, which is responsible
for serialization a java object to a bytes. This methods ends with a
fallback code

writeVal(val.getClass().getName() + ':' + val.toString());

which, in case when field type is unknown, field is serialize as
string : (this is my case).

When I convert enum to string all works fine but I don't want do that.

How can I properly send a java object which contains an enum field to
solr via solrj?


Best regards,
Marcin