I'm trying to setup actuator metrics in Spring Boot 2 RESTful app, however - the list of supported metrics below does not include the
http.server.requests metric,
which is part of Spring MVC metrics, as described in https://docs.spring.io/spring-boot/docs/current/reference/htmlsingle/#production-ready-metrics-spring-mvc
Below are the available metrics that are returned:
{
"names": [
"jvm.threads.states",
"jvm.memory.used",
"jvm.gc.memory.promoted",
"jvm.memory.max",
"jvm.gc.max.data.size",
"jvm.memory.committed",
"system.cpu.count",
"logback.events",
"tomcat.global.sent",
"jvm.buffer.memory.used",
"tomcat.sessions.created",
"jvm.threads.daemon",
"system.cpu.usage",
"jvm.gc.memory.allocated",
"tomcat.global.request.max",
"tomcat.global.request",
"tomcat.sessions.expired",
"jvm.threads.live",
"jvm.threads.peak",
"tomcat.global.received",
"process.uptime",
"tomcat.sessions.rejected",
"process.cpu.usage",
"tomcat.threads.config.max",
"jvm.classes.loaded",
"jvm.classes.unloaded",
"tomcat.global.error",
"tomcat.sessions.active.current",
"tomcat.sessions.alive.max",
"jvm.gc.live.data.size",
"tomcat.threads.current",
"jvm.gc.pause",
"jvm.buffer.count",
"jvm.buffer.total.capacity",
"tomcat.sessions.active.max",
"tomcat.threads.busy",
"process.start.time"
]
}
I have included following dependencies (among all):
...
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>io.micrometer</groupId>
<artifactId>micrometer-core</artifactId>
</dependency>
<dependency>
<groupId>io.micrometer</groupId>
<artifactId>micrometer-registry-prometheus</artifactId>
</dependency>
...
Is there a way to include the http.server.requests metric in my Spring Boot 2 application?
As it turned out - you need to do at least one http request to the application itself - excluding the management endpoints.
Just hitting any url within the app with a browser caused the http.server.requests to appear in the list of metrics.
Related
I wanna use Kafka client in Spring boot.
After reading the offical documentaion,
I added the maven dependency.
Then I tried to start Spring Boot. It throws
ClassNotFoundException.
This class is 'org.springframework.kafka.listener.RecordInterceptor '
Could anyone can solve this problem?
Version:
<spring.boot.version>2.2.1.RELEASE</spring.boot.version>
<spring.version>5.2.1.RELEASE</spring.version>
pom.xml:
<dependency>
<groupId>org.springframework.kafka</groupId>
<artifactId>spring-kafka</artifactId>
<version>${spring.boot.version}</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
<version>${spring.boot.version}</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-security</artifactId>
<version>${spring.boot.version}</version>
</dependency>
When using Spring Boot, you should let boot manage the version, for Boot 2.2.1, the proper version is 2.3.3.
Docs.
But, when using Boot, you can omit the version and Boot will automatically use the right version.
<dependency>
<groupId>org.springframework.kafka</groupId>
<artifactId>spring-kafka</artifactId>
</dependency>
I am using Spring boot version 2.2.0.M4. When I am adding dependencies
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-netflix-eureka-client</artifactId>
<version>2.1.2.RELEASE</version>
</dependency>
while starting server it fails to start with below mentioned error
APPLICATION FAILED TO START
Description:
An attempt was made to call a method that does not exist. The attempt was made from the following location:
org.springframework.cloud.client.discovery.health.DiscoveryCompositeHealthIndicator.<init>(DiscoveryCompositeHealthIndicator.java:42)
The correct way of working with Spring Cloud projects versioning is using the dependencyManagement plugin and release trains versions rather than passing versions of separate artifacts manually.
You can get a correct pom generated automatically (with all the correct versions) at start.spring.io.
On the date that question was posted, a version of Spring Cloud supporting Spring Boot 2.2.x has not been released yet. The latest Spring Cloud release version available is Greenwich.SR2, that supports Spring Boot 2.1.6.RELEASE.
UPDATE: Spring Cloud Hoxton.M1 that supports Spring Boot 2.2.0.M4 was released on 3rd July 2019. You can now use it and also generate correct build files with this version from start.spring.io.
For the following dependency:
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.3.4.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
The Following spring cloud version worked for me.
<properties>
<java.version>11</java.version>
<spring-cloud.version>Hoxton.SR4</spring-cloud.version>
</properties>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-dependencies</artifactId>
<version>${spring-cloud.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
I am building an application where Rest endpoints uses, boot bindings to send Neo4j Entitites to Neo4j Repo, and thats the pattern we repeated few times across jpa backed repositories. In current configuration;
<dependency>
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-neo4j</artifactId>
</dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
JPA repositories and neo4j repositories works ok, until i add;
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
Erros i am facing are;
APPLICATION FAILED TO START
Description:
Constructor in org.springframework.data.neo4j.repository.config.Neo4jOgmEntityInstantiatorConfigurationBean required a single bean, but 2 were found:
- mvcConversionService: defined by method 'mvcConversionService' in class path resource [org/springframework/boot/autoconfigure/web/servlet/WebMvcAutoConfiguration$EnableWebMvcConfiguration.class]
- integrationConversionService: defined in null
:: Spring Boot :: (v2.1.0.M2)
:: Java 8
Updating project dependencies to
<spring.boot.version>2.1.0.RELEASE</spring.boot.version>
<spring.cloud.version>2.1.0.RC3</spring.cloud.version>
has fixed the issue as per #meistermeier suggestion.
I can't make Arquillian and Websphere Embedded EJBContainer work smoothly together.
Because I can't use the arquillian-was-embedded-8 Jar File (Missing in Company Maven repository and Jenkins).
I try to load the WebSphereExtension (LoadableExtension) in my Junit test without success. Can someone point me to the right solution?
My second question is, even if i load this jar file locally in my IDE i also have problems with the interface (on my EJB's). See the same issue here:
[arquillian-was-embedded-8 runs but can't inject EJB. NullPointerException
How can i avoid this?
My maven Dependencies:
<dependency>
<groupId>com.ibm.websphere</groupId>
<artifactId>com.ibm.ws.ejb.embeddableContainer</artifactId>
<version>8.0.0.11</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.ibm.websphere</groupId>
<artifactId>endorsed_apis</artifactId>
<version>8.0.0.11</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.jboss.arquillian</groupId>
<artifactId>arquillian-bom</artifactId>
<version>1.1.4.Final</version>
<type>pom</type>
<scope>import</scope>
</dependency>
<dependency>
<groupId>org.jboss.arquillian</groupId>
<artifactId>arquillian-build</artifactId>
<version>1.1.4.Final</version>
<type>pom</type>
<scope>import</scope>
</dependency>
<dependency>
<groupId>org.jboss.arquillian.container</groupId>
<artifactId>arquillian-container-spi</artifactId>
<version>1.1.4.Final</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.jboss.arquillian.junit</groupId>
<artifactId>arquillian-junit-container</artifactId>
<version>1.1.4.Final</version>
<scope>test</scope>
</dependency>
Java 6, Junit 4.12, IDE Luna 4.4.2
Thank you in advance, I would appreciate it a lot
I found the solution. I don't need to build the artifacts if I use this
in src/test/resources/META-INF/services/org.jboss.arquillian.core.spi.LoadableExtension (this is a file name)
with the contents --> /path/to/WebSphereExtension
The second problem I resolve like this:
#EJB(mappedName = "java:global/test/MyEjbTest!com.home.coem.Processor")
Processor test1;
Processor is the interface name and MyEjbTest is the implementation bean!
I hope it will help somebody
In my webapp, I am using Spring MVC as my controller layer. However, using the tags provided by the MVC context:
<mvn:annotation-driven />
<mvc:resources />
causes a log4j exception:
<Mar 26, 2012 1:49:50 PM EDT> <Warning> <HTTP> <BEA-101162> <User defined listener
org.springframework.web.context.ContextLoaderListener failed:
java.lang.NoClassDefFoundError: org/apache/log4j/spi/ThrowableInformation.
java.lang.NoClassDefFoundError: org/apache/log4j/spi/ThrowableInformation
at org.apache.log4j.spi.LoggingEvent.<init>(LoggingEvent.java:165)
at org.apache.log4j.Category.forcedLog(Category.java:391)
at org.apache.log4j.Category.log(Category.java:856)
at org.slf4j.impl.Log4jLoggerAdapter.log(Log4jLoggerAdapter.java:597)
at org.apache.commons.logging.impl.SLF4JLocationAwareLog.error(SLF4JLocationAwareLog.java:225)
Truncated. see log file for complete stacktrace
(LoggingEvent.java:165)
at org.apache.log4j.Category.forcedLog(Category.java:391)
at org.apache.log4j.Category.log(Category.java:856)
at org.slf4j.impl.Log4jLoggerAdapter.log(Log4jLoggerAdapter.java:597)
at org.apache.commons.logging.impl.SLF4JLocationAwareLog.error(SLF4JLocationAwareLog.java:225)
Truncated. see log file for complete stacktrace
Basic stuff:
log4j-1.2.16.jar is defined in the maven POM and is in the application library.
Since it's a weblogic server, I have the following in the weblogic.xml file to try to prevent conflicts:
<wls:prefer-application-packages>
<wls:package-name>org.apache.log4j.*</wls:package-name>
</wls:prefer-application-packages>
(Update) I manually excluded commons-logging in the maven POM for the application.
(Update) I already had the slf4j jars in my Maven POM (removing the jcl-over-slf4j has no effect):
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>jcl-over-slf4j</artifactId>
<version>1.5.8</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>1.5.8</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
<version>1.5.8</version>
<scope>runtime</scope>
</dependency>
Basically, I need to exclude the basic css and js directories as web as a single directory under WEB-INF/ that contains some jspf files that I do NOT wish to write a controller for (dropdown menus definitions used by jquery superfish).
Any help?
Add slf4j-log4 connector to the POM:
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
<version>${slf4j-version}</version>
<scope>runtime</scope>
</dependency>