Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

knapsack start up problem #75

Open
HemaAnusha opened this issue May 29, 2015 · 15 comments
Open

knapsack start up problem #75

HemaAnusha opened this issue May 29, 2015 · 15 comments

Comments

@HemaAnusha
Copy link

Hi,
Am using elasticsearch-knapsack plugin for update settings and for few other actions but am unable to start it , I just started using normal client creation as:

public class KnapSackImport {

private static Client client = null;

@Inject
public static Client getClient()
{
Client client = new TransportClient()
.addTransportAddress(new InetSocketTransportAddress("192.168.1.59", 9300));
if(client!=null)
{
System.out.println("client");
}
return client;
}

public static void main(String args[])
{

getClient();

}

}

So when am running this am getting :

Exception in thread "main" org.elasticsearch.common.inject.CreationException: Guice creation errors:

  1. No implementation for org.elasticsearch.cluster.ClusterService was bound.
    while locating org.elasticsearch.cluster.ClusterService
    for parameter 1 at org.xbib.elasticsearch.knapsack.KnapsackService.(Unknown Source)
    at org.xbib.elasticsearch.knapsack.KnapsackModule.configure(KnapsackModule.java:25)

  2. A binding to org.xbib.elasticsearch.knapsack.KnapsackService was already configured at org.xbib.elasticsearch.knapsack.KnapsackModule.configure(KnapsackModule.java:25).
    at org.xbib.elasticsearch.knapsack.KnapsackModule.configure(KnapsackModule.java:25)

2 errors
at org.elasticsearch.common.inject.internal.Errors.throwCreationExceptionIfErrorsExist(Errors.java:344)
at org.elasticsearch.common.inject.InjectorBuilder.initializeStatically(InjectorBuilder.java:151)
at org.elasticsearch.common.inject.InjectorBuilder.build(InjectorBuilder.java:102)
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.client.transport.TransportClient.(TransportClient.java:187)
at org.elasticsearch.client.transport.TransportClient.(TransportClient.java:115)
at com.knapsack.KnapSackImport.getClient(KnapSackImport.java:21)
at com.knapsack.KnapSackImport.main(KnapSackImport.java:33)

Can anyone trace this and tell me how to proceed with this ..

@jprante
Copy link
Owner

jprante commented May 29, 2015

You can not run the Knapsack plugin at transport client side. It must run at server side in a node being part of the cluster.

@HemaAnusha
Copy link
Author

Hi,
Thanks for your response, but When I used to run with the Node client (the following code).

package com.knapsack;

import java.io.File;
import java.io.FileReader;
import java.io.IOException;
import java.net.URI;
import java.nio.file.Path;
import java.nio.file.Paths;

import org.elasticsearch.action.admin.indices.create.CreateIndexRequestBuilder;
import org.elasticsearch.action.index.IndexRequest;
import org.elasticsearch.client.Client;
import org.elasticsearch.client.transport.TransportClient;
import org.elasticsearch.common.inject.Inject;
import org.elasticsearch.common.settings.ImmutableSettings;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.common.transport.InetSocketTransportAddress;
import org.elasticsearch.node.Node;
import org.elasticsearch.node.NodeBuilder;
import org.json.simple.parser.JSONParser;
import org.json.simple.parser.ParseException;
import org.xbib.elasticsearch.action.knapsack.exp.KnapsackExportRequest;
import org.xbib.elasticsearch.action.knapsack.exp.KnapsackExportRequestBuilder;
import org.xbib.elasticsearch.action.knapsack.imp.KnapsackImportRequest;

public class KnapSackImport {

private static Client client = null;
private static Settings settings=null;


public static Client getClient()
{
    settings=ImmutableSettings.settingsBuilder().put("cluster.name", "elasticsearch").build();
    Node node = NodeBuilder.nodeBuilder().settings(settings).node();
    client = node.client();
    return client;
}

public static void main(String args[]) throws IOException, ParseException
{

    KnapsackImportRequest imp=new KnapsackImportRequest();
    String settings=imp.getIndexSettings("sayt");
    CreateIndexRequestBuilder createIndexRequestBuilder=getClient().admin().indices().prepareCreate("sayt1");
    System.out.println(createIndexRequestBuilder);
    imp.addIndexSettings("sayt1", settings);
}

}

Am getting the Exception as:

