ibm / cloudant-spring Goto Github PK
View Code? Open in Web Editor NEWLicense: Apache License 2.0
License: Apache License 2.0
Please read these guidelines before opening an issue.
I have put my client credentials in the application.prop like below
cloudant.url=https://ca5401d9-c380-428e-acd9-bf4621b73e26-bluemix.cloudantnosqldb.appdomain.cloud
cloudant.username=***************
cloudant.password=************
and then i have autowired as mentioned in the readme of this repository
@Autowired
private CloudantClient client;
through my controller i am calling this method to see if its working
public List getAllDbs() {
return client.getAllDbs();
}
I am supposed to be getting right results with list of dbs available.
Currently it is throwing me errors like this below,
com.cloudant.client.org.lightcouch.CouchDbException: 401 Unauthorized at https://2a6085c6-394e-4a69-8074-6334f6b0c91a-bluemix.cloudant.com:443/_all_dbs. Error: unauthorized. Reason: one of _all_dbs, _admin, server_admin is required for this request.
But i do have right access. Not sure which part i am doing it wrong.
1.8
This should probably now be publish
- do we need to do anything to the gradle file to ensure signing is working?
Using a legacy API key (and therefore a database that already exists):
cloudant:
url: https://example.cloudant.com
username: mylegacyapikey
password: passphrase
db: test
Under the covers this is effectively:
CloudantClient client = ClientBuilder
.url(config.getUrl())
.username(config.getUsername())
.password(config.getPassword());
.build();
client.database("test", true);
Expected the Database
bean to be instantiated.
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name ‘database’ defined in class path resource [com/ibm/cloudant/spring/boot/CloudantAutoConfiguration.class]:
Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [com.cloudant.client.api.Database]:
Factory method ‘database’ threw exception; nested exception is
com.cloudant.client.org.lightcouch.CouchDbException: 403 Forbidden. Error: forbidden. Reason: one of _admin, server_admin is required for this request.
0.0.3
1.8.0_181
Any
Note this issue is caused because cloudant-spring always calls client.database(..., true)
i.e. asking to create the database. Since a legacy API key never has permission to create a database this call is invalid when using an API key resulting in a permissions exception.
Under the hood java-cloudant issues the create call and returns the existing db in cases of a 412
(i.e. the database already exists). It could be argued that java-cloudant should be more lenient and in the case of a 403
check for existence of the database to accommodate a request using a legacy API key, although the call to create is technically invalid.
To resolve this issue requires either:
i) Update java-cloudant to be more lenient and then update the dependency here.
or
ii) Provide a configuration option for controling the create boolean in cloudant-spring
Below is the connection properties in my application.properties
file
cloudant.url=http://something.cloudapp.azure.com:5984
cloudant.username=************
cloudant.password=************
I have then autowired the CloudantClient component in my class as below.
@Autowired
private CloudantClient client;
public void sample(){
log.info(client.getAllDbs().toString());
}
Above code is suppose to print the database list or some string.
client
is null and hence NullPointerException
is thrown at the line client.getAllDbs()
<groupId>com.cloudant</groupId>
<artifactId>cloudant-spring-boot-starter</artifactId>
<version>0.0.4</version>
11 OpenJDK macOS
Spring boot 2.4.0
Thanks.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.