I'm playing with couchbase and spring data couchbase. For that purposes I have installed couchbase with version 5.5.1 build 3511
and enabled test buckets. I've created user beer-sample
with password beer-sample
and added him all privileges to bucket beer-sample
.
Then I've created this sample application with configuration for couchbase. When I start the application and query for existing beers in bucket I'm getting exception:
com.couchbase.client.java.error.ViewDoesNotExistException: View beer/all does not exist.
at com.couchbase.client.java.view.ViewQueryResponseMapper$BuildViewResult.call(ViewQueryResponseMapper.java:211)
at com.couchbase.client.java.view.ViewQueryResponseMapper$BuildViewResult.call(ViewQueryResponseMapper.java:185)
at rx.internal.operators.OnSubscribeMap$MapSubscriber.onNext(OnSubscribeMap.java:69)
at rx.internal.operators.OnSubscribeMap$MapSubscriber.onNext(OnSubscribeMap.java:77)
at rx.internal.producers.SingleProducer.request(SingleProducer.java:65)
at rx.Subscriber.setProducer(Subscriber.java:211)
at rx.internal.operators.OnSubscribeMap$MapSubscriber.setProducer(OnSubscribeMap.java:102)
at rx.internal.operators.OnSubscribeMap$MapSubscriber.setProducer(OnSubscribeMap.java:102)
at rx.internal.operators.OperatorSingle$ParentSubscriber.onCompleted(OperatorSingle.java:113)
at rx.internal.operators.OperatorObserveOn$ObserveOnSubscriber.checkTerminated(OperatorObserveOn.java:281)
at rx.internal.operators.OperatorObserveOn$ObserveOnSubscriber.call(OperatorObserveOn.java:216)
at rx.internal.schedulers.ScheduledAction.run(ScheduledAction.java:55)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$201(ScheduledThreadPoolExecutor.java:180)
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:293)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
at java.lang.Thread.run(Thread.java:748)
Caused by: rx.exceptions.OnErrorThrowable$OnNextValue: OnError while emitting onNext value: com.couchbase.client.java.document.json.JsonObject.class
at rx.exceptions.OnErrorThrowable.addValueAsLastCause(OnErrorThrowable.java:118)
at rx.internal.operators.OnSubscribeMap$MapSubscriber.onNext(OnSubscribeMap.java:73)
... 16 more
I guess that indexes should be automatically created with my config, but maybe I'm wrong.
You are using Spring's couchbase repository interface in your BeerRepository
. The findAll()
method of the interface expects a Couchbase View
to be present to get the data. So you need to either create the View manually in couchbase, or can annotate your BeerRepository
interface with @ViewIndexed(designDoc = "beer", viewName = "all")
, which would create the view automatically if it isn't present.
The mistake that you had done was to annotate your Beer
class with @ViewIndexed
, since the annotation is supposed to be used for your Repository interfaces. More info on the annotation here.
All that said, you should also check out leveraging Couchbase's N1QL
queries for accessing data from Couchbase. You may use the @Query
annotation on your repository methods for the same. More info on using the @Query
annotation here.