Exception in thread "main" java.lang.NoSuchFieldError: LUCENE_4_10_1
at org.elasticsearch.Version.(Version.java:206)
at org.elasticsearch.node.internal.InternalNode.(InternalNode.java:136)
at org.elasticsearch.node.NodeBuilder.build(NodeBuilder.java:159)
at org.elasticsearch.node.NodeBuilder.node(NodeBuilder.java:166)
at com.knapsack.KnapSackImport.getClient(KnapSackImport.java:38)
at com.knapsack.KnapSackImport.main(KnapSackImport.java:48)

May I know why am getting this exception? and how to solve this

@HemaAnusha
Copy link
Author

And May I know why we should not use Transport Client?

@jprante
Copy link
Owner

jprante commented Jun 1, 2015

You are using a wrong Elasticsearch / Knapsack version combination.

@HemaAnusha
Copy link
Author

May I know Which versions combination I have to use?

@jprante
Copy link
Owner

jprante commented Jun 1, 2015

Knapsack uses indexed data from cluster nodes, it is an internal export/import cluster service. Because TransportClient does not hold any cluster service, this combination is not possible.

@jprante
Copy link
Owner

jprante commented Jun 1, 2015

The correct ones from the README of course. Example: Elasticsearch 1.5.2 with Knapsack 1.5.2.0

@HemaAnusha
Copy link
Author

Hi, I have changed the knapsack jar to 1.4.0.0 as am using Elasticsearch1.4.0 and then I have tried,

package com.knapsack;

import java.io.IOException;

import org.elasticsearch.action.admin.indices.create.CreateIndexRequestBuilder;
import org.elasticsearch.client.Client;
import org.elasticsearch.node.Node;
import static org.elasticsearch.node.NodeBuilder.*;
import org.json.simple.parser.ParseException;
import org.xbib.elasticsearch.action.knapsack.imp.KnapsackImportRequest;

public class KnapSackImport {

private static Client client = null;

public static Client getClient()
{
    Node node = nodeBuilder().clusterName("elasticsearch").node();
    client = node.client();
    return client;
}

public static void main(String args[]) throws IOException, ParseException
{

    KnapsackImportRequest imp=new KnapsackImportRequest();
    String settings=imp.getIndexSettings("sayt");
    CreateIndexRequestBuilder createIndexRequestBuilder=getClient().admin().indices().prepareCreate("sayt1");
    System.out.println(createIndexRequestBuilder);
    imp.addIndexSettings("sayt1", settings);
}

}

Even am getting the error as:
Exception in thread "main" java.lang.NoSuchFieldError: V_1_4_2
at org.elasticsearch.shield.ShieldVersion.(ShieldVersion.java:40)
at org.elasticsearch.shield.license.LicenseModule.verifyLicensePlugin(LicenseModule.java:49)
at org.elasticsearch.shield.license.LicenseModule.(LicenseModule.java:33)
at org.elasticsearch.shield.ShieldModule.spawnModules(ShieldModule.java:55)
at org.elasticsearch.shield.support.AbstractShieldModule$Spawn.spawnModules(AbstractShieldModule.java:57)
at org.elasticsearch.common.inject.ModulesBuilder.add(ModulesBuilder.java:44)
at org.elasticsearch.common.inject.ModulesBuilder.add(ModulesBuilder.java:46)
at org.elasticsearch.node.internal.InternalNode.(InternalNode.java:167)
at org.elasticsearch.node.NodeBuilder.build(NodeBuilder.java:159)
at org.elasticsearch.node.NodeBuilder.node(NodeBuilder.java:166)
at com.knapsack.KnapSackImport.getClient(KnapSackImport.java:21)
at com.knapsack.KnapSackImport.main(KnapSackImport.java:31)

Is this problem related to knapsack or any other and may I know the relevant solution

@jprante
Copy link
Owner

jprante commented Jun 1, 2015

Shield is not supported, sorry. It is not open source.

@HemaAnusha
Copy link
Author

So is there any solution for this or else do I need to use knapsack in other way?

@jprante
Copy link
Owner

jprante commented Jun 1, 2015

Sure, you have to disable Shield or ask Shield support for a solution.

@HemaAnusha
Copy link
Author

Okay Thank you So much..

@HemaAnusha
Copy link
Author

