You are viewing a plain text version of this content. The canonical link for it is here.
Posted to solr-user@lucene.apache.org by Karthik Manimaran <ka...@gmail.com> on 2011/01/27 19:02:57 UTC
EmbeddedSolr issues
Hi,
Am getting the following messages while using EmbeddedSolr to retrieve
the Term Vectors. I also happened to go through
https://issues.apache.org/jira/browse/SOLR-914 . Should I ignore these
messages and proceed or should I make any changes?
[#|2011-01-27T11:56:34.593-0500|INFO|glassfish3.0.1|javax.enterprise.system.std.com.sun.enterprise.v3.services.impl|_ThreadId=33|_ThreadName=21687399
[Finalizer] Error org.apache.solr.core.CoreContainer - CoreContainer was
not shutdown prior to finalize(), indicates a bug -- POSSIBLE RESOURCE
LEAK!!!
[#|2011-01-27T11:56:34.609-0500|INFO|glassfish3.0.1|javax.enterprise.system.std.com.sun.enterprise.v3.services.impl|_ThreadId=33|_ThreadName=21687415
[Finalizer] Error org.apache.solr.core.SolrCore - Too many close
[count:-1] on org.apache.solr.core.SolrCore@1638e30. Please report this
exception to solr-user@lucene.apache.org
[#|2011-01-27T11:56:34.611-0500|INFO|glassfish3.0.1|javax.enterprise.system.std.com.sun.enterprise.v3.services.impl|_ThreadId=33|_ThreadName=21687417
[Finalizer] Error org.apache.solr.core.SolrCore - REFCOUNT ERROR:
unreferenced org.apache.solr.core.SolrCore@1638e30 (UserIndexCore) has a
reference count of -1
[#|2011-01-27T11:56:34.613-0500|INFO|glassfish3.0.1|javax.enterprise.system.std.com.sun.enterprise.v3.services.impl|_ThreadId=33|_ThreadName=21687419
[Finalizer] Error org.apache.solr.common.util.ConcurrentLRUCache -
ConcurrentLRUCache was not destroyed prior to finalize(), indicates a
bug -- POSSIBLE RESOURCE LEAK!!!
[#|2011-01-27T11:56:34.613-0500|INFO|glassfish3.0.1|javax.enterprise.system.std.com.sun.enterprise.v3.services.impl|_ThreadId=33|_ThreadName=21687420
[Finalizer] Error org.apache.solr.common.util.ConcurrentLRUCache -
ConcurrentLRUCache was not destroyed prior to finalize(), indicates a
bug -- POSSIBLE RESOURCE LEAK!!!
This is the code am using:
public static SolrCore USER_IDX_CORE;
public static Map<String, String> getTermsVector(String userId) throws
ParserConfigurationException, IOException, SAXException {
Map<String, String> freqMap = new HashMap<String, String>();
try {
SolrConfig USER_IDX_SOLR_CONFIG = new
SolrConfig(USER_IDX_CONFIG_FILE);
IndexSchema USER_IDX_SCHEMA = new
IndexSchema(USER_IDX_SOLR_CONFIG, USER_IDX_SCHEMA_FILE, null);
CoreContainer USER_IDX_CONTAINER = new CoreContainer(new
SolrResourceLoader(SolrIndexer.USER_IDX_SOLR_HOME));
CoreDescriptor USER_IDX_CORE_DESCRIPTOR = new
CoreDescriptor(USER_IDX_CONTAINER, USER_IDX_CORE_NAME,
USER_IDX_SOLR_CONFIG.getResourceLoader()
.getInstanceDir());
USER_IDX_CORE_DESCRIPTOR.setConfigName(USER_IDX_SOLR_CONFIG.getResourceName());
USER_IDX_CORE_DESCRIPTOR.setSchemaName(USER_IDX_SCHEMA.getResourceName());
USER_IDX_CORE = new SolrCore(null, USER_IDX_DATA_DIR,
USER_IDX_SOLR_CONFIG, USER_IDX_SCHEMA, USER_IDX_CORE_DESCRIPTOR);
USER_IDX_CONTAINER.register(USER_IDX_CORE_NAME,
USER_IDX_CORE, false);
SearchComponent tvComp =
USER_IDX_CORE.getSearchComponent("tvComponent");
ModifiableSolrParams params = new ModifiableSolrParams();
params.add(CommonParams.Q, FIELD_USER_ID + ":" + userId);
params.add(CommonParams.QT, "tvrh");
params.add(TermVectorParams.TF, "true");
params.add(TermVectorComponent.COMPONENT_NAME, "true");
SolrRequestHandler handler =
USER_IDX_CORE.getRequestHandler("tvrh");
SolrQueryResponse rsp;
rsp = new SolrQueryResponse();
rsp.add("responseHeader", new SimpleOrderedMap());
handler.handleRequest(new
LocalSolrQueryRequest(USER_IDX_CORE, params), rsp);
NamedList terms = (NamedList) ((NamedList) ((NamedList)
rsp.getValues().get(TermVectorComponent.TERM_VECTORS)).getVal(0)).get(FIELD_USER_ALL);
if (terms != null) {
for (int i = 0; i < terms.size(); i++) {
NamedList freq = (NamedList) terms.getVal(i);
freqMap.put(terms.getName(i),
freq.getVal(0).toString());
}
}
} catch (Exception e) {
e.printStackTrace();
} finally {
try {
USER_IDX_CORE.close();
USER_IDX_CONTAINER.shutdown();
} catch (Exception e) {
e.printStackTrace();
}
}
return freqMap;
}
Also, USER_IDX_CONTAINER.shutdown(); throws a NullPointerException
indicating the reference doesn't exist by the time the code execution
reaches it.
If I don't use thie snippet
try {
USER_IDX_CORE.close();
USER_IDX_CONTAINER.shutdown();
} catch (Exception e) {
e.printStackTrace();
}
I get a similar POSSIBLE RESORUCE LEAK!!! message that says SolrCore
wasn't closed.
Am calling this code via a message queue, and no concurrent calls happen.
Thanks,
Karthik.