Background info
- I have a jmeter test plan which is verifying json API calls. I wanted to use ATLANTBH jsonpathassertion component which seems to be far simpler rather than a regex extractor and then an assertion. I have added an assertion step using jp#gc - JSON Path Assertion with an example JSON Path: $.results[0].fulfilments[0].fulfilmentType against an expected value
Problem
Running tests in jmeter (2.1.3) gui works successfully but fails from command line or when run in jenkins environment. I have added the jmeter-plugins in the pom
thanks for any help
<plugin>
<groupId>com.lazerycode.jmeter</groupId>
<artifactId>jmeter-maven-plugin</artifactId>
<version>1.10.1</version>
<configuration>
<testResultsTimestamp>false</testResultsTimestamp>
<propertiesUser>
<server>${server}</server>
</propertiesUser>
</configuration>
<executions>
<execution>
<id>jmeter-tests</id>
<phase>verify</phase>
<goals>
<goal>jmeter</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>kg.apc</groupId>
<artifactId>jmeter-plugins</artifactId>
<version>1.0.0</version>
</plugin>
Jmeter logs as below
2015/09/02 11:21:29 ERROR - jmeter.JMeter: Error in NonGUIDriver java.lang.IllegalArgumentException: Problem loading XML from:'C:\PP\functional-test\src\test\jmeter\BAT_Scenarios.jmx', conversion error com.thoughtworks.xstream.converters.ConversionException: com.atlantbh.jmeter.plugins.jsonutils.jsonpathassertion.JSONPathAssertion : com.atlantbh.jmeter.plugins.jsonutils.jsonpathassertion.JSONPathAssertion
---- Debugging information ----
message : com.atlantbh.jmeter.plugins.jsonutils.jsonpathassertion.JSONPathAssertion
cause-exception : com.thoughtworks.xstream.mapper.CannotResolveClassException
cause-message : com.atlantbh.jmeter.plugins.jsonutils.jsonpathassertion.JSONPathAssertion
class : org.apache.jorphan.collections.ListedHashTree
required-type : org.apache.jorphan.collections.ListedHashTree
converter-type : org.apache.jmeter.save.converters.HashTreeConverter
path : /jmeterTestPlan/hashTree/hashTree/hashTree/hashTree[3]/hashTree/com.atlantbh.jmeter.plugins.jsonutils.jsonpathassertion.JSONPathAssertion
line number : 279
------------------------------- : com.atlantbh.jmeter.plugins.jsonutils.jsonpathassertion.JSONPathAssertion : com.atlantbh.jmeter.plugins.jsonutils.jsonpathassertion.JSONPathAssertion
---- Debugging information ----
message : com.atlantbh.jmeter.plugins.jsonutils.jsonpathassertion.JSONPathAssertion
cause-exception : com.thoughtworks.xstream.mapper.CannotResolveClassException
cause-message : com.atlantbh.jmeter.plugins.jsonutils.jsonpathassertion.JSONPathAssertion
class : org.apache.jorphan.collections.ListedHashTree
required-type : org.apache.jorphan.collections.ListedHashTree
converter-type : org.apache.jmeter.save.converters.HashTreeConverter
path : /jmeterTestPlan/hashTree/hashTree/hashTree/hashTree[3]/hashTree/com.atlantbh.jmeter.plugins.jsonutils.jsonpathassertion.JSONPathAssertion
line number : 279
-------------------------------
message : com.atlantbh.jmeter.plugins.jsonutils.jsonpathassertion.JSONPathAssertion : com.atlantbh.jmeter.plugins.jsonutils.jsonpathassertion.JSONPathAssertion
---- Debugging information ----
message : com.atlantbh.jmeter.plugins.jsonutils.jsonpathassertion.JSONPathAssertion
cause-exception : com.thoughtworks.xstream.mapper.CannotResolveClassException
cause-message : com.atlantbh.jmeter.plugins.jsonutils.jsonpathassertion.JSONPathAssertion
class : org.apache.jorphan.collections.ListedHashTree
required-type : org.apache.jorphan.collections.ListedHashTree
converter-type : org.apache.jmeter.save.converters.HashTreeConverter
path : /jmeterTestPlan/hashTree/hashTree/hashTree/hashTree[3]/hashTree/com.atlantbh.jmeter.plugins.jsonutils.jsonpathassertion.JSONPathAssertion
line number : 279
-------------------------------
cause-exception : com.thoughtworks.xstream.converters.ConversionException
cause-message : com.atlantbh.jmeter.plugins.jsonutils.jsonpathassertion.JSONPathAssertion : com.atlantbh.jmeter.plugins.jsonutils.jsonpathassertion.JSONPathAssertion
first-jmeter-class : org.apache.jmeter.save.converters.HashTreeConverter.unmarshal(HashTreeConverter.java:67)
class : org.apache.jmeter.save.ScriptWrapper
required-type : org.apache.jorphan.collections.ListedHashTree
converter-type : org.apache.jmeter.save.ScriptWrapperConverter
path : /jmeterTestPlan/hashTree/hashTree/hashTree/hashTree[3]/hashTree/com.atlantbh.jmeter.plugins.jsonutils.jsonpathassertion.JSONPathAssertion
line number : 279
version : 2.13 r1665067
-------------------------------
at org.apache.jmeter.save.SaveService.readTree(SaveService.java:586)
at org.apache.jmeter.save.SaveService.loadTree(SaveService.java:537)
at org.apache.jmeter.JMeter.runNonGui(JMeter.java:750)
at org.apache.jmeter.JMeter.startNonGui(JMeter.java:737)
at org.apache.jmeter.JMeter.start(JMeter.java:395)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at org.apache.jmeter.NewDriver.main(NewDriver.java:264)
Caused by: com.thoughtworks.xstream.converters.ConversionException: com.atlantbh.jmeter.plugins.jsonutils.jsonpathassertion.JSONPathAssertion : com.atlantbh.jmeter.plugins.jsonutils.jsonpathassertion.JSONPathAssertion
---- Debugging information ----
message : com.atlantbh.jmeter.plugins.jsonutils.jsonpathassertion.JSONPathAssertion
cause-exception : com.thoughtworks.xstream.mapper.CannotResolveClassException
cause-message : com.atlantbh.jmeter.plugins.jsonutils.jsonpathassertion.JSONPathAssertion
class : org.apache.jorphan.collections.ListedHashTree
required-type : org.apache.jorphan.collections.ListedHashTree
converter-type : org.apache.jmeter.save.converters.HashTreeConverter
path : /jmeterTestPlan/hashTree/hashTree/hashTree/hashTree[3]/hashTree/com.atlantbh.jmeter.plugins.jsonutils.jsonpathassertion.JSONPathAssertion
line number : 279
------------------------------- : com.atlantbh.jmeter.plugins.jsonutils.jsonpathassertion.JSONPathAssertion : com.atlantbh.jmeter.plugins.jsonutils.jsonpathassertion.JSONPathAssertion
---- Debugging information ----
message : com.atlantbh.jmeter.plugins.jsonutils.jsonpathassertion.JSONPathAssertion
cause-exception : com.thoughtworks.xstream.mapper.CannotResolveClassException
cause-message : com.atlantbh.jmeter.plugins.jsonutils.jsonpathassertion.JSONPathAssertion
class : org.apache.jorphan.collections.ListedHashTree
required-type : org.apache.jorphan.collections.ListedHashTree
converter-type : org.apache.jmeter.save.converters.HashTreeConverter
path : /jmeterTestPlan/hashTree/hashTree/hashTree/hashTree[3]/hashTree/com.atlantbh.jmeter.plugins.jsonutils.jsonpathassertion.JSONPathAssertion
line number : 279
-------------------------------
message : com.atlantbh.jmeter.plugins.jsonutils.jsonpathassertion.JSONPathAssertion : com.atlantbh.jmeter.plugins.jsonutils.jsonpathassertion.JSONPathAssertion
---- Debugging information ----
message : com.atlantbh.jmeter.plugins.jsonutils.jsonpathassertion.JSONPathAssertion
cause-exception : com.thoughtworks.xstream.mapper.CannotResolveClassException
cause-message : com.atlantbh.jmeter.plugins.jsonutils.jsonpathassertion.JSONPathAssertion
class : org.apache.jorphan.collections.ListedHashTree
required-type : org.apache.jorphan.collections.ListedHashTree
converter-type : org.apache.jmeter.save.converters.HashTreeConverter
path : /jmeterTestPlan/hashTree/hashTree/hashTree/hashTree[3]/hashTree/com.atlantbh.jmeter.plugins.jsonutils.jsonpathassertion.JSONPathAssertion
line number : 279
-------------------------------
cause-exception : com.thoughtworks.xstream.converters.ConversionException
cause-message : com.atlantbh.jmeter.plugins.jsonutils.jsonpathassertion.JSONPathAssertion : com.atlantbh.jmeter.plugins.jsonutils.jsonpathassertion.JSONPathAssertion
first-jmeter-class : org.apache.jmeter.save.converters.HashTreeConverter.unmarshal(HashTreeConverter.java:67)
class : org.apache.jmeter.save.ScriptWrapper
required-type : org.apache.jorphan.collections.ListedHashTree
converter-type : org.apache.jmeter.save.ScriptWrapperConverter
path : /jmeterTestPlan/hashTree/hashTree/hashTree/hashTree[3]/hashTree/com.atlantbh.jmeter.plugins.jsonutils.jsonpathassertion.JSONPathAssertion
line number : 279
version : 2.13 r1665067
-------------------------------
at org.apache.jmeter.save.ScriptWrapperConverter.createConversionException(ScriptWrapperConverter.java:105)
at org.apache.jmeter.save.ScriptWrapperConverter.unmarshal(ScriptWrapperConverter.java:99)
at com.thoughtworks.xstream.core.TreeUnmarshaller.convert(TreeUnmarshaller.java:72)
at com.thoughtworks.xstream.core.AbstractReferenceUnmarshaller.convert(AbstractReferenceUnmarshaller.java:65)
at com.thoughtworks.xstream.core.TreeUnmarshaller.convertAnother(TreeUnmarshaller.java:66)
at com.thoughtworks.xstream.core.TreeUnmarshaller.convertAnother(TreeUnmarshaller.java:50)
at com.thoughtworks.xstream.core.TreeUnmarshaller.start(TreeUnmarshaller.java:134)
at com.thoughtworks.xstream.core.AbstractTreeMarshallingStrategy.unmarshal(AbstractTreeMarshallingStrategy.java:32)
at com.thoughtworks.xstream.XStream.unmarshal(XStream.java:1206)
at com.thoughtworks.xstream.XStream.unmarshal(XStream.java:1190)
at com.thoughtworks.xstream.XStream.fromXML(XStream.java:1061)
at org.apache.jmeter.save.SaveService.readTree(SaveService.java:559)
... 9 more
Caused by: com.thoughtworks.xstream.converters.ConversionException: com.atlantbh.jmeter.plugins.jsonutils.jsonpathassertion.JSONPathAssertion : com.atlantbh.jmeter.plugins.jsonutils.jsonpathassertion.JSONPathAssertion
---- Debugging information ----
message : com.atlantbh.jmeter.plugins.jsonutils.jsonpathassertion.JSONPathAssertion
cause-exception : com.thoughtworks.xstream.mapper.CannotResolveClassException
cause-message : com.atlantbh.jmeter.plugins.jsonutils.jsonpathassertion.JSONPathAssertion
class : org.apache.jorphan.collections.ListedHashTree
required-type : org.apache.jorphan.collections.ListedHashTree
converter-type : org.apache.jmeter.save.converters.HashTreeConverter
path : /jmeterTestPlan/hashTree/hashTree/hashTree/hashTree[3]/hashTree/com.atlantbh.jmeter.plugins.jsonutils.jsonpathassertion.JSONPathAssertion
line number : 279
-------------------------------
at com.thoughtworks.xstream.core.TreeUnmarshaller.convert(TreeUnmarshaller.java:79)
at com.thoughtworks.xstream.core.AbstractReferenceUnmarshaller.convert(AbstractReferenceUnmarshaller.java:65)
at com.thoughtworks.xstream.core.TreeUnmarshaller.convertAnother(TreeUnmarshaller.java:66)
at com.thoughtworks.xstream.core.TreeUnmarshaller.convertAnother(TreeUnmarshaller.java:50)
at com.thoughtworks.xstream.converters.collections.AbstractCollectionConverter.readItem(AbstractCollectionConverter.java:71)
at org.apache.jmeter.save.converters.HashTreeConverter.unmarshal(HashTreeConverter.java:67)
at com.thoughtworks.xstream.core.TreeUnmarshaller.convert(TreeUnmarshaller.java:72)
at com.thoughtworks.xstream.core.AbstractReferenceUnmarshaller.convert(AbstractReferenceUnmarshaller.java:65)
at com.thoughtworks.xstream.core.TreeUnmarshaller.convertAnother(TreeUnmarshaller.java:66)
at com.thoughtworks.xstream.core.TreeUnmarshaller.convertAnother(TreeUnmarshaller.java:50)
at com.thoughtworks.xstream.converters.collections.AbstractCollectionConverter.readItem(AbstractCollectionConverter.java:71)
at org.apache.jmeter.save.converters.HashTreeConverter.unmarshal(HashTreeConverter.java:67)
at com.thoughtworks.xstream.core.TreeUnmarshaller.convert(TreeUnmarshaller.java:72)
at com.thoughtworks.xstream.core.AbstractReferenceUnmarshaller.convert(AbstractReferenceUnmarshaller.java:65)
at com.thoughtworks.xstream.core.TreeUnmarshaller.convertAnother(TreeUnmarshaller.java:66)
at com.thoughtworks.xstream.core.TreeUnmarshaller.convertAnother(TreeUnmarshaller.java:50)
at com.thoughtworks.xstream.converters.collections.AbstractCollectionConverter.readItem(AbstractCollectionConverter.java:71)
at org.apache.jmeter.save.converters.HashTreeConverter.unmarshal(HashTreeConverter.java:67)
at com.thoughtworks.xstream.core.TreeUnmarshaller.convert(TreeUnmarshaller.java:72)
at com.thoughtworks.xstream.core.AbstractReferenceUnmarshaller.convert(AbstractReferenceUnmarshaller.java:65)
at com.thoughtworks.xstream.core.TreeUnmarshaller.convertAnother(TreeUnmarshaller.java:66)
at com.thoughtworks.xstream.core.TreeUnmarshaller.convertAnother(TreeUnmarshaller.java:50)
at com.thoughtworks.xstream.converters.collections.AbstractCollectionConverter.readItem(AbstractCollectionConverter.java:71)
at org.apache.jmeter.save.converters.HashTreeConverter.unmarshal(HashTreeConverter.java:67)
at com.thoughtworks.xstream.core.TreeUnmarshaller.convert(TreeUnmarshaller.java:72)
at com.thoughtworks.xstream.core.AbstractReferenceUnmarshaller.convert(AbstractReferenceUnmarshaller.java:65)
at com.thoughtworks.xstream.core.TreeUnmarshaller.convertAnother(TreeUnmarshaller.java:66)
at com.thoughtworks.xstream.core.TreeUnmarshaller.convertAnother(TreeUnmarshaller.java:50)
at org.apache.jmeter.save.ScriptWrapperConverter.unmarshal(ScriptWrapperConverter.java:95)
... 19 more
Caused by: com.thoughtworks.xstream.mapper.CannotResolveClassException: com.atlantbh.jmeter.plugins.jsonutils.jsonpathassertion.JSONPathAssertion
at com.thoughtworks.xstream.mapper.DefaultMapper.realClass(DefaultMapper.java:79)
at com.thoughtworks.xstream.mapper.MapperWrapper.realClass(MapperWrapper.java:30)
at com.thoughtworks.xstream.mapper.DynamicProxyMapper.realClass(DynamicProxyMapper.java:55)
at com.thoughtworks.xstream.mapper.MapperWrapper.realClass(MapperWrapper.java:30)
at com.thoughtworks.xstream.mapper.PackageAliasingMapper.realClass(PackageAliasingMapper.java:88)
at com.thoughtworks.xstream.mapper.MapperWrapper.realClass(MapperWrapper.java:30)
at com.thoughtworks.xstream.mapper.ClassAliasingMapper.realClass(ClassAliasingMapper.java:79)
at com.thoughtworks.xstream.mapper.MapperWrapper.realClass(MapperWrapper.java:30)
at com.thoughtworks.xstream.mapper.MapperWrapper.realClass(MapperWrapper.java:30)
at com.thoughtworks.xstream.mapper.MapperWrapper.realClass(MapperWrapper.java:30)
at com.thoughtworks.xstream.mapper.MapperWrapper.realClass(MapperWrapper.java:30)
at com.thoughtworks.xstream.mapper.MapperWrapper.realClass(MapperWrapper.java:30)
at com.thoughtworks.xstream.mapper.MapperWrapper.realClass(MapperWrapper.java:30)
at com.thoughtworks.xstream.mapper.ArrayMapper.realClass(ArrayMapper.java:74)
at com.thoughtworks.xstream.mapper.MapperWrapper.realClass(MapperWrapper.java:30)
at com.thoughtworks.xstream.mapper.MapperWrapper.realClass(MapperWrapper.java:30)
at com.thoughtworks.xstream.mapper.MapperWrapper.realClass(MapperWrapper.java:30)
at com.thoughtworks.xstream.mapper.MapperWrapper.realClass(MapperWrapper.java:30)
at com.thoughtworks.xstream.mapper.MapperWrapper.realClass(MapperWrapper.java:30)
at com.thoughtworks.xstream.mapper.MapperWrapper.realClass(MapperWrapper.java:30)
at com.thoughtworks.xstream.mapper.SecurityMapper.realClass(SecurityMapper.java:71)
at com.thoughtworks.xstream.mapper.MapperWrapper.realClass(MapperWrapper.java:30)
at com.thoughtworks.xstream.mapper.MapperWrapper.realClass(MapperWrapper.java:30)
at org.apache.jmeter.save.SaveService$XStreamWrapper$1.realClass(SaveService.java:94)
at com.thoughtworks.xstream.mapper.MapperWrapper.realClass(MapperWrapper.java:30)
at com.thoughtworks.xstream.mapper.CachingMapper.realClass(CachingMapper.java:47)
at com.thoughtworks.xstream.core.util.HierarchicalStreams.readClassType(HierarchicalStreams.java:29)
at com.thoughtworks.xstream.converters.collections.AbstractCollectionConverter.readItem(AbstractCollectionConverter.java:70)
at org.apache.jmeter.save.converters.HashTreeConverter.unmarshal(HashTreeConverter.java:67)
at com.thoughtworks.xstream.core.TreeUnmarshaller.convert(TreeUnmarshaller.java:72)
... 47 more
It looks like your POM is configured incorrectly. I would expect it to look like this:
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.example</groupId>
<artifactId>tst</artifactId>
<packaging>jar</packaging>
<version>1.0-SNAPSHOT</version>
<build>
<plugins>
<plugin>
<groupId>com.lazerycode.jmeter</groupId>
<artifactId>jmeter-maven-plugin</artifactId>
<version>1.10.1</version>
<configuration>
<testResultsTimestamp>false</testResultsTimestamp>
<jmeterPlugins>
<plugin>
<groupId>kg.apc</groupId>
<artifactId>jmeter-plugins</artifactId>
</plugin>
</jmeterPlugins>
</configuration>
<executions>
<execution>
<id>jmeter-tests</id>
<phase>verify</phase>
<goals>
<goal>jmeter</goal>
</goals>
</execution>
</executions>
<dependencies>
<dependency>
<groupId>kg.apc</groupId>
<artifactId>jmeter-plugins</artifactId>
<version>1.0.0</version>
</dependency>
</dependencies>
</plugin>
</plugins>
</build>
</project>
Even then you may run into transitive dependency issues if you are not using Maven 3:
https://github.com/jmeter-maven-plugin/jmeter-maven-plugin/issues/92
Or different transitive dependency issues if you update to version 1.3.0 of jmeter-plugins:
https://github.com/jmeter-maven-plugin/jmeter-maven-plugin/issues/131
Hurry up the next release of Jmeter :/
Related
I am trying to launch a simple Eureka server via Spring Cloud Netflix and in Kotlin, but I keep receiving Request execution error. endpoint=DefaultEndpoint{ serviceUrl='http://localhost:8761/eureka/}, exception=java.net.ConnectException: Connection refused stacktrace=com.sun.jersey.api.client.ClientHandlerException: java.net.ConnectException: Connection refused, no matter how many times I change my application.properties in a variety of different ways, with the help of multiple posts on here. How can I fix this?
My pom.xml:
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.7.3</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-dependencies</artifactId>
<version>2021.0.4</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
<artifactId>discovery-server</artifactId>
<groupId>org.shopping</groupId>
<version>0.0.1-SNAPSHOT</version>
<packaging>pom</packaging>
<name>discovery-server</name>
<properties>
<java.version>11</java.version>
<kotlin.version>1.6.21</kotlin.version>
<spring-cloud.version>2021.0.4</spring-cloud.version>
</properties>
<dependencies>
<dependency>
<groupId>org.jetbrains.kotlin</groupId>
<artifactId>kotlin-reflect</artifactId>
</dependency>
<dependency>
<groupId>org.jetbrains.kotlin</groupId>
<artifactId>kotlin-stdlib-jdk8</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-config</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-netflix-eureka-server</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-bootstrap</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<sourceDirectory>${project.basedir}/src/main/kotlin</sourceDirectory>
<testSourceDirectory>${project.basedir}/src/test/kotlin</testSourceDirectory>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.jetbrains.kotlin</groupId>
<artifactId>kotlin-maven-plugin</artifactId>
<configuration>
<args>
<arg>-Xjsr305=strict</arg>
</args>
<compilerPlugins>
<plugin>spring</plugin>
</compilerPlugins>
</configuration>
<dependencies>
<dependency>
<groupId>org.jetbrains.kotlin</groupId>
<artifactId>kotlin-maven-allopen</artifactId>
<version>${kotlin.version}</version>
</dependency>
</dependencies>
</plugin>
</plugins>
</build>
</project>
My DiscoveryServerApplication:
package com.shopping.discoveryserver
import org.springframework.boot.autoconfigure.SpringBootApplication
import org.springframework.boot.runApplication
import org.springframework.cloud.netflix.eureka.server.EnableEurekaServer
#SpringBootApplication
#EnableEurekaServer
class DiscoveryServerApplication
fun main(args: Array<String>) {
runApplication<DiscoveryServerApplication>(*args)
}
My application.properties:
server.port=8761
spring.application.name=eureka-server
eureka.instance.hostname=localhost
eureka.server.maxThreadsForPeerReplication=0
eureka.client.registerWithEureka=false
eureka.client.fetchRegistry=false
Spring Boot log:
2022-10-17 00:17:38.665 INFO 81886 --- [ main] c.c.c.ConfigServicePropertySourceLocator : Fetching config from server at : http://localhost:8888
2022-10-17 00:17:38.743 INFO 81886 --- [ main] c.c.c.ConfigServicePropertySourceLocator : Connect Timeout Exception on Url - http://localhost:8888. Will be trying the next url if available
2022-10-17 00:17:38.743 WARN 81886 --- [ main] c.c.c.ConfigServicePropertySourceLocator : Could not locate PropertySource: I/O error on GET request for "http://localhost:8888/application/default": Connection refused; nested exception is java.net.ConnectException: Connection refused
2022-10-17 00:17:38.745 INFO 81886 --- [ main] c.s.d.DiscoveryServerApplicationKt : No active profile set, falling back to 1 default profile: "default"
2022-10-17 00:17:39.393 INFO 81886 --- [ main] o.s.cloud.context.scope.GenericScope : BeanFactory id=c3bbf1c6-4eb5-3807-b805-19115a4714b1
2022-10-17 00:17:39.606 INFO 81886 --- [ main] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat initialized with port(s): 8080 (http)
2022-10-17 00:17:39.613 INFO 81886 --- [ main] o.apache.catalina.core.StandardService : Starting service [Tomcat]
2022-10-17 00:17:39.614 INFO 81886 --- [ main] org.apache.catalina.core.StandardEngine : Starting Servlet engine: [Apache Tomcat/9.0.65]
2022-10-17 00:17:39.723 INFO 81886 --- [ main] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring embedded WebApplicationContext
2022-10-17 00:17:39.723 INFO 81886 --- [ main] w.s.c.ServletWebServerApplicationContext : Root WebApplicationContext: initialization completed in 963 ms
2022-10-17 00:17:40.044 INFO 81886 --- [ main] c.s.j.s.i.a.WebApplicationImpl : Initiating Jersey application, version 'Jersey: 1.19.4 05/24/2017 03:20 PM'
2022-10-17 00:17:40.093 INFO 81886 --- [ main] c.n.d.provider.DiscoveryJerseyProvider : Using JSON encoding codec LegacyJacksonJson
2022-10-17 00:17:40.093 INFO 81886 --- [ main] c.n.d.provider.DiscoveryJerseyProvider : Using JSON decoding codec LegacyJacksonJson
2022-10-17 00:17:40.192 INFO 81886 --- [ main] c.n.d.provider.DiscoveryJerseyProvider : Using XML encoding codec XStreamXml
2022-10-17 00:17:40.192 INFO 81886 --- [ main] c.n.d.provider.DiscoveryJerseyProvider : Using XML decoding codec XStreamXml
2022-10-17 00:17:40.882 INFO 81886 --- [ main] DiscoveryClientOptionalArgsConfiguration : Eureka HTTP Client uses Jersey
2022-10-17 00:17:40.927 WARN 81886 --- [ main] iguration$LoadBalancerCaffeineWarnLogger : Spring Cloud LoadBalancer is currently working with the default cache. While this cache implementation is useful for development and tests, it's recommended to use Caffeine cache in production.You can switch to using Caffeine cache, by adding it and org.springframework.cache.caffeine.CaffeineCacheManager to the classpath.
2022-10-17 00:17:40.939 INFO 81886 --- [ main] o.s.c.n.eureka.InstanceInfoFactory : Setting initial instance status as: STARTING
2022-10-17 00:17:40.972 INFO 81886 --- [ main] com.netflix.discovery.DiscoveryClient : Initializing Eureka in region us-east-1
2022-10-17 00:17:41.089 INFO 81886 --- [ main] c.n.d.provider.DiscoveryJerseyProvider : Using JSON encoding codec LegacyJacksonJson
2022-10-17 00:17:41.089 INFO 81886 --- [ main] c.n.d.provider.DiscoveryJerseyProvider : Using JSON decoding codec LegacyJacksonJson
2022-10-17 00:17:41.089 INFO 81886 --- [ main] c.n.d.provider.DiscoveryJerseyProvider : Using XML encoding codec XStreamXml
2022-10-17 00:17:41.089 INFO 81886 --- [ main] c.n.d.provider.DiscoveryJerseyProvider : Using XML decoding codec XStreamXml
2022-10-17 00:17:41.172 INFO 81886 --- [ main] c.n.d.s.r.aws.ConfigClusterResolver : Resolving eureka endpoints via configuration
2022-10-17 00:17:41.183 INFO 81886 --- [ main] com.netflix.discovery.DiscoveryClient : Disable delta property : false
2022-10-17 00:17:41.183 INFO 81886 --- [ main] com.netflix.discovery.DiscoveryClient : Single vip registry refresh property : null
2022-10-17 00:17:41.184 INFO 81886 --- [ main] com.netflix.discovery.DiscoveryClient : Force full registry fetch : false
2022-10-17 00:17:41.184 INFO 81886 --- [ main] com.netflix.discovery.DiscoveryClient : Application is null : false
2022-10-17 00:17:41.184 INFO 81886 --- [ main] com.netflix.discovery.DiscoveryClient : Registered Applications size is zero : true
2022-10-17 00:17:41.184 INFO 81886 --- [ main] com.netflix.discovery.DiscoveryClient : Application version is -1: true
2022-10-17 00:17:41.184 INFO 81886 --- [ main] com.netflix.discovery.DiscoveryClient : Getting all instance registry info from the eureka server
2022-10-17 00:17:41.228 INFO 81886 --- [ main] c.n.d.s.t.d.RedirectingEurekaHttpClient : Request execution error. endpoint=DefaultEndpoint{ serviceUrl='http://localhost:8761/eureka/}, exception=java.net.ConnectException: Connection refused stacktrace=com.sun.jersey.api.client.ClientHandlerException: java.net.ConnectException: Connection refused
...
at com.shopping.discoveryserver.DiscoveryServerApplicationKt.main(DiscoveryServerApplication.kt:15)
Caused by: java.net.ConnectException: Connection refused
I figured it out, and since this seems to be an unanswered & common question on here, I will post my pom & properties file on here (adapted from Cannot connect to Eureka server. Exception: java.net.ConnectException: Connection refused: connect):
My pom.xml:
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.1.4.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<artifactId>api-discovery</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>discovery-server</name>
<description>Demo project for Spring Boot</description>
<properties>
<java.version>11</java.version>
<kotlin.version>1.6.21</kotlin.version>
</properties>
<dependencies>
<dependency>
<groupId>org.jetbrains.kotlin</groupId>
<artifactId>kotlin-reflect</artifactId>
</dependency>
<dependency>
<groupId>org.jetbrains.kotlin</groupId>
<artifactId>kotlin-stdlib-jdk8</artifactId>
</dependency>
<dependency>
<!-- Setup Spring Boot -->
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter</artifactId>
</dependency>
<dependency>
<!-- Setup Spring MVC & REST, use Embedded Tomcat -->
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<!-- Spring Cloud starter -->
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-eureka-server</artifactId>
<version>1.4.6.RELEASE</version>
</dependency>
<dependency>
<groupId>javax.xml.bind</groupId>
<artifactId>jaxb-api</artifactId>
<version>2.2.11</version>
</dependency>
<dependency>
<groupId>com.sun.xml.bind</groupId>
<artifactId>jaxb-core</artifactId>
<version>2.2.11</version>
</dependency>
<dependency>
<groupId>com.sun.xml.bind</groupId>
<artifactId>jaxb-impl</artifactId>
<version>2.2.11</version>
</dependency>
<dependency>
<groupId>javax.activation</groupId>
<artifactId>activation</artifactId>
<version>1.1.1</version>
</dependency>
</dependencies>
<!-- Spring Cloud dependencies -->
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-dependencies</artifactId>
<version>Finchley.RELEASE</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
<build>
<sourceDirectory>${project.basedir}/src/main/kotlin</sourceDirectory>
<testSourceDirectory>${project.basedir}/src/test/kotlin</testSourceDirectory>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.jetbrains.kotlin</groupId>
<artifactId>kotlin-maven-plugin</artifactId>
<configuration>
<args>
<arg>-Xjsr305=strict</arg>
</args>
<compilerPlugins>
<plugin>spring</plugin>
</compilerPlugins>
</configuration>
<dependencies>
<dependency>
<groupId>org.jetbrains.kotlin</groupId>
<artifactId>kotlin-maven-allopen</artifactId>
<version>${kotlin.version}</version>
</dependency>
</dependencies>
</plugin>
</plugins>
</build>
</project>
My application.properties:
server.port=8761
spring.application.name=eureka-server
eureka.instance.hostname=localhost
eureka.server.maxThreadsForPeerReplication=0
eureka.client.registerWithEureka=false
eureka.client.fetchRegistry=false
I ended up not using spring-cloud-starter-netflix-eureka-server as a dependency, and instead opted for the (deprecated) spring-cloud-starter-eureka-server. Eureka is accessible from localhost:8761.
Here's the error I am getting :
:: Spring Boot :: (v2.4.3)
2021-04-11 23:44:53.501 INFO 7012 --- [ restartedMain] com.example.demo.LibraryApplication : Starting LibraryApplication using Java 15.0.2 on LAPTOP-SL7RT9CR with PID 7012 (C:\Users\LINDANI\Library\target\classes started by LINDANI in C:\Users\LINDANI\Library)
2021-04-11 23:44:53.506 INFO 7012 --- [ restartedMain] com.example.demo.LibraryApplication : No active profile set, falling back to default profiles: default
2021-04-11 23:44:53.506 DEBUG 7012 --- [ restartedMain] o.s.boot.SpringApplication : Loading source class com.example.demo.LibraryApplication
2021-04-11 23:44:54.050 DEBUG 7012 --- [ restartedMain] o.s.b.devtools.restart.ChangeableUrls : Matching URLs for reloading : [file:/C:/Users/LINDANI/Library/target/classes/]
2021-04-11 23:44:54.050 DEBUG 7012 --- [ restartedMain] o.s.b.d.settings.DevToolsSettings : Included patterns for restart : []
2021-04-11 23:44:54.050 DEBUG 7012 --- [ restartedMain] o.s.b.d.settings.DevToolsSettings : Excluded patterns for restart : [/spring-boot-starter-[\w-]+/, /spring-boot/(bin|build|out)/, /spring-boot-starter/(bin|build|out)/, /spring-boot-devtools/(bin|build|out)/, /spring-boot-actuator/(bin|build|out)/, /spring-boot-autoconfigure/(bin|build|out)/]
2021-04-11 23:44:54.050 INFO 7012 --- [ restartedMain] .e.DevToolsPropertyDefaultsPostProcessor : Devtools property defaults active! Set 'spring.devtools.add-properties' to 'false' to disable
2021-04-11 23:44:54.050 INFO 7012 --- [ restartedMain] .e.DevToolsPropertyDefaultsPostProcessor : For additional web related logging consider setting the 'logging.level.web' property to 'DEBUG'
2021-04-11 23:44:54.050 DEBUG 7012 --- [ restartedMain] ConfigServletWebServerApplicationContext : Refreshing org.springframework.boot.web.servlet.context.AnnotationConfigServletWebServerApplicationContext#b77404b
2021-04-11 23:44:57.930 INFO 7012 --- [ restartedMain] .s.d.r.c.RepositoryConfigurationDelegate : Bootstrapping Spring Data JPA repositories in DEFAULT mode.
2021-04-11 23:44:58.142 INFO 7012 --- [ restartedMain] .s.d.r.c.RepositoryConfigurationDelegate : Finished Spring Data repository scanning in 173 ms. Found 1 JPA repository interfaces.
2021-04-11 23:45:00.254 DEBUG 7012 --- [ restartedMain] .s.b.w.e.t.TomcatServletWebServerFactory : Code archive: C:\Users\LINDANI\.m2\repository\org\springframework\boot\spring-boot\2.4.3\spring-boot-2.4.3.jar
2021-04-11 23:45:00.254 DEBUG 7012 --- [ restartedMain] .s.b.w.e.t.TomcatServletWebServerFactory : Code archive: C:\Users\LINDANI\.m2\repository\org\springframework\boot\spring-boot\2.4.3\spring-boot-2.4.3.jar
2021-04-11 23:45:00.259 DEBUG 7012 --- [ restartedMain] .s.b.w.e.t.TomcatServletWebServerFactory : None of the document roots [src/main/webapp, public, static] point to a directory and will be ignored.
2021-04-11 23:45:00.537 INFO 7012 --- [ restartedMain] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat initialized with port(s): 8080 (http)
2021-04-11 23:45:00.587 INFO 7012 --- [ restartedMain] o.apache.catalina.core.StandardService : Starting service [Tomcat]
2021-04-11 23:45:00.587 INFO 7012 --- [ restartedMain] org.apache.catalina.core.StandardEngine : Starting Servlet engine: [Apache Tomcat/9.0.43]
2021-04-11 23:45:00.978 INFO 7012 --- [ restartedMain] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring embedded WebApplicationContext
2021-04-11 23:45:00.980 DEBUG 7012 --- [ restartedMain] w.s.c.ServletWebServerApplicationContext : Published root WebApplicationContext as ServletContext attribute with name [org.springframework.web.context.WebApplicationContext.ROOT]
2021-04-11 23:45:00.980 INFO 7012 --- [ restartedMain] w.s.c.ServletWebServerApplicationContext : Root WebApplicationContext: initialization completed in 6930 ms
2021-04-11 23:45:01.009 DEBUG 7012 --- [ restartedMain] o.s.b.w.s.ServletContextInitializerBeans : Mapping filters: characterEncodingFilter urls=[/*] order=-2147483648, formContentFilter urls=[/*] order=-9900, requestContextFilter urls=[/*] order=-105
2021-04-11 23:45:01.014 DEBUG 7012 --- [ restartedMain] o.s.b.w.s.ServletContextInitializerBeans : Mapping servlets: dispatcherServlet urls=[/]
2021-04-11 23:45:01.124 DEBUG 7012 --- [ restartedMain] o.s.b.w.s.f.OrderedRequestContextFilter : Filter 'requestContextFilter' configured for use
2021-04-11 23:45:01.124 DEBUG 7012 --- [ restartedMain] s.b.w.s.f.OrderedCharacterEncodingFilter : Filter 'characterEncodingFilter' configured for use
2021-04-11 23:45:01.124 DEBUG 7012 --- [ restartedMain] o.s.b.w.s.f.OrderedFormContentFilter : Filter 'formContentFilter' configured for use
2021-04-11 23:45:02.337 INFO 7012 --- [ restartedMain] o.hibernate.jpa.internal.util.LogHelper : HHH000204: Processing PersistenceUnitInfo [name: default]
2021-04-11 23:45:02.694 INFO 7012 --- [ restartedMain] org.hibernate.Version : HHH000412: Hibernate ORM core version 5.4.28.Final
2021-04-11 23:45:03.244 INFO 7012 --- [ restartedMain] o.hibernate.annotations.common.Version : HCANN000001: Hibernate Commons Annotations {5.1.2.Final}
2021-04-11 23:45:03.539 INFO 7012 --- [ restartedMain] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Starting...
2021-04-11 23:45:05.594 INFO 7012 --- [ restartedMain] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Start completed.
2021-04-11 23:45:05.636 INFO 7012 --- [ restartedMain] org.hibernate.dialect.Dialect : HHH000400: Using dialect: org.hibernate.dialect.MySQL8Dialect
2021-04-11 23:45:07.817 INFO 7012 --- [ restartedMain] o.h.e.t.j.p.i.JtaPlatformInitiator : HHH000490: Using JtaPlatform implementation: [org.hibernate.engine.transaction.jta.platform.internal.NoJtaPlatform]
2021-04-11 23:45:07.845 INFO 7012 --- [ restartedMain] j.LocalContainerEntityManagerFactoryBean : Initialized JPA EntityManagerFactory for persistence unit 'default'
2021-04-11 23:45:07.875 DEBUG 7012 --- [ restartedMain] o.s.b.d.livereload.LiveReloadServer : Starting live reload server on port 35729
2021-04-11 23:45:07.875 INFO 7012 --- [ restartedMain] o.s.b.d.a.OptionalLiveReloadServer : LiveReload server is running on port 35729
2021-04-11 23:45:08.217 WARN 7012 --- [ restartedMain] ConfigServletWebServerApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'bookserviceImp': Unsatisfied dependency expressed through field 'bookrepo'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'bookrepo' defined in com.example.demo.repo.Bookrepo defined in #EnableJpaRepositories declared on JpaRepositoriesRegistrar.EnableJpaRepositoriesConfiguration: Invocation of init method failed; nested exception is java.lang.IllegalArgumentException: Not a managed type: interface com.example.demo.repo.Bookrepo
2021-04-11 23:45:08.217 INFO 7012 --- [ restartedMain] j.LocalContainerEntityManagerFactoryBean : Closing JPA EntityManagerFactory for persistence unit 'default'
2021-04-11 23:45:08.240 INFO 7012 --- [ restartedMain] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Shutdown initiated...
2021-04-11 23:45:08.260 INFO 7012 --- [ restartedMain] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Shutdown completed.
2021-04-11 23:45:08.265 INFO 7012 --- [ restartedMain] o.apache.catalina.core.StandardService : Stopping service [Tomcat]
2021-04-11 23:45:08.275 DEBUG 7012 --- [ restartedMain] o.s.boot.devtools.restart.Restarter : Creating new Restarter for thread Thread[main,5,main]
2021-04-11 23:45:08.275 DEBUG 7012 --- [ restartedMain] o.s.boot.devtools.restart.Restarter : Immediately restarting application
2021-04-11 23:45:08.275 DEBUG 7012 --- [ restartedMain] o.s.boot.devtools.restart.Restarter : Created RestartClassLoader org.springframework.boot.devtools.restart.classloader.RestartClassLoader#434a0335
2021-04-11 23:45:08.275 DEBUG 7012 --- [ restartedMain] o.s.boot.devtools.restart.Restarter : Starting application com.example.demo.LibraryApplication with URLs [file:/C:/Users/LINDANI/Library/target/classes/]
2021-04-11 23:45:08.407 ERROR 7012 --- [ restartedMain] o.s.boot.SpringApplication : Application run failed
org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'bookserviceImp': Unsatisfied dependency expressed through field 'bookrepo'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'bookrepo' defined in com.example.demo.repo.Bookrepo defined in #EnableJpaRepositories declared on JpaRepositoriesRegistrar.EnableJpaRepositoriesConfiguration: Invocation of init method failed; nested exception is java.lang.IllegalArgumentException: Not a managed type: interface com.example.demo.repo.Bookrepo
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.resolveFieldValue(AutowiredAnnotationBeanPostProcessor.java:660) ~[spring-beans-5.3.4.jar:5.3.4]
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:640) ~[spring-beans-5.3.4.jar:5.3.4]
at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:119) ~[spring-beans-5.3.4.jar:5.3.4]
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessProperties(AutowiredAnnotationBeanPostProcessor.java:399) ~[spring-beans-5.3.4.jar:5.3.4]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1413) ~[spring-beans-5.3.4.jar:5.3.4]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:601) ~[spring-beans-5.3.4.jar:5.3.4]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:524) ~[spring-beans-5.3.4.jar:5.3.4]
at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:335) ~[spring-beans-5.3.4.jar:5.3.4]
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:234) ~[spring-beans-5.3.4.jar:5.3.4]
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:333) ~[spring-beans-5.3.4.jar:5.3.4]
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:208) ~[spring-beans-5.3.4.jar:5.3.4]
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:944) ~[spring-beans-5.3.4.jar:5.3.4]
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:917) ~[spring-context-5.3.4.jar:5.3.4]
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:582) ~[spring-context-5.3.4.jar:5.3.4]
at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:144) ~[spring-boot-2.4.3.jar:2.4.3]
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:767) ~[spring-boot-2.4.3.jar:2.4.3]
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:759) ~[spring-boot-2.4.3.jar:2.4.3]
at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:426) ~[spring-boot-2.4.3.jar:2.4.3]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:326) ~[spring-boot-2.4.3.jar:2.4.3]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1311) ~[spring-boot-2.4.3.jar:2.4.3]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1300) ~[spring-boot-2.4.3.jar:2.4.3]
at com.example.demo.LibraryApplication.main(LibraryApplication.java:10) ~[classes/:na]
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:na]
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:64) ~[na:na]
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:na]
at java.base/java.lang.reflect.Method.invoke(Method.java:564) ~[na:na]
at org.springframework.boot.devtools.restart.RestartLauncher.run(RestartLauncher.java:49) ~[spring-boot-devtools-2.4.3.jar:2.4.3]
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'bookrepo' defined in com.example.demo.repo.Bookrepo defined in #EnableJpaRepositories declared on JpaRepositoriesRegistrar.EnableJpaRepositoriesConfiguration: Invocation of init method failed; nested exception is java.lang.IllegalArgumentException: Not a managed type: interface com.example.demo.repo.Bookrepo
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1786) ~[spring-beans-5.3.4.jar:5.3.4]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:602) ~[spring-beans-5.3.4.jar:5.3.4]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:524) ~[spring-beans-5.3.4.jar:5.3.4]
at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:335) ~[spring-beans-5.3.4.jar:5.3.4]
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:234) ~[spring-beans-5.3.4.jar:5.3.4]
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:333) ~[spring-beans-5.3.4.jar:5.3.4]
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:208) ~[spring-beans-5.3.4.jar:5.3.4]
at org.springframework.beans.factory.config.DependencyDescriptor.resolveCandidate(DependencyDescriptor.java:276) ~[spring-beans-5.3.4.jar:5.3.4]
at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1380) ~[spring-beans-5.3.4.jar:5.3.4]
at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:1300) ~[spring-beans-5.3.4.jar:5.3.4]
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.resolveFieldValue(AutowiredAnnotationBeanPostProcessor.java:657) ~[spring-beans-5.3.4.jar:5.3.4]
... 26 common frames omitted
Caused by: java.lang.IllegalArgumentException: Not a managed type: interface com.example.demo.repo.Bookrepo
at org.hibernate.metamodel.internal.MetamodelImpl.managedType(MetamodelImpl.java:582) ~[hibernate-core-5.4.28.Final.jar:5.4.28.Final]
at org.hibernate.metamodel.internal.MetamodelImpl.managedType(MetamodelImpl.java:85) ~[hibernate-core-5.4.28.Final.jar:5.4.28.Final]
at org.springframework.data.jpa.repository.support.JpaMetamodelEntityInformation.<init>(JpaMetamodelEntityInformation.java:75) ~[spring-data-jpa-2.4.5.jar:2.4.5]
at org.springframework.data.jpa.repository.support.JpaEntityInformationSupport.getEntityInformation(JpaEntityInformationSupport.java:66) ~[spring-data-jpa-2.4.5.jar:2.4.5]
at org.springframework.data.jpa.repository.support.JpaRepositoryFactory.getEntityInformation(JpaRepositoryFactory.java:229) ~[spring-data-jpa-2.4.5.jar:2.4.5]
at org.springframework.data.jpa.repository.support.JpaRepositoryFactory.getTargetRepository(JpaRepositoryFactory.java:179) ~[spring-data-jpa-2.4.5.jar:2.4.5]
at org.springframework.data.jpa.repository.support.JpaRepositoryFactory.getTargetRepository(JpaRepositoryFactory.java:162) ~[spring-data-jpa-2.4.5.jar:2.4.5]
at org.springframework.data.jpa.repository.support.JpaRepositoryFactory.getTargetRepository(JpaRepositoryFactory.java:72) ~[spring-data-jpa-2.4.5.jar:2.4.5]
at org.springframework.data.repository.core.support.RepositoryFactorySupport.getRepository(RepositoryFactorySupport.java:281) ~[spring-data-commons-2.4.5.jar:2.4.5]
at org.springframework.data.repository.core.support.RepositoryFactoryBeanSupport.lambda$afterPropertiesSet$5(RepositoryFactoryBeanSupport.java:323) ~[spring-data-commons-2.4.5.jar:2.4.5]
at org.springframework.data.util.Lazy.getNullable(Lazy.java:230) ~[spring-data-commons-2.4.5.jar:2.4.5]
at org.springframework.data.util.Lazy.get(Lazy.java:114) ~[spring-data-commons-2.4.5.jar:2.4.5]
at org.springframework.data.repository.core.support.RepositoryFactoryBeanSupport.afterPropertiesSet(RepositoryFactoryBeanSupport.java:329) ~[spring-data-commons-2.4.5.jar:2.4.5]
at org.springframework.data.jpa.repository.support.JpaRepositoryFactoryBean.afterPropertiesSet(JpaRepositoryFactoryBean.java:144) ~[spring-data-jpa-2.4.5.jar:2.4.5]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1845) ~[spring-beans-5.3.4.jar:5.3.4]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1782) ~[spring-beans-5.3.4.jar:5.3.4]
... 36 common frames omitted
Process finished with exit code 0
Here's the pom file:
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.4.3</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<groupId>com.example</groupId>
<artifactId>demo</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>Library</name>
<description>Demo project for Spring Boot</description>
<properties>
<java.version>11</java.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-thymeleaf</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
<scope>runtime</scope>
<optional>true</optional>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>
Make sure Your Repository class is annotated with #Repository.
#Repository
public interface BookRepository extends JpaRepository<Book, Integer>{
}
Check your service implementation class and annotate with #Service annotation.
Use #Autowired while creating objects of repository class in the service implementation class.
#Service
public class BookServiceImplementation implements CommentService{
#Autowired
private BookRepository bookRepository;
}
I use Spring Boot 2.1.1.RELEASE with webflux.
Dependencies are like below:
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-webflux</artifactId>
</dependency>
Here goes the Controller, I use Hooks.onOperatorDebug(); as reactor's document says it Can open debug mode.
#RestController
public class TestController {
#GetMapping("/test")
public Mono test(String a) {
Hooks.onOperatorDebug();
return Mono.just("test1")
.map(t -> t + "test2")
.zipWith(Mono.error(() -> new IllegalArgumentException("error")));
}
#PostMapping("/test")
public Mono post(#RequestBody Req req) {
return Mono.just(req);
}
}
class Req {
private String a;
private String b;
public String getA() {
return a;
}
public void setA(String a) {
this.a = a;
}
public String getB() {
return b;
}
public void setB(String b) {
this.b = b;
}
}
log level is below:
logging:
level:
root: trace
When I call <http://localhost:8080/test> , I Can only get logs like below:
2018-12-10 21:41:17.001 DEBUG 31340 --- [ctor-http-nio-2] r.n.http.server.HttpServerOperations : [id: 0x7cc865b4, L:/0:0:0:0:0:0:0:1:8080 - R:/0:0:0:0:0:0:0:1:52638] Increasing pending responses, now 1
2018-12-10 21:41:17.001 DEBUG 31340 --- [ctor-http-nio-2] reactor.netty.http.server.HttpServer : [id: 0x7cc865b4, L:/0:0:0:0:0:0:0:1:8080 - R:/0:0:0:0:0:0:0:1:52638] Handler is being applied: org.springframework.http.server.reactive.ReactorHttpHandlerAdapter#3a0ad630
2018-12-10 21:41:17.002 TRACE 31340 --- [ctor-http-nio-2] o.s.w.s.adapter.HttpWebHandlerAdapter : [7cc865b4] HTTP GET "/test?a=b", headers={masked}
2018-12-10 21:41:17.002 TRACE 31340 --- [ctor-http-nio-2] o.s.b.f.s.DefaultListableBeanFactory : Returning cached instance of singleton bean 'testController'
2018-12-10 21:41:17.002 DEBUG 31340 --- [ctor-http-nio-2] s.w.r.r.m.a.RequestMappingHandlerMapping : [7cc865b4] Mapped to public reactor.core.publisher.Mono com.itmuch.webfluxtest.TestController.test(java.lang.String)
2018-12-10 21:41:17.003 DEBUG 31340 --- [ctor-http-nio-2] reactor.core.publisher.Hooks : Enabling stacktrace debugging via onOperatorDebug
2018-12-10 21:41:17.003 DEBUG 31340 --- [ctor-http-nio-2] reactor.core.publisher.Hooks : Hooking onEachOperator: onOperatorDebug
2018-12-10 21:41:17.003 DEBUG 31340 --- [ctor-http-nio-2] o.s.w.r.r.m.a.ResponseBodyResultHandler : Using 'application/json;charset=UTF-8;q=0.8' given [text/html, application/xhtml+xml, image/webp, image/apng, application/xml;q=0.9, */*;q=0.8] and supported [application/json;charset=UTF-8, application/*+json;charset=UTF-8, text/event-stream]
2018-12-10 21:41:17.003 DEBUG 31340 --- [ctor-http-nio-2] o.s.w.r.r.m.a.ResponseBodyResultHandler : [7cc865b4] 0..1 [?]
2018-12-10 21:41:17.008 TRACE 31340 --- [ctor-http-nio-2] o.s.w.r.function.server.RouterFunctions : [7cc865b4] Matched org.springframework.boot.autoconfigure.web.reactive.error.DefaultErrorWebExceptionHandler$$Lambda$520/509612428#4c3d17a7
2018-12-10 21:41:17.009 TRACE 31340 --- [ctor-http-nio-2] o.s.c.e.PropertySourcesPropertyResolver : Searching for key 'spring.template.provider.cache' in PropertySource 'server.ports'
2018-12-10 21:41:17.009 TRACE 31340 --- [ctor-http-nio-2] o.s.c.e.PropertySourcesPropertyResolver : Searching for key 'spring.template.provider.cache' in PropertySource 'configurationProperties'
2018-12-10 21:41:17.009 TRACE 31340 --- [ctor-http-nio-2] o.s.c.e.PropertySourcesPropertyResolver : Searching for key 'spring.template.provider.cache' in PropertySource 'systemProperties'
2018-12-10 21:41:17.009 TRACE 31340 --- [ctor-http-nio-2] o.s.c.e.PropertySourcesPropertyResolver : Searching for key 'spring.template.provider.cache' in PropertySource 'systemEnvironment'
2018-12-10 21:41:17.009 TRACE 31340 --- [ctor-http-nio-2] o.s.c.e.PropertySourcesPropertyResolver : Searching for key 'spring.template.provider.cache' in PropertySource 'random'
2018-12-10 21:41:17.009 TRACE 31340 --- [ctor-http-nio-2] o.s.c.e.PropertySourcesPropertyResolver : Searching for key 'spring.template.provider.cache' in PropertySource 'applicationConfig: [classpath:/application.yml]'
2018-12-10 21:41:17.009 TRACE 31340 --- [ctor-http-nio-2] o.s.c.e.PropertySourcesPropertyResolver : Could not find key 'spring.template.provider.cache' in any property source
2018-12-10 21:41:17.009 TRACE 31340 --- [ctor-http-nio-2] o.s.c.e.PropertySourcesPropertyResolver : Searching for key 'spring.template.provider.cache' in PropertySource 'server.ports'
2018-12-10 21:41:17.009 TRACE 31340 --- [ctor-http-nio-2] o.s.c.e.PropertySourcesPropertyResolver : Searching for key 'spring.template.provider.cache' in PropertySource 'configurationProperties'
2018-12-10 21:41:17.009 TRACE 31340 --- [ctor-http-nio-2] o.s.c.e.PropertySourcesPropertyResolver : Searching for key 'spring.template.provider.cache' in PropertySource 'systemProperties'
2018-12-10 21:41:17.009 TRACE 31340 --- [ctor-http-nio-2] o.s.c.e.PropertySourcesPropertyResolver : Searching for key 'spring.template.provider.cache' in PropertySource 'systemEnvironment'
2018-12-10 21:41:17.009 TRACE 31340 --- [ctor-http-nio-2] o.s.c.e.PropertySourcesPropertyResolver : Searching for key 'spring.template.provider.cache' in PropertySource 'random'
2018-12-10 21:41:17.009 TRACE 31340 --- [ctor-http-nio-2] o.s.c.e.PropertySourcesPropertyResolver : Searching for key 'spring.template.provider.cache' in PropertySource 'applicationConfig: [classpath:/application.yml]'
2018-12-10 21:41:17.010 TRACE 31340 --- [ctor-http-nio-2] o.s.c.e.PropertySourcesPropertyResolver : Could not find key 'spring.template.provider.cache' in any property source
2018-12-10 21:41:17.010 TRACE 31340 --- [ctor-http-nio-2] o.s.c.e.PropertySourcesPropertyResolver : Searching for key 'spring.template.provider.cache' in PropertySource 'server.ports'
2018-12-10 21:41:17.010 TRACE 31340 --- [ctor-http-nio-2] o.s.c.e.PropertySourcesPropertyResolver : Searching for key 'spring.template.provider.cache' in PropertySource 'configurationProperties'
2018-12-10 21:41:17.010 TRACE 31340 --- [ctor-http-nio-2] o.s.c.e.PropertySourcesPropertyResolver : Searching for key 'spring.template.provider.cache' in PropertySource 'systemProperties'
2018-12-10 21:41:17.010 TRACE 31340 --- [ctor-http-nio-2] o.s.c.e.PropertySourcesPropertyResolver : Searching for key 'spring.template.provider.cache' in PropertySource 'systemEnvironment'
2018-12-10 21:41:17.010 TRACE 31340 --- [ctor-http-nio-2] o.s.c.e.PropertySourcesPropertyResolver : Searching for key 'spring.template.provider.cache' in PropertySource 'random'
2018-12-10 21:41:17.010 TRACE 31340 --- [ctor-http-nio-2] o.s.c.e.PropertySourcesPropertyResolver : Searching for key 'spring.template.provider.cache' in PropertySource 'applicationConfig: [classpath:/application.yml]'
2018-12-10 21:41:17.010 TRACE 31340 --- [ctor-http-nio-2] o.s.c.e.PropertySourcesPropertyResolver : Could not find key 'spring.template.provider.cache' in any property source
2018-12-10 21:41:17.010 DEBUG 31340 --- [ctor-http-nio-2] .a.w.r.e.DefaultErrorWebExceptionHandler : [7cc865b4] Resolved [IllegalArgumentException: error] for HTTP GET /test
2018-12-10 21:41:17.011 TRACE 31340 --- [ctor-http-nio-2] o.s.core.codec.CharSequenceEncoder : [7cc865b4] Writing "<html><body><h1>Whitelabel Error Page</h1><p>This application has no configured error view, so you are seeing this as a fallback.</p><div id='created'>Mon Dec 10 21:41:17 CST 2018</div><div>There was an unexpected error (type=Internal Server Error, status=500).</div><div>error</div></body></html>"
2018-12-10 21:41:17.011 DEBUG 31340 --- [ctor-http-nio-2] r.n.channel.ChannelOperationsHandler : [id: 0x7cc865b4, L:/0:0:0:0:0:0:0:1:8080 - R:/0:0:0:0:0:0:0:1:52638] Writing object DefaultHttpResponse(decodeResult: success, version: HTTP/1.1)
HTTP/1.1 500 Internal Server Error
Content-Type: text/html
Content-Length: 297
2018-12-10 21:41:17.011 DEBUG 31340 --- [ctor-http-nio-2] r.n.channel.ChannelOperationsHandler : [id: 0x7cc865b4, L:/0:0:0:0:0:0:0:1:8080 - R:/0:0:0:0:0:0:0:1:52638] Writing object
2018-12-10 21:41:17.011 TRACE 31340 --- [ctor-http-nio-2] r.n.channel.ChannelOperationsHandler : [id: 0x7cc865b4, L:/0:0:0:0:0:0:0:1:8080 - R:/0:0:0:0:0:0:0:1:52638] Pending write size = 297
2018-12-10 21:41:17.012 TRACE 31340 --- [ctor-http-nio-2] o.s.w.s.adapter.HttpWebHandlerAdapter : [7cc865b4] Completed 500 INTERNAL_SERVER_ERROR, headers={masked}
2018-12-10 21:41:17.012 TRACE 31340 --- [ctor-http-nio-2] o.s.h.s.r.ReactorHttpHandlerAdapter : [7cc865b4] Handling completed
2018-12-10 21:41:17.012 DEBUG 31340 --- [ctor-http-nio-2] r.n.http.server.HttpServerOperations : [id: 0x7cc865b4, L:/0:0:0:0:0:0:0:1:8080 - R:/0:0:0:0:0:0:0:1:52638] Last HTTP response frame
2018-12-10 21:41:17.012 DEBUG 31340 --- [ctor-http-nio-2] r.n.channel.ChannelOperationsHandler : [id: 0x7cc865b4, L:/0:0:0:0:0:0:0:1:8080 - R:/0:0:0:0:0:0:0:1:52638] Writing object EmptyLastHttpContent
2018-12-10 21:41:17.012 DEBUG 31340 --- [ctor-http-nio-2] r.n.http.server.HttpServerOperations : [id: 0x7cc865b4, L:/0:0:0:0:0:0:0:1:8080 - R:/0:0:0:0:0:0:0:1:52638] Decreasing pending responses, now 0
2018-12-10 21:41:17.013 TRACE 31340 --- [ctor-http-nio-2] reactor.netty.channel.ChannelOperations : [id: 0x7cc865b4, L:/0:0:0:0:0:0:0:1:8080 - R:/0:0:0:0:0:0:0:1:52638] Disposing ChannelOperation from a channel
java.lang.Exception: ChannelOperation terminal stack
at reactor.netty.channel.ChannelOperations.terminate(ChannelOperations.java:363) [reactor-netty-0.8.3.RELEASE.jar:0.8.3.RELEASE]
at reactor.netty.http.server.HttpServerOperations.cleanHandlerTerminate(HttpServerOperations.java:509) [reactor-netty-0.8.3.RELEASE.jar:0.8.3.RELEASE]
at reactor.netty.http.server.HttpTrafficHandler.operationComplete(HttpTrafficHandler.java:297) [reactor-netty-0.8.3.RELEASE.jar:0.8.3.RELEASE]
at reactor.netty.http.server.HttpTrafficHandler.operationComplete(HttpTrafficHandler.java:54) [reactor-netty-0.8.3.RELEASE.jar:0.8.3.RELEASE]
at io.netty.util.concurrent.DefaultPromise.notifyListener0(DefaultPromise.java:511) [netty-common-4.1.31.Final.jar:4.1.31.Final]
at io.netty.util.concurrent.DefaultPromise.notifyListenersNow(DefaultPromise.java:485) [netty-common-4.1.31.Final.jar:4.1.31.Final]
at io.netty.util.concurrent.DefaultPromise.notifyListeners(DefaultPromise.java:424) [netty-common-4.1.31.Final.jar:4.1.31.Final]
at io.netty.util.concurrent.DefaultPromise.trySuccess(DefaultPromise.java:103) [netty-common-4.1.31.Final.jar:4.1.31.Final]
at io.netty.util.internal.PromiseNotificationUtil.trySuccess(PromiseNotificationUtil.java:48) [netty-common-4.1.31.Final.jar:4.1.31.Final]
at io.netty.channel.ChannelOutboundBuffer.safeSuccess(ChannelOutboundBuffer.java:696) [netty-transport-4.1.31.Final.jar:4.1.31.Final]
at io.netty.channel.ChannelOutboundBuffer.remove(ChannelOutboundBuffer.java:258) [netty-transport-4.1.31.Final.jar:4.1.31.Final]
at io.netty.channel.nio.AbstractNioByteChannel.doWriteInternal(AbstractNioByteChannel.java:216) [netty-transport-4.1.31.Final.jar:4.1.31.Final]
at io.netty.channel.nio.AbstractNioByteChannel.doWrite0(AbstractNioByteChannel.java:209) [netty-transport-4.1.31.Final.jar:4.1.31.Final]
at io.netty.channel.socket.nio.NioSocketChannel.doWrite(NioSocketChannel.java:397) [netty-transport-4.1.31.Final.jar:4.1.31.Final]
at io.netty.channel.AbstractChannel$AbstractUnsafe.flush0(AbstractChannel.java:934) [netty-transport-4.1.31.Final.jar:4.1.31.Final]
at io.netty.channel.nio.AbstractNioChannel$AbstractNioUnsafe.flush0(AbstractNioChannel.java:360) [netty-transport-4.1.31.Final.jar:4.1.31.Final]
at io.netty.channel.AbstractChannel$AbstractUnsafe.flush(AbstractChannel.java:901) [netty-transport-4.1.31.Final.jar:4.1.31.Final]
at io.netty.channel.DefaultChannelPipeline$HeadContext.flush(DefaultChannelPipeline.java:1396) [netty-transport-4.1.31.Final.jar:4.1.31.Final]
at io.netty.channel.AbstractChannelHandlerContext.invokeFlush0(AbstractChannelHandlerContext.java:776) [netty-transport-4.1.31.Final.jar:4.1.31.Final]
at io.netty.channel.AbstractChannelHandlerContext.invokeFlush(AbstractChannelHandlerContext.java:768) [netty-transport-4.1.31.Final.jar:4.1.31.Final]
at io.netty.channel.AbstractChannelHandlerContext.flush(AbstractChannelHandlerContext.java:749) [netty-transport-4.1.31.Final.jar:4.1.31.Final]
at io.netty.channel.CombinedChannelDuplexHandler$DelegatingChannelHandlerContext.flush(CombinedChannelDuplexHandler.java:533) [netty-transport-4.1.31.Final.jar:4.1.31.Final]
at io.netty.channel.ChannelOutboundHandlerAdapter.flush(ChannelOutboundHandlerAdapter.java:115) [netty-transport-4.1.31.Final.jar:4.1.31.Final]
at io.netty.channel.CombinedChannelDuplexHandler.flush(CombinedChannelDuplexHandler.java:358) [netty-transport-4.1.31.Final.jar:4.1.31.Final]
at io.netty.channel.AbstractChannelHandlerContext.invokeFlush0(AbstractChannelHandlerContext.java:776) [netty-transport-4.1.31.Final.jar:4.1.31.Final]
at io.netty.channel.AbstractChannelHandlerContext.invokeFlush(AbstractChannelHandlerContext.java:768) [netty-transport-4.1.31.Final.jar:4.1.31.Final]
at io.netty.channel.AbstractChannelHandlerContext.flush(AbstractChannelHandlerContext.java:749) [netty-transport-4.1.31.Final.jar:4.1.31.Final]
at io.netty.channel.ChannelDuplexHandler.flush(ChannelDuplexHandler.java:117) [netty-transport-4.1.31.Final.jar:4.1.31.Final]
at io.netty.channel.AbstractChannelHandlerContext.invokeFlush0(AbstractChannelHandlerContext.java:776) [netty-transport-4.1.31.Final.jar:4.1.31.Final]
at io.netty.channel.AbstractChannelHandlerContext.invokeFlush(AbstractChannelHandlerContext.java:768) [netty-transport-4.1.31.Final.jar:4.1.31.Final]
at io.netty.channel.AbstractChannelHandlerContext.flush(AbstractChannelHandlerContext.java:749) [netty-transport-4.1.31.Final.jar:4.1.31.Final]
at reactor.netty.channel.ChannelOperationsHandler.doWrite(ChannelOperationsHandler.java:283) [reactor-netty-0.8.3.RELEASE.jar:0.8.3.RELEASE]
at reactor.netty.channel.ChannelOperationsHandler.drain(ChannelOperationsHandler.java:465) [reactor-netty-0.8.3.RELEASE.jar:0.8.3.RELEASE]
at reactor.netty.channel.ChannelOperationsHandler.flush(ChannelOperationsHandler.java:194) [reactor-netty-0.8.3.RELEASE.jar:0.8.3.RELEASE]
at io.netty.channel.AbstractChannelHandlerContext.invokeFlush0(AbstractChannelHandlerContext.java:776) [netty-transport-4.1.31.Final.jar:4.1.31.Final]
at io.netty.channel.AbstractChannelHandlerContext.invokeWriteAndFlush(AbstractChannelHandlerContext.java:802) [netty-transport-4.1.31.Final.jar:4.1.31.Final]
at io.netty.channel.AbstractChannelHandlerContext.write(AbstractChannelHandlerContext.java:814) [netty-transport-4.1.31.Final.jar:4.1.31.Final]
at io.netty.channel.AbstractChannelHandlerContext.writeAndFlush(AbstractChannelHandlerContext.java:794) [netty-transport-4.1.31.Final.jar:4.1.31.Final]
at io.netty.channel.AbstractChannelHandlerContext.writeAndFlush(AbstractChannelHandlerContext.java:837) [netty-transport-4.1.31.Final.jar:4.1.31.Final]
at io.netty.channel.DefaultChannelPipeline.writeAndFlush(DefaultChannelPipeline.java:1071) [netty-transport-4.1.31.Final.jar:4.1.31.Final]
at io.netty.channel.AbstractChannel.writeAndFlush(AbstractChannel.java:300) [netty-transport-4.1.31.Final.jar:4.1.31.Final]
at reactor.netty.http.server.HttpServerOperations.onOutboundComplete(HttpServerOperations.java:487) [reactor-netty-0.8.3.RELEASE.jar:0.8.3.RELEASE]
at reactor.netty.channel.ChannelOperations.onComplete(ChannelOperations.java:191) [reactor-netty-0.8.3.RELEASE.jar:0.8.3.RELEASE]
at reactor.core.publisher.FluxOnAssembly$OnAssemblySubscriber.onComplete(FluxOnAssembly.java:383) [reactor-core-3.2.3.RELEASE.jar:3.2.3.RELEASE]
at reactor.core.publisher.MonoPeekTerminal$MonoTerminalPeekSubscriber.onComplete(MonoPeekTerminal.java:321) [reactor-core-3.2.3.RELEASE.jar:3.2.3.RELEASE]
at reactor.core.publisher.FluxOnAssembly$OnAssemblySubscriber.onComplete(FluxOnAssembly.java:383) [reactor-core-3.2.3.RELEASE.jar:3.2.3.RELEASE]
at reactor.core.publisher.FluxPeekFuseable$PeekFuseableConditionalSubscriber.onComplete(FluxPeekFuseable.java:578) [reactor-core-3.2.3.RELEASE.jar:3.2.3.RELEASE]
at reactor.core.publisher.FluxOnAssembly$OnAssemblySubscriber.onComplete(FluxOnAssembly.java:383) [reactor-core-3.2.3.RELEASE.jar:3.2.3.RELEASE]
at reactor.core.publisher.Operators$MonoSubscriber.onComplete(Operators.java:1516) [reactor-core-3.2.3.RELEASE.jar:3.2.3.RELEASE]
at reactor.core.publisher.MonoIgnoreThen$ThenAcceptInner.onComplete(MonoIgnoreThen.java:314) [reactor-core-3.2.3.RELEASE.jar:3.2.3.RELEASE]
at reactor.core.publisher.FluxOnAssembly$OnAssemblySubscriber.onComplete(FluxOnAssembly.java:383) [reactor-core-3.2.3.RELEASE.jar:3.2.3.RELEASE]
at reactor.core.publisher.Operators.complete(Operators.java:131) [reactor-core-3.2.3.RELEASE.jar:3.2.3.RELEASE]
at reactor.core.publisher.MonoEmpty.subscribe(MonoEmpty.java:45) [reactor-core-3.2.3.RELEASE.jar:3.2.3.RELEASE]
at reactor.core.publisher.MonoDefer.subscribe(MonoDefer.java:52) [reactor-core-3.2.3.RELEASE.jar:3.2.3.RELEASE]
at reactor.core.publisher.MonoOnAssembly.subscribe(MonoOnAssembly.java:76) [reactor-core-3.2.3.RELEASE.jar:3.2.3.RELEASE]
at reactor.core.publisher.MonoIgnoreThen$ThenIgnoreMain.drain(MonoIgnoreThen.java:153) [reactor-core-3.2.3.RELEASE.jar:3.2.3.RELEASE]
at reactor.core.publisher.MonoIgnoreThen.subscribe(MonoIgnoreThen.java:56) [reactor-core-3.2.3.RELEASE.jar:3.2.3.RELEASE]
at reactor.core.publisher.MonoOnAssembly.subscribe(MonoOnAssembly.java:71) [reactor-core-3.2.3.RELEASE.jar:3.2.3.RELEASE]
at reactor.core.publisher.MonoPeekFuseable.subscribe(MonoPeekFuseable.java:70) [reactor-core-3.2.3.RELEASE.jar:3.2.3.RELEASE]
at reactor.core.publisher.MonoOnAssembly.subscribe(MonoOnAssembly.java:71) [reactor-core-3.2.3.RELEASE.jar:3.2.3.RELEASE]
at reactor.core.publisher.MonoPeekTerminal.subscribe(MonoPeekTerminal.java:61) [reactor-core-3.2.3.RELEASE.jar:3.2.3.RELEASE]
at reactor.core.publisher.MonoOnAssembly.subscribe(MonoOnAssembly.java:76) [reactor-core-3.2.3.RELEASE.jar:3.2.3.RELEASE]
at reactor.netty.http.server.HttpServerHandle.onStateChange(HttpServerHandle.java:64) [reactor-netty-0.8.3.RELEASE.jar:0.8.3.RELEASE]
at reactor.netty.tcp.TcpServerBind$ChildObserver.onStateChange(TcpServerBind.java:226) [reactor-netty-0.8.3.RELEASE.jar:0.8.3.RELEASE]
at reactor.netty.http.server.HttpServerOperations.onInboundNext(HttpServerOperations.java:434) [reactor-netty-0.8.3.RELEASE.jar:0.8.3.RELEASE]
at reactor.netty.channel.ChannelOperationsHandler.channelRead(ChannelOperationsHandler.java:141) [reactor-netty-0.8.3.RELEASE.jar:0.8.3.RELEASE]
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:362) [netty-transport-4.1.31.Final.jar:4.1.31.Final]
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:348) [netty-transport-4.1.31.Final.jar:4.1.31.Final]
at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:340) [netty-transport-4.1.31.Final.jar:4.1.31.Final]
at reactor.netty.http.server.HttpTrafficHandler.channelRead(HttpTrafficHandler.java:159) [reactor-netty-0.8.3.RELEASE.jar:0.8.3.RELEASE]
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:362) [netty-transport-4.1.31.Final.jar:4.1.31.Final]
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:348) [netty-transport-4.1.31.Final.jar:4.1.31.Final]
at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:340) [netty-transport-4.1.31.Final.jar:4.1.31.Final]
at io.netty.channel.CombinedChannelDuplexHandler$DelegatingChannelHandlerContext.fireChannelRead(CombinedChannelDuplexHandler.java:438) [netty-transport-4.1.31.Final.jar:4.1.31.Final]
at io.netty.handler.codec.ByteToMessageDecoder.fireChannelRead(ByteToMessageDecoder.java:323) [netty-codec-4.1.31.Final.jar:4.1.31.Final]
at io.netty.handler.codec.ByteToMessageDecoder.channelRead(ByteToMessageDecoder.java:297) [netty-codec-4.1.31.Final.jar:4.1.31.Final]
at io.netty.channel.CombinedChannelDuplexHandler.channelRead(CombinedChannelDuplexHandler.java:253) [netty-transport-4.1.31.Final.jar:4.1.31.Final]
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:362) [netty-transport-4.1.31.Final.jar:4.1.31.Final]
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:348) [netty-transport-4.1.31.Final.jar:4.1.31.Final]
at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:340) [netty-transport-4.1.31.Final.jar:4.1.31.Final]
at io.netty.channel.DefaultChannelPipeline$HeadContext.channelRead(DefaultChannelPipeline.java:1434) [netty-transport-4.1.31.Final.jar:4.1.31.Final]
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:362) [netty-transport-4.1.31.Final.jar:4.1.31.Final]
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:348) [netty-transport-4.1.31.Final.jar:4.1.31.Final]
at io.netty.channel.DefaultChannelPipeline.fireChannelRead(DefaultChannelPipeline.java:965) [netty-transport-4.1.31.Final.jar:4.1.31.Final]
at io.netty.channel.nio.AbstractNioByteChannel$NioByteUnsafe.read(AbstractNioByteChannel.java:163) [netty-transport-4.1.31.Final.jar:4.1.31.Final]
at io.netty.channel.nio.NioEventLoop.processSelectedKey(NioEventLoop.java:648) [netty-transport-4.1.31.Final.jar:4.1.31.Final]
at io.netty.channel.nio.NioEventLoop.processSelectedKeysOptimized(NioEventLoop.java:583) [netty-transport-4.1.31.Final.jar:4.1.31.Final]
at io.netty.channel.nio.NioEventLoop.processSelectedKeys(NioEventLoop.java:500) [netty-transport-4.1.31.Final.jar:4.1.31.Final]
at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:462) [netty-transport-4.1.31.Final.jar:4.1.31.Final]
at io.netty.util.concurrent.SingleThreadEventExecutor$5.run(SingleThreadEventExecutor.java:897) [netty-common-4.1.31.Final.jar:4.1.31.Final]
at java.lang.Thread.run(Thread.java:748) [na:1.8.0_192]
2018-12-10 21:41:17.013 DEBUG 31340 --- [ctor-http-nio-2] r.n.channel.ChannelOperationsHandler : [id: 0x7cc865b4, L:/0:0:0:0:0:0:0:1:8080 - R:/0:0:0:0:0:0:0:1:52638] No ChannelOperation attached. Dropping: EmptyLastHttpContent
The reactor's debug mode is not been actived.
So I wonder How to debug in spring webflux?Or is there anyway help us find errors in our code quickly?
In reactor, Hooks.onOperatorDebug() instruments the Reactor operators to collect more information about the current stack during the execution. This has a performance cost, and should not be done in production. This is a static call that needs to be done only once per JVM execution, so no need to repeat it for every controller call. With Spring Boot, this is done automatically for you is you have the spring-boot-devtools dependency on classpath.
Since Spring Boot 2.1, you can get better logs for web-related operations by setting to DEBUG the web logging group, so logging.level.web=debug. This will log useful information about web requests processing.
In your case, you seem also to be missing information about the execution of the Reactor pipeline. In this case, you should add log() operators in your pipeline to understand what signals are going through your pipeline.
In this particular code snippet, I'm seeing several things:
the String a method parameter seems odd since it's not coupled with an annotation that fetches data from the incoming request such as #RequestParam
the Mono.zipWith(Mono) operator doesn't make sense here; the result will always be an error signal with an IllegalArgumentException. So it is expected for the Spring Boot error handling to process that exception and render an HTML error page
I am breaking my head with this issue. I have a simple controller class with the capability to render a simple html page along with the Spring boot initializer class.
I have placed the HTML page in the static folder under src/main/resources directory.
But I am not able to get the html page. Instead I get 404 error.
Below is the structure of my project
Below is my Pom.xml
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.example</groupId>
<artifactId>demo</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging>
<name>demo</name>
<description>Demo project for Spring Boot</description>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.5.1.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<java.version>1.8</java.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>
Below are the controller and Spring Initializer class
DemoApplication.java:
package com.example;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
#SpringBootApplication
public class DemoApplication {
public static void main(String[] args) {
SpringApplication.run(DemoApplication.class, args);
}
}
SimpleController.java:
package com.example.controller;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
#Controller
public class SimpleController {
#RequestMapping("/")
public String home(){
System.out.println("Hello Home...");
return "home";
}
}
home.html:
<!DOCTYPE html>
<html>
<head>
<meta charset="ISO-8859-1">
<title>Hello</title>
</head>
<body>
Helloooo......
</body>
</html>
Console Logs on running the Spring Boot:
:: Spring Boot :: (v1.5.1.RELEASE)
2017-02-28 10:46:26.676 INFO 8240 --- [ main] com.example.DemoApplication : Starting DemoApplication on abc with PID 8240 (C:\SpringBootEx\demo\target\classes started by abc in C:\SpringBootEx\demo)
2017-02-28 10:46:26.681 INFO 8240 --- [ main] com.example.DemoApplication : No active profile set, falling back to default profiles: default
2017-02-28 10:46:26.771 INFO 8240 --- [ main] ationConfigEmbeddedWebApplicationContext : Refreshing org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext#70b0b186: startup date [Tue Feb 28 10:46:26 MST 2017]; root of context hierarchy
2017-02-28 10:46:28.281 INFO 8240 --- [ main] trationDelegate$BeanPostProcessorChecker : Bean 'org.springframework.boot.autoconfigure.validation.ValidationAutoConfiguration' of type [class org.springframework.boot.autoconfigure.validation.ValidationAutoConfiguration] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2017-02-28 10:46:28.514 INFO 8240 --- [ main] trationDelegate$BeanPostProcessorChecker : Bean 'validator' of type [class org.springframework.validation.beanvalidation.LocalValidatorFactoryBean] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2017-02-28 10:46:28.949 INFO 8240 --- [ main] s.b.c.e.t.TomcatEmbeddedServletContainer : Tomcat initialized with port(s): 8080 (http)
2017-02-28 10:46:28.973 INFO 8240 --- [ main] o.apache.catalina.core.StandardService : Starting service Tomcat
2017-02-28 10:46:28.974 INFO 8240 --- [ main] org.apache.catalina.core.StandardEngine : Starting Servlet Engine: Apache Tomcat/8.5.11
2017-02-28 10:46:29.194 INFO 8240 --- [ost-startStop-1] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring embedded WebApplicationContext
2017-02-28 10:46:29.194 INFO 8240 --- [ost-startStop-1] o.s.web.context.ContextLoader : Root WebApplicationContext: initialization completed in 2428 ms
2017-02-28 10:46:29.448 INFO 8240 --- [ost-startStop-1] o.s.b.w.servlet.ServletRegistrationBean : Mapping servlet: 'dispatcherServlet' to [/]
2017-02-28 10:46:29.455 INFO 8240 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'characterEncodingFilter' to: [/]
2017-02-28 10:46:29.457 INFO 8240 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'hiddenHttpMethodFilter' to: [/]
2017-02-28 10:46:29.458 INFO 8240 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'httpPutFormContentFilter' to: [/]
2017-02-28 10:46:29.458 INFO 8240 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'requestContextFilter' to: [/]
2017-02-28 10:46:29.967 INFO 8240 --- [ main] s.w.s.m.m.a.RequestMappingHandlerAdapter : Looking for #ControllerAdvice: org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext#70b0b186: startup date [Tue Feb 28 10:46:26 MST 2017]; root of context hierarchy
2017-02-28 10:46:30.071 INFO 8240 --- [ main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/]}" onto public java.lang.String com.example.controller.SimpleController.home()
2017-02-28 10:46:30.080 INFO 8240 --- [ main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/error]}" onto public org.springframework.http.ResponseEntity> org.springframework.boot.autoconfigure.web.BasicErrorController.error(javax.servlet.http.HttpServletRequest)
2017-02-28 10:46:30.081 INFO 8240 --- [ 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.BasicErrorController.errorHtml(javax.servlet.http.HttpServletRequest,javax.servlet.http.HttpServletResponse)
2017-02-28 10:46:30.145 INFO 8240 --- [ main] o.s.w.s.handler.SimpleUrlHandlerMapping : Mapped URL path [/webjars/] onto handler of type [class org.springframework.web.servlet.resource.ResourceHttpRequestHandler]
2017-02-28 10:46:30.145 INFO 8240 --- [ main] o.s.w.s.handler.SimpleUrlHandlerMapping : Mapped URL path [/] onto handler of type [class org.springframework.web.servlet.resource.ResourceHttpRequestHandler]
2017-02-28 10:46:30.194 INFO 8240 --- [ main] o.s.w.s.handler.SimpleUrlHandlerMapping : Mapped URL path [/**/favicon.ico] onto handler of type [class org.springframework.web.servlet.resource.ResourceHttpRequestHandler]
2017-02-28 10:46:30.478 INFO 8240 --- [ main] o.s.j.e.a.AnnotationMBeanExporter : Registering beans for JMX exposure on startup
2017-02-28 10:46:30.582 INFO 8240 --- [ main] s.b.c.e.t.TomcatEmbeddedServletContainer : Tomcat started on port(s): 8080 (http)
2017-02-28 10:46:30.590 INFO 8240 --- [ main] com.example.DemoApplication : Started DemoApplication in 4.391 seconds (JVM running for 5.147)
2017-02-28 10:49:04.176 INFO 8240 --- [nio-8080-exec-1] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring FrameworkServlet 'dispatcherServlet'
2017-02-28 10:49:04.176 INFO 8240 --- [nio-8080-exec-1] o.s.web.servlet.DispatcherServlet : FrameworkServlet 'dispatcherServlet': initialization started
2017-02-28 10:49:04.205 INFO 8240 --- [nio-8080-exec-1] o.s.web.servlet.DispatcherServlet : FrameworkServlet 'dispatcherServlet': initialization completed in 29 ms
Hello Home...
Can someone please help me in getting the view rendered? Thanks..
You can place home.html into one of the following locations:
src/main/resources/META-INF/resources/home.html
src/main/resources/resources/home.html
src/main/resources/static/home.html
src/main/resources/public/home.html
and make
#RequestMapping("/")
public String home() {
System.out.println("Hello Home...");
return "home.html";
}
Add the below tags inside <build></build>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
<resources>
<resource>
<directory>src/main/resources</directory>
</resource>
</resources>`
</build>
I am using Spring Rest and Mongo in Maven to make a web service that connects to a server. The problem is that I haven't written any code for Mongo and it is trying to connect to localhost throwing me a MongoSocketOpenException. The only code I've written is a two line code that starts spring from main.This is the stacktrace:
2015-12-22 12:46:43.193 INFO 5720 --- [ main] fhirepsos.ws.Server : Starting Server on HarisPC with PID 5720 (C:\Users\Haris\workspace\FHIRtoepSOSConversion\target\classes started by Haris in C:\Users\Haris\workspace\FHIRtoepSOSConversion)
2015-12-22 12:46:43.197 INFO 5720 --- [ main] fhirepsos.ws.Server : No profiles are active
2015-12-22 12:46:43.260 INFO 5720 --- [ main] ationConfigEmbeddedWebApplicationContext : Refreshing org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext#31f924f5: startup date [Tue Dec 22 12:46:43 EET 2015]; root of context hierarchy
2015-12-22 12:46:44.007 INFO 5720 --- [ main] o.s.b.f.s.DefaultListableBeanFactory : Overriding bean definition for bean 'beanNameViewResolver' 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.web.ErrorMvcAutoConfiguration$WhitelabelErrorViewConfiguration; factoryMethodName=beanNameViewResolver; initMethodName=null; destroyMethodName=(inferred); defined in class path resource [org/springframework/boot/autoconfigure/web/ErrorMvcAutoConfiguration$WhitelabelErrorViewConfiguration.class]] with [Root bean: class [null]; scope=; abstract=false; lazyInit=false; autowireMode=3; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=org.springframework.boot.autoconfigure.web.WebMvcAutoConfiguration$WebMvcAutoConfigurationAdapter; factoryMethodName=beanNameViewResolver; initMethodName=null; destroyMethodName=(inferred); defined in class path resource [org/springframework/boot/autoconfigure/web/WebMvcAutoConfiguration$WebMvcAutoConfigurationAdapter.class]]
2015-12-22 12:46:44.735 INFO 5720 --- [ main] s.b.c.e.t.TomcatEmbeddedServletContainer : Tomcat initialized with port(s): 9001 (http)
2015-12-22 12:46:44.750 INFO 5720 --- [ main] o.apache.catalina.core.StandardService : Starting service Tomcat
2015-12-22 12:46:44.751 INFO 5720 --- [ main] org.apache.catalina.core.StandardEngine : Starting Servlet Engine: Apache Tomcat/8.0.28
2015-12-22 12:46:44.865 INFO 5720 --- [ost-startStop-1] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring embedded WebApplicationContext
2015-12-22 12:46:44.866 INFO 5720 --- [ost-startStop-1] o.s.web.context.ContextLoader : Root WebApplicationContext: initialization completed in 1610 ms
2015-12-22 12:46:45.161 INFO 5720 --- [ost-startStop-1] o.s.b.c.e.ServletRegistrationBean : Mapping servlet: 'dispatcherServlet' to [/]
2015-12-22 12:46:45.166 INFO 5720 --- [ost-startStop-1] o.s.b.c.embedded.FilterRegistrationBean : Mapping filter: 'characterEncodingFilter' to: [/*]
2015-12-22 12:46:45.166 INFO 5720 --- [ost-startStop-1] o.s.b.c.embedded.FilterRegistrationBean : Mapping filter: 'hiddenHttpMethodFilter' to: [/*]
2015-12-22 12:46:45.167 INFO 5720 --- [ost-startStop-1] o.s.b.c.embedded.FilterRegistrationBean : Mapping filter: 'httpPutFormContentFilter' to: [/*]
2015-12-22 12:46:45.167 INFO 5720 --- [ost-startStop-1] o.s.b.c.embedded.FilterRegistrationBean : Mapping filter: 'requestContextFilter' to: [/*]
2015-12-22 12:46:45.393 INFO 5720 --- [ main] s.w.s.m.m.a.RequestMappingHandlerAdapter : Looking for #ControllerAdvice: org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext#31f924f5: startup date [Tue Dec 22 12:46:43 EET 2015]; root of context hierarchy
2015-12-22 12:46:45.467 INFO 5720 --- [ 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.BasicErrorController.error(javax.servlet.http.HttpServletRequest)
2015-12-22 12:46:45.468 INFO 5720 --- [ 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.BasicErrorController.errorHtml(javax.servlet.http.HttpServletRequest)
2015-12-22 12:46:45.499 INFO 5720 --- [ main] o.s.w.s.handler.SimpleUrlHandlerMapping : Mapped URL path [/webjars/**] onto handler of type [class org.springframework.web.servlet.resource.ResourceHttpRequestHandler]
2015-12-22 12:46:45.499 INFO 5720 --- [ main] o.s.w.s.handler.SimpleUrlHandlerMapping : Mapped URL path [/**] onto handler of type [class org.springframework.web.servlet.resource.ResourceHttpRequestHandler]
2015-12-22 12:46:45.539 INFO 5720 --- [ main] o.s.w.s.handler.SimpleUrlHandlerMapping : Mapped URL path [/**/favicon.ico] onto handler of type [class org.springframework.web.servlet.resource.ResourceHttpRequestHandler]
2015-12-22 12:46:45.726 INFO 5720 --- [ main] org.mongodb.driver.cluster : Cluster created with settings {hosts=[localhost:27017], mode=SINGLE, requiredClusterType=UNKNOWN, serverSelectionTimeout='30000 ms', maxWaitQueueSize=500}
2015-12-22 12:46:45.796 INFO 5720 --- [ main] o.s.j.e.a.AnnotationMBeanExporter : Registering beans for JMX exposure on startup
2015-12-22 12:46:45.874 INFO 5720 --- [ main] s.b.c.e.t.TomcatEmbeddedServletContainer : Tomcat started on port(s): 9001 (http)
2015-12-22 12:46:45.878 INFO 5720 --- [ main] fhirepsos.ws.Server : Started Server in 3.033 seconds (JVM running for 3.383)
2015-12-22 12:46:46.764 INFO 5720 --- [localhost:27017] org.mongodb.driver.cluster : Exception in monitor thread while connecting to server localhost:27017
com.mongodb.MongoSocketOpenException: Exception opening socket
at com.mongodb.connection.SocketStream.open(SocketStream.java:63) ~[mongo-java-driver-3.2.0.jar:na]
at com.mongodb.connection.InternalStreamConnection.open(InternalStreamConnection.java:114) ~[mongo-java-driver-3.2.0.jar:na]
at com.mongodb.connection.DefaultServerMonitor$ServerMonitorRunnable.run(DefaultServerMonitor.java:128) ~[mongo-java-driver-3.2.0.jar:na]
at java.lang.Thread.run(Unknown Source) [na:1.8.0_65]
Caused by: java.net.ConnectException: Connection refused: connect
at java.net.DualStackPlainSocketImpl.waitForConnect(Native Method) ~[na:1.8.0_65]
at java.net.DualStackPlainSocketImpl.socketConnect(Unknown Source) ~[na:1.8.0_65]
at java.net.AbstractPlainSocketImpl.doConnect(Unknown Source) ~[na:1.8.0_65]
at java.net.AbstractPlainSocketImpl.connectToAddress(Unknown Source) ~[na:1.8.0_65]
at java.net.AbstractPlainSocketImpl.connect(Unknown Source) ~[na:1.8.0_65]
at java.net.PlainSocketImpl.connect(Unknown Source) ~[na:1.8.0_65]
at java.net.SocksSocketImpl.connect(Unknown Source) ~[na:1.8.0_65]
at java.net.Socket.connect(Unknown Source) ~[na:1.8.0_65]
at com.mongodb.connection.SocketStreamHelper.initialize(SocketStreamHelper.java:50) ~[mongo-java-driver-3.2.0.jar:na]
at com.mongodb.connection.SocketStream.open(SocketStream.java:58) ~[mongo-java-driver-3.2.0.jar:na]
... 3 common frames omitted
This is my pom.xml
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>fhirepsos.ws</groupId>
<artifactId>FHIRtoepSOSConversion</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>FHIR to epSOS Conversion</name>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.3.0.RELEASE</version>
</parent>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.mongodb</groupId>
<artifactId>mongo-java-driver</artifactId>
<version>3.2.0</version>
</dependency>
<dependency>
<groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-fhir-base</artifactId>
<version>1.3</version>
</dependency>
<dependency>
<groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-fhir-structures-dstu2</artifactId>
<version>1.3</version>
</dependency>
</dependencies>
<properties>
<java.version>1.8</java.version>
</properties>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
<repositories>
<repository>
<id>spring-releases</id>
<url>https://repo.spring.io/libs-release</url>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<id>spring-releases</id>
<url>https://repo.spring.io/libs-release</url>
</pluginRepository>
</pluginRepositories>
</project>
Finally I have to state that despite the exception the program works fine
Thanks in advance!
Spring Boot has a feature called "auto configuration". In this case, as soon as the Mongo driver is detected on the classpath, the MongoAutoConfiguration is activated with default values, which point to localhost:27017. If you don't want that behaviour, you can now either configure the properties for MongoDB (see http://docs.spring.io/spring-boot/docs/current/reference/htmlsingle/#boot-features-mongodb for valid property keys) or disable the MongoAutoConfiguration:
#SpringBootApplication(exclude = {MongoAutoConfiguration.class, MongoDataAutoConfiguration.class})
In some cases, if you are using reactive you also need to remove MongoReactiveAutoConfiguration
spring:
autoconfigure:
exclude:
- org.springframework.boot.autoconfigure.mongo.MongoAutoConfiguration
- org.springframework.boot.autoconfigure.mongo.MongoReactiveAutoConfiguration
Spring boot throws this exception when Mongo DB is not running. Please make sure that Mongodb is running. It got resolved for me after starting Mongo DB.
for springboot, you should add following config to your application.property
spring.data.mongodb.host=localhost(your mongo server)
spring.data.mongodb.port=27017(mongo port)