Hi,
As you said I disabled the shield as shown,
public class KnapSackImport {

private static Client client = null;

public static Client getClient()
{
    Node node = nodeBuilder().settings(ImmutableSettings.builder().put("shield.enabled",false)).clusterName("elasticsearch").node();
    client = node.client();
    return client;
}

public static void main(String args[]) throws IOException, ParseException
{

    KnapsackImportRequest imp=new KnapsackImportRequest();
    String settings=imp.getIndexSettings("sayt");
    CreateIndexRequestBuilder createIndexRequestBuilder=getClient().admin().indices().prepareCreate("sayt1");
    System.out.println(createIndexRequestBuilder);
    imp.addIndexSettings("sayt1", settings);
}

}

But am getting again the exception as:
Exception in thread "main" org.elasticsearch.common.inject.CreationException: Guice creation errors:

  1. A binding to org.xbib.elasticsearch.knapsack.KnapsackService was already configured at org.xbib.elasticsearch.knapsack.KnapsackModule.configure(KnapsackModule.java:25).
    at org.xbib.elasticsearch.knapsack.KnapsackModule.configure(KnapsackModule.java:25)

1 error
at org.elasticsearch.common.inject.internal.Errors.throwCreationExceptionIfErrorsExist(Errors.java:344)
at org.elasticsearch.common.inject.InjectorBuilder.initializeStatically(InjectorBuilder.java:151)
at org.elasticsearch.common.inject.InjectorBuilder.build(InjectorBuilder.java:102)
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:197)
at org.elasticsearch.node.NodeBuilder.build(NodeBuilder.java:159)
at org.elasticsearch.node.NodeBuilder.node(NodeBuilder.java:166)
at com.knapsack.KnapSackImport.getClient(KnapSackImport.java:22)
at com.knapsack.KnapSackImport.main(KnapSackImport.java:32)
,

May I know the reason and solution to this?

@jprante
Copy link
Owner

jprante commented Jun 1, 2015

You seem to have an error in your node setup, maybe you initialized twice. The getClient() method makes no sense, there is a node created (and not started) for each client?

This simple node test works: c20195d

@HemaAnusha
Copy link
Author

Hi Jorg,
The following changes I have done using that simple node test:

public class KnapSackImport {

private static Client client = null; 
static Node node=null;

public static void main(String args[]) throws IOException, ParseException
{

    Settings settings = settingsBuilder()
    .put("cluster.name", "test-cluster-" + NetworkUtils.getLocalAddress().getHostName())
    .put("gateway.type", "none")
    .put("index.store.type", "memory")
    .put("http.enabled", false)
    .put("discovery.zen.multicast.enabled", false).put("shield.enabled", false)
    .build();

    node = nodeBuilder().settings(settings).build();
    node.start();
    client = node.client();
    client.admin().cluster().prepareHealth().setWaitForGreenStatus().execute().actionGet();
    if(client!=null)
    {
        System.out.println("client created");
    }
    else
        System.out.println("not");

    KnapsackImportRequest imp=new KnapsackImportRequest();
    String settingsSayt=imp.getIndexSettings("sayt");
    CreateIndexRequestBuilder createIndexRequestBuilder=client.admin().indices().prepareCreate("sayt1");
    System.out.println(createIndexRequestBuilder);
    imp.addIndexSettings("sayt1", settingsSayt);

    node.stop();
}

}

Again am getting the exception as:

Exception in thread "main" org.elasticsearch.common.inject.CreationException: Guice creation errors:

  1. A binding to org.xbib.elasticsearch.knapsack.KnapsackService was already configured at org.xbib.elasticsearch.knapsack.KnapsackModule.configure(KnapsackModule.java:25).
    at org.xbib.elasticsearch.knapsack.KnapsackModule.configure(KnapsackModule.java:25)

1 error
at org.elasticsearch.common.inject.internal.Errors.throwCreationExceptionIfErrorsExist(Errors.java:344)
at org.elasticsearch.common.inject.InjectorBuilder.initializeStatically(InjectorBuilder.java:151)
at org.elasticsearch.common.inject.InjectorBuilder.build(InjectorBuilder.java:102)
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:197)
at org.elasticsearch.node.NodeBuilder.build(NodeBuilder.java:159)
at com.knapsack.KnapSackImport.main(KnapSackImport.java:34)

Where am getting the problem at node , May I know solution to this..

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants