Elasticsearch client java.lang.ExceptionInInitializerError in 5.3 - java

Following code listed here on TransportClient.
Using elasticsearch and client dependencies.
<dependency>
<groupId>org.elasticsearch</groupId>
<artifactId>elasticsearch</artifactId>
<version>5.3.0</version>
</dependency>
<dependency>
<groupId>org.elasticsearch.client</groupId>
<artifactId>transport</artifactId>
<version>5.3.0</version>
</dependency>
Exception:
Exception in thread "main" java.lang.ExceptionInInitializerError
at org.elasticsearch.common.logging.DeprecationLogger.<clinit>(DeprecationLogger.java:138)
at org.elasticsearch.common.xcontent.support.AbstractXContentParser.<init>(AbstractXContentParser.java:57)
at org.elasticsearch.common.xcontent.json.JsonXContentParser.<init>(JsonXContentParser.java:44)
at org.elasticsearch.common.xcontent.json.JsonXContent.createParser(JsonXContent.java:103)
at org.elasticsearch.common.settings.Setting.parseableStringToList(Setting.java:832)
at org.elasticsearch.common.settings.Setting.lambda$listSetting$27(Setting.java:786)
at org.elasticsearch.common.settings.Setting.listSetting(Setting.java:791)
at org.elasticsearch.common.settings.Setting.listSetting(Setting.java:786)
at org.elasticsearch.common.network.NetworkService.<clinit>(NetworkService.java:50)
at org.elasticsearch.client.transport.TransportClient.newPluginService(TransportClient.java:98)
at org.elasticsearch.client.transport.TransportClient.buildTemplate(TransportClient.java:126)
at org.elasticsearch.client.transport.TransportClient.<init>(TransportClient.java:268)
at org.elasticsearch.transport.client.PreBuiltTransportClient.<init>(PreBuiltTransportClient.java:125)
at org.elasticsearch.transport.client.PreBuiltTransportClient.<init>(PreBuiltTransportClient.java:111)
at org.elasticsearch.transport.client.PreBuiltTransportClient.<init>(PreBuiltTransportClient.java:101)
at xxx.test.runner.ESRunner.initESClient(ESRunner.java:120)
at xxx.test.runner.ESRunner.inti(ESRunner.java:62)
at xxx.test.runner.ESRunner.main(ESRunner.java:46)
Caused by: java.lang.IllegalStateException: Error finding the build shortHash. Stopping Elasticsearch now so it doesn't run in subtly broken ways. This is likely a build bug.
at org.elasticsearch.Build.<clinit>(Build.java:62)
... 18 more
Could it missing some dependency, or something else? Any help is appreciated. Thanks.

i had the same problem. use 5.2.2 instead. the problem is (at least for me) that the transportClient of 5.3 reads the manifest file of the jar which isn't possible because the application runs on wildfly (the jar file is on a virtual file system)

Related

In AWS EC2 , java.lang.NoClassDefFoundError: org/apache/http/config/Lookup is thrown

I use Apache HTTP to outsource certain parts of my program to AWS Lamda.
When I run this locally on a Windows system, everything works.
But when the program is deployed (EC2 Instance - ubuntu environment) and a request is started via apache http. I get the following error message:
java.lang.NoClassDefFoundError: org/apache/http/config/Lookup
I use the following maven dependencies:
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpcore</artifactId>
<version>4.4.15</version>
</dependency>
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
<version>4.5.13</version>
</dependency>
At the following point in the code the error is thrown:
this.client = HttpClients.createDefault();
I have also tried other versions of Apache HTTP.
If you need more info let me know.
Can anyone tell me what I need to consider or what I may be doing wrong?

Hibernate does not work in the app console

