I am trying to upload my application spring boot on jenkins, try to exclude #EnableAutoConfiguration(exclude = {DataSourceAutoConfiguration.class, DataSourceTransactionManagerAutoConfiguration.class, HibernateJpaAutoConfiguration.class})
classes with
but continues to show the error
I'm using
gradle
buildscript {
ext {
DEPENDENCY_MANAGEMENT_VERSION = '1.0.6.RELEASE'
SPRING_BOOT_VERSION = '2.2.2.RELEASE'
SONARQUBE_VERSION = '2.6.1'
DEPENDENCY_CHECK_VERSION = '2.0.0'
}
repositories {
maven {
url "${artifactory_contextUrl}/virtual-release-bns"
credentials {
username = "${artifactory_user}"
password = "${artifactory_password}"
}
}
flatDir {
dirs "libs"
}
}
dependencies {
classpath("io.spring.gradle:dependency-management-plugin:${DEPENDENCY_MANAGEMENT_VERSION}")
classpath("org.springframework.boot:spring-boot-gradle-plugin:${SPRING_BOOT_VERSION}")
classpath("org.sonarsource.scanner.gradle:sonarqube-gradle-plugin:${SONARQUBE_VERSION}")
classpath("org.owasp:dependency-check-gradle:${DEPENDENCY_CHECK_VERSION}")
}
}
apply plugin: 'org.sonarqube'
apply plugin: 'org.springframework.boot'
apply plugin: 'org.owasp.dependencycheck'
/* -------------------------------- */
/* - Include other gradle scripts - */
/* -------------------------------- */
def gradlePath = "${rootProject.projectDir}${project.property('gradle.path')}"
apply from: "${gradlePath}/libraries.gradle"
apply from: "${gradlePath}/build-config.gradle"
apply from: "${gradlePath}/build-java.gradle"
apply from: "${gradlePath}/build-report.gradle"
apply from: "${gradlePath}/build-sonar.gradle"
apply from: "${gradlePath}/build-dependencycheck.gradle"
apply from: "${gradlePath}/build-dependencies.gradle"
apply from: "${gradlePath}/build-spring-conf.gradle"
apply from: "${gradlePath}/build-plato.gradle"
allprojects {
apply plugin: 'io.spring.dependency-management'
dependencyManagement {
imports {
mavenBom("org.springframework.boot:spring-boot-dependencies:${SPRING_BOOT_VERSION}")
}
}
}
file Application.properties
# ============================================================================
# Parameter Properties for project 'prueba pr'
# ============================================================================
# Properties
# Only allow properties that are environment independent
# The application.properties name is changed to avoid environment conflict
# ============================================================================
# Application name, different context
spring.application.name=prueba
spring.mvc.locale=es_ES
# Avoid error 405 with spring information
spring.mvc.throw-exception-if-no-handler-found=true
spring.resources.add-mappings=false
# Allow that spring interceptor does not filter option
spring.mvc.dispatch-options-request=true
# static resources location
#spring.resources.static-locations=classpath:/webapp
# Application name, different context
server.port=9980
server.contextPath=/dotrx
spring.application.name=dotrx
spring.application.profiles=dev
spring.profiles=dev
spring.profiles.active=dev
# JMX Actuator
spring.jmx.default-domain=fg
endpoints.jmx.domain=fg
endpoints.jmx.unique-name=true
# JMX Actuator deactivate endpoint
endpoints.trace.enabled=false
endpoints.shutdown.enabled=false
endpoints.info.enabled=false
endpoints.flyway.enabled=false
endpoints.mappings.enabled=false
endpoints.dump.enabled=false
endpoints.docs.enabled=false
endpoints.configprops.enabled=false
endpoints.autoconfig.enabled=false
endpoints.auditevents.enabled=false
endpoints.env.enabled=false
endpoints.heapdump.enabled=false
endpoints.loggers.enabled=false
endpoints.metrics.enabled=false
endpoints.beans.enabled=false
# Datasouces JNDI
sybase.datasource.jndi-name=jdbc/DSSYB_CLDC101
#OAuth
app.token.secret=fg
#Adm Token
app.adm.token.secret=123
f89a06
# Atr Properties
atr.socket.numsession=50
# JSON config folder in classpath
rcfg.json.folder=conf
# JSON i18n texts backoffice
backoffice.file.path=i18n/cms-backoffice.json
# fg Variables
gf.atr.service=CLDC124.uatchl.bns,6100
fg.atr.timeout=60
# fg SYBASE
fg.datasource.url=jdbc:sybase:360
fg.datasource.driverclassname=com.sybase.jdbc4.jdbc.SybDataSource
fg.datasource.username=admin
fg.datasource.pass=123
#Loggable Properties
loggable.system.log.name=SystemOut
loggable.error.log.name=ErrorOut
#Transactional Logger
logger.namespace=fg
logger.token.header=Authorization
logger.token.signature=fg
logger.token.claims.userRut=user.key
logger.token.claims.clientRut=enterprise.key
logger.writing.endpoint=http://123.com
logger.writing.alg=HS256
logger.writing.typ=Authorization
logger.writing.signature=MSLOGGER
logger.writing.expiration=900
logger.pathfile=./controller-dotrx/src/main/resources/logger.json
log.error=exceptions
ERROR
c.s.d.p.mapper.config.SybaseDBConfig : SybaseDBConfig getDataSource end
2020-02-07 10:08:37.216 ERROR 9616 --- [ main] o.s.b.web.embedded.tomcat.TomcatStarter : Error starting Tomcat context. Exception: org.springframework.beans.factory.BeanCreationException. Message: Error creating bean with name 'servletEndpointRegistrar' defined in class path resource [org/springframework/boot/actuate/autoconfigure/endpoint/web/ServletEndpointManagementContextConfiguration$WebMvcServletEndpointManagementContextConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.boot.actuate.endpoint.web.ServletEndpointRegistrar]: Factory method 'servletEndpointRegistrar' threw exception; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'healthEndpoint' defined in class path resource [org/springframework/boot/actuate/autoconfigure/health/HealthEndpointConfiguration.class]: Unsatisfied dependency expressed through method 'healthEndpoint' parameter 0; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'healthContributorRegistry' defined in class path resource [org/springframework/boot/actuate/autoconfigure/health/HealthEndpointConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.boot.actuate.health.HealthContributorRegistry]: Factory method 'healthContributorRegistry' threw exception; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'dbHealthContributor' defined in class path resource [org/springframework/boot/actuate/autoconfigure/jdbc/DataSourceHealthContributorAutoConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.boot.actuate.health.HealthContributor]: Factory method 'dbHealthContributor' threw exception; nested exception is java.lang.IllegalArgumentException: Beans must not be empty
2020-02-07 10:08:37.247 INFO 9616 --- [ main] o.apache.catalina.core.StandardService : Stopping service [Tomcat]
2020-02-07 10:08:37.263 WARN 9616 --- [ main] ConfigServletWebServerApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.context.ApplicationContextException: Unable to start web server; nested exception is org.springframework.boot.web.server.WebServerException: Unable to start embedded Tomcat
2020-02-07 10:08:37.263 INFO 9616 --- [ main] ConditionEvaluationReportLoggingListener :
Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled.
2020-02-07 10:08:37.303 ERROR 9616 --- [ main] o.s.boot.SpringApplication : Application run failed
Related
I am currently using spring boot 2.7.0-M1 and following is my dependencies in build.gradle:
implementation 'org.springframework.boot:spring-boot-starter-actuator'
implementation 'org.springframework.boot:spring-boot-starter-web'
implementation 'org.springframework.cloud:spring-cloud-starter-config'
implementation 'org.springframework.boot:spring-boot-starter-cache'
compileOnly 'org.projectlombok:lombok'
implementation 'org.springframework.cloud:spring-cloud-starter-bootstrap'
developmentOnly 'org.springframework.boot:spring-boot-devtools'
implementation 'io.micrometer:micrometer-registry-datadog:latest.release'
datadogagent("com.datadoghq:dd-java-agent:$datadoghq_dd_version")
implementation("com.datadoghq:dd-trace-api:${datadoghq_dd_version}")
However, when i try to set micrometer bean:
#Configuration
public class MeterRegistryConfig {
#Bean
MeterRegistry meterRegistry(ApplicationContext context) {
DatadogConfig config = new DatadogConfig() {
#Override
public Duration step() {
return Duration.ofSeconds(10);
}
#Override
public String get(String k) {
return null; // accept the rest of the defaults
}
};
return new DatadogMeterRegistry(config, Clock.SYSTEM);
}
}
I am getting a startup error:
2022-02-05 05:07:56.457 ERROR 7897 --- [ restartedMain] o.s.b.web.embedded.tomcat.TomcatStarter : Error starting Tomcat context. Exception: org.springframework.beans.factory.UnsatisfiedDependencyException. Message: Error creating bean with name 'webMvcMetricsFilter' defined in class path resource [org/springframework/boot/actuate/autoconfigure/metrics/web/servlet/WebMvcMetricsAutoConfiguration.class]: Unsatisfied dependency expressed through method 'webMvcMetricsFilter' parameter 0; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'compositeMeterRegistry' defined in class path resource [org/springframework/boot/actuate/autoconfigure/metrics/CompositeMeterRegistryConfiguration.class]: Unsatisfied dependency expressed through method 'compositeMeterRegistry' parameter 1; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'meterRegistry' defined in class path resource [com/hbomax/ml/mlsvc/config/MeterRegistryConfig.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [io.micrometer.core.instrument.MeterRegistry]: Factory method 'meterRegistry' threw exception; nested exception is io.micrometer.core.instrument.config.validate.ValidationException: datadog.apiKey was 'null' but it is required
2022-02-05 05:07:56.504 INFO 7897 --- [ restartedMain] o.apache.catalina.core.StandardService : Stopping service [Tomcat]
2022-02-05 05:07:56.520 WARN 7897 --- [ restartedMain] ConfigServletWebServerApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.context.ApplicationContextException: Unable to start web server; nested exception is org.springframework.boot.web.server.WebServerException: Unable to start embedded Tomcat
2022-02-05 05:07:56.541 INFO 7897 --- [ restartedMain] ConditionEvaluationReportLoggingListener :
Here's my application.yaml:
management:
info:
git:
mode: full
metrics:
distribution:
percentiles:
http:
server:
requests: 0.5, 0.95, 0.99
percentiles-histogram:
http:
server:
requests: true
sla:
http:
server:
requests: 200ms, 400ms, 600ms
export:
datadog:
step: 30s
enabled: true
api-key: xxxxxxx
tags:
application: ${spring.application.name}
env: ${spring.profiles}
Can someone help me understand what is the issue? I tried searching around but din't get any solution. I tried replacing api-key with apiKey(I know it's silly) but no success.
Any help folks?
You are using Spring Boot's configuration properties in application.yml but you are also making your own DatadogMeterRegistry that doesn't use those configuration properties, and therefore it will not have the required API key configuration.
You can delete the MeterRegistryConfig class entirely and instead use the DatadogMeterRegistry that Spring Boot will auto-configure from configuration properties because you have the micrometer-registry-datadog dependency on your classpath. See this section of the Spring Boot documentation.
For me, it was just the hierarchy is changed when updated from Spring boot 2 -> 3.
Update the below:
management:
.....
metrics: // Changed to datadog
.....
export: // Changed to metrics
datadog: // Changed to export
step: 30s
enabled: true
api-key: xxxxxxx
.....
To :
management:
.....
datadog:
.....
metrics:
export:
step: 30s
enabled: true
api-key: xxxxxxx
.....
I have this issue in a Spring Boot microservices JHipster project, the issue started without changing any code. the microservers are deployed in a Kubernetes Microsoft Azure enviroment. The issue is related to a Hazelcast problem.
Stack trace:
2021-08-05T15:36:00.921185708Z 2021-08-05 15:36:00.920 ERROR 7 --- [ration.thread-0] com.hazelcast.security : [10.32.0.18]:5701 [dev] [3.12.7] Node could not join cluster. Before join check failed node is going to shutdown now!
2021-08-05T15:36:00.92269528Z 2021-08-05 15:36:00.922 ERROR 7 --- [ration.thread-0] com.hazelcast.security : [10.32.0.18]:5701 [dev] [3.12.7] Reason of failure for node join: Joining node's version 3.12.7 is not compatible with cluster version 3.9 (Rolling Member Upgrades are only supported in Hazelcast Enterprise)
2021-08-05T15:36:00.923792359Z 2021-08-05 15:36:00.923 WARN 7 --- [ration.thread-0] com.hazelcast.instance.Node : [10.32.0.18]:5701 [dev] [3.12.7] Terminating forcefully...
2021-08-05T15:36:00.924224151Z 2021-08-05 15:36:00.924 INFO 7 --- [ration.thread-0] com.hazelcast.instance.Node : [10.32.0.18]:5701 [dev] [3.12.7] Shutting down connection manager...
2021-08-05T15:36:00.929472551Z 2021-08-05 15:36:00.929 INFO 7 --- [ration.thread-0] com.hazelcast.nio.tcp.TcpIpConnection : [10.32.0.18]:5701 [dev] [3.12.7] Connection[id=1, /10.32.0.18:49367->/10.40.0.24:5701, qualifier=null, endpoint=[10.40.0.24]:5701, alive=false, type=MEMBER] closed. Reason: EndpointManager is stopping
2021-08-05T15:36:00.937643697Z 2021-08-05 15:36:00.937 INFO 7 --- [ration.thread-0] com.hazelcast.instance.Node : [10.32.0.18]:5701 [dev] [3.12.7] Shutting down node engine...
2021-08-05T15:36:01.002501471Z 2021-08-05 15:36:01.002 INFO 7 --- [ration.thread-0] com.hazelcast.instance.NodeExtension : [10.32.0.18]:5701 [dev] [3.12.7] Destroying node NodeExtension.
2021-08-05T15:36:01.002715567Z 2021-08-05 15:36:01.002 INFO 7 --- [ration.thread-0] com.hazelcast.instance.Node : [10.32.0.18]:5701 [dev] [3.12.7] Hazelcast Shutdown is completed in 79 ms.
2021-08-05T15:36:04.930340712Z 2021-08-05 15:36:04.926 ERROR 7 --- [ main] com.hazelcast.instance.Node : [10.32.0.18]:5701 [dev] [3.12.7] Could not join cluster. Shutting down now!
2021-08-05T15:36:04.930373712Z 2021-08-05 15:36:04.927 INFO 7 --- [ main] com.hazelcast.core.LifecycleService : [10.32.0.18]:5701 [dev] [3.12.7] [10.32.0.18]:5701 is SHUTTING_DOWN
2021-08-05T15:36:04.932312175Z 2021-08-05 15:36:04.931 INFO 7 --- [ main] com.hazelcast.instance.Node : [10.32.0.18]:5701 [dev] [3.12.7] Node is already shutting down... Waiting for shutdown process to complete...
2021-08-05T15:36:04.932877065Z 2021-08-05 15:36:04.932 INFO 7 --- [ main] com.hazelcast.core.LifecycleService : [10.32.0.18]:5701 [dev] [3.12.7] [10.32.0.18]:5701 is SHUTDOWN
2021-08-05T15:36:05.038848261Z 2021-08-05 15:36:05.038 WARN 7 --- [ main] com.hazelcast.util.PhoneHome : [10.32.0.18]:5701 [dev] [3.12.7] Could not schedule phone home task! Most probably Hazelcast failed to start.
2021-08-05T15:36:05.04047403Z 2021-08-05 15:36:05.039 INFO 7 --- [ main] com.hazelcast.instance.Node : [10.32.0.18]:5701 [dev] [3.12.7] Node is already shutting down... Waiting for shutdown process to complete...
2021-08-05T15:36:05.042475292Z 2021-08-05 15:36:05.042 WARN 7 --- [ main] ConfigServletWebServerApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.context.ApplicationContextException: Unable to start web server; nested exception is java.lang.RuntimeException: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'servletEndpointRegistrar' defined in class path resource [org/springframework/boot/actuate/autoconfigure/endpoint/web/ServletEndpointManagementContextConfiguration$WebMvcServletEndpointManagementContextConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.boot.actuate.endpoint.web.ServletEndpointRegistrar]: Factory method 'servletEndpointRegistrar' threw exception; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'healthEndpoint' defined in class path resource [org/springframework/boot/actuate/autoconfigure/health/HealthEndpointConfiguration.class]: Unsatisfied dependency expressed through method 'healthEndpoint' parameter 0; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'healthContributorRegistry' defined in class path resource [org/springframework/boot/actuate/autoconfigure/health/HealthEndpointConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.boot.actuate.health.HealthContributorRegistry]: Factory method 'healthContributorRegistry' threw exception; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'hazelcastHealthContributor' defined in class path resource [org/springframework/boot/actuate/autoconfigure/hazelcast/HazelcastHealthContributorAutoConfiguration.class]: Unsatisfied dependency expressed through method 'hazelcastHealthContributor' parameter 0; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'hazelcastInstance' defined in class path resource [.../.../.../.../config/CacheConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [com.hazelcast.core.HazelcastInstance]: Factory method 'hazelcastInstance' threw exception; nested exception is java.lang.IllegalStateException: Node failed to start!
2021-08-05T15:36:05.042724688Z 2021-08-05 15:36:05.042 INFO 7 --- [ main] x.x.x.x.config.CacheConfiguration : Closing Cache Manager
2021-08-05T15:36:05.254458785Z 2021-08-05 15:36:05.253 ERROR 7 --- [ main] o.s.boot.SpringApplication : Application run failed
2021-08-05T15:36:05.254488484Z
2021-08-05T15:36:05.254494684Z org.springframework.context.ApplicationContextException: Unable to start web server; nested exception is java.lang.RuntimeException: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'servletEndpointRegistrar' defined in class path resource [org/springframework/boot/actuate/autoconfigure/endpoint/web/ServletEndpointManagementContextConfiguration$WebMvcServletEndpointManagementContextConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.boot.actuate.endpoint.web.ServletEndpointRegistrar]: Factory method 'servletEndpointRegistrar' threw exception; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'healthEndpoint' defined in class path resource [org/springframework/boot/actuate/autoconfigure/health/HealthEndpointConfiguration.class]: Unsatisfied dependency expressed through method 'healthEndpoint' parameter 0; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'healthContributorRegistry' defined in class path resource [org/springframework/boot/actuate/autoconfigure/health/HealthEndpointConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.boot.actuate.health.HealthContributorRegistry]: Factory method 'healthContributorRegistry' threw exception; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'hazelcastHealthContributor' defined in class path resource [org/springframework/boot/actuate/autoconfigure/hazelcast/HazelcastHealthContributorAutoConfiguration.class]: Unsatisfied dependency expressed through method 'hazelcastHealthContributor' parameter 0; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'hazelcastInstance' defined in class path resource [.../.../.../.../config/CacheConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [com.hazelcast.core.HazelcastInstance]: Factory method 'hazelcastInstance' threw exception; nested exception is java.lang.IllegalStateException: Node failed to start!
2021-08-05T15:36:05.254519084Z at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.onRefresh(ServletWebServerApplicationContext.java:156)
2021-08-05T15:36:05.254522883Z at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:544)
2021-08-05T15:36:05.254526583Z at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:141)
2021-08-05T15:36:05.254530283Z at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:747)
2021-08-05T15:36:05.254534083Z at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:397)
2021-08-05T15:36:05.254537583Z at org.springframework.boot.SpringApplication.run(SpringApplication.java:315)
CacheConfiguration class
import io.github.jhipster.config.JHipsterProperties;
import com.hazelcast.config.*;
import com.hazelcast.core.HazelcastInstance;
import com.hazelcast.core.Hazelcast;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.boot.autoconfigure.web.ServerProperties;
import org.springframework.cache.CacheManager;
import org.springframework.boot.info.BuildProperties;
import org.springframework.boot.info.GitProperties;
import org.springframework.cache.interceptor.KeyGenerator;
import org.springframework.beans.factory.annotation.Autowired;
import io.github.jhipster.config.cache.PrefixedKeyGenerator;
import org.springframework.cache.annotation.EnableCaching;
import org.springframework.cloud.client.ServiceInstance;
import org.springframework.cloud.client.discovery.DiscoveryClient;
import org.springframework.cloud.client.serviceregistry.Registration;
import org.springframework.context.annotation.*;
import org.springframework.core.env.Environment;
import org.springframework.core.env.Profiles;
import javax.annotation.PreDestroy;
#Configuration
#EnableCaching
public class CacheConfiguration {
private GitProperties gitProperties;
private BuildProperties buildProperties;
private final Logger log = LoggerFactory.getLogger(CacheConfiguration.class);
private final Environment env;
private final ServerProperties serverProperties;
private final DiscoveryClient discoveryClient;
private Registration registration;
public CacheConfiguration(Environment env, ServerProperties serverProperties, DiscoveryClient discoveryClient) {
this.env = env;
this.serverProperties = serverProperties;
this.discoveryClient = discoveryClient;
}
#Autowired(required = false)
public void setRegistration(Registration registration) {
this.registration = registration;
}
#PreDestroy
public void destroy() {
log.info("Closing Cache Manager");
Hazelcast.shutdownAll();
}
#Bean
public CacheManager cacheManager(HazelcastInstance hazelcastInstance) {
log.debug("Starting HazelcastCacheManager");
return new com.hazelcast.spring.cache.HazelcastCacheManager(hazelcastInstance);
}
#Bean
public HazelcastInstance hazelcastInstance(JHipsterProperties jHipsterProperties) {
log.debug("Configuring Hazelcast");
HazelcastInstance hazelCastInstance = Hazelcast.getHazelcastInstanceByName("bpm");
if (hazelCastInstance != null) {
log.debug("Hazelcast already initialized");
return hazelCastInstance;
}
Config config = new Config();
config.setInstanceName("bpm");
config.getNetworkConfig().getJoin().getMulticastConfig().setEnabled(false);
if (this.registration == null) {
log.warn("No discovery service is set up, Hazelcast cannot create a cluster.");
} else {
// The serviceId is by default the application's name,
// see the "spring.application.name" standard Spring property
String serviceId = registration.getServiceId();
log.debug("Configuring Hazelcast clustering for instanceId: {}", serviceId);
// In development, everything goes through 127.0.0.1, with a different port
if (env.acceptsProfiles(Profiles.of(JHipsterConstants.SPRING_PROFILE_DEVELOPMENT))) {
log.debug("Application is running with the \"dev\" profile, Hazelcast " +
"cluster will only work with localhost instances");
System.setProperty("hazelcast.local.localAddress", "127.0.0.1");
config.getNetworkConfig().setPort(serverProperties.getPort() + 5701);
config.getNetworkConfig().getJoin().getTcpIpConfig().setEnabled(true);
for (ServiceInstance instance : discoveryClient.getInstances(serviceId)) {
String clusterMember = "127.0.0.1:" + (instance.getPort() + 5701);
log.debug("Adding Hazelcast (dev) cluster member {}", clusterMember);
config.getNetworkConfig().getJoin().getTcpIpConfig().addMember(clusterMember);
}
} else { // Production configuration, one host per instance all using port 5701
config.getNetworkConfig().setPort(5701);
config.getNetworkConfig().getJoin().getTcpIpConfig().setEnabled(true);
for (ServiceInstance instance : discoveryClient.getInstances(serviceId)) {
String clusterMember = instance.getHost() + ":5701";
log.debug("Adding Hazelcast (prod) cluster member {}", clusterMember);
config.getNetworkConfig().getJoin().getTcpIpConfig().addMember(clusterMember);
}
}
}
config.getMapConfigs().put("default", initializeDefaultMapConfig(jHipsterProperties));
// Full reference is available at: https://docs.hazelcast.org/docs/management-center/3.9/manual/html/Deploying_and_Starting.html
config.setManagementCenterConfig(initializeDefaultManagementCenterConfig(jHipsterProperties));
config.getMapConfigs().put("xxx.xxx.xxx.xxx.domain.*", initializeDomainMapConfig(jHipsterProperties));
return Hazelcast.newHazelcastInstance(config);
}
private ManagementCenterConfig initializeDefaultManagementCenterConfig(JHipsterProperties jHipsterProperties) {
ManagementCenterConfig managementCenterConfig = new ManagementCenterConfig();
managementCenterConfig.setEnabled(jHipsterProperties.getCache().getHazelcast().getManagementCenter().isEnabled());
managementCenterConfig.setUrl(jHipsterProperties.getCache().getHazelcast().getManagementCenter().getUrl());
managementCenterConfig.setUpdateInterval(jHipsterProperties.getCache().getHazelcast().getManagementCenter().getUpdateInterval());
return managementCenterConfig;
}
private MapConfig initializeDefaultMapConfig(JHipsterProperties jHipsterProperties) {
MapConfig mapConfig = new MapConfig();
/*
Number of backups. If 1 is set as the backup-count for example,
then all entries of the map will be copied to another JVM for
fail-safety. Valid numbers are 0 (no backup), 1, 2, 3.
*/
mapConfig.setBackupCount(jHipsterProperties.getCache().getHazelcast().getBackupCount());
/*
Valid values are:
NONE (no eviction),
LRU (Least Recently Used),
LFU (Least Frequently Used).
NONE is the default.
*/
mapConfig.setEvictionPolicy(EvictionPolicy.LRU);
/*
Maximum size of the map. When max size is reached,
map is evicted based on the policy defined.
Any integer between 0 and Integer.MAX_VALUE. 0 means
Integer.MAX_VALUE. Default is 0.
*/
mapConfig.setMaxSizeConfig(new MaxSizeConfig(0, MaxSizeConfig.MaxSizePolicy.USED_HEAP_SIZE));
return mapConfig;
}
private MapConfig initializeDomainMapConfig(JHipsterProperties jHipsterProperties) {
MapConfig mapConfig = new MapConfig();
mapConfig.setTimeToLiveSeconds(jHipsterProperties.getCache().getHazelcast().getTimeToLiveSeconds());
return mapConfig;
}
#Autowired(required = false)
public void setGitProperties(GitProperties gitProperties) {
this.gitProperties = gitProperties;
}
#Autowired(required = false)
public void setBuildProperties(BuildProperties buildProperties) {
this.buildProperties = buildProperties;
}
#Bean
public KeyGenerator keyGenerator() {
return new PrefixedKeyGenerator(this.gitProperties, this.buildProperties);
}
}
pom.xml version of dependencies
<maven.version>3.3.9</maven.version>
<java.version>1.8</java.version>
Hazelcast dependencies:
<dependency>
<groupId>com.hazelcast</groupId>
<artifactId>hazelcast</artifactId>
</dependency>
<dependency>
<groupId>com.hazelcast</groupId>
<artifactId>hazelcast-hibernate53</artifactId>
</dependency>
<dependency>
<groupId>com.hazelcast</groupId>
<artifactId>hazelcast-spring</artifactId>
</dependency>
please help.
Two processes with the (default) cluster name dev have found each other and attempted to cluster together. Versions are incompatible so this fails.
You could turn off discovery on both processes, but if you don't control the other this may not be viable.
Instead you could use config.getGroupConfig().setName('...') to change the name of your cluster to prevent the join attempt.
Startup error
2020-11-06 18:07:31.452 WARN 13120 --- [ main] ConfigServletWebServerApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.BeanDefinitionStoreException: Failed to parse configuration class [com.maple.MapleApplication]; nested exception is org.springframework.context.annotation.ConflictingBeanDefinitionException: Annotation-specified bean name 'a' for bean class [com.maple.a.d.a.a] conflicts with existing, non-compatible bean definition of same name and class [com.maple.a.b.a]
2020-11-06 18:07:31.463 ERROR 13120 --- [ main] o.s.boot.SpringApplication : Application run failed
org.springframework.beans.factory.BeanDefinitionStoreException: Failed to parse configuration class [com.maple.MapleApplication]; nested exception is org.springframework.context.annotation.ConflictingBeanDefinitionException: Annotation-specified bean name 'a' for bean class [com.maple.a.d.a.a] conflicts with existing, non-compatible bean definition of same name and class [com.maple.a.b.a]
I tried to use Spring definition.getBeanClassName() naming rules, but it didn’t work. Is it too much trouble if you want to manually set the name of each bean on the annotation? Can ProGuard provide the function of not repeating the class name? I haven’t found it yet.
I went back to programming my old program https://github.com/JonkiPro/REST-Web-Services. I've updated Spring Boot from version 15.6 to version 2.0.0. I have encountered many problems with compilation, but I can not deal with one. Well, during compilation, he throws me in the console
2018-03-18 21:54:53.339 ERROR 3220 --- [ost-startStop-1] com.zaxxer.hikari.HikariConfig : HikariPool-1 - jdbcUrl is required with driverClassName.
2018-03-18 21:54:55.392 INFO 3220 --- [ost-startStop-1] j.LocalContainerEntityManagerFactoryBean : Building JPA container EntityManagerFactory for persistence unit 'unit'
2018-03-18 21:54:56.698 INFO 3220 --- [ost-startStop-1] j.LocalContainerEntityManagerFactoryBean : Initialized JPA EntityManagerFactory for persistence unit 'unit'
2018-03-18 21:54:56.778 ERROR 3220 --- [ost-startStop-1] com.zaxxer.hikari.HikariConfig : HikariPool-1 - jdbcUrl is required with driverClassName.
2018-03-18 21:54:56.782 ERROR 3220 --- [ost-startStop-1] o.s.b.web.embedded.tomcat.TomcatStarter : Error starting Tomcat context. Exception: org.springframework.beans.factory.UnsatisfiedDependencyException. Message: Error creating bean with name 'webSecurityConfig': Unsatisfied dependency expressed through field 'userDetailsService'; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'userDetailsService' defined in file [C:\Users\Jonatan\Documents\GitHub\REST-Web-Services\web\out\production\classes\com\web\web\security\service\impl\UserDetailsServiceImpl.class]: Unsatisfied dependency expressed through constructor parameter 0; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'userRepository': Cannot create inner bean '(inner bean)#65d6e77b' of type [org.springframework.orm.jpa.SharedEntityManagerCreator] while setting bean property 'entityManager'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name '(inner bean)#65d6e77b': Cannot resolve reference to bean 'entityManagerFactory' while setting constructor argument; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'entityManagerFactory': Post-processing of FactoryBean's singleton object failed; nested exception is java.lang.IllegalArgumentException: jdbcUrl is required with driverClassName.
2018-03-18 21:54:56.821 WARN 3220 --- [ main] ConfigServletWebServerApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.context.ApplicationContextException: Unable to start web server; nested exception is org.springframework.boot.web.server.WebServerException: Unable to start embedded Tomcat
I've never had such a mistake. I do not know what it means completely. My properties for the base look like this
spring:
datasource:
driver-class-name: org.postgresql.Driver
url: jdbc:postgresql:database
username: root
password: root
schema: classpath:/db/init/schema.sql
I do not know how to deal with this error. I've been programming quite a long time, but for the first time I'm meeting the concept of hikari. I'm using a Tomcat(in Spring Boot) server and a PostgreSQL database.
I had the same issue in another context.
From the 79. Data Access - Configure a Custom DataSource
if you happen to have Hikari on the classpath, this basic setup does not work, because Hikari has no url property (but does have a jdbcUrl property)
Hikari is the default pool in spring boot 2.
so you can replace the config
url: jdbc:postgresql:database -> jdbc-url: jdbc:postgresql:database
or you can keep the config but you need to define another Bean to handle the mapping (aliases)
#Bean
#Primary
#ConfigurationProperties("app.datasource")
public DataSourceProperties dataSourceProperties() {
return new DataSourceProperties();
}
#Bean
#ConfigurationProperties("app.datasource")
public DataSource dataSource(DataSourceProperties properties) {
return properties.initializeDataSourceBuilder().
.build();
}
Either remove spring.datasource.driver-class-name property or rename the spring.datasource.url property to spring.datasource.jdbc-url.
This is reported in your error:
java.lang.IllegalArgumentException: jdbcUrl is required with driverClassName
First option looks cleaner and Spring Boot will figure out the default driver class name based on the spring.datasource.url property value (see org.springframework.boot.jdbc.DatabaseDriver class if you want to debug this).
I have spring boot application which use 2 databases. I defined 2 configurations providing specified datasources. I want to have that datasources managed separately by liquibase. I defined 2 separated changelog files.
The problem is that I can't define 2 separate beans for liquibase.
Here are my config classes:
...
public class CCSConfiguration {
...
#Bean
#ConfigurationProperties("ccs.liquibase")
public LiquibaseProperties ccsLiquibaseProperties() {
return new LiquibaseProperties();
}
#Bean
public SpringLiquibase ccsLiquibase(LiquibaseProperties liquibaseProperties) {
...
}
...
}
...
public class CCAConfiguration {
...
#ConfigurationProperties("cca.liquibase")
public LiquibaseProperties ccaLiquibaseProperties() {
return new LiquibaseProperties();
}
#Bean
public SpringLiquibase ccaLiquibase(LiquibaseProperties liquibaseProperties) {
...
}
...
}
And properties:
cca:
liquibase:
change-log: classpath:config/liquibase/cca/master.xml
ccs:
liquibase:
change-log: classpath:config/liquibase/ccs/master.xml
With this config i get following error while running appliction:
2017-04-11 14:26:55.664 WARN 34292 --- [ restartedMain] ationConfigEmbeddedWebApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.NoSuchBeanDefinitionException: No bean named 'liquibase' available
2017-04-11 14:26:55.711 WARN 34292 --- [ restartedMain] o.s.boot.SpringApplication : Error handling failed (Error creating bean with name 'delegatingApplicationListener' defined in class path resource [org/springframework/security/config/annotation/web/configuration/WebSecurityConfiguration.class]: BeanPostProcessor before instantiation of bean failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.cache.config.internalCacheAdvisor' defined in class path resource [org/springframework/cache/annotation/ProxyCachingConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.cache.interceptor.BeanFactoryCacheOperationSourceAdvisor]: Factory method 'cacheAdvisor' threw exception; nested exception is java.lang.NullPointerException)
2017-04-11 14:26:55.939 ERROR 34292 --- [ restartedMain] o.s.b.d.LoggingFailureAnalysisReporter :
***************************
APPLICATION FAILED TO START
***************************
Description:
A component required a bean named 'liquibase' that could not be found.
Action:
Consider defining a bean named 'liquibase' in your configuration.
So, is it possible to define multiple liquibase beans for different datasources?
there are two options:
you define a bean named liquibase to let spring-boot integrated process to update your schema on you first DS. You have to handle the second one by hand
you disable liquibase automatic update at startup with
enabled: false
and define your way DS and liquibase beans to update your two databases