Java JPA, Liberty and Solr, problem when connecting with Solr, can not find the property file

0

I'm with a Web Service in Java JPA with server Liberty and Apache Solr as indexer of data. However, at the moment that the application needs to connect to Solr it throws this error

  

com.ban.cos.solr.SolrConnections: Error reading configuration file: ejb \ conf \ searcher.properties (The system can not find the specified path)

The rest of the error corresponds to a% co_of ordinary%. I'm explaining how this connection is coming:

In the service to which I invoke the connection I refer to the SolrConnection file

QueryResponse response = this.solrConnections.getSolrMov().query(query);

In the Solr Connections file I do a NullPointerException to a @Resource that will contain the connection query

import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.util.Properties;

import javax.annotation.PostConstruct;
import javax.annotation.Resource;
import javax.ejb.Singleton;

import org.apache.solr.client.solrj.impl.CloudSolrServer;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

@Singleton
public class SolrConnections {

private static final Logger LOG = 
LoggerFactory.getLogger(SolrConnections.class);

@Resource(lookup = "conf/COS_PROPS_LOCATION")
private String propertiesPath;

private CloudSolrServer solrCas;
private CloudSolrServer solrCon;
private CloudSolrServer solrMov;

@PostConstruct
public void init() {
    File propsFile = new File(this.propertiesPath);
    try {
        InputStream targetStream = new FileInputStream(propsFile);
        Properties props = new Properties();
        props.load(targetStream);
        this.solrCas = new CloudSolrServer(props.getProperty("bc.solr.zkHost"));
        this.solrCas.setDefaultCollection(props.getProperty("bc.indices.cas"));

        this.solrCon = new CloudSolrServer(props.getProperty("bc.solr.zkHost"));
        this.solrCon.setDefaultCollection(props.getProperty("bc.indices.con"));

        this.solrMov = new CloudSolrServer(props.getProperty("bc.solr.zkHost"));
        this.solrMov.setDefaultCollection(props.getProperty("bc.indices.mov"));
    } catch (FileNotFoundException e) {
        LOG.error("Error leyendo archivo de configuración: {}", e.getMessage());
    } catch (IOException e) {
        LOG.error("Error leyendo archivo de configuración: {}", e.getMessage());
    }
}

public CloudSolrServer getSolrCas() {
    return this.solrCas;
}

public CloudSolrServer getSolrCon() {
    return this.solrCon;
}

public CloudSolrServer getSolrMov() {
    return this.solrMov;
}
}

The String points to the server of lookup that contains an entry Liberty , which addresses the file JNDI .

<jndiEntry id="${conf.cos}" jndiName="conf/COS_PROPS_LOCATION" value="ejb/conf/buscador.properties"/>

The property corresponds to the value of the file I am looking for, but I tried changing it by removing the subdirectories and still can not find it.

Any idea of this error? Thank you very much.

    
asked by Darius 28.04.2017 в 19:43
source

1 answer

0

I already solved the solution was to set the value of jndiEntry to an absolute path.

    
answered by 08.05.2017 / 23:14
source