Can I use Xfire with SpringBoot? - spring-boot

My application uses Xfire as a web service client, It a legacy system where service is written in Perl, I am modifying/rewriting application with Spring boot, when I add the Maven dependency, it shows error when I try to build
<dependency>
<groupId>org.codehaus.xfire</groupId>
<artifactId>xfire-core</artifactId>
<version>1.2.6</version>
</dependency>
<dependency>
<groupId>org.codehaus.xfire</groupId>
<artifactId>xfire-spring</artifactId>
<version>1.2.6</version>
</dependency>
<dependency>
<groupId>org.codehaus.xfire</groupId>
<artifactId>xfire-aegis</artifactId>
<version>1.2.6</version>
</dependency>
[ERROR] contextLoads(com.au.cis.IPND.IpndApplicationTests) Time elapsed: 0.001 s <<< ERROR!
java.lang.IllegalStateException: Failed to load ApplicationContext
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'spring.datasource-org.springframework.boot.autoconfigure.jdbc.DataSourceProperties': Instantiation of bean failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.boot.autoconfigure.jdbc.DataSourceProperties]: Constructor threw exception; nested exception is java.lang.NoClassDefFoundError: org/springframework/jdbc/datasource/embedded/EmbeddedDatabaseType
Caused by: org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.boot.autoconfigure.jdbc.DataSourceProperties]: Constructor threw exception; nested exception is java.lang.NoClassDefFoundError: org/springframework/jdbc/datasource/embedded/EmbeddedDatabaseType
Caused by: java.lang.NoClassDefFoundError: org/springframework/jdbc/datasource/embedded/EmbeddedDatabaseType
Caused by: java.lang.ClassNotFoundException: org.springframework.jdbc.datasource.embedded.EmbeddedDatabaseType'
I don't know where database has been used

EmbeddedDatabaseType is part of spring-jdbc, so I would suggest adding the following dependency (if you do not already have it):
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-jdbc</artifactId>
<version>5.2.1.RELEASE</version>
</dependency>
Please do adjust the version number (5.2.1.RELEASE) to match your other Spring dependencies!

Related

How to run micrometer elastic with micrometer spring legacy?

im quite new to spring and am trying to connect my application to an elk.
The Application is running spring boot 1.5.5, hence I'm using micrometer legacy.
My pom looks like this:
<dependency>
<groupId>io.micrometer</groupId>
<artifactId>micrometer-spring-legacy</artifactId>
<version>1.3.9</version>
</dependency>
<dependency>
<groupId>io.micrometer</groupId>
<artifactId>micrometer-registry-elastic</artifactId>
<version>1.5.1</version>
</dependency>
Whenever I'm trying to start my app I recieve following error:
2020-06-19 13:38:29 [ WARN] Exception encountered during context initialization - cancelling refresh attempt: org.springframework.context.ApplicationContextException: Unable to start embedded containe
r; nested exception is org.springframework.boot.context.embedded.EmbeddedServletContainerException: Unable to start embedded Tomcat > [main] org.springframework.boot.context.embedded.AnnotationConfigEm
beddedWebApplicationContext
2020-06-19 13:38:39 [ INFO]
Error starting ApplicationContext. To display the auto-configuration report re-run your application with 'debug' enabled. > [main] org.springframework.boot.autoconfigure.logging.AutoConfigurationReport
LoggingInitializer
2020-06-19 13:38:39 [ERROR] Application startup failed > [main] org.springframework.boot.SpringApplication
org.springframework.context.ApplicationContextException: Unable to start embedded container; nested exception is org.springframework.boot.context.embedded.EmbeddedServletContainerException: Unable to
start embedded Tomcat
at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.onRefresh(EmbeddedWebApplicationContext.java:137)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:537)
at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.refresh(EmbeddedWebApplicationContext.java:122)
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:693)
at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:360)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:303)
at org.apache.camel.spring.boot.FatJarRouter.main(FatJarRouter.java:26)
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:498)
at org.springframework.boot.loader.MainMethodRunner.run(MainMethodRunner.java:48)
at org.springframework.boot.loader.Launcher.launch(Launcher.java:87)
at org.springframework.boot.loader.Launcher.launch(Launcher.java:50)
at org.springframework.boot.loader.PropertiesLauncher.main(PropertiesLauncher.java:595)
Caused by: org.springframework.boot.context.embedded.EmbeddedServletContainerException: Unable to start embedded Tomcat
at org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServletContainer.initialize(TomcatEmbeddedServletContainer.java:138)
at org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServletContainer.<init>(TomcatEmbeddedServletContainer.java:87)
at org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServletContainerFactory.getTomcatEmbeddedServletContainer(TomcatEmbeddedServletContainerFactory.java:554)
at org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServletContainerFactory.getEmbeddedServletContainer(TomcatEmbeddedServletContainerFactory.java:179)
at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.createEmbeddedServletContainer(EmbeddedWebApplicationContext.java:164)
at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.onRefresh(EmbeddedWebApplicationContext.java:134)
... 14 common frames omitted
Caused by: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'webMetricsFilter' defined in class path resource [io/micrometer/spring/autoconfigure/web/serv
let/WebMvcMetricsAutoConfiguration.class]: Unsatisfied dependency expressed through method 'webMetricsFilter' parameter 0; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyExc
eption: Error creating bean with name 'elasticMeterRegistry' defined in class path resource [io/micrometer/spring/autoconfigure/export/elastic/ElasticMetricsExportAutoConfiguration.class]: Unsatisfied
dependency expressed through method 'elasticMeterRegistry' parameter 0; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'elasticConfig' define
d in class path resource [io/micrometer/spring/autoconfigure/export/elastic/ElasticMetricsExportAutoConfiguration.class]: Post-processing of merged bean definition failed; nested exception is java.lang
.IllegalStateException: Failed to introspect bean class [io.micrometer.spring.autoconfigure.export.elastic.ElasticPropertiesConfigAdapter] for persistence metadata: could not find class that it depends
on
at org.springframework.beans.factory.support.ConstructorResolver.createArgumentArray(ConstructorResolver.java:749)
at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:467)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateUsingFactoryMethod(AbstractAutowireCapableBeanFactory.java:1178)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1072)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:511)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:481)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:312)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:308)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:202)
at org.springframework.boot.web.servlet.ServletContextInitializerBeans.getOrderedBeansOfType(ServletContextInitializerBeans.java:234)
at org.springframework.boot.web.servlet.ServletContextInitializerBeans.addAsRegistrationBean(ServletContextInitializerBeans.java:182)
at org.springframework.boot.web.servlet.ServletContextInitializerBeans.addAsRegistrationBean(ServletContextInitializerBeans.java:177)
at org.springframework.boot.web.servlet.ServletContextInitializerBeans.addAdaptableBeans(ServletContextInitializerBeans.java:159)
at org.springframework.boot.web.servlet.ServletContextInitializerBeans.<init>(ServletContextInitializerBeans.java:80)
at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.getServletContextInitializerBeans(EmbeddedWebApplicationContext.java:241)
at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.selfInitialize(EmbeddedWebApplicationContext.java:228)
at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.access$000(EmbeddedWebApplicationContext.java:89)
at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext$1.onStartup(EmbeddedWebApplicationContext.java:213)
at org.springframework.boot.context.embedded.tomcat.TomcatStarter.onStartup(TomcatStarter.java:55)
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5245)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1420)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1410)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
at java.lang.Thread.run(Thread.java:748)
Caused by: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'elasticMeterRegistry' defined in class path resource [io/micrometer/spring/autoconfigure/expo
rt/elastic/ElasticMetricsExportAutoConfiguration.class]: Unsatisfied dependency expressed through method 'elasticMeterRegistry' parameter 0; nested exception is org.springframework.beans.factory.BeanCr
eationException: Error creating bean with name 'elasticConfig' defined in class path resource [io/micrometer/spring/autoconfigure/export/elastic/ElasticMetricsExportAutoConfiguration.class]: Post-proce
at java.lang.Class.getMethods(Class.java:1643)
at org.springframework.util.ReflectionUtils.findConcreteMethodsOnInterfaces(ReflectionUtils.java:635)
at org.springframework.util.ReflectionUtils.getDeclaredMethods(ReflectionUtils.java:614)
at org.springframework.util.ReflectionUtils.doWithLocalMethods(ReflectionUtils.java:489)
at org.springframework.orm.jpa.support.PersistenceAnnotationBeanPostProcessor.buildPersistenceMetadata(PersistenceAnnotationBeanPostProcessor.java:431)
at org.springframework.orm.jpa.support.PersistenceAnnotationBeanPostProcessor.findPersistenceMetadata(PersistenceAnnotationBeanPostProcessor.java:397)
... 54 common frames omitted
Caused by: java.lang.ClassNotFoundException: io.micrometer.core.instrument.config.validate.Validated
at java.net.URLClassLoader.findClass(URLClassLoader.java:382)
at java.lang.ClassLoader.loadClass(ClassLoader.java:419)
at org.springframework.boot.loader.LaunchedURLClassLoader.loadClass(LaunchedURLClassLoader.java:94)
at java.lang.ClassLoader.loadClass(ClassLoader.java:352)
... 63 common frames omitted
The root cause seems to be the class io.micrometer.core.instrument.config.validate.Validated which seems not to be present in the package as it should be.
Any ideas on that?
the root case was a mismatch of the versions o micrometer core which was pulled by other dependencies.
I imported the following
<dependency>
<groupId>io.micrometer</groupId>
<artifactId>micrometer-spring-legacy</artifactId>
<version>1.3.9</version>
</dependency>
<dependency>
<groupId>io.micrometer</groupId>
<artifactId>micrometer-registry-elastic</artifactId>
<version>1.5.1</version>
</dependency>
And run into the error above because both dependencies contain a version of micrometer core. In my case version 1.3.9. The needed class was added to micrometer.core with release 1.5.x
So the solution was to define that dependency explicit with version 1.5.x
<dependency>
<groupId>io.micrometer</groupId>
<artifactId>micrometer-spring-legacy</artifactId>
<version>1.3.9</version>
</dependency>
<dependency>
<groupId>io.micrometer</groupId>
<artifactId>micrometer-registry-elastic</artifactId>
<version>1.5.1</version>
</dependency>
<!-- https://mvnrepository.com/artifact/io.micrometer/micrometer-core -->
<dependency>
<groupId>io.micrometer</groupId>
<artifactId>micrometer-core</artifactId>
<version>1.5.1</version>
</dependency>
Anyway the application does not start due to socket timeouts but te error above is fixed. :D
Migration to spring boot 2 might be a faster solution. xD

Getting the following error, any tips to resolving it? I am trying to convert from OAM to OKTA for authentication

I have a Spring application that I’ve been trying to switch over to Okta. I have not made it connect with OKTA yet. I am getting an error related to client registration.
I am using following dependencies
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.1.1.RELEASE</version>
<!-- <version>1.4.2.RELEASE</version>-->
</parent>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-security</artifactId>
<!--<version>1.5.2.RELEASE</version>-->
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-oauth2-client</artifactId>
</dependency>
Application.properties
spring.security.oauth2.client.provider.okta.issuer-uri=https://dev-327711.okta.com/oauth2/default
spring.security.oauth2.client.registration.okta.provider=okta
spring.security.oauth2.client.registration.okta.client-name=awards2
spring.security.oauth2.client.registration.okta.client-id=xxxx
spring.security.oauth2.client.registration.okta.client-secret=xxxx
spring.security.oauth2.client.registration.okta.redirect-uri=/authorization-code/callback
spring.security.oauth2.client.registration.okta.scope=openid,profile,email
Error trace:
Caused by: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'securityConfiguration': Unsatisfied dependency expressed through method 'setContentNegotationStrategy' parameter 0;
nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'org.springframework.boot.autoconfigure.web.servlet.WebMvcAutoConfiguration$EnableWebMvcConfiguration':
Unsatisfied dependency expressed through method 'setConfigurers' parameter 0; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'org.springframework.security.config.annotation.web.configuration.OAuth2ClientConfiguration$OAuth2ClientWebMvcSecurityConfiguration':
Unsatisfied dependency expressed through method 'setClientRegistrationRepository' parameter 0; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'clientRegistrationRepository' defined in class path resource [org/springframework/boot/autoconfigure/security/oauth2/client/servlet/OAuth2ClientRegistrationRepositoryConfiguration.class]:
Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException:
Failed to instantiate [org.springframework.security.oauth2.client.registration.InMemoryClientRegistrationRepository]: Factory method 'clientRegistrationRepository' threw exception; nested exception is java.lang.NoSuchMethodError: org.springframework.security.oauth2.client.registration.ClientRegistration.withRegistrationId(Ljava/lang/String;)Lorg/springframework/security/oauth2/client/registration/ClientRegistration$Builder;
After reading OAuth2 document I resolved this issue by adding "autoconfigure" dependency.
<dependency>
<groupId>org.springframework.security.oauth.boot</groupId>
<artifactId>spring-security-oauth2-autoconfigure</artifactId>
<version>2.4.5</version>
</dependency>
https://docs.spring.io/spring-security-oauth2-boot/docs/2.0.0.RC2/reference/htmlsingle/

