TransportAddress instantiation error

I am getting the following error:
java.lang.InstantiationError: org.elasticsearch.common.transport.TransportAddress

I am using 7.2.0 which is many versions ahead from what I had been using but in earlier versions same error. I think in some versions the class was abstract and not instantiable.

I am attempting to instantiate the class as follows:

new TransportAddress(host, port);

Is there a fundamental reason why this would not work or would the error come from, e.g., a bad host or port?

May be. But anyway you should use the Rest Client as the TransportClient will be removed in the next major version.

RestClient instead of TransportAddress or instead of TransportClient? I am getting an error instantiating TransportAddress.

RestClient instead of TransportClient.

What are you using this class for?

I did not explicitly mention TransportClient; my problem was with TransportAddress which I am trying to instantiate using a constructor I think I saw in the documentation. Is TransportClient relevant to this?

I think I might not be able to instantiate TransportAddress (which I am doing from cached data) but instead need to use InetSocketTransportAddress since apparently (at least in some versions of the library) TransportAddress is abstract.

What are you using this class for?
Any code to share?

The constructor use as shown in the first post:
TransportAddress t = new TransportAddress(host, port);

is the what I am trying to do. I do not get a compile but rather a runtime error. If TransportAddress is abstract, maybe I should just use a concrete subclass, specifically InetSocketTransportAddress? I am not sure what led us to try TransportAddress.

Using this because we are storing strings representing host and port and want to recreate the TransportAddress from cache.

My question is "what do you need a TransportAddress for?"
What are you trying to do with that?

TransportAddress is the type of a List which is a field in TransportClient which are updating.
So have you been saying all along we should be using RestClient instead which maybe does not have this List? And if there is no List in RestClient, how do we do the equivalent of adding/removing elements from this list?

Ok. So I finally got my answer. You want to build a client. Great.

Here's the documentation https://www.elastic.co/guide/en/elasticsearch/client/java-rest/current/index.html

Feel free to ask questions if you are not able to make it work.

Strictly speaking i want to modify an existing client object. We are invoking on the TransportClient object the methods addTransportAddress() and removeTransportAddress(). These two methods take TransportAddress objects that I am trying to recreate from cached values.

It is not clear to me at this point how to do this with the Rest Client -- it does not appear to have a list of such addresses.

May be the sniffer is what you want. Hard to say as I have no idea of what you really want to do at the end. Which problem do you think you would solve?

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.