ElasticSearch AbstractMethodError while making client - java

I am trying to make an elastic search transport client, but getting below error
Caused by: java.lang.AbstractMethodError:
org.elasticsearch.transport.TcpTransport.sendMessage(Ljava/lang/Object;Lorg/elasticsearch/common/bytes/BytesReference;Ljava/lang/Runnable;)V
at
org.elasticsearch.transport.TcpTransport.internalSendMessage(TcpTransport.java:1111)
at
org.elasticsearch.transport.TcpTransport.sendRequestToChannel(TcpTransport.java:1093)
at
org.elasticsearch.transport.TcpTransport.executeHandshake(TcpTransport.java:1600)
Here is my code :
Settings settings = Settings.builder()
.put("cluster.name", "elasticsearch")
.put("node.name", "node1").build();
TransportClient client = new PreBuiltTransportClient(settings)
.addTransportAddress(new InetSocketTransportAddress(InetAddress.getByName("localhost"), 9300));
Is this a dependency issue?

I got stuck on this. You can't mix dependency versions.
Turned out I was using spring-data-elasticsearch in one project that depended on another project that had the plain elasticsearch dependency. These included differing versions and caused that error.
That was not fun to track down.

It is a dependency issue. In maven pom, i have below dependencies
<dependency>
<groupId>org.elasticsearch</groupId>
<artifactId>elasticsearch</artifactId>
<version>5.6.2</version>
</dependency>
<dependency>
<groupId>org.elasticsearch.client</groupId>
<artifactId>transport</artifactId>
<version>5.6.3</version>
</dependency>
I have removed the dependency of org.elasticsearch, and it is running fine.

Related

Getting error while using Jira rest java client

I am trying to use jira-rest-java-client-api in my Jira server plugin.
I am using following versions,
Jira - 7.13.0
jira-rest-client. Version - 5.2.0
In my pom I have added jira-rest-java-client-api and jira-rest-java-client-core dependency like,
<dependency>
<groupId>com.atlassian.jira</groupId>
<artifactId>jira-rest-java-client-api</artifactId>
<version>${jira-rest-client.version}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.atlassian.jira</groupId>
<artifactId>jira-rest-java-client-core</artifactId>
<version>${jira-rest-client.version}</version>
<scope>provided</scope>
</dependency>
I have added scope as provided so when I am building project using maven (atlas-mvn clean package) there is no error, but when I am trying to start the Jira server, my plugin is not added to Jira.
Getting following error
Unable to resolve 185.0: missing requirement [185.0]
osgi.wiring.package;
(osgi.wiring.package=com.atlassian.jira.rest.client.api)
Also, If I have not added the scope as provided then getting an error for banned dependencies while building using atlas-mvn clean package.
Any help would be appreciated, Thanks.

How do I resolve Could not find artifact javax.xml.bind:jaxb-api:pom:2.3.0-b161121.1438 in central (https://repo1.maven.org/maven2)?

I'm migrating an app to use ehcache 3.10.0 but getting a build error: Could not find artifact javax.xml.bind:jaxb-api:pom:2.3.0-b161121.1438 in central (https://repo1.maven.org/maven2)
I see the file in my local .m2 directory:
.m2\repository\javax\xml\bind\jaxb-api -- 2.3.0-b161121.1438
So that's an IDE issue for why it's not seen in my local build, since it does exist on my local .m2, but this version (2.3.0-b161121.1438) is still not available on maven, https://repo1.maven.org/maven2/javax/xml/bind/jaxb-api/
So the build fails with that artifact error. Any tips on how to resolve it?
A similar issue has been reported on the ehcache3 github: https://github.com/ehcache/ehcache3/issues/2881
This dependency is causing the issue, from the ehcache pom.xml:
https://search.maven.org/artifact/org.ehcache/ehcache/3.10.0/jar
<dependency>
<groupId>org.glassfish.jaxb</groupId>
<artifactId>jaxb-runtime</artifactId>
<version>[2.2,3)</version>
<scope>runtime</scope>
</dependency>
Due to the open ended version the following dependency chain is causing this issue: Failed to collect dependencies at org.ehcache:ehcache:jar:3.10.0 -> org.glassfish.jaxb:jaxb-runtime:jar:2.3.0-b170127.1453 -> org.glassfish.jaxb:jaxb-core:jar:2.3.0-b170127.1453 -> javax.xml.bind:jaxb-api:jar:2.3.0-b161121.1438 ...
The only repository i could find that has this specific build is https://maven.java.net/#nexus-search;gav~javax.xml.bind~jaxb-api~2.3.0-b161121.1438~~
But if you look in the following file you can see the error on retrieving the artifact from this repository: .m2\repository\javax\xml\bind\jaxb-api\2.3.0-b161121.1438\jaxb-api-2.3.0-b161121.1438.pom.lastUpdated
Which is for me (with maven 3.8.4): https\://maven.java.net/content/repositories/releases/.error= http\://0.0.0.0/.error=Could not transfer artifact javax.xml.bind\:jaxb-api\:pom\:2.3.0-b161121.1438 from/to maven-default-http-blocker (http\://0.0.0.0/)\: Blocked mirror for repositories\: [...]
This is because maven 3.8.x has started blocking HTTP repositories by default. You could unblock the HTTP repository as follows: How to disable maven blocking external HTTP repositories?
But i would advice you not to unblock unsafe (non HTTPS) repositories. This would need to be changed in the maven settings.xml, complicating the build process.
My preferred solution would be to add an exclusion to the pom.xml file to ignore this specific jaxb-runtime version.
<dependency>
<groupId>org.ehcache</groupId>
<artifactId>ehcache</artifactId>
<version>3.10.0</version>
<exclusions>
<exclusion>
<groupId>org.glassfish.jaxb</groupId>
<artifactId>jaxb-runtime</artifactId>
</exclusion>
</exclusions>
</dependency>
If you then still need the jaxb-runtime for your project to compile or run, you could include any other compatible version by adding a new dependency to it in your own pom.xml. In this case you can also use dependency management instead of exclusions.
You can pick one here: https://search.maven.org/artifact/org.glassfish.jaxb/jaxb-runtime
Make sure it satisfies the ehcache requirements: <version>[2.2,3)</version>

Connect SMB endpoint with Camel v3 and the camel-jcifs from camel-extra

I have the following maven versions in my pom.xml (among others):
<dependency>
<groupId>org.apache.camel.springboot</groupId>
<artifactId>camel-spring-boot-starter</artifactId>
<version>3.7.0</version>
</dependency>
<dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-core</artifactId>
<version>3.7.0</version>
</dependency>
<dependency>
<groupId>org.apache-extras.camel-extra</groupId>
<artifactId>camel-jcifs</artifactId>
<version>2.25.2</version>
<exclusions>
<exclusion>
<groupId>com.sun.xml.bind</groupId>
<artifactId>jaxb-impl</artifactId>
</exclusion>
</exclusions>
</dependency>
Camel spring-boot version = 3.7.0 and I want to connect to a SMB endpoint like this:
smb://sharedriveuser#server-instance.sub.domain.net/folder?initialDelay=0&delay=9000&autoCreate=false&noop=true&idempotent=true&password=ThePassWorD&filter=#csvFileFilter
I read the Camel 3 Migration Guide and found nothing regarding this camel-extras.
When trying to connect, I get an error like the password option is not supported anymore:
Caused by: org.apache.camel.ResolveEndpointFailedException: Failed to resolve endpoint: smb://sharedriveuser#server-instance.sub.domain.net/folder?initialDelay=0&delay=9000&autoCreate=false&noop=true&idempotent=true&password=xxxxxx&filter=#csvFileFilter due to: There are 1 parameters that couldn't be set on the endpoint. Check the uri if the parameters are spelt correctly and that they are properties of the endpoint. Unknown parameters=[{password=ThePassWorD}]
The actual documentation link google found many times, seems dead.
From Maven central, there is no version 3.x of the lib camel-jcifs and I am wondering if the lib is still compatible with Camel 3.x.x, otherwise is there another alternative with Camel 3?
I also tried to downgrade the camel-jcifs to 2.24.3 with the same error.
Camel-extras is a separated project from the Apache Camel. There is some work in place in the camel-extra repository to support camel 3[1], but it is still to be completed and there is no release in sight.
[1] https://github.com/camel-extra/camel-extra/commit/f028dfdfaa467958c58abea0d604f8fe2f17be04
There is now a pull request to add camel-jcifs to the 3.x version:
https://github.com/camel-extra/camel-extra/pull/39
You might also get my fork and build it yourself:
https://github.com/bebbo/camel-extra *
It got merged and is in the official repository:
https://github.com/camel-extra/camel-extra
To use it with quarkus, you have to convert some List types to arrays.

How to avoid dependency conflict when using dropwizard + jersey client

I have a DropWizard REST API written and works. One of the resource endpoints actually writes an email, however as soon as I add the following dependencies DropWizard starts to fail on start up
<dependency>
<groupId>com.sun.jersey</groupId>
<artifactId>jersey-client</artifactId>
<version>1.18.1</version>
</dependency>
<dependency>
<groupId>com.sun.jersey</groupId>
<artifactId>jersey-core</artifactId>
<version>1.18.1</version>
</dependency>
<dependency>
<groupId>com.sun.jersey.contribs</groupId>
<artifactId>jersey-multipart</artifactId>
<version>1.18.1</version>
</dependency>
The DropWizard dependency is:
<dependency>
<groupId>io.dropwizard</groupId>
<artifactId>dropwizard-core</artifactId>
<version>0.8.1</version>
</dependency>
The error on startup is really long, summarised below
WARN [2015-05-01 20:06:08,887] org.glassfish.jersey.internal.Errors: The following warnings have been detected: WARNING: Unknown HK2 failure detected:
MultiException stack 1 of 2
java.lang.NullPointerException
at com.sun.jersey.core.provider.jaxb.AbstractJAXBProvider.setConfiguration(AbstractJAXBProvider.java:113)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
....
MultiException stack 2 of 2
java.lang.IllegalStateException: Unable to perform operation: method inject on com.sun.jersey.core.impl.provider.entity.XMLRootElementProvider$App
at org.jvnet.hk2.internal.ClazzCreator.create(ClazzCreator.java:395)
....
MultiException stack 3 of 3
java.lang.IllegalStateException: Unable to perform operation: create on org.glassfish.jersey.message.internal.MessageBodyFactory
...
I'm guessing DropWizard is using another conflicting dependency so how do I deal with this?
Thanks in advance
Dropwizard 0.8.x uses Jersey 2.x which naturally conflicts with your Jersey 1.x dependencies.
I think it might be fine with jersey-client as long as you don't have dropwizard-client dependency but jersey-core will conflict at many points with dropwizard's jersey which I don't think you can fix. And also I don't think you'd need jersey-core for sending email anyway.
If you do need jersey for this, try using Jersey 2.16 instead which is the version dropwizard is using.
I had the same problem (I'm using DW 0.9.2 and have unwanted transitive dependencies of both DW 0.7.2 and Jersey 1.x)
The solution was pretty simple: in the dependency that's bringing you those two family of libraries, declare an exclusion and it should work, for instance, this is how I did it in Gradle:
compile("com.example.culprit:culprit:1.2.3") {
exclude group: 'io.dropwizard'
exclude group: 'com.sun.jersey'
}
The syntax for Maven is pretty similar (more verbose actually ;-) )
Hope this helps someone.

What's the minimum classpath for an Axis2 client?

I want to build an Axis2 client (I'm only accessing a remote web service, I'm not implementing one!) with Maven2 and I don't want to add 21MB of JARs to my project. What do I have to put in my pom.xml to compile the code when I've converted the WSDL with ADB?
The minimum jars for the client are:
activation-1.1.jar
axiom-api-1.2.8.jar
axiom-impl-1.2.8.jar
axis2-adb-1.5.1.jar
axis2-kernel-1.5.1.jar
axis2-transport-http-1.5.1.jar
axis2-transport-local-1.5.1.jar
commons-codec-1.3.jar
commons-httpclient-3.1.jar
commons-logging-1.1.1.jar
httpcore-4.0.jar
mail-1.4.jar
neethi-2.0.4.jar
wsdl4j-1.6.2.jar
XmlSchema-1.4.3.jar
STAX jars below are not part of Axis2 1.5.1 release and will be needed if your JDK version is less than 6:
stax-1.2.0.jar
stax-api-1.0.1.jar
(Note: This response was provided by Aaron Digulla himself. What follows is the exact text of his own answer.)
In maven2, the minimum dependency set to make an ADB client work ("ADB" as in the way you created the Java classes from the WSDL) is this:
<dependency>
<groupId>org.apache.axis2</groupId>
<artifactId>axis2-kernel</artifactId>
<version>1.4.1</version>
</dependency>
<dependency>
<groupId>org.apache.axis2</groupId>
<artifactId>axis2-adb</artifactId>
<version>1.4.1</version>
</dependency>
Hmmm... it seems I can't flag that as the correct answer. Can someone please copy this so I can flag his post?
Had to add the transports, too
<dependency>
<groupId>org.apache.axis2</groupId>
<artifactId>axis2-adb</artifactId>
<version>1.5.4</version>
</dependency>
<dependency>
<groupId>org.apache.axis2</groupId>
<artifactId>axis2-transport-local</artifactId>
<version>1.5.4</version>
</dependency>
<dependency>
<groupId>org.apache.axis2</groupId>
<artifactId>axis2-transport-http</artifactId>
<version>1.5.4</version>
</dependency>
Minimal dependency for a working client in summary
axiom-api-1.2.14.jar
axiom-impl-1.2.14.jar
axis2-adb-1.6.3.jar
axis2-kernel-1.6.3.jar
axis2-transport-http-1.6.3.jar
axis2-transport-local-1.6.3.jar
commons-codec-1.3.jar
commons-httpclient-3.1.jar
commons-logging-1.1.1.jar
httpcore-4.0.jar
mail-1.4.jar
neethi-3.0.2.jar
wsdl4j-1.6.2.jar
XmlSchema-1.4.7.jar
Listed below the minimal dependencies with details
client stub uses the ServiceClient Class generated with %AXIS2_HOME%\bin\WSDL2Java tool against a given WSDL (for generating you would need all axis jars on classpath, achieved most easily by setting AXIS_HOME)
Classes required by Client stub at COMPILE time
axiom-api-1.2.14.jar -- required at compilation time by client stub for org.apache.axiom.om.OMElement, org.apache.axiom.soap.SOAPEnvelope, org.apache.axiom.soap.SOAPFactory, org.apache.axiom.om.OMNamespace
axis2-adb-1.6.3.jar -- required at compilation time by client stub for org.apache.axis2.databinding.ADBException
axis2-kernel-1.6.3.jar -- required at compilation time by client stub for org.apache.axis2.AxisFault Class
Classes required for successful invocation of Client stub at RUN time
axiom-impl-1.2.14.jar (without this org.apache.axiom.om.OMException: No meta factory found for feature 'default'; this usually means that axiom-impl.jar is not in the classpath)
axis2-transport-http-1.6.3.jar (without this org.apache.axis2.deployment.DeploymentException: org.apache.axis2.transport.http.CommonsHTTPTransportSender)
axis2-transport-local-1.6.3.jar (without this org.apache.axis2.deployment.DeploymentException: org.apache.axis2.transport.local.LocalTransportSender)
commons-codec-1.3.jar (without this java.lang.NoClassDefFoundError: org/apache/commons/codec/DecoderException)
commons-httpclient-3.1.jar (without this org.apache.axis2.deployment.DeploymentException: org/apache/commons/httpclient/HttpException)
commons-logging-1.1.1.jar (without this java.lang.NoClassDefFoundError: org/apache/commons/logging/LogFactory)
httpcore-4.0.jar (without this java.lang.NoClassDefFoundError: org/apache/http/HttpResponseFactory)
mail-1.4.jar (without this java.lang.NoClassDefFoundError: javax/mail/internet/ParseException)
neethi-3.0.2.jar (without this java.lang.NoClassDefFoundError: org/apache/neethi/PolicyComponent)
wsdl4j-1.6.2.jar (without this java.lang.NoClassDefFoundError: javax/wsdl/WSDLException)
XmlSchema-1.4.7.jar (without this java.lang.ClassNotFoundException: org/apache/ws/commons/schema/XmlSchema)
org.apache.axis2.AxisFault: Connection refused: connect -> ERROR ONLY if the web service is not up or accessible for some other reason
Note the exact version(s), however behavior would be generic enough subject to packaging changes across version, hence, mentionined the FQCNs above-
Axis Version - 1.6.3
Tomcat Version - Apache Tomcat/7.0.64
Servlet version - 3.0
java.runtime.version - 1.7.0_79-b15
Axis2 version 1.6.2 wouldn't work for me without axis2-xmlbeans (though this may have something to do with the fact that I'm also using the axis2-wsdl2code-maven-plugin plugin and xmlbeans as my data binding framework). I have the following POM:
<dependency>
<groupId>org.apache.axis2</groupId>
<artifactId>axis2-kernel</artifactId>
<version>1.6.2</version>
</dependency>
<dependency>
<groupId>org.apache.axis2</groupId>
<artifactId>axis2-adb</artifactId>
<version>1.6.2</version>
</dependency>
<dependency>
<groupId>org.apache.axis2</groupId>
<artifactId>axis2-transport-http</artifactId>
<version>1.6.2</version>
</dependency>
<dependency>
<groupId>org.apache.axis2</groupId>
<artifactId>axis2-transport-local</artifactId>
<version>1.6.2</version>
</dependency>
<dependency>
<groupId>org.apache.axis2</groupId>
<artifactId>axis2-xmlbeans</artifactId>
<version>1.6.2</version>
</dependency>
If your client is running on Java 6, consider using JAX-WS for consuming the WS. JAX-WS uses the JAXB standard for binding and you don't need a single extra jar for the client.
Actually, you only need the axis-abd dependency since the axis2-kernel is a sub-dependency of axis-abd.
Therefore you can sum it up with:
<dependency>
<groupId>org.apache.axis2</groupId>
<artifactId>axis2-adb</artifactId>
<version>1.5.1</version>
</dependency>
In Axis2 version 1.5.1 the maven modules appear to have been restructured.
My Groovy scripts (Using ADB binding) have the following dependencies:
#Grapes([
#Grab(group='org.apache.axis2', module='axis2-kernel', version='1.5.1'),
#Grab(group='org.apache.axis2', module='axis2-adb', version='1.5.1'),
#Grab(group='org.apache.axis2', module='axis2-transport-local', version='1.5.1'),
#Grab(group='org.apache.axis2', module='axis2-transport-http', version='1.5.1'),
])
There's a logic to these. I could use an alternative binding framework when generating my stub or could use an alternative transport protocol to HTTP.
Example code in this answer
For those using Gradle, here I exclude unnecessary libraries:
dependencies {
ext.compileEx = { lib, exModules, exGroups ->
compile (lib) {
exModules.each { exclude module : "$it" }
exGroups.each { exclude group: "$it" }
}
}
List axisExModules = [ 'axiom-compat', 'jaxen', 'apache-mime4j-core' ]
List axisExGroups = [ 'javax.servlet', 'commons-fileupload', 'org.apache.woden',
'javax.ws.rs', 'org.apache.geronimo.specs', 'org.codehaus.woodstox' ]
compileEx ('org.apache.axis2:axis2-adb:1.6.3', axisExModules, axisExGroups)
compileEx ('org.apache.axis2:axis2-transport-local:1.6.3', axisExModules, axisExGroups)
compileEx ('org.apache.axis2:axis2-transport-http:1.6.3', axisExModules, axisExGroups)
}
Here is my original post in the Gradle forums.

Categories

Resources