Upgrade spring boot version from 1.5.13 to 1.5.19 occurred Error creating bean with name 'payloadRootAnnotationMethodEndpointMapping'

Error creating bean with name 'payloadRootAnnotationMethodEndpointMapping' defined in class path resource [org/springframework/ws/config/annotation/DelegatingWsConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.ws.server.endpoint.mapping.PayloadRootAnnotationMethodEndpointMapping]: Factory method 'payloadRootAnnotationMethodEndpointMapping' threw exception; nested exception is java.lang.ExceptionInInitializerError
Failed to instantiate [org.springframework.ws.server.endpoint.mapping.PayloadRootAnnotationMethodEndpointMapping]: Factory method 'payloadRootAnnotationMethodEndpointMapping' threw exception; nested exception is java.lang.ExceptionInInitializerError
Not supported: http://javax.xml.XMLConstants/property/accessExternalDTD
I have fixed this problem by adding the following to pom.xml:
<exclusion>
<groupId>xalan</groupId>
<artifactId>xalan</artifactId>
</exclusion>
Maybe it shouldn't have xalan in the Maven dependencies.

Getting "Error creating bean with name 'springSecurityFilterChain'" in Spring Boot

I got this error when I run the application. I tried to solve this problem by reading several posts but it makes no sense.
Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled.
and
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'springSecurityFilterChain' defined in class path resource [org/springframework/security/config/annotation/web/configuration/WebSecurityConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [javax.servlet.Filter]: Factory method 'springSecurityFilterChain' threw exception; nested exception is java.lang.RuntimeException: javax.xml.bind.JAXBException: Implementation of JAXB-API has not been found on module path or classpath.
- with linked exception:
[java.lang.ClassNotFoundException: com.sun.xml.internal.bind.v2.ContextFactory]
In the exception stack trace it seems not able to find the JAXB-API . Do you have this dependency to your project - jaxb-api.
Java 11 removed the Java EE modules: java.xml.bind (JAXB) - REMOVED
You can fix the issue by using alternate versions of the Java EE technologies. Simply add Maven dependencies that contain the classes you need:
<dependency>
<groupId>javax.xml.bind</groupId>
<artifactId>jaxb-api</artifactId>
<version>2.3.1</version>
</dependency>
<dependency>
<groupId>com.sun.xml.bind</groupId>
<artifactId>jaxb-core</artifactId>
<version>2.3.0.1</version>
</dependency>
<dependency>
<groupId>com.sun.xml.bind</groupId>
<artifactId>jaxb-impl</artifactId>
<version>2.3.2</version>
</dependency>
For Details Read This StackOverflow Answer

org.springframework.cloud.CloudException: No unique service matching interface org.springframework.amqp.rabbit.connection.ConnectionFactory found.

I am trying to deploy the springboot application in Pivotal Cloud Foundry. I am getting following exception.
Caused by: org.springframework.cloud.CloudException: No unique service matching interface org.springframework.amqp.rabbit.connection.ConnectionFactory found. Expected 1, found 0
Caused by: org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.amqp.rabbit.connection.ConnectionFactory]: Factory method 'rabbitConnectionFactory' threw exception; nested exception is org.springframework.cloud.CloudException: No unique service matching interface org.springframework.amqp.rabbit.connection.ConnectionFactory found. Expected 1, found 0
Try adding spring-cloud-services-starter-service-registry maven dependency.
<dependency>
<groupId>io.pivotal.spring.cloud</groupId>
<artifactId>spring-cloud-services-starter-service-registry</artifactId>
<version>3.1.5.RELEASE</version>
</dependency>

Resources