简体   繁体   中英

“not authorized to execute this request” using the arangodb java driver

I want to use the java driver for ArangoDB in a Maven project on Eclipse. I am trying to follow the tutorial for the java driver for ArangoDB available here , but I cannot even get the simpler application to work, even starting from a clean project.

main.java:

package test;

import com.arangodb.ArangoDB;

public class main {

    public static void main(String[] args) {

        ArangoDB arangoDB = new ArangoDB.Builder().build();

        arangoDB.createDatabase("myDatabase");
    }

}

pom.xml:

<project xmlns="http://maven.apache.org/POM/4.0.0" 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 
http://maven.apache.org/xsd/maven-4.0.0.xsd">
  <modelVersion>4.0.0</modelVersion>
  <groupId>test</groupId>
   <artifactId>test</artifactId>
  <version>0.0.1-SNAPSHOT</version>
  <dependencies>
    <dependency>
        <groupId>com.arangodb</groupId>
        <artifactId>arangodb-java-driver</artifactId>
        <version>4.2.0</version>
    </dependency>
  </dependencies>
</project>

I get the following error when running the code:

SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
SLF4J: Defaulting to no-operation (NOP) logger implementation
SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.
Exception in thread "main" com.arangodb.ArangoDBException: Response: 401, Error: 11 - not authorized to execute this request
    at com.arangodb.internal.velocystream.VstCommunication.checkError(VstCommunication.java:106)
    at com.arangodb.internal.velocystream.VstCommunicationSync.execute(VstCommunicationSync.java:134)
    at com.arangodb.internal.velocystream.VstCommunicationSync.execute(VstCommunicationSync.java:46)
    at com.arangodb.internal.velocystream.VstCommunication.execute(VstCommunication.java:96)
    at com.arangodb.internal.velocystream.VstProtocol.execute(VstProtocol.java:46)
    at com.arangodb.internal.ArangoExecutorSync.execute(ArangoExecutorSync.java:58)
    at com.arangodb.ArangoDB.createDatabase(ArangoDB.java:437)
    at test.main.main(main.java:12)

I tried other basic operations, none work (even a simple arangoDB.getVersion(); ).


If I add the following dependency to the pom.xml, it removes warnings but not the errors:

<dependency> 
    <groupId>org.slf4j</groupId>
    <artifactId>slf4j-simple</artifactId>
    <version>1.7.22</version>
</dependency>

Result:

Exception in thread "main" com.arangodb.ArangoDBException: Response: 401, Error: 11 - not authorized to execute this request
    at com.arangodb.internal.velocystream.VstCommunication.checkError(VstCommunication.java:106)
    at com.arangodb.internal.velocystream.VstCommunicationSync.execute(VstCommunicationSync.java:134)
    at com.arangodb.internal.velocystream.VstCommunicationSync.execute(VstCommunicationSync.java:46)
    at com.arangodb.internal.velocystream.VstCommunication.execute(VstCommunication.java:96)
    at com.arangodb.internal.velocystream.VstProtocol.execute(VstProtocol.java:46)
    at com.arangodb.internal.ArangoExecutorSync.execute(ArangoExecutorSync.java:58)
    at com.arangodb.ArangoDB.createDatabase(ArangoDB.java:437)
    at test.main.main(main.java:12)

You need to specify connection data to your db like user, password and etc, all what is db need to succesfully connection, check again javadoc of class Builder and set user and password.

ArangoDB arangoDB = new ArangoDB.Builder().build();

Here you setup nothing and build ArrangoDb instance without any connection data at all

I want to use the java driver for ArangoDB in a Maven project on Eclipse. I am trying to follow the tutorial for the java driver for ArangoDB available here , but I cannot even get the simpler application to work, even starting from a clean project.

main.java:

package test;

import com.arangodb.ArangoDB;

public class main {

    public static void main(String[] args) {

        ArangoDB arangoDB = new ArangoDB.Builder().build();

        arangoDB.createDatabase("myDatabase");
    }

}

pom.xml:

<project xmlns="http://maven.apache.org/POM/4.0.0" 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 
http://maven.apache.org/xsd/maven-4.0.0.xsd">
  <modelVersion>4.0.0</modelVersion>
  <groupId>test</groupId>
   <artifactId>test</artifactId>
  <version>0.0.1-SNAPSHOT</version>
  <dependencies>
    <dependency>
        <groupId>com.arangodb</groupId>
        <artifactId>arangodb-java-driver</artifactId>
        <version>4.2.0</version>
    </dependency>
  </dependencies>
</project>

I get the following error when running the code:

SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
SLF4J: Defaulting to no-operation (NOP) logger implementation
SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.
Exception in thread "main" com.arangodb.ArangoDBException: Response: 401, Error: 11 - not authorized to execute this request
    at com.arangodb.internal.velocystream.VstCommunication.checkError(VstCommunication.java:106)
    at com.arangodb.internal.velocystream.VstCommunicationSync.execute(VstCommunicationSync.java:134)
    at com.arangodb.internal.velocystream.VstCommunicationSync.execute(VstCommunicationSync.java:46)
    at com.arangodb.internal.velocystream.VstCommunication.execute(VstCommunication.java:96)
    at com.arangodb.internal.velocystream.VstProtocol.execute(VstProtocol.java:46)
    at com.arangodb.internal.ArangoExecutorSync.execute(ArangoExecutorSync.java:58)
    at com.arangodb.ArangoDB.createDatabase(ArangoDB.java:437)
    at test.main.main(main.java:12)

I tried other basic operations, none work (even a simple arangoDB.getVersion(); ).


If I add the following dependency to the pom.xml, it removes warnings but not the errors:

<dependency> 
    <groupId>org.slf4j</groupId>
    <artifactId>slf4j-simple</artifactId>
    <version>1.7.22</version>
</dependency>

Result:

Exception in thread "main" com.arangodb.ArangoDBException: Response: 401, Error: 11 - not authorized to execute this request
    at com.arangodb.internal.velocystream.VstCommunication.checkError(VstCommunication.java:106)
    at com.arangodb.internal.velocystream.VstCommunicationSync.execute(VstCommunicationSync.java:134)
    at com.arangodb.internal.velocystream.VstCommunicationSync.execute(VstCommunicationSync.java:46)
    at com.arangodb.internal.velocystream.VstCommunication.execute(VstCommunication.java:96)
    at com.arangodb.internal.velocystream.VstProtocol.execute(VstProtocol.java:46)
    at com.arangodb.internal.ArangoExecutorSync.execute(ArangoExecutorSync.java:58)
    at com.arangodb.ArangoDB.createDatabase(ArangoDB.java:437)
    at test.main.main(main.java:12)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM