System.err.println causes NullPointerException when using ElasticSearch as a java library #2321

Closed
Avatah opened this Issue Oct 12, 2012 · 7 comments

Comments

Projects
None yet
6 participants

Avatah commented Oct 12, 2012

After upgrade of Elastic Search java library from version 0.19.4 to 0.19.9 there are random NullPointerExceptions when using System.err.
They are caused by code in org.elasticsearch.common.compress.snappy.xerial.XerialSnappy.
Best way to repair this would be to patch snappy-java library and remove broken code from XerialSnappy.
If it's impossible then maybe at least replace System.setErr(null) to System.setErr(nullPrintStream) where nullPrintStream is an instance of PrintStream that does nothing when invoked from Snappy?

Owner

kimchy commented Oct 20, 2012

Can you share the stack trace you get? I don't get this when snappy fails to load.

I am also facing this issue. Here is my stack. Check if it is useful

2012-10-27 11:01:01,860 DEBUG: com.github.joschi.jadconfig.JadConfig - Trimmed parameter value twilio_sender
2012-10-27 11:01:01,860 DEBUG: com.github.joschi.jadconfig.JadConfig - Validating parameter twilio_sender
2012-10-27 11:01:01,861 DEBUG: com.github.joschi.jadconfig.JadConfig - Validating parameter twilio_sender with value
2012-10-27 11:01:01,861 DEBUG: com.github.joschi.jadconfig.JadConfig - Converting parameter value twilio_sender:
2012-10-27 11:01:01,861 DEBUG: com.github.joschi.jadconfig.JadConfig - Trying to find converter class class com.github.joschi.jadconfig.converters.NoConverter for type class java.lang.String
2012-10-27 11:01:01,862 DEBUG: com.github.joschi.jadconfig.JadConfig - Loaded converter class for type class java.lang.String: com.github.joschi.jadconfig.converters.StringConverter@6766afb3
2012-10-27 11:01:01,862 DEBUG: com.github.joschi.jadconfig.JadConfig - Setting parameter twilio_sender to
2012-10-27 11:01:01,866 DEBUG: com.github.joschi.jadconfig.JadConfig - Invoking validator method public void org.graylog2.Configuration.validate() throws com.github.joschi.jadconfig.ValidationException in org.graylog2.Configuration@4c5e176f
2012-10-27 11:01:02,237 INFO : org.elasticsearch.node - [graylog2-server] {0.19.9}[32313]: initializing ...
2012-10-27 11:01:02,933 INFO : org.elasticsearch.plugins - [graylog2-server] loaded [], sites []
2012-10-27 11:01:02,941 DEBUG: org.elasticsearch.common.compress.lzf - using [UnsafeChunkDecoder] decoder
2012-10-27 11:01:02,942 DEBUG: org.elasticsearch.common.compress - failed to load xerial snappy-java
java.lang.NoClassDefFoundError: org/xerial/snappy/Snappy
at org.elasticsearch.common.compress.snappy.xerial.XerialSnappy.(XerialSnappy.java:41)
at org.elasticsearch.common.compress.CompressorFactory.(CompressorFactory.java:58)
at org.elasticsearch.node.internal.InternalNode.(InternalNode.java:121)
at org.elasticsearch.node.NodeBuilder.build(NodeBuilder.java:159)
at org.elasticsearch.node.NodeBuilder.node(NodeBuilder.java:166)
at org.graylog2.indexer.EmbeddedElasticSearchClient.(EmbeddedElasticSearchClient.java:88)
at org.graylog2.Core.initialize(Core.java:148)
at org.graylog2.Main.main(Main.java:121)
Caused by: java.lang.ClassNotFoundException: org.xerial.snappy.Snappy
at java.net.URLClassLoader$1.run(URLClassLoader.java:217)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:205)
at java.lang.ClassLoader.loadClass(ClassLoader.java:321)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:294)
at java.lang.ClassLoader.loadClass(ClassLoader.java:266)
... 8 more
2012-10-27 11:01:03,283 TRACE: org.elasticsearch.monitor.sigar - failed to load sigar
java.lang.ClassNotFoundException: org.hyperic.sigar.Sigar
at java.net.URLClassLoader$1.run(URLClassLoader.java:217)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:205)
at java.lang.ClassLoader.loadClass(ClassLoader.java:321)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:294)
at java.lang.ClassLoader.loadClass(ClassLoader.java:266)
at org.elasticsearch.monitor.MonitorModule.configure(MonitorModule.java:80)
at org.elasticsearch.common.inject.AbstractModule.configure(AbstractModule.java:60)
at org.elasticsearch.common.inject.spi.Elements$RecordingBinder.install(Elements.java:201)
at org.elasticsearch.common.inject.spi.Elements.getElements(Elements.java:82)
at org.elasticsearch.common.inject.InjectorShell$Builder.build(InjectorShell.java:130)
at org.elasticsearch.common.inject.InjectorBuilder.build(InjectorBuilder.java:99)
at org.elasticsearch.common.inject.Guice.createInjector(Guice.java:93)
at org.elasticsearch.common.inject.Guice.createInjector(Guice.java:70)
at org.elasticsearch.common.inject.ModulesBuilder.createInjector(ModulesBuilder.java:59)
at org.elasticsearch.node.internal.InternalNode.(InternalNode.java:152)
at org.elasticsearch.node.NodeBuilder.build(NodeBuilder.java:159)
at org.elasticsearch.node.NodeBuilder.node(NodeBuilder.java:166)
at org.graylog2.indexer.EmbeddedElasticSearchClient.(EmbeddedElasticSearchClient.java:88)
at org.graylog2.Core.initialize(Core.java:148)
at org.graylog2.Main.main(Main.java:121)
2012-10-27 11:01:03,604 DEBUG: org.elasticsearch.threadpool - [graylog2-server] creating thread_pool [generic], type [cached], keep_alive [30s]
2012-10-27 11:01:03,609 DEBUG: org.elasticsearch.threadpool - [graylog2-server] creating thread_pool [index], type [cached], keep_alive [5m]
2012-10-27 11:01:03,609 DEBUG: org.elasticsearch.threadpool - [graylog2-server] creating thread_pool [bulk], type [cached], keep_alive [5m]
2012-10-27 11:01:03,609 DEBUG: org.elasticsearch.threadpool - [graylog2-

Owner

kimchy commented Oct 27, 2012

@devilankur18 those are valid output messages, thats DEBUG output noting that snappy did not load. Can you check 0.19.11? I did not get the relevant stack trace, but if an NullPointerException happened, it shouldn't happen now.

I am using elasticsearch-0.19.10 and find the Error when submit the jsp form
my java class code:
queryFilters.add(FilterBuilders.prefixFilter("Education", getZeducation()));
log.debug(FilterBuilders.prefixFilter("Education", getZeducation()));
queryFilters.add(FilterBuilders.prefixFilter("ResumeHeadline", getZresumeHeadline()));
FilterBuilder aggFilter = FilterBuilders.andFilter(queryFilters);
SearchResponse response = client.prepareSearch("resume_index")
.setSearchType(SearchType.DFS_QUERY_THEN_FETCH)
.setQuery(QueryBuilders.prefixQuery("Name",getZname()))
.setFilter(aggFilter)
Error:

failed to load xerial snappy-java
java.lang.NoClassDefFoundError: org/xerial/snappy/Snappy
at org.elasticsearch.common.compress.snappy.xerial.XerialSnappy.(XerialSnappy.java:41)
at org.elasticsearch.common.compress.CompressorFactory.(CompressorFactory.java:58)
at org.elasticsearch.client.transport.TransportClient.(TransportClient.java:161)
at org.elasticsearch.client.transport.TransportClient.(TransportClient.java:117)
at com.SaralHiring.Search.execute(Search.java:57)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at com.opensymphony.xwork2.DefaultActionInvocation.invokeAction(DefaultActionInvocation.java:452)
at com.opensymphony.xwork2.DefaultActionInvocation.invokeActionOnly(DefaultActionInvocation.java:291)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:254)
at com.opensymphony.xwork2.interceptor.DefaultWorkflowInterceptor.doIntercept(DefaultWorkflowInterceptor.java:176)
at com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:98)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)
at com.opensymphony.xwork2.validator.ValidationInterceptor.doIntercept(ValidationInterceptor.java:263)
at org.apache.struts2.interceptor.validation.AnnotationValidationInterceptor.doIntercept(AnnotationValidationInterceptor.java:68)
at com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:98)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)
at com.opensymphony.xwork2.interceptor.ConversionErrorInterceptor.intercept(ConversionErrorInterceptor.java:133)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)
at com.opensymphony.xwork2.interceptor.ParametersInterceptor.doIntercept(ParametersInterceptor.java:207)
at com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:98)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)
at com.opensymphony.xwork2.interceptor.ParametersInterceptor.doIntercept(ParametersInterceptor.java:207)
at com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:98)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)
at com.opensymphony.xwork2.interceptor.StaticParametersInterceptor.intercept(StaticParametersInterceptor.java:190)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)
at org.apache.struts2.interceptor.MultiselectInterceptor.intercept(MultiselectInterceptor.java:75)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)
at org.apache.struts2.interceptor.CheckboxInterceptor.intercept(CheckboxInterceptor.java:94)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)
at org.apache.struts2.interceptor.FileUploadInterceptor.intercept(FileUploadInterceptor.java:243)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)
at com.opensymphony.xwork2.interceptor.ModelDrivenInterceptor.intercept(ModelDrivenInterceptor.java:100)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)
at com.opensymphony.xwork2.interceptor.ScopedModelDrivenInterceptor.intercept(ScopedModelDrivenInterceptor.java:141)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)
at org.apache.struts2.interceptor.debugging.DebuggingInterceptor.intercept(DebuggingInterceptor.java:267)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)
at com.opensymphony.xwork2.interceptor.ChainingInterceptor.intercept(ChainingInterceptor.java:142)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)
at com.opensymphony.xwork2.interceptor.PrepareInterceptor.doIntercept(PrepareInterceptor.java:166)
at com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:98)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)
at com.opensymphony.xwork2.interceptor.I18nInterceptor.intercept(I18nInterceptor.java:176)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)
at org.apache.struts2.interceptor.ServletConfigInterceptor.intercept(ServletConfigInterceptor.java:164)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)
at com.opensymphony.xwork2.interceptor.AliasInterceptor.intercept(AliasInterceptor.java:190)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)
at com.opensymphony.xwork2.interceptor.ExceptionMappingInterceptor.intercept(ExceptionMappingInterceptor.java:187)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)
at org.apache.struts2.impl.StrutsActionProxy.execute(StrutsActionProxy.java:52)

The reason is in the very first line of the stack trace:

java.lang.NoClassDefFoundError: org/xerial/snappy/Snappy

This may be due to a known problem with Snappy on OS X with JDK 7. The workaround is to extract the native
library and copy it somewhere on the classpath, e.g. ./lib.

@ghost ghost assigned spinscale May 27, 2013

Member

spinscale commented May 27, 2013

Hey,

do you still hit this issue with 0.90? (you shouldnt as we do not use snappy anymore)
If not, can you close this issue or alternatively can someone provide more information (with the current version) so we can find out, what needs to be fixed?

Member

spinscale commented Jun 24, 2013

Closing. Please reopen, if you still find this to be valid in current versions. Thanks!

@spinscale spinscale closed this Jun 24, 2013

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment