I'm a frontend developer so my knowledge of Java, Spring and IntelliJ is virtually zero.
I accidentally deleted my company's repo on my local machine so I re-cloned it back from GitHub. I was unable to click the "debug" button as it was grayed out so I asked a colleague what their Run/Debug configurations were and added it to my editor.
Normally, I would click on "debug" and it would run and work with the frontend, but now when I run it this is the error I receive:
updated based on Kaj Hejer recommendation:
Connected to the target VM, address: '127.0.0.1:60174', transport: 'socket'
2021-03-31 13:02:22.350 INFO ['casino-api':main::] c.company.casinoapi.CasinoApiApplication - Starting CasinoApiApplication on Marks-MacBook-Pro.local with PID 7352 (/Users/work/Documents/casino-api/target/classes started by work in /Users/work/Documents/casino-api)
2021-03-31 13:02:22.353 INFO ['casino-api':main::] c.company.casinoapi.CasinoApiApplication - The following profiles are active: local
2021-03-31 13:02:23.781 INFO ['casino-api':main::] o.apache.coyote.http11.Http11NioProtocol - Initializing ProtocolHandler ["http-nio-8080"]
2021-03-31 13:02:23.781 INFO ['casino-api':main::] org.apache.catalina.core.StandardService - Starting service [Tomcat]
2021-03-31 13:02:23.781 INFO ['casino-api':main::] org.apache.catalina.core.StandardEngine - Starting Servlet engine: [Apache Tomcat/9.0.31]
2021-03-31 13:02:23.870 INFO ['casino-api':main::] o.a.c.c.C.[Tomcat].[localhost].[/] - Initializing Spring embedded WebApplicationContext
2021-03-31 13:02:23.871 INFO ['casino-api':main::] o.s.web.context.ContextLoader - Root WebApplicationContext: initialization completed in 1480 ms
2021-03-31 13:02:24.171 INFO ['casino-api':main::] io.lettuce.core.EpollProvider - Starting without optional epoll library
2021-03-31 13:02:24.171 INFO ['casino-api':main::] io.lettuce.core.KqueueProvider - Starting without optional kqueue library
2021-03-31 13:02:24.418 INFO ['casino-api':main::] o.f.core.internal.license.VersionPrinter - Flyway Community Edition 6.0.8 by Redgate
2021-03-31 13:02:24.423 INFO ['casino-api':main::] com.zaxxer.hikari.HikariDataSource - HikariPool-1 - Starting...
2021-03-31 13:02:24.483 INFO ['casino-api':main::] com.zaxxer.hikari.HikariDataSource - HikariPool-1 - Start completed.
2021-03-31 13:02:24.500 INFO ['casino-api':main::] o.f.c.internal.database.DatabaseFactory - Database: jdbc:mysql://0.0.0.0:4306/api (MySQL 10.4)
2021-03-31 13:02:24.570 INFO ['casino-api':main::] o.f.core.internal.command.DbValidate - Successfully validated 3 migrations (execution time 00:00.019s)
2021-03-31 13:02:24.583 INFO ['casino-api':main::] o.f.core.internal.command.DbMigrate - Current version of schema `api`: 2
2021-03-31 13:02:24.583 WARN ['casino-api':main::] o.f.core.internal.command.DbMigrate - Schema `api` has a version (2) that is newer than the latest available migration (1) !
2021-03-31 13:02:24.585 INFO ['casino-api':main::] o.f.core.internal.command.DbMigrate - Schema `api` is up to date. No migration necessary.
2021-03-31 13:02:24.674 INFO ['casino-api':main::] o.hibernate.jpa.internal.util.LogHelper - HHH000204: Processing PersistenceUnitInfo [name: default]
2021-03-31 13:02:24.741 INFO ['casino-api':main::] org.hibernate.Version - HHH000412: Hibernate Core {5.4.10.Final}
2021-03-31 13:02:24.871 INFO ['casino-api':main::] org.hibernate.annotations.common.Version - HCANN000001: Hibernate Commons Annotations {5.1.0.Final}
2021-03-31 13:02:24.981 INFO ['casino-api':main::] org.hibernate.dialect.Dialect - HHH000400: Using dialect: org.hibernate.dialect.MariaDBDialect
2021-03-31 13:02:25.139 WARN ['casino-api':main::] org.hibernate.cfg.AnnotationBinder - HHH000457: Joined inheritance hierarchy [com.company.casinoapi.model.game.GameLog] defined explicit #DiscriminatorColumn. Legacy Hibernate behavior was to ignore the #DiscriminatorColumn. However, as part of issue HHH-6911 we now apply the explicit #DiscriminatorColumn. If you would prefer the legacy behavior, enable the `hibernate.discriminator.ignore_explicit_for_joined` setting (hibernate.discriminator.ignore_explicit_for_joined=true)
2021-03-31 13:02:25.893 INFO ['casino-api':main::] o.h.e.t.j.p.i.JtaPlatformInitiator - HHH000490: Using JtaPlatform implementation: [org.hibernate.engine.transaction.jta.platform.internal.NoJtaPlatform]
2021-03-31 13:02:26.260 WARN ['casino-api':main::] o.s.b.a.o.j.JpaBaseConfiguration$JpaWebConfiguration - spring.jpa.open-in-view is enabled by default. Therefore, database queries may be performed during view rendering. Explicitly configure spring.jpa.open-in-view to disable this warning
2021-03-31 13:02:26.502 WARN ['casino-api':main::] o.s.b.w.s.c.AnnotationConfigServletWebServerApplicationContext - Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'gameReportController': Unsatisfied dependency expressed through field 'jwtAuthenticator'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'globalJWTConfig' defined in class path resource [com/company/casinoapi/config/JWTAuthConfig.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [com.company.casinoapi.bean.JWTAuthenticator]: Factory method 'globalJWTConfig' threw exception; nested exception is java.nio.file.NoSuchFileException: src/main/resources/secrets/api-engine-secret.key
2021-03-31 13:02:26.505 INFO ['casino-api':main::] com.zaxxer.hikari.HikariDataSource - HikariPool-1 - Shutdown initiated...
2021-03-31 13:02:26.522 INFO ['casino-api':main::] com.zaxxer.hikari.HikariDataSource - HikariPool-1 - Shutdown completed.
2021-03-31 13:02:26.550 INFO ['casino-api':main::] org.apache.catalina.core.StandardService - Stopping service [Tomcat]
2021-03-31 13:02:26.564 ERROR ['casino-api':main::] o.springframework.boot.SpringApplication - Application run failed
org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'gameReportController': Unsatisfied dependency expressed through field 'jwtAuthenticator'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'globalJWTConfig' defined in class path resource [com/company/casinoapi/config/JWTAuthConfig.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [com.company.casinoapi.bean.JWTAuthenticator]: Factory method 'globalJWTConfig' threw exception; nested exception is java.nio.file.NoSuchFileException: src/main/resources/secrets/api-engine-secret.key
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:643)
at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:130)
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessProperties(AutowiredAnnotationBeanPostProcessor.java:399)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1422)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:594)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:517)
at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:323)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:321)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:202)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:879)
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:878)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:550)
at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:141)
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:747)
at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:397)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:315)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1226)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1215)
at com.company.casinoapi.CasinoApiApplication.main(CasinoApiApplication.java:10)
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'globalJWTConfig' defined in class path resource [com/company/casinoapi/config/JWTAuthConfig.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [com.company.casinoapi.bean.JWTAuthenticator]: Factory method 'globalJWTConfig' threw exception; nested exception is java.nio.file.NoSuchFileException: src/main/resources/secrets/api-engine-secret.key
at org.springframework.beans.factory.support.ConstructorResolver.instantiate(ConstructorResolver.java:656)
at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:484)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateUsingFactoryMethod(AbstractAutowireCapableBeanFactory.java:1338)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1177)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:557)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:517)
at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:323)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:321)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:202)
at org.springframework.beans.factory.config.DependencyDescriptor.resolveCandidate(DependencyDescriptor.java:276)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1287)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:1207)
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:640)
... 19 common frames omitted
Caused by: org.springframework.beans.BeanInstantiationException: Failed to instantiate [com.company.casinoapi.bean.JWTAuthenticator]: Factory method 'globalJWTConfig' threw exception; nested exception is java.nio.file.NoSuchFileException: src/main/resources/secrets/api-engine-secret.key
at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:185)
at org.springframework.beans.factory.support.ConstructorResolver.instantiate(ConstructorResolver.java:651)
... 32 common frames omitted
Caused by: java.nio.file.NoSuchFileException: src/main/resources/secrets/api-engine-secret.key
at java.base/sun.nio.fs.UnixException.translateToIOException(UnixException.java:92)
at java.base/sun.nio.fs.UnixException.rethrowAsIOException(UnixException.java:111)
at java.base/sun.nio.fs.UnixException.rethrowAsIOException(UnixException.java:116)
at java.base/sun.nio.fs.UnixFileSystemProvider.newByteChannel(UnixFileSystemProvider.java:219)
at java.base/java.nio.file.Files.newByteChannel(Files.java:370)
at java.base/java.nio.file.Files.newByteChannel(Files.java:421)
at java.base/java.nio.file.spi.FileSystemProvider.newInputStream(FileSystemProvider.java:420)
at java.base/java.nio.file.Files.newInputStream(Files.java:155)
at java.base/java.nio.file.Files.newBufferedReader(Files.java:2838)
at java.base/java.nio.file.Files.readAllLines(Files.java:3329)
at com.company.casinoapi.bean.JWTAuthenticator.<init>(JWTAuthenticator.java:28)
at com.company.casinoapi.config.JWTAuthConfig.globalJWTConfig(JWTAuthConfig.java:17)
at com.company.casinoapi.config.JWTAuthConfig$$EnhancerBySpringCGLIB$$8d9d3081.CGLIB$globalJWTConfig$0(<generated>)
at com.company.casinoapi.config.JWTAuthConfig$$EnhancerBySpringCGLIB$$8d9d3081$$FastClassBySpringCGLIB$$f2f1d21b.invoke(<generated>)
at org.springframework.cglib.proxy.MethodProxy.invokeSuper(MethodProxy.java:244)
at org.springframework.context.annotation.ConfigurationClassEnhancer$BeanMethodInterceptor.intercept(ConfigurationClassEnhancer.java:331)
at com.company.casinoapi.config.JWTAuthConfig$$EnhancerBySpringCGLIB$$8d9d3081.globalJWTConfig(<generated>)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:566)
at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:154)
... 33 common frames omitted
Disconnected from the target VM, address: '127.0.0.1:60174', transport: 'socket'
Process finished with exit code 1
In the stacktrace you can see the following:
Caused by: org.springframework.beans.BeanInstantiationException: Failed to instantiate [io.lettuce.core.api.StatefulRedisConnection]: Factory method 'connection' threw exception; nested exception is io.lettuce.core.RedisConnectionException: Unable to connect to 0.0.0.0:6380
at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:185)
at org.springframework.beans.factory.support.ConstructorResolver.instantiate(ConstructorResolver.java:651)
... 96 common frames omitted
Caused by: io.lettuce.core.RedisConnectionException: Unable to connect to 0.0.0.0:6380
at io.lettuce.core.RedisConnectionException.create(RedisConnectionException.java:7
It looks like you app is trying to connect to a redis-server. I suggest you hear with your colleague how they start the redis-server.
First you need to add api-engine-secret.key file to your project in the path src/main/resources/secrets, maybe this file not pushed to GitHub repository, So you need to get it from a colleague.
I am trying to run some spring boot application, but i am getting below issue:
:: Built with Spring Boot :: 2.3.1.RELEASE
2020-08-30 17:43:17.953 GMT+05:30 INFO rid=NA cid=NA 21756 --- [ main] o.s.s.petclinic.PetClinicApplication : Starting PetClinicApplication v2.3.1.BUILD-SNAPSHOT on saasas-WX-3 with PID 21756 (C:
\work\upstream\fault-tolerance-demo\target\spring-petclinic-2.3.1.BUILD-SNAPSHOT.jar started by krsoni in C:\work\upstream\fault-tolerance-demo)
2020-08-30 17:43:17.959 GMT+05:30 INFO rid=NA cid=NA 21756 --- [ main] o.s.s.petclinic.PetClinicApplication : No active profile set, falling back to default profiles: default
2020-08-30 17:43:19.799 GMT+05:30 WARN rid=NA cid=NA 21756 --- [ main] ConfigServletWebServerApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: org
.springframework.beans.factory.support.BeanDefinitionOverrideException: Invalid bean definition with name 'dispatcherServlet' defined in class path resource [com/mycompany/asr/autoconfigure/asr/ASRAutoConfiguration
.class]: Cannot register bean definition [Root bean: class [null]; scope=; abstract=false; lazyInit=null; autowireMode=3; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=com.mycompany.asr.
autoconfigure.asr.ASRAutoConfiguration; factoryMethodName=getDispatcherServlet; initMethodName=null; destroyMethodName=(inferred); defined in class path resource [com/mycompany/asr/autoconfigure/asr/ASRAutoConfigur
ation.class]] for bean 'dispatcherServlet': There is already [Root bean: class [null]; scope=; abstract=false; lazyInit=null; autowireMode=3; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBea
nName=org.springframework.boot.autoconfigure.web.servlet.DispatcherServletAutoConfiguration$DispatcherServletConfiguration; factoryMethodName=dispatcherServlet; initMethodName=null; destroyMethodName=(inferred)
; defined in class path resource [org/springframework/boot/autoconfigure/web/servlet/DispatcherServletAutoConfiguration$DispatcherServletConfiguration.class]] bound.
2020-08-30 17:43:19.811 GMT+05:30 INFO rid=NA cid=NA 21756 --- [ main] ConditionEvaluationReportLoggingListener :
Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled.
2020-08-30 17:43:19.813 GMT+05:30 ERROR rid=NA cid=NA 21756 --- [ main] o.s.b.d.LoggingFailureAnalysisReporter :
***************************
APPLICATION FAILED TO START
***************************
Description:
The bean 'dispatcherServlet', defined in class path resource [com/mycompany/asr/autoconfigure/asr/ASRAutoConfiguration.class], could not be registered. A bean with that name has already been defined in class path r
esource [org/springframework/boot/autoconfigure/web/servlet/DispatcherServletAutoConfiguration$DispatcherServletConfiguration.class] and overriding is disabled.
Action:
Consider renaming one of the beans or enabling overriding by setting spring.main.allow-bean-definition-overriding=true
Class where this bean definition is below. And its a third party jar ,which cant be modified:
#Configuration
#PropertySource("asr.properties")
#EnableConfigurationProperties(AsrProperties.class)
public class ASRAutoConfiguration {
#Autowired
AsrProperties asrProperties;
#Bean
public EmbeddedServletContainerCustomizer getEmbeddedServletContainerCustomizer() {
// this property is accessed from many Contexts, so setting in system is the easiest
System.setProperty("org.apache.catalina.STRICT_SERVLET_COMPLIANCE", "true");
// configure Tomcat based on properties
AsrTomcatProperties asrTomcatProperties = new AsrTomcatProperties();
asrTomcatProperties.setConnectionTimeout(asrProperties.getServer().getConnectionTimeout());
asrTomcatProperties.setMaxSwallowSize(asrProperties.getServer().getMaxSwallowSize());
return new AsrEmbeddedTomcatCustomizer(asrTomcatProperties);
}
/**
* This is done to disable Spring MVC dispatcherServlet
*/
#Bean(name = "dispatcherServlet")
public String getDispatcherServlet() {
return "";
}
#Bean
public WebApplicationExceptionResponseBuilder getWebApplicationExceptionResponseBuilder() {
return new WebApplicationExceptionResponseBuilder();
}
#Bean
public ScmContext getScmContext() {
return new ScmContext();
}
}
I followed these threads https://brudenko.com/spring-bean-override, https://blog.tratif.com/2018/03/08/when-two-beans-collide/ . But if i am setting spring.main.allow-bean-definition-overriding=true in application.properties. I start getting below error:
2020-08-30 18:24:14.438 GMT+05:30 INFO rid=NA cid=NA 13076 --- [ main] o.s.s.petclinic.PetClinicApplication : Starting PetClinicApplication v2.3.1.BUILD-SNAPSHOT on sasas-WX-3 with PID 13076 (C:
\work\upstream\fault-tolerance-demo\target\spring-petclinic-2.3.1.BUILD-SNAPSHOT.jar started by krsoni in C:\work\upstream\fault-tolerance-demo)
2020-08-30 18:24:14.444 GMT+05:30 INFO rid=NA cid=NA 13076 --- [ main] o.s.s.petclinic.PetClinicApplication : No active profile set, falling back to default profiles: default
2020-08-30 18:24:16.293 GMT+05:30 ERROR rid=NA cid=NA 13076 --- [ main] o.s.boot.SpringApplication : Application run failed
java.lang.IllegalStateException: Error processing condition on de.codecentric.spring.boot.chaos.monkey.configuration.ChaosMonkeyConfiguration.chaosMonkeyRestEndpoint
at org.springframework.boot.autoconfigure.condition.SpringBootCondition.matches(SpringBootCondition.java:60)
at org.springframework.context.annotation.ConditionEvaluator.shouldSkip(ConditionEvaluator.java:108)
at org.springframework.context.annotation.ConfigurationClassBeanDefinitionReader.loadBeanDefinitionsForBeanMethod(ConfigurationClassBeanDefinitionReader.java:184)
at org.springframework.context.annotation.ConfigurationClassBeanDefinitionReader.loadBeanDefinitionsForConfigurationClass(ConfigurationClassBeanDefinitionReader.java:144)
at org.springframework.context.annotation.ConfigurationClassBeanDefinitionReader.loadBeanDefinitions(ConfigurationClassBeanDefinitionReader.java:120)
at org.springframework.context.annotation.ConfigurationClassPostProcessor.processConfigBeanDefinitions(ConfigurationClassPostProcessor.java:331)
at org.springframework.context.annotation.ConfigurationClassPostProcessor.postProcessBeanDefinitionRegistry(ConfigurationClassPostProcessor.java:236)
at org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanDefinitionRegistryPostProcessors(PostProcessorRegistrationDelegate.java:280)
at org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanFactoryPostProcessors(PostProcessorRegistrationDelegate.java:96)
at org.springframework.context.support.AbstractApplicationContext.invokeBeanFactoryPostProcessors(AbstractApplicationContext.java:707)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:533)
at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:143)
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:758)
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:750)
at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:397)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:315)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1237)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1226)
at org.springframework.samples.petclinic.PetClinicApplication.main(PetClinicApplication.java:32)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at org.springframework.boot.loader.JarLauncher.main(JarLauncher.java:88)
Caused by: java.lang.IllegalStateException: Failed to introspect Class [com.mycompany.asr.autoconfigure.asr.ASRAutoConfiguration] from ClassLoader [org.springframework.boot.loader.LaunchedURLClassLoader#5197848c]
at org.springframework.util.ReflectionUtils.getDeclaredMethods(ReflectionUtils.java:481)
at org.springframework.util.ReflectionUtils.doWithMethods(ReflectionUtils.java:358)
at org.springframework.util.ReflectionUtils.getUniqueDeclaredMethods(ReflectionUtils.java:414)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.lambda$getTypeForFactoryMethod$2(AbstractAutowireCapableBeanFactory.java:743)
at java.util.concurrent.ConcurrentHashMap.computeIfAbsent(Unknown Source)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.getTypeForFactoryMethod(AbstractAutowireCapableBeanFactory.java:742)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.determineTargetType(AbstractAutowireCapableBeanFactory.java:681)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.predictBeanType(AbstractAutowireCapableBeanFactory.java:649)
at org.springframework.beans.factory.support.AbstractBeanFactory.isFactoryBean(AbstractBeanFactory.java:1608)
at org.springframework.boot.loader.LaunchedURLClassLoader.loadClass(LaunchedURLClassLoader.java:151)
at java.lang.ClassLoader.loadClass(Unknown Source)
... 46 common frames omitted
2020-08-30 18:24:16.299 GMT+05:30 WARN rid=NA cid=NA 13076 --- [ main] o.s.boot.SpringApplication : Unable to close ApplicationContext
java.lang.IllegalStateException: Failed to introspect Class [com.mycompany.asr.autoconfigure.asr.ASRAutoConfiguration] from ClassLoader [org.springframework.boot.loader.LaunchedURLClassLoader#5197848c]
at org.springframework.util.ReflectionUtils.getDeclaredMethods(ReflectionUtils.java:481)
Caused by: java.lang.NoClassDefFoundError: org/springframework/boot/context/embedded/EmbeddedServletContainerCustomizer
at java.lang.Class.getDeclaredMethods0(Native Method)
at java.lang.Class.privateGetDeclaredMethods(Unknown Source)
at java.lang.Class.getDeclaredMethods(Unknown Source)
at org.springframework.util.ReflectionUtils.getDeclaredMethods(ReflectionUtils.java:463)
... 29 common frames omitted
Caused by: java.lang.ClassNotFoundException: org.springframework.boot.context.embedded.EmbeddedServletContainerCustomizer
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at org.springframework.boot.loader.LaunchedURLClassLoader.loadClass(LaunchedURLClassLoader.java:151)
at java.lang.ClassLoader.loadClass(Unknown Source)
... 33 common frames omitted
https://docs.spring.io/spring-boot/docs/current/reference/htmlsingle/#howto-switch-off-the-spring-mvc-dispatcherservlet
'If you have additional servlets you can declare a #Bean of type Servlet or ServletRegistrationBean for each and Spring Boot will register them transparently to the container. Because servlets are registered that way, they can be mapped to a sub-context of the DispatcherServlet without invoking it.
Configuring the DispatcherServlet yourself is unusual but if you really need to do it, a #Bean of type DispatcherServletPath must be provided as well to provide the path of your custom DispatcherServlet.'
I got a problem with my application. Everything has been working fine till I conterized App with Docker.
I Have Docker container with Cassandra instance in there docker run -p 9042:9042 --name cassandra cassandra:latest
*When I run my app in IntelliJ or run by cmd java -jar myjar.jar it works fine. The problem occurs when
I trying to use Docker or Docker-compose to start the app docker run -p 8080:8080 --name api {image here} or docker-compose up
Docker File:
FROM openjdk:8
COPY . /target/myjar.jar
EXPOSE 8080
ENTRYPOINT ["java","-jar","target/myjar.jar"]
Docker-Compose
version: '3'
services:
app:
build: ./app
ports:
- "8080:8080"
depends-on:
-cassandra
cassandra:
container_name 'cassandra'
image: cassandra
ports:
- "9042:9042"
What I have tried to solve the problem:
changing application ports
building docker and docker-compose file in diffrent way.
application.properties
spring.data.cassandra.keyspace-name=message
spring.data.cassandra.schema-action=create_if_not_exists
spring.data.cassandra.contact-points=127.0.0.1
spring.data.cassandra.port=9042
the error when I try to run container from image (Fragment)
2020-06-13 11:42:53.320 INFO 1 --- [ main] .s.d.r.c.RepositoryConfigurationDelegate : Bootstrapping Spring Data Reactive Cassandra repositories in DEFAULT mode.
2020-06-13 11:42:53.379 INFO 1 --- [ main] .s.d.r.c.RepositoryConfigurationDelegate : Finished Spring Data repository scanning in 51ms. Found 0 Reactive Cassandra repository interfaces.
2020-06-13 11:42:53.387 INFO 1 --- [ main] .s.d.r.c.RepositoryConfigurationDelegate : Bootstrapping Spring Data Cassandra repositories in DEFAULT mode.
2020-06-13 11:42:53.406 INFO 1 --- [ main] .s.d.r.c.RepositoryConfigurationDelegate : Finished Spring Data repository scanning in 18ms. Found 1 Cassandra repository interfaces.
2020-06-13 11:42:54.030 INFO 1 --- [ main] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat initialized with port(s): 8080 (http)
2020-06-13 11:42:54.050 INFO 1 --- [ main] o.apache.catalina.core.StandardService : Starting service [Tomcat]
2020-06-13 11:42:54.050 INFO 1 --- [ main] org.apache.catalina.core.StandardEngine : Starting Servlet engine: [Apache Tomcat/9.0.35]
2020-06-13 11:42:54.146 INFO 1 --- [ main] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring embedded WebApplicationContext
2020-06-13 11:42:54.146 INFO 1 --- [ main] o.s.web.context.ContextLoader : Root WebApplicationContext: initialization completed in 1734 ms
2020-06-13 11:42:54.611 INFO 1 --- [ main] c.d.o.d.i.core.DefaultMavenCoordinates : DataStax Java driver for Apache Cassandra(R) (com.datastax.oss:java-driver-core) version 4.6.1
2020-06-13 11:42:55.364 INFO 1 --- [ s0-admin-0] c.d.oss.driver.internal.core.time.Clock : Using native clock for microsecond precision
2020-06-13 11:42:55.371 INFO 1 --- [ s0-admin-0] c.d.o.d.i.core.metadata.MetadataManager : [s0] No contact points provided, defaulting to /127.0.0.1:9042
2020-06-13 11:42:55.567 WARN 1 --- [ s0-admin-1] c.d.o.d.i.c.control.ControlConnection : [s0] Error connecting to Node(endPoint=/127.0.0.1:9042, hostId=null, hashCode=530346a1), trying next node (ConnectionInitException: [s0|control|connecting...] Protocol initialization request, step 1 (OPTIONS): failed to send request (java.nio.channels.ClosedChannelException))
2020-06-13 11:42:55.586 WARN 1 --- [ main] ConfigServletWebServerApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'messageApi' defined in URL [jar:file:/asrecruitment-0.0.1-SNAPSHOT.jar!/BOOT-INF/classes!/com/mycompany/asrecruitment/api/MessageApi.class]: Unsatisfied dependency expressed through constructor parameter 0; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'messageService' defined in URL [jar:file:/asrecruitment-0.0.1-SNAPSHOT.jar!/BOOT-INF/classes!/com/mycompany/asrecruitment/service/MessageService.class]: Unsatisfied dependency expressed through constructor parameter 0; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'messageRepo' defined in com.mycompany.asrecruitment.repository.MessageRepo defined in #EnableCassandraRepositories declared on CassandraRepositoriesRegistrar.EnableCassandraRepositoriesConfiguration: Cannot resolve reference to bean 'cassandraTemplate' while setting bean property 'cassandraTemplate'; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'org.springframework.boot.autoconfigure.data.cassandra.CassandraDataAutoConfiguration': Unsatisfied dependency expressed through constructor parameter 0; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'appConfig': Invocation of init method failed; nested exception is com.datastax.oss.driver.api.core.AllNodesFailedException: Could not reach any contact point, make sure you've provided valid addresses (showing first 1 nodes, use getAllErrors() for more): Node(endPoint=/127.0.0.1:9042, hostId=null, hashCode=530346a1): [com.datastax.oss.driver.api.core.connection.ConnectionInitException: [s0|control|connecting...] Protocol initialization request, step 1 (OPTIONS): failed to send request (java.nio.channels.ClosedChannelException)]
2020-06-13 11:42:55.590 INFO 1 --- [ main] o.apache.catalina.core.StandardService : Stopping service [Tomcat]
2020-06-13 11:42:55.613 INFO 1 --- [ main] ConditionEvaluationReportLoggingListener :
Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled.
2020-06-13 11:42:55.636 ERROR 1 --- [ main] o.s.boot.SpringApplication : Application run failed
org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'messageApi' defined in URL [jar:file:/asrecruitment-0.0.1-SNAPSHOT.jar!/BOOT-INF/classes!/com/mycompany/asrecruitment/api/MessageApi.class]: Unsatisfied dependency expressed through constructor parameter 0; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'messageService' defined in URL [jar:file:/asrecruitment-0.0.1-SNAPSHOT.jar!/BOOT-INF/classes!/com/mycompany/asrecruitment/service/MessageService.class]: Unsatisfied dependency expressed through constructor parameter 0; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'messageRepo' defined in com.mycompany.asrecruitment.repository.MessageRepo defined in #EnableCassandraRepositories declared on CassandraRepositoriesRegistrar.EnableCassandraRepositoriesConfiguration: Cannot resolve reference to bean 'cassandraTemplate' while setting bean property 'cassandraTemplate'; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'org.springframework.boot.autoconfigure.data.cassandra.CassandraDataAutoConfiguration': Unsatisfied dependency expressed through constructor parameter 0; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'appConfig': Invocation of init method failed; nested exception is com.datastax.oss.driver.api.core.AllNodesFailedException: Could not reach any contact point, make sure you've provided valid addresses (showing first 1 nodes, use getAllErrors() for more): Node(endPoint=/127.0.0.1:9042, hostId=null, hashCode=530346a1): [com.datastax.oss.driver.api.core.connection.ConnectionInitException: [s0|control|connecting...] Protocol initialization request, step 1 (OPTIONS): failed to send request (java.nio.channels.ClosedChannelException)]
at org.springframework.beans.factory.support.ConstructorResolver.createArgumentArray(ConstructorResolver.java:798) ~[spring-beans-5.2.6.RELEASE.jar!/:5.2.6.RELEASE]
at org.springframework.beans.factory.support.ConstructorResolver.autowireConstructor(ConstructorResolver.java:228) ~[spring-beans-5.2.6.RELEASE.jar!/:5.2.6.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.autowireConstructor(AbstractAutowireCapableBeanFactory.java:1358) ~[spring-beans-5.2.6.RELEASE.jar!/:5.2.6.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1204) ~[spring-beans-5.2.6.RELEASE.jar!/:5.2.6.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:557) ~[spring-beans-5.2.6.RELEASE.jar!/:5.2.6.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:517) ~[spring-beans-5.2.6.RELEASE.jar!/:5.2.6.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:323) ~[spring-beans-5.2.6.RELEASE.jar!/:5.2.6.RELEASE]
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:226) ~[spring-beans-5.2.6.RELEASE.jar!/:5.2.6.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:321) ~[spring-beans-5.2.6.RELEASE.jar!/:5.2.6.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:202) ~[spring-beans-5.2.6.RELEASE.jar!/:5.2.6.RELEASE]
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:895) ~[spring-beans-5.2.6.RELEASE.jar!/:5.2.6.RELEASE]
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:878) ~[spring-context-5.2.6.RELEASE.jar!/:5.2.6.RELEASE]
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:550) ~[spring-context-5.2.6.RELEASE.jar!/:5.2.6.RELEASE]
at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:143) ~[spring-boot-2.3.0.RELEASE.jar!/:2.3.0.RELEASE]
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:758) [spring-boot-2.3.0.RELEASE.jar!/:2.3.0.RELEASE]
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:750) [spring-boot-2.3.0.RELEASE.jar!/:2.3.0.RELEASE]
at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:397) [spring-boot-2.3.0.RELEASE.jar!/:2.3.0.RELEASE]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:315) [spring-boot-2.3.0.RELEASE.jar!/:2.3.0.RELEASE]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1237) [spring-boot-2.3.0.RELEASE.jar!/:2.3.0.RELEASE]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1226) [spring-boot-2.3.0.RELEASE.jar!/:2.3.0.RELEASE]
at com.mycompany.asrecruitment.app.main(app.java:12) [classes!/:0.0.1-SNAPSHOT]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_212]
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_212]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_212]
at java.lang.reflect.Method.invoke(Method.java:498) ~[na:1.8.0_212]
at org.springframework.boot.loader.MainMethodRunner.run(MainMethodRunner.java:49) [asrecruitment-0.0.1-SNAPSHOT.jar:0.0.1-SNAPSHOT]
at org.springframework.boot.loader.Launcher.launch(Launcher.java:109) [asrecruitment-0.0.1-SNAPSHOT.jar:0.0.1-SNAPSHOT]
at org.springframework.boot.loader.Launcher.launch(Launcher.java:58) [asrecruitment-0.0.1-SNAPSHOT.jar:0.0.1-SNAPSHOT]
at org.springframework.boot.loader.JarLauncher.main(JarLauncher.java:88) [asrecruitment-0.0.1-SNAPSHOT.jar:0.0.1-SNAPSHOT]
Caused by: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'messageService' defined in URL [jar:file:/asrecruitment-0.0.1-SNAPSHOT.jar!/BOOT-INF/classes!/com/mycompany/asrecruitment/service/MessageService.class]: Unsatisfied dependency expressed through constructor parameter 0; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'messageRepo' defined in com.mycompany.asrecruitment.repository.MessageRepo defined in #EnableCassandraRepositories declared on CassandraRepositoriesRegistrar.EnableCassandraRepositoriesConfiguration: Cannot resolve reference to bean 'cassandraTemplate' while setting bean property 'cassandraTemplate'; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'org.springframework.boot.autoconfigure.data.cassandra.CassandraDataAutoConfiguration': Unsatisfied dependency expressed through constructor parameter 0; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'appConfig': Invocation of init method failed; nested exception is com.datastax.oss.driver.api.core.AllNodesFailedException: Could not reach any contact point, make sure you've provided valid addresses (showing first 1 nodes, use getAllErrors() for more): Node(endPoint=/127.0.0.1:9042, hostId=null, hashCode=530346a1): [com.datastax.oss.driver.api.core.connection.ConnectionInitException: [s0|control|connecting...] Protocol initialization request, step 1 (OPTIONS): failed to send request (java.nio.channels.ClosedChannelException)]
at org.springframework.beans.factory.support.ConstructorResolver.createArgumentArray(ConstructorResolver.java:798) ~[spring-beans-5.2.6.RELEASE.jar!/:5.2.6.RELEASE]
at org.springframework.beans.factory.support.ConstructorResolver.autowireConstructor(ConstructorResolver.java:228) ~[spring-beans-5.2.6.RELEASE.jar!/:5.2.6.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.autowireConstructor(AbstractAutowireCapableBeanFactory.java:1358) ~[spring-beans-5.2.6.RELEASE.jar!/:5.2.6.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1204) ~[spring-beans-5.2.6.RELEASE.jar!/:5.2.6.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:557) ~[spring-beans-5.2.6.RELEASE.jar!/:5.2.6.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:517) ~[spring-beans-5.2.6.RELEASE.jar!/:5.2.6.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:323) ~[spring-beans-5.2.6.RELEASE.jar!/:5.2.6.RELEASE]
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:226) ~[spring-beans-5.2.6.RELEASE.jar!/:5.2.6.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:321) ~[spring-beans-5.2.6.RELEASE.jar!/:5.2.6.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:202) ~[spring-beans-5.2.6.RELEASE.jar!/:5.2.6.RELEASE]
at org.springframework.beans.factory.config.DependencyDescriptor.resolveCandidate(DependencyDescriptor.java:276) ~[spring-beans-5.2.6.RELEASE.jar!/:5.2.6.RELEASE]
at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1306) ~[spring-beans-5.2.6.RELEASE.jar!/:5.2.6.RELEASE]
at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:1226) ~[spring-beans-5.2.6.RELEASE.jar!/:5.2.6.RELEASE]
at org.springframework.beans.factory.support.ConstructorResolver.resolveAutowiredArgument(ConstructorResolver.java:885) ~[spring-beans-5.2.6.RELEASE.jar!/:5.2.6.RELEASE]
at org.springframework.beans.factory.support.ConstructorResolver.createArgumentArray(ConstructorResolver.java:789) ~[spring-beans-5.2.6.RELEASE.jar!/:5.2.6.RELEASE]
... 28 common frames omitted
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'messageRepo' defined in com.mycompany.asrecruitment.repository.MessageRepo defined in #EnableCassandraRepositories declared on CassandraRepositoriesRegistrar.EnableCassandraRepositoriesConfiguration: Cannot resolve reference to bean 'cassandraTemplate' while setting bean property 'cassandraTemplate'; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'org.springframework.boot.autoconfigure.data.cassandra.CassandraDataAutoConfiguration': Unsatisfied dependency expressed through constructor parameter 0; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'appConfig': Invocation of init method failed; nested exception is com.datastax.oss.driver.api.core.AllNodesFailedException: Could not reach any contact point, make sure you've provided valid addresses (showing first 1 nodes, use getAllErrors() for more): Node(endPoint=/127.0.0.1:9042, hostId=null, hashCode=530346a1): [com.datastax.oss.driver.api.core.connection.ConnectionInitException: [s0|control|connecting...] Protocol initialization request, step 1 (OPTIONS): failed to send request (java.nio.channels.ClosedChannelException)]
at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:342) ~[spring-beans-5.2.6.RELEASE.jar!/:5.2.6.RELEASE]
at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveValueIfNecessary(BeanDefinitionValueResolver.java:113) ~[spring-beans-5.2.6.RELEASE.jar!/:5.2.6.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1699) ~[spr
** Proper run java -jar **
2020-06-13 13:35:19.461 INFO 12088 --- [ main] .s.d.r.c.RepositoryConfigurationDelegate : Bootstrapping Spring Data Reactive Cassandra repositories in DEFAULT mode.
2020-06-13 13:35:19.593 INFO 12088 --- [ main] .s.d.r.c.RepositoryConfigurationDelegate : Finished Spring Data repository scanning in 116ms. Found 0 Reactive Cassandra repository interfaces.
2020-06-13 13:35:19.609 INFO 12088 --- [ main] .s.d.r.c.RepositoryConfigurationDelegate : Bootstrapping Spring Data Cassandra repositories in DEFAULT mode.
2020-06-13 13:35:19.630 INFO 12088 --- [ main] .s.d.r.c.RepositoryConfigurationDelegate : Finished Spring Data repository scanning in 23ms. Found 1 Cassandra repository interfaces.
2020-06-13 13:35:21.111 INFO 12088 --- [ main] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat initialized with port(s): 8080 (http)
2020-06-13 13:35:21.134 INFO 12088 --- [ main] o.apache.catalina.core.StandardService : Starting service [Tomcat]
2020-06-13 13:35:21.134 INFO 12088 --- [ main] org.apache.catalina.core.StandardEngine : Starting Servlet engine: [Apache Tomcat/9.0.35]
2020-06-13 13:35:21.296 INFO 12088 --- [ main] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring embedded WebApplicationContext
2020-06-13 13:35:21.296 INFO 12088 --- [ main] o.s.web.context.ContextLoader : Root WebApplicationContext: initialization completed in 3376 ms
2020-06-13 13:35:21.945 INFO 12088 --- [ main] c.d.o.d.i.core.DefaultMavenCoordinates : DataStax Java driver for Apache Cassandra(R) (com.datastax.oss:java-driver-core) version 4.6.1
2020-06-13 13:35:22.985 INFO 12088 --- [ s0-admin-0] c.d.oss.driver.internal.core.time.Clock : Using native clock for microsecond precision
2020-06-13 13:35:22.985 INFO 12088 --- [ s0-admin-0] c.d.o.d.i.core.metadata.MetadataManager : [s0] No contact points provided, defaulting to /127.0.0.1:9042
2020-06-13 13:35:23.961 INFO 12088 --- [ s0-io-0] c.d.o.d.i.core.channel.ChannelFactory : [s0] Failed to connect with protocol DSE_V2, retrying with DSE_V1
2020-06-13 13:35:23.979 INFO 12088 --- [ s0-io-1] c.d.o.d.i.core.channel.ChannelFactory : [s0] Failed to connect with protocol DSE_V1, retrying with V4
2020-06-13 13:35:24.387 INFO 12088 --- [ s0-io-2] c.d.oss.driver.api.core.uuid.Uuids : PID obtained through native call to getpid(): 12088
2020-06-13 13:35:26.186 INFO 12088 --- [ s1-admin-0] c.d.oss.driver.internal.core.time.Clock : Using native clock for microsecond precision
2020-06-13 13:35:26.186 INFO 12088 --- [ s1-admin-0] c.d.o.d.i.core.metadata.MetadataManager : [s1] No contact points provided, defaulting to /127.0.0.1:9042
2020-06-13 13:35:26.214 INFO 12088 --- [ s1-io-0] c.d.o.d.i.core.channel.ChannelFactory : [s1] Failed to connect with protocol DSE_V2, retrying with DSE_V1
2020-06-13 13:35:26.231 INFO 12088 --- [ s1-io-1] c.d.o.d.i.core.channel.ChannelFactory : [s1] Failed to connect with protocol DSE_V1, retrying with V4
2020-06-13 13:35:30.078 INFO 12088 --- [ s2-admin-0] c.d.oss.driver.internal.core.time.Clock : Using native clock for microsecond precision
2020-06-13 13:35:31.698 INFO 12088 --- [ s2-admin-0] c.d.o.d.i.core.metadata.MetadataManager : [s2] No contact points provided, defaulting to /127.0.0.1:9042
2020-06-13 13:35:31.720 INFO 12088 --- [ s2-io-0] c.d.o.d.i.core.channel.ChannelFactory : [s2] Failed to connect with protocol DSE_V2, retrying with DSE_V1
2020-06-13 13:35:31.732 INFO 12088 --- [ s2-io-1] c.d.o.d.i.core.channel.ChannelFactory : [s2] Failed to connect with protocol DSE_V1, retrying with V4
2020-06-13 13:35:32.618 INFO 12088 --- [ main] o.s.s.concurrent.ThreadPoolTaskExecutor : Initializing ExecutorService 'applicationTaskExecutor'
2020-06-13 13:35:32.943 INFO 12088 --- [ main] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat started on port(s): 8080 (http) with context path ''
2020-06-13 13:35:32.946 INFO 12088 --- [ main] com.mycompany.asrecruitment.app : Started app in 16.206 seconds (JVM running for 17.064)
The problem here is your application isn't connecting with the Cassadra's DB image.
2020-06-13 11:42:55.567 WARN 1 --- [ s0-admin-1]
c.d.o.d.i.c.control.ControlConnection : [s0] Error connecting to
Node(endPoint=/127.0.0.1:9042, hostId=null, hashCode=530346a1), trying
next node (ConnectionInitException: [s0|control|connecting...]
Protocol initialization request, step 1 (OPTIONS): failed to send
request (java.nio.channels.ClosedChannelException))
Fist, in your docker-compose.yml, you need to create an environment variable to be the cassandra host and then set your application.properties.
Docker-compose.yml
version: '3'
services:
app:
build: ./app
ports:
- "8086:8080"
depends-on:
-cassandra
cassandra:
container_name 'cassandra'
image: cassandra
ports:
- "9044:9042"
environment:
- CASSANDRA_HOST=cassandra
P.S. You can change the first port number to not confuse, but it's not a mistake.
application.properties
spring.data.cassandra.keyspace-name=message
spring.data.cassandra.schema-action=create_if_not_exists
spring.data.cassandra.contact-points=${CASSANDRA_HOST}
spring.data.cassandra.port=9042
It is important to check the cluster's name (spring.data.cassandra.cluster = <name>) in the cassandra.yaml inside the cassandra's image. It should be the same as in your application's image.
I have defined Camel routes in 2 XML files, and would like to run the application using Spring Boot component.
Here is the main code:
Object[] sources = {
"META-INF/spring/propertiesContext.xml",
"META-INF/spring/concurrent-route-context.xml"
};
ApplicationContext applicationContext = new SpringApplication(sources).run(args);
CamelSpringBootApplicationController applicationController = applicationContext
.getBean(CamelSpringBootApplicationController.class);
applicationController.blockMainThread();
However, I got the following error during startup
2015-08-19 14:54:04.203 ERROR 13812 --- [ main] o.s.boot.SpringApplication : Application startup failed
org.springframework.context.ApplicationContextException: Unable to start embedded container; nested exception is org.springframework.context.ApplicationContextException: Unable to start EmbeddedWebApplicationContext due to missing EmbeddedServletContainerFactory bean.
at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.onRefresh(EmbeddedWebApplicationContext.java:133)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:474)
at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.refresh(EmbeddedWebApplicationContext.java:118)
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:686)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:320)
at com.oocl.b2b.camel.spring.boot.test.ConcurrencyTest.testSpringBoot(ConcurrencyTest.java:44)
at com.oocl.b2b.camel.spring.boot.test.ConcurrencyTest.main(ConcurrencyTest.java:29)
Caused by: org.springframework.context.ApplicationContextException: Unable to start EmbeddedWebApplicationContext due to missing EmbeddedServletContainerFactory bean.
at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.getEmbeddedServletContainerFactory(EmbeddedWebApplicationContext.java:183)
at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.createEmbeddedServletContainer(EmbeddedWebApplicationContext.java:156)
at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.onRefresh(EmbeddedWebApplicationContext.java:130)
... 6 common frames omitted
If I update my pom.xml by using "spring-boot-starter" instead of "spring-boot-starter-web", I got another exception
2015-08-19 15:02:06.930 INFO 4528 --- [ main] o.a.camel.spring.SpringCamelContext : Apache Camel 2.15.2 (CamelContext: concurrent-route-context) started in 1.320 seconds
2015-08-19 15:02:06.932 INFO 4528 --- [ main] c.o.b.c.s.boot.test.ConcurrencyTest : Started ConcurrencyTest in 2.615 seconds (JVM running for 2.867)
Exception in thread "main" 2015-08-19 15:02:06.933 INFO 4528 --- [ Thread-1] s.c.a.AnnotationConfigApplicationContext : Closing org.springframework.context.annotation.AnnotationConfigApplicationContext#142f024: startup date [Wed Aug 19 15:02:05 CST 2015]; root of context hierarchy
2015-08-19 15:02:06.934 INFO 4528 --- [ Thread-1] o.a.camel.spring.SpringCamelContext : Apache Camel 2.15.2 (CamelContext: concurrent-route-context) is shutting down
org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type [org.apache.camel.spring.boot.CamelSpringBootApplicationController] is defined
at org.springframework.beans.factory.support.DefaultListableBeanFactory.getBean(DefaultListableBeanFactory.java:371)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.getBean(DefaultListableBeanFactory.java:331)
at org.springframework.context.support.AbstractApplicationContext.getBean(AbstractApplicationContext.java:968)
at com.oocl.b2b.camel.spring.boot.test.ConcurrencyTest.testSpringBoot(ConcurrencyTest.java:47)
at com.oocl.b2b.camel.spring.boot.test.ConcurrencyTest.main(ConcurrencyTest.java:30)
2015-08-19 15:02:06.937 INFO 4528 --- [ Thread-1] o.a.camel.impl.DefaultShutdownStrategy : Starting to graceful shutdown 4 routes (timeout 300 seconds)
Would anyone please advice if I have made any mis-config?
I don't know if you've found a solution for this yet, but try this for your application class:
#Configuration
#EnableAutoConfiguration
public class TestSpringBootApplication
{
public static void main(String... args)
{
(new SpringApplication("META-INF/spring/propertiesContext.xml",
"META-INF/spring/concurrent-route-context.xml")).run(args);
}
}
I have a Spring Boot app, which ran fine on my Windows machine, but is now failing to start on my xUbuntu VM running on Virtual Box.
I call it using following command:
java -Djava.net.preferIPv4Stack=true -jar -Xmx1500m highlighter-0.0.1.jar
I added -Djava.net.preferIPv4Stack=true after reading these multiple answers, but it did not solve the issue.
I get following error:
2015-01-28 17:20:02.844 DEBUG 18612 --- [ main] o.s.w.s.resource.ResourceUrlProvider : Looking for resource handler mappings
2015-01-28 17:20:02.845 DEBUG 18612 --- [ main] o.s.b.f.s.DefaultListableBeanFactory : Returning cached instance of singleton bean 'viewControllerHandlerMapping'
2015-01-28 17:20:02.845 DEBUG 18612 --- [ main] o.s.b.f.s.DefaultListableBeanFactory : Returning cached instance of singleton bean 'resourceHandlerMapping'
2015-01-28 17:20:02.845 DEBUG 18612 --- [ main] o.s.b.f.s.DefaultListableBeanFactory : Returning cached instance of singleton bean 'faviconHandlerMapping'
2015-01-28 17:20:02.845 DEBUG 18612 --- [ main] o.s.w.s.resource.ResourceUrlProvider : Found resource handler mapping: URL pattern="/**/favicon.ico", locations=[class path resource [META-INF/resources/], class path resource [resources/], class path resource [static/], class path resource [public/], class path resource []], resolvers=[org.springframework.web.servlet.resource.PathResourceResolver#2e9e8b52]
2015-01-28 17:20:02.845 DEBUG 18612 --- [ main] o.s.w.s.resource.ResourceUrlProvider : Found resource handler mapping: URL pattern="/webjars/**", locations=[class path resource [META-INF/resources/webjars/]], resolvers=[org.springframework.web.servlet.resource.PathResourceResolver#6a90f803]
2015-01-28 17:20:02.846 DEBUG 18612 --- [ main] o.s.w.s.resource.ResourceUrlProvider : Found resource handler mapping: URL pattern="/**", locations=[ServletContext resource [/], class path resource [META-INF/resources/], class path resource [resources/], class path resource [static/], class path resource [public/]], resolvers=[org.springframework.web.servlet.resource.PathResourceResolver#c09fd55]
2015-01-28 17:20:02.847 DEBUG 18612 --- [ main] o.s.c.e.PropertySourcesPropertyResolver : Searching for key 'spring.liveBeansView.mbeanDomain' in [servletConfigInitParams]
2015-01-28 17:20:02.847 DEBUG 18612 --- [ main] o.s.c.e.PropertySourcesPropertyResolver : Searching for key 'spring.liveBeansView.mbeanDomain' in [servletContextInitParams]
2015-01-28 17:20:02.847 DEBUG 18612 --- [ main] o.s.c.e.PropertySourcesPropertyResolver : Searching for key 'spring.liveBeansView.mbeanDomain' in [systemProperties]
2015-01-28 17:20:02.847 DEBUG 18612 --- [ main] o.s.c.e.PropertySourcesPropertyResolver : Searching for key 'spring.liveBeansView.mbeanDomain' in [systemEnvironment]
2015-01-28 17:20:02.847 DEBUG 18612 --- [ main] o.s.c.e.PropertySourcesPropertyResolver : Searching for key 'spring.liveBeansView.mbeanDomain' in [random]
2015-01-28 17:20:02.847 DEBUG 18612 --- [ main] o.s.c.e.PropertySourcesPropertyResolver : Searching for key 'spring.liveBeansView.mbeanDomain' in [applicationConfig: [file:./application.properties]]
2015-01-28 17:20:02.847 DEBUG 18612 --- [ main] o.s.c.e.PropertySourcesPropertyResolver : Could not find key 'spring.liveBeansView.mbeanDomain' in any property source. Returning [null]
2015-01-28 17:20:02.870 ERROR 18612 --- [ main] o.a.coyote.http11.Http11NioProtocol : Failed to start end point associated with ProtocolHandler ["http-nio-80"]
java.net.SocketException: Permission denied
at sun.nio.ch.Net.bind0(Native Method)
at sun.nio.ch.Net.bind(Net.java:436)
at sun.nio.ch.Net.bind(Net.java:428)
at sun.nio.ch.ServerSocketChannelImpl.bind(ServerSocketChannelImpl.java:214)
at sun.nio.ch.ServerSocketAdaptor.bind(ServerSocketAdaptor.java:74)
at org.apache.tomcat.util.net.NioEndpoint.bind(NioEndpoint.java:343)
at org.apache.tomcat.util.net.AbstractEndpoint.start(AbstractEndpoint.java:737)
at org.apache.coyote.AbstractProtocol.start(AbstractProtocol.java:471)
at org.apache.coyote.http11.Http11NioProtocol.start(Http11NioProtocol.java:80)
at org.apache.catalina.connector.Connector.startInternal(Connector.java:986)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
at org.apache.catalina.core.StandardService.addConnector(StandardService.java:237)
at org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServletContainer.addPreviouslyRemovedConnectors(TomcatEmbeddedServletContainer.java:186)
at org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServletContainer.start(TomcatEmbeddedServletContainer.java:149)
at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.startEmbeddedServletContainer(EmbeddedWebApplicationContext.java:287)
at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.finishRefresh(EmbeddedWebApplicationContext.java:141)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:483)
at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.refresh(EmbeddedWebApplicationContext.java:118)
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:691)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:321)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:961)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:950)
at com.dash.nlpHighlight.web.App.main(App.java:16)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:483)
at org.springframework.boot.loader.MainMethodRunner.run(MainMethodRunner.java:53)
at java.lang.Thread.run(Thread.java:745)
2015-01-28 17:20:02.872 ERROR 18612 --- [ main] o.apache.catalina.core.StandardService : Failed to start connector [Connector[HTTP/1.1-80]]
org.apache.catalina.LifecycleException: Failed to start component [Connector[HTTP/1.1-80]]
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:154)
at org.apache.catalina.core.StandardService.addConnector(StandardService.java:237)
at org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServletContainer.addPreviouslyRemovedConnectors(TomcatEmbeddedServletContainer.java:186)
at org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServletContainer.start(TomcatEmbeddedServletContainer.java:149)
at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.startEmbeddedServletContainer(EmbeddedWebApplicationContext.java:287)
at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.finishRefresh(EmbeddedWebApplicationContext.java:141)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:483)
at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.refresh(EmbeddedWebApplicationContext.java:118)
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:691)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:321)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:961)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:950)
at com.dash.nlpHighlight.web.App.main(App.java:16)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:483)
at org.springframework.boot.loader.MainMethodRunner.run(MainMethodRunner.java:53)
at java.lang.Thread.run(Thread.java:745)
Caused by: org.apache.catalina.LifecycleException: service.getName(): "Tomcat"; Protocol handler start failed
at org.apache.catalina.connector.Connector.startInternal(Connector.java:993)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
... 18 common frames omitted
Caused by: java.net.SocketException: Permission denied
at sun.nio.ch.Net.bind0(Native Method)
at sun.nio.ch.Net.bind(Net.java:436)
at sun.nio.ch.Net.bind(Net.java:428)
at sun.nio.ch.ServerSocketChannelImpl.bind(ServerSocketChannelImpl.java:214)
at sun.nio.ch.ServerSocketAdaptor.bind(ServerSocketAdaptor.java:74)
at org.apache.tomcat.util.net.NioEndpoint.bind(NioEndpoint.java:343)
at org.apache.tomcat.util.net.AbstractEndpoint.start(AbstractEndpoint.java:737)
at org.apache.coyote.AbstractProtocol.start(AbstractProtocol.java:471)
at org.apache.coyote.http11.Http11NioProtocol.start(Http11NioProtocol.java:80)
at org.apache.catalina.connector.Connector.startInternal(Connector.java:986)
... 19 common frames omitted
2015-01-28 17:20:02.886 INFO 18612 --- [ main] o.apache.catalina.core.StandardService : Stopping service Tomcat
2015-01-28 17:20:02.911 INFO 18612 --- [ main] .b.l.ClasspathLoggingApplicationListener : Application failed to start with classpath: [jar:file:/home/dash/Dropbox/Projects/NLP/highlighter/build/libs/highlighter-0.0.1.jar!/, jar:file:/home/dash/Dropbox/Projects/NLP/highlighter/build/libs/highlighter-0.0.1.jar!/lib/spring-boot-starter-web-1.2.1.RELEASE.jar!/, jar:file:/home/dash/Dropbox/Projects/NLP/highlighter/build/libs/highlighter-0.0.1.jar!/lib/stanford-corenlp-3.5.0.jar!/, jar:file:/home/dash/Dropbox/Projects/NLP/highlighter/build/libs/highlighter-0.0.1.jar!/lib/stanford-corenlp-3.5.0-models.jar!/, jar:file:/home/dash/Dropbox/Projects/NLP/highlighter/build/libs/highlighter-0.0.1.jar!/lib/junit-4.12.jar!/, jar:file:/home/dash/Dropbox/Projects/NLP/highlighter/build/libs/highlighter-0.0.1.jar!/lib/spring-boot-starter-1.2.1.RELEASE.jar!/, jar:file:/home/dash/Dropbox/Projects/NLP/highlighter/build/libs/highlighter-0.0.1.jar!/lib/spring-boot-starter-tomcat-1.2.1.RELEASE.jar!/, jar:file:/home/dash/Dropbox/Projects/NLP/highlighter/build/libs/highlighter-0.0.1.jar!/lib/jackson-databind-2.4.4.jar!/, jar:file:/home/dash/Dropbox/Projects/NLP/highlighter/build/libs/highlighter-0.0.1.jar!/lib/hibernate-validator-5.1.3.Final.jar!/, jar:file:/home/dash/Dropbox/Projects/NLP/highlighter/build/libs/highlighter-0.0.1.jar!/lib/spring-core-4.1.4.RELEASE.jar!/, jar:file:/home/dash/Dropbox/Projects/NLP/highlighter/build/libs/highlighter-0.0.1.jar!/lib/spring-web-4.1.4.RELEASE.jar!/, jar:file:/home/dash/Dropbox/Projects/NLP/highlighter/build/libs/highlighter-0.0.1.jar!/lib/spring-webmvc-4.1.4.RELEASE.jar!/, jar:file:/home/dash/Dropbox/Projects/NLP/highlighter/build/libs/highlighter-0.0.1.jar!/lib/xom-1.2.10.jar!/, jar:file:/home/dash/Dropbox/Projects/NLP/highlighter/build/libs/highlighter-0.0.1.jar!/lib/joda-time-2.1.jar!/, jar:file:/home/dash/Dropbox/Projects/NLP/highlighter/build/libs/highlighter-0.0.1.jar!/lib/jollyday-0.4.7.jar!/, jar:file:/home/dash/Dropbox/Projects/NLP/highlighter/build/libs/highlighter-0.0.1.jar!/lib/ejml-0.23.jar!/, jar:file:/home/dash/Dropbox/Projects/NLP/highlighter/build/libs/highlighter-0.0.1.jar!/lib/javax.json-api-1.0.jar!/, jar:file:/home/dash/Dropbox/Projects/NLP/highlighter/build/libs/highlighter-0.0.1.jar!/lib/hamcrest-core-1.3.jar!/, jar:file:/home/dash/Dropbox/Projects/NLP/highlighter/build/libs/highlighter-0.0.1.jar!/lib/spring-boot-1.2.1.RELEASE.jar!/, jar:file:/home/dash/Dropbox/Projects/NLP/highlighter/build/libs/highlighter-0.0.1.jar!/lib/spring-boot-autoconfigure-1.2.1.RELEASE.jar!/, jar:file:/home/dash/Dropbox/Projects/NLP/highlighter/build/libs/highlighter-0.0.1.jar!/lib/spring-boot-starter-logging-1.2.1.RELEASE.jar!/, jar:file:/home/dash/Dropbox/Projects/NLP/highlighter/build/libs/highlighter-0.0.1.jar!/lib/snakeyaml-1.14.jar!/, jar:file:/home/dash/Dropbox/Projects/NLP/highlighter/build/libs/highlighter-0.0.1.jar!/lib/tomcat-embed-core-8.0.15.jar!/, jar:file:/home/dash/Dropbox/Projects/NLP/highlighter/build/libs/highlighter-0.0.1.jar!/lib/tomcat-embed-el-8.0.15.jar!/, jar:file:/home/dash/Dropbox/Projects/NLP/highlighter/build/libs/highlighter-0.0.1.jar!/lib/tomcat-embed-logging-juli-8.0.15.jar!/, jar:file:/home/dash/Dropbox/Projects/NLP/highlighter/build/libs/highlighter-0.0.1.jar!/lib/tomcat-embed-websocket-8.0.15.jar!/, jar:file:/home/dash/Dropbox/Projects/NLP/highlighter/build/libs/highlighter-0.0.1.jar!/lib/jackson-annotations-2.4.0.jar!/, jar:file:/home/dash/Dropbox/Projects/NLP/highlighter/build/libs/highlighter-0.0.1.jar!/lib/jackson-core-2.4.4.jar!/, jar:file:/home/dash/Dropbox/Projects/NLP/highlighter/build/libs/highlighter-0.0.1.jar!/lib/validation-api-1.1.0.Final.jar!/, jar:file:/home/dash/Dropbox/Projects/NLP/highlighter/build/libs/highlighter-0.0.1.jar!/lib/jboss-logging-3.1.3.GA.jar!/, jar:file:/home/dash/Dropbox/Projects/NLP/highlighter/build/libs/highlighter-0.0.1.jar!/lib/classmate-1.0.0.jar!/, jar:file:/home/dash/Dropbox/Projects/NLP/highlighter/build/libs/highlighter-0.0.1.jar!/lib/spring-aop-4.1.4.RELEASE.jar!/, jar:file:/home/dash/Dropbox/Projects/NLP/highlighter/build/libs/highlighter-0.0.1.jar!/lib/spring-beans-4.1.4.RELEASE.jar!/, jar:file:/home/dash/Dropbox/Projects/NLP/highlighter/build/libs/highlighter-0.0.1.jar!/lib/spring-context-4.1.4.RELEASE.jar!/, jar:file:/home/dash/Dropbox/Projects/NLP/highlighter/build/libs/highlighter-0.0.1.jar!/lib/spring-expression-4.1.4.RELEASE.jar!/, jar:file:/home/dash/Dropbox/Projects/NLP/highlighter/build/libs/highlighter-0.0.1.jar!/lib/xercesImpl-2.8.0.jar!/, jar:file:/home/dash/Dropbox/Projects/NLP/highlighter/build/libs/highlighter-0.0.1.jar!/lib/xalan-2.7.0.jar!/, jar:file:/home/dash/Dropbox/Projects/NLP/highlighter/build/libs/highlighter-0.0.1.jar!/lib/jaxb-api-2.2.7.jar!/, jar:file:/home/dash/Dropbox/Projects/NLP/highlighter/build/libs/highlighter-0.0.1.jar!/lib/jcl-over-slf4j-1.7.8.jar!/, jar:file:/home/dash/Dropbox/Projects/NLP/highlighter/build/libs/highlighter-0.0.1.jar!/lib/jul-to-slf4j-1.7.8.jar!/, jar:file:/home/dash/Dropbox/Projects/NLP/highlighter/build/libs/highlighter-0.0.1.jar!/lib/log4j-over-slf4j-1.7.8.jar!/, jar:file:/home/dash/Dropbox/Projects/NLP/highlighter/build/libs/highlighter-0.0.1.jar!/lib/logback-classic-1.1.2.jar!/, jar:file:/home/dash/Dropbox/Projects/NLP/highlighter/build/libs/highlighter-0.0.1.jar!/lib/aopalliance-1.0.jar!/, jar:file:/home/dash/Dropbox/Projects/NLP/highlighter/build/libs/highlighter-0.0.1.jar!/lib/slf4j-api-1.7.8.jar!/, jar:file:/home/dash/Dropbox/Projects/NLP/highlighter/build/libs/highlighter-0.0.1.jar!/lib/logback-core-1.1.2.jar!/, jar:file:/home/dash/Dropbox/Projects/NLP/highlighter/build/libs/highlighter-0.0.1.jar!/lib/xml-apis-2.0.2.jar!/]
2015-01-28 17:20:02.913 DEBUG 18612 --- [ main] utoConfigurationReportLoggingInitializer :
=========================
AUTO-CONFIGURATION REPORT
=========================
...
2015-01-28 17:20:02.918 ERROR 18612 --- [ main] o.s.boot.SpringApplication : Application startup failed
java.lang.IllegalStateException: Tomcat connector in failed state
at org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServletContainer.start(TomcatEmbeddedServletContainer.java:157)
at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.startEmbeddedServletContainer(EmbeddedWebApplicationContext.java:287)
at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.finishRefresh(EmbeddedWebApplicationContext.java:141)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:483)
at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.refresh(EmbeddedWebApplicationContext.java:118)
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:691)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:321)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:961)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:950)
at com.dash.nlpHighlight.web.App.main(App.java:16)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:483)
at org.springframework.boot.loader.MainMethodRunner.run(MainMethodRunner.java:53)
at java.lang.Thread.run(Thread.java:745)
2015-01-28 17:20:02.919 INFO 18612 --- [ main] ationConfigEmbeddedWebApplicationContext : Closing org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext#5b5ba2dc: startup date [Wed Jan 28 17:19:37 EST 2015]; root of context hierarchy
2015-01-28 17:20:02.919 DEBUG 18612 --- [ main] o.s.b.f.s.DefaultListableBeanFactory : Returning cached instance of singleton bean 'lifecycleProcessor'
2015-01-28 17:20:02.920 DEBUG 18612 --- [ main] o.s.b.f.s.DefaultListableBeanFactory : Destroying singletons in org.springframework.beans.factory.support.DefaultListableBeanFactory#3e1057f5: defining beans [org.springframework.context.annotation.internalConfigurationAnnotationProcessor,org.springframework.context.annotation.internalAutowiredAnnotationProcessor,org.springframework.context.annotation.internalRequiredAnnotationProcessor,org.springframework.context.annotation.internalCommonAnnotationProcessor,sampleController,org.springframework.context.annotation.ConfigurationClassPostProcessor.importAwareProcessor,org.springframework.context.annotation.ConfigurationClassPostProcessor.enhancedConfigurationProcessor,org.springframework.boot.autoconfigure.AutoConfigurationPackages,org.springframework.boot.autoconfigure.PropertyPlaceholderAutoConfiguration,org.springframework.boot.autoconfigure.condition.BeanTypeRegistry,propertySourcesPlaceholderConfigurer,org.springframework.boot.autoconfigure.web.EmbeddedServletContainerAutoConfiguration$EmbeddedTomcat,tomcatEmbeddedServletContainerFactory,org.springframework.boot.autoconfigure.web.EmbeddedServletContainerAutoConfiguration,embeddedServletContainerCustomizerBeanPostProcessor,org.springframework.boot.autoconfigure.web.DispatcherServletAutoConfiguration$DispatcherServletConfiguration,dispatcherServlet,dispatcherServletRegistration,org.springframework.boot.autoconfigure.web.DispatcherServletAutoConfiguration,org.springframework.boot.autoconfigure.web.ErrorMvcAutoConfiguration$WhitelabelErrorViewConfiguration,error,beanNameViewResolver,org.springframework.boot.autoconfigure.web.ErrorMvcAutoConfiguration,errorAttributes,basicErrorController,org.springframework.boot.autoconfigure.web.WebMvcAutoConfiguration$EnableWebMvcConfiguration,requestMappingHandlerAdapter,requestMappingHandlerMapping,mvcContentNegotiationManager,viewControllerHandlerMapping,beanNameHandlerMapping,resourceHandlerMapping,mvcResourceUrlProvider,defaultServletHandlerMapping,mvcConversionService,mvcValidator,mvcPathMatcher,mvcUrlPathHelper,mvcUriComponentsContributor,httpRequestHandlerAdapter,simpleControllerHandlerAdapter,handlerExceptionResolver,mvcViewResolver,org.springframework.boot.autoconfigure.web.WebMvcAutoConfiguration$WebMvcAutoConfigurationAdapter$FaviconConfiguration,faviconHandlerMapping,faviconRequestHandler,org.springframework.boot.autoconfigure.web.WebMvcAutoConfiguration$WebMvcAutoConfigurationAdapter,defaultViewResolver,requestContextListener,viewResolver,spring.mvc.CONFIGURATION_PROPERTIES,spring.resources.CONFIGURATION_PROPERTIES,org.springframework.boot.context.properties.ConfigurationPropertiesBindingPostProcessor,org.springframework.boot.context.properties.ConfigurationPropertiesBindingPostProcessor.store,org.springframework.boot.autoconfigure.web.WebMvcAutoConfiguration,hiddenHttpMethodFilter,org.springframework.boot.autoconfigure.jackson.JacksonAutoConfiguration$JacksonObjectMapperBuilderConfiguration,jacksonObjectMapperBuilder,http.mappers.CONFIGURATION_PROPERTIES,spring.jackson.CONFIGURATION_PROPERTIES,org.springframework.boot.autoconfigure.jackson.JacksonAutoConfiguration$JacksonObjectMapperConfiguration,jacksonObjectMapper,org.springframework.boot.autoconfigure.jackson.JacksonAutoConfiguration,org.springframework.boot.autoconfigure.web.HttpMessageConvertersAutoConfiguration$StringHttpMessageConverterConfiguration,stringHttpMessageConverter,spring.http.encoding.CONFIGURATION_PROPERTIES,org.springframework.boot.autoconfigure.web.HttpMessageConvertersAutoConfiguration$MappingJackson2HttpMessageConverterConfiguration,mappingJackson2HttpMessageConverter,org.springframework.boot.autoconfigure.web.HttpMessageConvertersAutoConfiguration,messageConverters,org.springframework.boot.autoconfigure.jmx.JmxAutoConfiguration,mbeanExporter,objectNamingStrategy,mbeanServer,org.springframework.boot.autoconfigure.web.HttpEncodingAutoConfiguration,characterEncodingFilter,org.springframework.boot.autoconfigure.web.MultipartAutoConfiguration,multipartConfigElement,multipartResolver,multipart.CONFIGURATION_PROPERTIES,org.springframework.boot.autoconfigure.web.ServerPropertiesAutoConfiguration,serverProperties]; root of factory hierarchy
2015-01-28 17:20:02.922 DEBUG 18612 --- [ main] o.s.b.f.support.DisposableBeanAdapter : Invoking destroy() on bean with name 'mbeanExporter'
2015-01-28 17:20:02.922 INFO 18612 --- [ main] o.s.j.e.a.AnnotationMBeanExporter : Unregistering JMX-exposed beans on shutdown
2015-01-28 17:20:02.923 DEBUG 18612 --- [ main] o.s.b.f.support.DisposableBeanAdapter : Invoking destroy() on bean with name 'mvcValidator'
2015-01-28 17:20:02.924 DEBUG 18612 --- [ main] o.s.b.f.support.DisposableBeanAdapter : Invoking destroy() on bean with name 'characterEncodingFilter'
2015-01-28 17:20:02.924 DEBUG 18612 --- [ main] o.s.b.f.support.DisposableBeanAdapter : Invoking destroy() on bean with name 'hiddenHttpMethodFilter'
2015-01-28 17:20:02.924 DEBUG 18612 --- [ main] o.s.b.f.support.DisposableBeanAdapter : Invoking destroy() on bean with name 'org.springframework.boot.context.properties.ConfigurationPropertiesBindingPostProcessor'
java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:483)
at org.springframework.boot.loader.MainMethodRunner.run(MainMethodRunner.java:53)
at java.lang.Thread.run(Thread.java:745)
Caused by: java.lang.IllegalStateException: Tomcat connector in failed state
at org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServletContainer.start(TomcatEmbeddedServletContainer.java:157)
at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.startEmbeddedServletContainer(EmbeddedWebApplicationContext.java:287)
at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.finishRefresh(EmbeddedWebApplicationContext.java:141)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:483)
at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.refresh(EmbeddedWebApplicationContext.java:118)
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:691)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:321)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:961)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:950)
at com.dash.nlpHighlight.web.App.main(App.java:16)
... 6 more
I found the answer here:
According to w3.org doc ports below 1024 are priviledged on Linux. Only root can bind to such ports.
You should either use ports >1024 or run under root account (not recommended).
The solution is to set different port in "application.properties" file, e.g. server.port=${port:8181} or to run as root using sudo (not recommended).
sometimes you can get same error on cloud env like openshift, cause localhost is not allowed there, you need also specify IP while starting app with param
--server.address=$OPENSHIFT_DIY_IP
In java API Class to add
System.setProperty("java.net.preferIPv4Stack", "true");
this line.
Change the listening port to 8181
java -Djava.net.preferIPv4Stack=true -jar -Xmx1500m highlighter-0.0.1.jar -Dserver.port=8181
Port numbers have a range of 0..65535 (although often 0 has special meaning). In the original BSD TCP implementation, only root can bind to ports 1..1023, and dynamically assigned ports were assigned from the range 1024..5000.