Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
314 views
in Technique[技术] by (71.8m points)

Spring data couchbase 3.0.9 release - com.couchbase.client.java.error.ViewDoesNotExistException View person/all does not exist

I'm using Spring boot 2.0.4 with couchbase server (enterprise 5.5) as a docker container on my local machine. I have a configuration class which extends AbstractCouchbaseConfiguration, where I have provided the couchbase cluster/bucket details.

The repository interface is annotated with @N1qlPrimaryIndexed and @ViewIndexed(designDoc = "person", viewName = "all") and my application.properties file has spring.data.couchbase.auto-index=true

From what I understand, Spring boot should be able to auto create the primary index and views.

This is my config class

public class CouchbaseConfig extends AbstractCouchbaseConfiguration {
@Value("${couchbase_host}")
private String hostname;

@Value("${couchbase_bucket}")
private String bucket;

@Override
@Bean(name = BeanNames.COUCHBASE_CLUSTER_INFO)
public ClusterInfo couchbaseClusterInfo() throws Exception {
    return couchbaseCluster().authenticate("Administrator","password").clusterManager().info();
}
@Bean
public Cluster cluster() {
    return CouchbaseCluster.create(getEnvironment(),hostname);
}
@Override
@Bean(destroyMethod = "close", name = BeanNames.COUCHBASE_BUCKET)
public Bucket couchbaseClient() throws Exception {
    return couchbaseCluster().openBucket(getBucketName());
}

@Override
protected List<String> getBootstrapHosts() {
    return Collections.singletonList(hostname);
}

@Override
protected String getBucketName() {
    return bucket;
}

@Override
protected String getBucketPassword() {
    return "password";
}

@Override
protected CouchbaseEnvironment getEnvironment() {
    CouchbaseEnvironment environment = DefaultCouchbaseEnvironment.builder()
                                        .connectTimeout(25000)
                                        .queryTimeout(75000)
                                        .kvTimeout(5000)
                                        .socketConnectTimeout(40000)
                                        .build();
    return environment;
}

When I start my app based on the above config,

2018-08-10 19:47:31.653  INFO 29198 --- [           main] i.InspectionsAggregateServiceApplication : No active profile set, falling back to default profiles: default
2018-08-10 19:47:31.697  INFO 29198 --- [           main] ConfigServletWebServerApplicationContext : Refreshing org.springframework.boot.web.servlet.context.AnnotationConfigServletWebServerApplicationContext@757acd7b: startup date [Fri Aug 10 19:47:31 CDT 2018]; root of context hierarchy
2018-08-10 19:47:32.283  INFO 29198 --- [           main] o.s.b.f.s.DefaultListableBeanFactory     : Overriding bean definition for bean 'requestContextFilter' with a different definition: replacing [Root bean: class [null]; scope=; abstract=false; lazyInit=false; autowireMode=3; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=org.springframework.boot.autoconfigure.jersey.JerseyAutoConfiguration; factoryMethodName=requestContextFilter; initMethodName=null; destroyMethodName=(inferred); defined in class path resource [org/springframework/boot/autoconfigure/jersey/JerseyAutoConfiguration.class]] with [Root bean: class [org.springframework.boot.autoconfigure.web.servlet.WebMvcAutoConfiguration$WebMvcAutoConfigurationAdapter]; scope=; abstract=false; lazyInit=false; autowireMode=3; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=null; factoryMethodName=requestContextFilter; initMethodName=null; destroyMethodName=(inferred); defined in class path resource [org/springframework/boot/autoconfigure/web/servlet/WebMvcAutoConfiguration$WebMvcAutoConfigurationAdapter.class]]
2018-08-10 19:47:32.463  INFO 29198 --- [           main] f.a.AutowiredAnnotationBeanPostProcessor : JSR-330 'javax.inject.Inject' annotation found and supported for autowiring
2018-08-10 19:47:32.836  INFO 29198 --- [           main] o.s.b.w.e.t.TomcatWebServer              : Tomcat initialized with port(s): 8080 (http)
2018-08-10 19:47:32.856  INFO 29198 --- [           main] o.a.c.c.StandardService                  : Starting service [Tomcat]
2018-08-10 19:47:32.856  INFO 29198 --- [           main] o.a.c.c.StandardEngine                   : Starting Servlet Engine: Apache Tomcat/8.5.32
2018-08-10 19:47:32.859  INFO 29198 --- [ost-startStop-1] o.a.c.c.AprLifecycleListener             : The APR based Apache Tomcat Native library which allows optimal performance in production environments was not found on the java.library.path: [/Users/lakshmananraman/Library/Java/Extensions:/Library/Java/Extensions:/Network/Library/Java/Extensions:/System/Library/Java/Extensions:/usr/lib/java:.]
2018-08-10 19:47:32.965  INFO 29198 --- [ost-startStop-1] o.a.c.c.C.[.[.[/]                        : Initializing Spring embedded WebApplicationContext
2018-08-10 19:47:32.966  INFO 29198 --- [ost-startStop-1] o.s.w.c.ContextLoader                    : Root WebApplicationContext: initialization completed in 1272 ms
2018-08-10 19:47:33.215  INFO 29198 --- [ost-startStop-1] o.s.b.w.s.ServletRegistrationBean        : Servlet com.ge.trans.rc360.inspection.config.JerseyConfig mapped to [/api/*]
2018-08-10 19:47:33.218  INFO 29198 --- [ost-startStop-1] o.s.b.w.s.ServletRegistrationBean        : Servlet dispatcherServlet mapped to [/]
2018-08-10 19:47:33.221  INFO 29198 --- [ost-startStop-1] o.s.b.w.s.FilterRegistrationBean         : Mapping filter: 'characterEncodingFilter' to: [/*]
2018-08-10 19:47:33.221  INFO 29198 --- [ost-startStop-1] o.s.b.w.s.FilterRegistrationBean         : Mapping filter: 'hiddenHttpMethodFilter' to: [/*]
2018-08-10 19:47:33.221  INFO 29198 --- [ost-startStop-1] o.s.b.w.s.FilterRegistrationBean         : Mapping filter: 'httpPutFormContentFilter' to: [/*]
2018-08-10 19:47:33.221  INFO 29198 --- [ost-startStop-1] o.s.b.w.s.FilterRegistrationBean         : Mapping filter: 'requestContextFilter' to: [/*]
2018-08-10 19:47:33.444  INFO 29198 --- [           main] c.c.c.c.CouchbaseCore                    : CouchbaseEnvironment: {sslEnabled=false, sslKeystoreFile='null', sslTruststoreFile='null', sslKeystorePassword=false, sslTruststorePassword=false, sslKeystore=null, sslTruststore=null, bootstrapHttpEnabled=true, bootstrapCarrierEnabled=true, bootstrapHttpDirectPort=8091, bootstrapHttpSslPort=18091, bootstrapCarrierDirectPort=11210, bootstrapCarrierSslPort=11207, ioPoolSize=8, computationPoolSize=8, responseBufferSize=16384, requestBufferSize=16384, kvServiceEndpoints=1, viewServiceEndpoints=12, queryServiceEndpoints=12, searchServiceEndpoints=12, configPollInterval=2500, configPollFloorInterval=50, ioPool=NioEventLoopGroup, kvIoPool=null, viewIoPool=null, searchIoPool=null, queryIoPool=null, coreScheduler=CoreScheduler, memcachedHashingStrategy=DefaultMemcachedHashingStrategy, eventBus=DefaultEventBus, packageNameAndVersion=couchbase-java-client/2.5.9 (git: 2.5.9, core: 1.5.9), retryStrategy=BestEffort, maxRequestLifetime=75000, retryDelay=ExponentialDelay{growBy 1.0 MICROSECONDS, powers of 2; lower=100, upper=100000}, reconnectDelay=ExponentialDelay{growBy 1.0 MILLISECONDS, powers of 2; lower=32, upper=4096}, observeIntervalDelay=ExponentialDelay{growBy 1.0 MICROSECONDS, powers of 2; lower=10, upper=100000}, keepAliveInterval=30000, continuousKeepAliveEnabled=true, keepAliveErrorThreshold=4, keepAliveTimeout=2500, autoreleaseAfter=2000, bufferPoolingEnabled=true, tcpNodelayEnabled=true, mutationTokensEnabled=false, socketConnectTimeout=40000, callbacksOnIoPool=false, disconnectTimeout=25000, requestBufferWaitStrategy=com.couchbase.client.core.env.DefaultCoreEnvironment$2@6b760460, certAuthEnabled=false, coreSendHook=null, forceSaslPlain=false, queryTimeout=75000, viewTimeout=75000, searchTimeout=75000, analyticsTimeout=75000, kvTimeout=5000, connectTimeout=25000, dnsSrvEnabled=false}
2018-08-10 19:47:33.701  INFO 29198 --- [      cb-io-1-1] c.c.c.c.n.Node                           : Connected to Node 127.0.0.1/localhost
2018-08-10 19:47:33.750  INFO 29198 --- [      cb-io-1-1] c.c.c.c.n.Node                           : Disconnected from Node 127.0.0.1/localhost
2018-08-10 19:47:34.146  INFO 29198 --- [      cb-io-1-2] c.c.c.c.n.Node                           : Connected to Node 127.0.0.1/localhost
2018-08-10 19:47:34.208  INFO 29198 --- [-computations-4] c.c.c.c.c.ConfigurationProvider          : Opened bucket person
2018-08-10 19:47:34.459  WARN 29198 --- [           main] c.c.c.c.e.CoreEnvironment                : More than 1 Couchbase Environments found (2), this can have severe impact on performance and stability. Reuse environments!
2018-08-10 19:47:34.460  INFO 29198 --- [           main] c.c.c.c.CouchbaseCore                    : CouchbaseEnvironment: {sslEnabled=false, sslKeystoreFile='null', sslTruststoreFile='null', sslKeystorePassword=false, sslTruststorePassword=false, sslKeystore=null, sslTruststore=null, bootstrapHttpEnabled=true, bootstrapCarrierEnabled=true, bootstrapHttpDirectPort=8091, bootstrapHttpSslPort=18091, bootstrapCarrierDirectPort=11210, bootstrapCarrierSslPort=11207, ioPoolSize=8, computationPoolSize=8, responseBufferSize=16384, requestBufferSize=16384, kvServiceEndpoints=1, viewServiceEndpoints=12, queryServiceEndpoints=12, searchServiceEndpoints=12, configPollInterval=2500, configPollFloorInterval=50, ioPool=NioEventLoopGroup, kvIoPool=null, viewIoPool=null, searchIoPool=null, queryIoPool=null, coreScheduler=CoreScheduler, memcachedHashingStrategy=DefaultMemcachedHashingStrategy, eventBus=DefaultEventBus, packageNameAndVersion=couchbase-java-client/2.5.9 (git: 2.5.9, core: 1.5.9), retryStrategy=BestEffort, maxRequestLifetime=75000, retryDelay=ExponentialDelay{growBy 1.0 MICROSECONDS, powers of 2; lower=100, upper=100000}, reconnectDelay=ExponentialDelay{growBy 1.0 MILLISECONDS, powers of 2; lower=32, upper=4096}, observeIntervalDelay=ExponentialDelay{growBy 1.0 MICROSECONDS, powers of 2; lower=10, upper=100000}, keepAliveInterval=30000, continuousKeepAliveEnabled=true, keepAliveErrorThreshold=4, keepAliveTimeout=2500, autoreleaseAfter=2000, bufferPoolingEnabled=true, tcpNodelayEnabled=true, mutationTokensEnabled=false, socketConnectTimeout=40000, callbacksOnIoPool=false, disconnectTimeout=25000, requestBufferWaitStrategy=com.couchbase.client.core.env.DefaultCoreEnvironment$2@1a87b51, certAuthEnabled=false, coreSendHook=null, forceSaslPlain=false, queryTimeout=75000, viewTimeout=75000, searchTimeout=75000, analyticsTimeout=75000, kvTimeout=5000, connectTimeout=25000, dnsSrvEnabled=false}
2018-08-10 19:47:34.569  INFO 29198 --- [           main] o.s.w.s.h.SimpleUrlHandlerMapping        : Mapped URL path [/**/favicon.ico] onto handler of type [class org.springframework.web.servlet.resource.ResourceHttpRequestHandler]
2018-08-10 19:47:34.681  INFO 29198 --- [           main] s.w.s.m.m.a.RequestMappingHandlerAdapter : Looking for @ControllerAdvice: org.springframework.boot.web.servlet.context.AnnotationConfigServletWebServerApplicationContext@757acd7b: startup date [Fri Aug 10 19:47:31 CDT 2018]; root of context hierarchy
2018-08-10 19:47:34.734  INFO 29198 --- [           main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/error]}" onto public org.springframework.http.ResponseEntity<java.util.Map<java.lang.String, java.lang.Object>> org.springframework.boot.autoconfigure.web.servlet.error.BasicErrorController.error(javax.servlet.http.HttpServletRequest)
2018-08-10 19:47:34.735  INFO 29198 --- [           main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/error],produces=[text/html]}" onto public org.springframework.web.servlet.ModelAndView org.springframework.boot.autoconfigure.web.servlet.error.BasicErrorController.errorHtml(javax.servlet.http.HttpServletRequest,javax.servlet.http.HttpServletResponse)
2018-08-10 19:47:34.754  INFO 29198 --- [           main] o.s.w.

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

After re-reading the docs again, I added a override on IndexManager method and after overriding the other methods, spring configured the environment correctly.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...