Hi,

I have created a customized java module (see code extract below) which
initialized the SolrYard and query dbpedia index file. It uses stanbol
0.12.0 packages. Everything works fine.
Now, I am trying to include this custom module in an OSGi environment
but getting the following error:

Caused by: org.apache.solr.common.SolrException: Error instantiating
shardHandlerFactory class
[org.apache.solr.handler.component.HttpShardHandlerFactory]: Error
loading class 'org.apache.solr.handler.component.HttpShardHandlerFactory'
       at 
org.apache.solr.handler.component.ShardHandlerFactory.newInstance(ShardHandlerFactory.java:54)
       at org.apache.solr.core.CoreContainer.load(CoreContainer.java:204)
       at 
com.abc.g11n.queryDbpedia.QueryDbpediaDirect.initYardNew(QueryDbpediaDirect.java:146)
       at 
com.abc.g11n.queryDbpedia.QueryDbpediaDirect.init(QueryDbpediaDirect.java:119)
       at 
com.adc.sharedcloud.worker.manthanta.DefaultCommand.<clinit>(DefaultCommand.java:59)
       ... 103 more

I was reading about StandaloneEmbeddedSolrServerProvider and I found
out that it is intended to be used outside of an OSGI environment as
specified at 
(http://www.go5th.com/jdocs/stanbol/commons/solr/managed/org/apache/stanbol/commons/solr/managed/standalone/StandaloneEmbeddedSolrServerProvider.html)

Could you please help me on how to initialize a SolrYard (to query
dbpedia index file) in an OSGi environment?


(Code that I am currently using to initialize the SolrYard)

    private static Yard yard;
    private static final String DBP_RES_ID = "Dbp_Res_ID";
    private static final String YARD_ID = "DbpYard";
    private static final String SOLR_CORE_NAME = "dbpedia";
    private static StandaloneEmbeddedSolrServerProvider solrServerProvider;
    private static SolrServer server;
    public static boolean dbpediaInitialised = false;

private static void initYard(String solrServerDir) throws
YardException, IOException {
        SolrYardConfig config = new SolrYardConfig(YARD_ID, SOLR_CORE_NAME);
        config.setName("Dbpedia Solr Yard");
        config.setDescription("The Solr Yard for querying dbpedia");
        config.setAllowInitialisation(false);
        System.setProperty(ManagedSolrServer.MANAGED_SOLR_DIR_PROPERTY,
solrServerDir);
        IndexReference solrServerRef =
IndexReference.parse(config.getSolrServerLocation());
        solrServerProvider = StandaloneEmbeddedSolrServerProvider.getInstance();
        server = solrServerProvider.getSolrServer(solrServerRef,
                config.isAllowInitialisation() ?
config.getIndexConfigurationName() : null);
        //Optional support for the nsPrefix service
        final NamespacePrefixService nsPrefixService;
        ServiceLoader<NamespacePrefixService> spsl =
ServiceLoader.load(NamespacePrefixService.class);
        Iterator<NamespacePrefixService> it = spsl.iterator();
        if(it.hasNext()){
            nsPrefixService = it.next();
        } else {
            nsPrefixService = null;
        }
        yard = new SolrYard(server, config, nsPrefixService);
    }


Regards,
Manish

Reply via email to