You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@solr.apache.org by Armin Mueller <am...@scopeset.de> on 2022/03/25 16:08:43 UTC

Failing to create a new core with SolrJ CoreAdminRequest.createCore

Hello,

I'm trying to create a new core with SolrJ's CoreAdminRequest.createCore.

The idea is to use 
"/opt/solr/server/solr/configsets/jcg_example_configs/solrconfig.xml" as 
config file and 
"/opt/solr/server/solr/configsets/jcg_example_configs/managed-schema" as 
schema file, (or later something we stage at container startup) so the 
call would look like this:

         SolrClient client = new 
HttpSolrClient.Builder("http://localhost:8983/solr").build();
         CoreAdminResponse resp = CoreAdminRequest.createCore("xyz", 
"xyz", client,
"/opt/solr/server/solr/configsets/jcg_example_configs/solrconfig.xml",
"/opt/solr/server/solr/configsets/jcg_example_configs/managed-schema");

I managed to convince solr to load solrconfig.xml by setting 
SOLR_OPTS=-Dsolr.allow.unsafe.resourceloading=true in my docker compose, 
but now the call above produces this:

Unable to create core [xyz] Caused by: Can't find resource 
'lang/contractions_it.txt' in classpath or '/var/solr/data/xyz' - 
/opt/solr/server/solr/configsets/jcg_example_configs has 
lang/contractions_it.txt - but that's obviously not in the classpath.

Any ideas?

Thanks,
Armin



Re: Failing to create a new core with SolrJ CoreAdminRequest.createCore

Posted by Shawn Heisey <ap...@elyograg.org>.
On 3/25/22 10:08, Armin Mueller wrote:
> I'm trying to create a new core with SolrJ's CoreAdminRequest.createCore.

CoreAdmin cannot create the directory/files for a new core.  They must 
already exist before the create is called.  If you want Solr to create 
cores without touching the filesystem yourself beforehand, you must run 
in SolrCloud mode, and then you'll be creating collections, not using 
CoreAdmin.  There is a ConfigSets feature for standalone mode that MIGHT 
do what you need, but I have never actually used it, and I don't think 
SolrJ has any convenience methods for it.

In wherever your solr home is, create the "xyz" directory, in that 
directory create a "conf" directory, and in the conf directory, put your 
solrconfig.xml, managed-schema, and any config files referenced by those 
files.  Change the ownership on all that to whatever user is running the 
Solr process.

Then when you run the createCore method, do it without the last two 
arguments.  Solr will find the config in the conf directory, create a 
data directory, and create a "core.properties" file so the core will be 
automatically loaded when Solr starts up again.

You might be thinking "but wait ... bin/solr can do it!"  That's because 
bin/solr creates the core directory and copies a config in place BEFORE 
it calls CoreAdmin.

Thanks,
Shawn