David
David

Reputation: 61

Why do I get "ManagedIndexSchema Error persisting managed schema => FileNotFoundException: (Access is denied)" when adding a field to a Solr core?

I have a java program running on windows that:

  1. Run Solr Server using "bin/solr.cmd restart -f -q -p 55183".
  2. Delete (if exists) the old core named "my_core" using "bin/solr.cmd delete -c my_core".
  3. Create a new core named "my_core" using "bin/solr.cmd create -c my_core".
  4. Configure the scheme using:
    "bin/solr.cmd config -c my_core -p 55183 -action set-user-property -property update.autoCreateFields -value false".
  5. Add a new field to the scheme using solrj's HTTP client.
  6. Does several more things including indexing some documents.

Everything works fine on my machine but when I send it to the company's servers farm for tests, step 5 (add field) fails.

The error Solr Server returns is:
2021-12-07 19:58:00.183 ERROR (qtp966739377-20) [ x:my_core] o.a.s.s.ManagedIndexSchema Error persisting managed schema C:\views\clones\clone2\0\Qrelease\3rd\Solr\server\solr\my_core\conf\managed-schema => java.io.FileNotFoundException: C:\views\clones\clone2\0\Qrelease\3rd\Solr\server\solr\my_core\conf\managed-schema (Access is denied)

The error the client returns is:
org.apache.solr.client.solrj.impl.HttpSolrClient$RemoteExecutionException: Error from server at http://localhost:55183/solr/find_it_core: error processing commands: {responseHeader={status=400,QTime=60},error={metadata={error-class=org.apache.solr.api.ApiBag$ExceptionWithErrObject,root-error-class=org.apache.solr.api.ApiBag$ExceptionWithErrObject},details=[Unable to persist managed schema. Error persisting managed schema C:\views\clones\clone2\0\Qrelease\3rd\Solr\server\solr\my_core\conf\managed-schema],msg=error processing commands,code=400}}

Any ideas why I'm able to make changes to the scheme on my computer but not on a remote one?

Upvotes: 3

Views: 1605

Answers (2)

Jennifer
Jennifer

Reputation: 95

I had the same problem but fixed it. Here were the details of my problem:

  1. Worked fine on the production servers from PHP, where I was sending credentials with every request in the URL. Have been using it that way for a long time.
  2. Ported to solrj on my test server, which has the same configuration as production, except that it is one server running ubuntu-18.04+tomcat-10.0.12+solr-8.8.1+mysql, rather than tomcat on the front-end and solr+mysql on the back-end. Besides the production DMZ, security settings are identical. Everything worked fine on the test server.
  3. Moved the solrj implementation to the front-end server and got auth errors (IOException).
  4. Added PreemptiveAuthInterceptor (e.g. see Solr basic authentication without setting credentials for each request) to my httpClient to the solrj and now the general auth problems went away, but I started to get the same error as you.

I also checked what @HectorCorrea suggested, but solr is running as the solr user, who also owns the managed-schema file. BTW the field was being created before the error - I could see it in the managed-schema file and also see it when accessing the schema by the Rest API. If my solution does not help you, please try checking these.

In frustration I just restarted the solr service and tried again. Now both the PHP and the solrj implementations work. The interesting thing is that other errors that I had in the log file also disappeared when creating new cores and adding fields, which did not happen with PHP:

o.a.s.c.ConfigSetProperties Did not find ConfigSet properties, assuming default properties:  => org.apache.solr.core.SolrResourceNotFoundException: Can't find resource 'configsetprops.json' in classpath or '/var/solr/data/my_core'
    at org.apache.solr.core.SolrResourceLoader.openResource(SolrResourceLoader.java:402)

also

o.a.s.m.SolrMetricManager Error loading metrics reporter, plugin info: {type = reporter,name = default,class = org.apache.solr.metrics.reporters.SolrJmxReporter,attributes = {name=default, class=org.apache.solr.metrics.reporters.SolrJmxReporter},} => javax.management.RuntimeMBeanException: java.security.AccessControlException: access denied ("java.lang.RuntimePermission" "accessClassInPackage.jdk.internal.reflect")
    at java.management/com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.rethrow(DefaultMBeanServerInterceptor.java:829)

followed at last by

o.a.s.h.RequestHandlerBase org.apache.solr.api.ApiBag$ExceptionWithErrObject: error processing commands, errors: [Unable to persist managed schema. Unable to reload core [my_core]],
    at org.apache.solr.handler.SchemaHandler.handleRequestBody(SchemaHandler.java:97)

To see if my experience matches with yours, you might see if you are getting similar errors in the logs.

Not clear to me why this worked, since nothing had changed in the .xml files for Solr. I will refrain from guessing about what might have caused this, but I will also mention that my solrj version is 8.11.0 on both test server and production, which does not match solr on either. Please try the restart and checking the other things that I mentioned above as well.

Upvotes: 0

Hector Correa
Hector Correa

Reputation: 26690

When you add a new field using Solr's HTTP API it results in the new field definition being added to the managed-schema file.

It works on your machine because the file managed-schema exists and you have write access to it.

The error on the server environment indicates that the file does not exist on the server, so I would first make sure that the core is created in the same was as you did in your local environment and make sure the file is indeed present.

I have also seen similar issues when the file does exist but the user that Solr runs under does not have write access to it.

Upvotes: 0

Related Questions