Springboot Couchbase Application can not be deployed in windows [closed] - java

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 2 years ago.
Improve this question
I am developing a Springboot application which connects to a remote Couchbase server to fetch data. The application is working fine for the local Couchbase server in my machine. But when I configured the API properties for the remote database, it throws a java.util.concurrent.TimeoutException. Following given is my error log.
2020-08-31 08:50:50.596 WARN 12692 --- [ main] ConfigServletWebServerApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'fileUploadController': Unsatisfied dependency expressed through field 'predictionService'; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'predictionServiceImpl': Unsatisfied dependency expressed through field 'predictionDao'; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'predictionDaoImpl': Unsatisfied dependency expressed through field 'predictionRepository'; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'couchbaseRepositoryOperationsMapping' defined in class path resource [com/example/couchbaseService/Configuration/CouchbaseConfiguration.class]: Unsatisfied dependency expressed through method 'repositoryOperationsMapping' parameter 0; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'couchbaseTemplate' defined in class path resource [com/example/couchbaseService/Configuration/CouchbaseConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.data.couchbase.core.CouchbaseTemplate]: Factory method 'couchbaseTemplate' threw exception; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'couchbaseBucket' defined in class path resource [com/example/couchbaseService/Configuration/CouchbaseConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [com.couchbase.client.java.Bucket]: Factory method 'couchbaseClient' threw exception; nested exception is java.lang.RuntimeException: java.util.concurrent.TimeoutException
2020-08-31 08:50:50.642 INFO 12692 --- [ main] c.c.client.core.env.CoreEnvironment : Shutdown kvIoPool: success
2020-08-31 08:50:50.645 INFO 12692 --- [ main] c.c.client.core.env.CoreEnvironment : Shutdown viewIoPool: success
2020-08-31 08:50:50.652 INFO 12692 --- [ main] c.c.client.core.env.CoreEnvironment : Shutdown queryIoPool: success
2020-08-31 08:50:50.656 INFO 12692 --- [ main] c.c.client.core.env.CoreEnvironment : Shutdown searchIoPool: success
2020-08-31 08:50:50.659 INFO 12692 --- [ main] c.c.client.core.env.CoreEnvironment : Shutdown Core Scheduler: success
2020-08-31 08:50:50.659 INFO 12692 --- [ Thread-5] c.c.client.core.env.CoreEnvironment : Shutdown Netty: success
2020-08-31 08:50:50.662 INFO 12692 --- [ main] c.c.client.core.env.CoreEnvironment : Shutdown Runtime Metrics Collector: success
2020-08-31 08:50:50.666 INFO 12692 --- [ main] c.c.client.core.env.CoreEnvironment : Shutdown Latency Metrics Collector: success
2020-08-31 08:50:50.683 INFO 12692 --- [ cb-io-1-2] c.c.client.core.endpoint.Endpoint : [][KeyValueEndpoint]: Got notified from Channel as inactive, attempting reconnect.
2020-08-31 08:50:50.690 INFO 12692 --- [entExecutor-2-2] c.c.client.core.env.CoreEnvironment : Shutdown IoPool: success
2020-08-31 08:50:50.703 INFO 12692 --- [ main] o.apache.catalina.core.StandardService : Stopping service [Tomcat]
As I couldn't figure out the cause, I tested the API in different windows machines and all attempts gave the same error. But, API successfully starts in a MacOS machine and works fine. I am using Java 11 and Couchbase enterprise edition 6.5.0. My springboot version is 2.0.1. Can anyone help me on this to figure out the cause? Thank you.

If you claim that it works on a Mac, and there's no problem with the code, then the problem could be with your corporate networking policy. Often times, companies have different profiles for Windows than Macs. It could also be a firewall/antivirus blocking outgoing traffic on your PC that Mac doesn't have.
To verify this theory, run a Couchbase server locally on your PC and see if you can connect to it.

Related

Springboot JPA yields "Failed to configure a DataSource" after profile change

I am developling a Springboot Application with an active database. First, I tried configuring my database by adding the following in application.properties:
spring.datasource.url = jdbc:mysql://127.0.0.1:3306/schema_name?characterEncoding=UTF-8&serverTimezone=GMT%2B8
spring.datasource.username = root
spring.datasource.password = password
spring.datasource.driver-class-name = com.mysql.jdbc.Driver
spring.jpa.properties.hibernate.hdm2ddl.auto = update
spring.jpa.show-sql = true
spring.jpa.properties.hibernate.format_sql = true
The Springboot Application can run perfectly fine with this configuration. However, as I try to move the above configuration lines in application-dev.properties and add spring.profiles.active = dev in my original application.properties, the following error yields:
2021-04-10 11:29:59.097 WARN 58148 --- [ restartedMain] ConfigServletWebServerApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'inMemoryDatabaseShutdownExecutor' defined in class path resource [org/springframework/boot/devtools/autoconfigure/DevToolsDataSourceAutoConfiguration.class]: Unsatisfied dependency expressed through method 'inMemoryDatabaseShutdownExecutor' parameter 0; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'dataSource' defined in class path resource [org/springframework/boot/autoconfigure/jdbc/DataSourceConfiguration$Hikari.class]: Bean instantiation via
factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [com.zaxxer.hikari.HikariDataSource]: Factory method 'dataSource' threw exception; nested exception is org.springframework.boot.autoconfigure.jdbc.DataSourceProperties$DataSourceBeanCreationException: Failed to determine a suitable driver class
2021-04-10 11:29:59.103 INFO 58148 --- [ restartedMain] o.apache.catalina.core.StandardService : Stopping service [Tomcat]
2021-04-10 11:29:59.134 INFO 58148 --- [ restartedMain] ConditionEvaluationReportLoggingListener :
Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled.
2021-04-10 11:29:59.172 ERROR 58148 --- [ restartedMain] o.s.b.d.LoggingFailureAnalysisReporter :
***************************
APPLICATION FAILED TO START
***************************
Description:
Failed to configure a DataSource: 'url' attribute is not specified and no embedded datasource could be configured.
Reason: Failed to determine a suitable driver class
Action:
Consider the following:
If you want an embedded database (H2, HSQL or Derby), please put it on the classpath.
If you have database settings to be loaded from a particular profile you may need to activate it (the profiles dev are currently active).
I searched for solutions but all of them suggests to either disable/exclude JPA (not the case) or configure the database connection properly (which I did, and succeeded in the main profile); from the error message it is also shown that dev profile is active. How can I solve this problem?

Getting error when upgrading spring boot from 2.2.2 to 2.3.2.RELEASE

I am upgrading from spring boot 2.2.2 to 2.3.2.RELEASE and getting below error. I am sure that it is not related to the port which is already in use. Also, I have changed the logging from logging.file to logging.file.name as per spring boot 2.3.2
WARN [framework_5_5][traceId:][spanId:][parentSpanId:][spanExportable:][bt:#build.time#][cbn:#current.branch#][main][2020-08-20 15:22:29,317]- org.springframework.context.support.AbstractApplicationContext.refresh:Line 559 - Exception encountered during context initialization - cancelling refresh attempt: org.springframework.context.ApplicationContextException: Failed to start bean 'webServerStartStop'; nested exception is org.springframework.boot.web.embedded.tomcat.ConnectorStartFailedException: Connector configured to listen on port 10090 failed to start
INFO [framework_5_5][traceId:][spanId:][parentSpanId:][spanExportable:][bt:#build.time#][cbn:#current.branch#][main][2020-08-20 15:22:29,321]- org.springframework.scheduling.concurrent.ExecutorConfigurationSupport.shutdown:Line 218 - Shutting down ExecutorService 'applicationTaskExecutor'
INFO [framework_5_5][traceId:][spanId:][parentSpanId:][spanExportable:][bt:#build.time#][cbn:#current.branch#][main][2020-08-20 15:22:29,324]- com.zaxxer.hikari.HikariDataSource.close:Line 350 - HikariPool-1 - Shutdown initiated...
INFO [framework_5_5][traceId:][spanId:][parentSpanId:][spanExportable:][bt:#build.time#][cbn:#current.branch#][main][2020-08-20 15:22:29,329]- com.zaxxer.hikari.HikariDataSource.close:Line 352 - HikariPool-1 - Shutdown completed.
INFO [framework_5_5][traceId:][spanId:][parentSpanId:][spanExportable:][bt:#build.time#][cbn:#current.branch#][main][2020-08-20 15:22:29,329]- com.zaxxer.hikari.HikariDataSource.close:Line 350 - HikariPool-2 - Shutdown initiated...
INFO [framework_5_5][traceId:][spanId:][parentSpanId:][spanExportable:][bt:#build.time#][cbn:#current.branch#][main][2020-08-20 15:22:29,337]- com.zaxxer.hikari.HikariDataSource.close:Line 352 - HikariPool-2 - Shutdown completed.
INFO [framework_5_5][traceId:][spanId:][parentSpanId:][spanExportable:][bt:#build.time#][cbn:#current.branch#][main][2020-08-20 15:22:29,353]- org.springframework.boot.autoconfigure.logging.ConditionEvaluationReportLoggingListener.logMessage:Line 136 -
Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled.
ERROR [framework_5_5][traceId:][spanId:][parentSpanId:][spanExportable:][bt:#build.time#][cbn:#current.branch#][main][2020-08-13 19:20:31,769]- org.springframework.boot.diagnostics.LoggingFailureAnalysisReporter.report:Line 40 -
***************************
APPLICATION FAILED TO START
***************************
Description:
The Tomcat connector configured to listen on port 10090 failed to start. The port may already be in use or the connector may be misconfigured.
Action:
Verify the connector's configuration, identify and stop any process that's listening on port 10090, or configure this application to listen on another port.
configure this application to listen on another port.
Above errors occurs when application is already running.
If you are using Eclipse or Intellij, could restart and run the application.
As i am not allowed to enter comment putting it here?
What is the solution for this.
I have added
((AbstractAjpProtocol<Long>)ajpConnector.getProtocolHandler()).setSecretRequired(false);
with ajp connector and issue is resolved
Updated:
You need to add this line of code to make it work with apache
protocol.setAddress(new InetSocketAddress(0).getAddress());
Port zero will let the system pick up an ephemeral port in a bind operation

Cant run spring boot application?

I'm working on an assignment with a team. And my team decided to use spring boot for the application. However for some reason whenever I run the application I get a different message on my terminal whereas my teammates have a different message on their terminal. Instead of "LiveReload server is running on port 35729" They get "tomcat initialized with port(s) 8081 (http)".
I am not sure what exactly to do since all of us are using the same project and I have built it as they told me to do so.
However it is still not working for me. Can anybody tell me how to fix it so I could get it to run. I have never used maven or spring boot before.
This is the message I am getting on my terminal
2020-06-13 23:05:35.538 INFO 34396 --- [ restartedMain] com.rest.WebApplication : Starting WebApplication on DESKTOP-1M4A445 with PID 34396 (Directory\project\target\classes started by USER in Directory/project)
2020-06-13 23:05:35.543 INFO 34396 --- [ restartedMain] com.rest.WebApplication : No active profile set, falling back to default profiles: default
2020-06-13 23:05:35.609 INFO 34396 --- [ restartedMain] .e.DevToolsPropertyDefaultsPostProcessor : Devtools property defaults active! Set 'spring.devtools.add-properties' to 'false' to disable
2020-06-13 23:05:36.520 INFO 34396 --- [ restartedMain] o.s.b.d.a.OptionalLiveReloadServer : LiveReload server is running on port 35729
2020-06-13 23:05:36.550 INFO 34396 --- [ restartedMain] com.rest.WebApplication : Started WebApplication in 1.452 seconds (JVM running for 2.035)
Process finished with exit code 0
Thank you so much.
It seems you have spring-boot-devtools dependency in the classpath. Because of this you see LiveReload server is running on port 35729 statement written to log.
From your logs, it seems tomcat is not started at all. Verify your properties files and make sure web environment is not turned off
For spring-boot 1.x, look for spring.main.web-environment=false property
For spring-boot 2.x, look for spring.main.web-application-type=none property

Spring framework ERROR 10904 [closed]

Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 6 years ago.
Improve this question
I was trying to build an application using the Spring framework but I got the following errors and am not sure why.
Whenever I try to run the application I get the bellow errors. I did set up my Maven in C drive and my application in D drive due to space. Can that be an issue?
What is causing the errors and how should I go about them?
ERROR 10904 --- [ main] o.a.coyote.http11.Http11NioProtocol : Failed to start end point associated with ProtocolHandler ["http-nio-8080"]
ERROR 10904 --- [ main] o.apache.catalina.core.StandardService : Failed to start connector [Connector[HTTP/1.1-8080]]
ERROR 10904 --- [ main] o.s.boot.SpringApplication : Application startup failed
INFO 10904 --- [ main] .b.l.ClasspathLoggingApplicationListener : Application failed to start with classpath: [file:/D:/GITHUB/webappaws/target/classes/, file:/C:/Users/codeLearner/.m2/repository/org/springframework/boot/spring-boot-starter-thymeleaf/1.3.6.RELEASE/spring-boot-starter-thymeleaf-1.3.6.RELEASE.jar, file:/C:/Users/codeLearner/.m2/repository/org/springframework/boot/spring-boot-starter/1.3.6.RELEASE/spring-boot-starter-1.3.6.RELEASE.jar, file:/C:/Users/codeLearner/.m2/repository/org/springframework/boot/spring-boot/1.3.6.RELEASE/spring-boot-1.3.6.RELEASE.jar, file:/C:/Users/codeLearner/.m2/repository/org/springframework/boot/spring-boot-autoconfigure/1.3.6.RELEASE/spring-boot-autoconfigure-1.3.6.RELEASE.jar, file:/C:/Users/codeLearner/.m2/repository/org/springframework/boot/spring-boot-starter-logging/1.3.6.RELEASE/spring-boot-starter-logging-1.3.6.RELEASE.jar, file:/C:/Users/codeLearner/.m2/repository/ch/qos/logback/logback-classic/1.1.7/logback-classic-1.1.7.jar, file:/C:/Users/codeLearner/.m2/repository/ch/qos/logback/logback-core/1.1.7/logback-core-1.1.7.jar, ...
Solved
What I did when launching the application was instead of relaunching it, I ran it and that's what cause the problem (I think)
When I go open localhost:8080 it displays what it should.
I am learning, which does counts for stupid mistakes and I learn with every new feedback .. not sure why I was voted down though...
Thank you Luke and Jim!

Why does Spring Boot application not exit gracefully?

I am running a Spring Boot application using bootRun task in Intellij (13.1.5 on Linux), and I am trying to shut down a listener thread in the lifecycle callback, however when stopping the app in IntelliJ, I find my listener thread is still running and logging.
In Console:
"Disconnected from the target VM, address: ..., transport: 'socket'
6:39:22 AM: External task execution finished 'bootRun'."
Then I did ps grep and kill the process,
only then console prints:
"2016-03-28 06:39:59.606 INFO 7740 --- [ Thread-1] ationConfigEmbeddedWebApplicationContext : Closing org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext#657617e6: ...2016-03-28 06:39:59.611 INFO 7740 --- [ Thread-1] o.s.j.e.a.AnnotationMBeanExporter : Unregistering JMX-exposed beans on shutdown"
My Questions:
Why stopping app in Intellij not closing application context?
Accodring to Doc, Spring Web app automatically registers shutdown hooks. But I have tried #PreDestroy, destroyMethod, and implements LifeCycle, why does none of them get called?

Categories