There was a problem after I connected the hibernate dependency to my project via the maven. Everything works in IntelliJ Idea, but if I run the jar from the console, then it throws me an error.
Exception in thread "main" java.lang.ExceptionInInitializerError
at org.hibernate.boot.registry.BootstrapServiceRegistryBuilder.build(BootstrapServiceRegistryBuilder.java:218)
at org.hibernate.boot.registry.StandardServiceRegistryBuilder.<init>(StandardServiceRegistryBuilder.java:87)
Caused by: java.lang.IllegalArgumentException: Invalid logger interface org.hibernate.internal.CoreMessageLogger (implementation not found in sun.misc.Launcher$AppClassLoader#7f31245a)
I can’t understand what the reason for this behavior is. Here is the version I'm using
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-core</artifactId>
<version>5.5.7.Final</version>
</dependency>

EJB ETL NoClassDefFoundError: org.apache.poi.util.SAXHelper during runtime

Root pom has the following dependencies,
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi</artifactId>
<version>3.16</version>
</dependency>
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi-ooxml</artifactId>
<version>3.16</version>
</dependency>
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi-ooxml-schemas</artifactId>
<version>3.16</version>
</dependency>
But during runtime, during etl process following error occurs,
EJB threw an unexpected (non-declared) exception during invocation of method "****" on bean "BeanId(***-ear#***-ejb.jar#***ServiceImpl, null)". Exception data: java.lang.NoClassDefFoundError: org.apache.poi.util.SAXHelper
Root cause is NoClassDefFoundError in the following code snippet,
XMLReader parser = SAXHelper.newXMLReader();
Environment used,
JDK 1.6.0_35
Websphere Application Server v8.0
Eclipse Juno Service Release 2
Full stack trace can be found here
Caused by: java.lang.ClassNotFoundException: org.apache.poi.util.SAXHelper
at java.net.URLClassLoader.findClass(URLClassLoader.java:434)
at com.ibm.ws.bootstrap.ExtClassLoader.findClass(ExtClassLoader.java:230)
at java.lang.ClassLoader.loadClassHelper(ClassLoader.java:703)
at java.lang.ClassLoader.loadClass(ClassLoader.java:682)
at com.ibm.ws.bootstrap.ExtClassLoader.loadClass(ExtClassLoader.java:123)
at java.lang.ClassLoader.loadClass(ClassLoader.java:665)
at com.ibm.ws.classloader.ProtectionClassLoader.loadClass(ProtectionClassLoader.java:62)
at com.ibm.ws.classloader.ProtectionClassLoader.loadClass(ProtectionClassLoader.java:58)
at com.ibm.ws.classloader.CompoundClassLoader.loadClass(CompoundClassLoader.java:566)
at java.lang.ClassLoader.loadClass(ClassLoader.java:665)
... 87 more
note: I have opened the ear archive and found the respective jars available. Checked Eclipse java build path also. Everything seems to be fine.
Thanks.
SAXHelper is in poi-ooxml-3.16.jar. I suspect that one of the static initializers in this class is failing.
https://github.com/apache/poi/blob/trunk/src/ooxml/java/org/apache/poi/util/SAXHelper.java

Exception in thread "main" java.lang.NoClassDefFoundError Could not initialize class org.bytedeco.javacpp.avutil

I have a java application that uses bytedeco/javacv library.
but when I run the application, I am getting the following exception.
Exception in thread "main" java.lang.NoClassDefFoundError: Could not initialize class org.bytedeco.javacpp.avutil
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Unknown Source)
at org.bytedeco.javacpp.Loader.load(Loader.java:386)
at org.bytedeco.javacpp.Loader.load(Loader.java:354)
at org.bytedeco.javacpp.avformat$AVFormatContext.<clinit>(avformat.java:2719)
at org.bytedeco.javacv.FFmpegFrameGrabber.startUnsafe(FFmpegFrameGrabber.java:391)
at org.bytedeco.javacv.FFmpegFrameGrabber.start(FFmpegFrameGrabber.java:385)
at com.diyoron.ai.examples.VideoFrameProccessor.main(VideoFrameProccessor.java:38)
Error getting static method ID of org/bytedeco/javacpp/Loader/putMemberOffset
The code is as following,
String videoPath = video.getAbsolutePath();
FFmpegFrameGrabber grabber = new FFmpegFrameGrabber(videoPath);
grabber.start();
According to this following statement in the README.MD
Additionally, we need to either set the javacpp.platform system
property (via the -D command line option) to something like
android-arm, or set the javacpp.platform.dependencies one to true to
get all the binaries for Android, Linux, Mac OS X, and Windows. On
build systems where this does not work, we need to add the
platform-specific artifacts manually. For examples with Gradle and
sbt, please refer to the README.md file of the JavaCPP Presets.
Another option available for Scala users is sbt-javacv.
~ Reference GitHub.
I added argument -Djavacpp.platform.dependencies="true", But still I am getting the exception. I am not sure what is causing this issue, I have very less experience in working with c++ wrappers.
PS: I have not installed any c++ dependencies/libraries or open-cv in my machine.
And all the solutions are related to Android and I haven't had much luck following those in my java related application.
Adding the following dependencies resolved the issue.
<!-- http://mvnrepository.com/artifact/org.bytedeco/javacv -->
<dependency>
<groupId>org.bytedeco</groupId>
<artifactId>javacv</artifactId>
<version>1.2</version>
</dependency>
<!-- http://mvnrepository.com/artifact/org.bytedeco/javacpp -->
<dependency>
<groupId>org.bytedeco</groupId>
<artifactId>javacpp</artifactId>
<version>1.2.1</version>
</dependency>
<dependency>
<groupId>org.bytedeco.javacpp-presets</groupId>
<artifactId>opencv</artifactId>
<version>3.1.0-1.2</version>
</dependency>
<dependency>
<groupId>org.bytedeco.javacpp-presets</groupId>
<artifactId>ffmpeg</artifactId>
<version>3.0.2-1.2</version>
</dependency>

Maven compilation and run time error java.lang.AbstractMethodError: oracle.jdbc.driver.T4CConnection.isValid(I)Z on Tomcat 8 Server

I've been converting a large Java Web App to a maven project, but I've run into an error in a handful of classes originating from the tomcat-dbcp jar. I get the following error messages from any class that needs to use BasicDataSource objects:
javax.servlet.ServletException: java.lang.AbstractMethodError: oracle.jdbc.driver.T4CConnection.isValid(I)Z
java.lang.AbstractMethodError: oracle.jdbc.driver.T4CConnection.isValid(I)Z
Now I know this jar is present on the server (as it is default in our Tomcat8 installation). So in maven I declared this dependency as such:
<dependency>
<groupId>org.apache.tomcat</groupId>
<artifactId>tomcat-dbcp</artifactId>
<version>8.0.26</version>
<scope>provided</scope>
</dependency>
But I'm still seeing this error. What can I do to eliminate this error?
This error did go away, though I have no idea why. The pom entry is still the same and still running on Tomcat 8. We did find a hacky temporary fix:
<dependency>
<groupId>com.oracle</groupId>
<artifactId>ojdbc7</artifactId>
<version>12.1.0.1</version>
<scope>system</scope>
<systemPath>${basedir}/lib/ojdbc7-12.1.0.1.jar</systemPath>
</dependency>
But we reverted back at some point and it is working fine.

Categories

Resources