java.lang.NoClassDefFoundError: kotlin/TypeCastException upon upgrade to spring-boot-starter-parent 2.7.5 - spring

I've recently upgraded my application to use spring-boo-starter 2.7.5 and it now throws the error java.lang.NoClassDefFoundError: kotlin/TypeCastException
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.7.5</version>
<relativePath/>
</parent>
the error happens in the part where I'm using the okhttp3.mockwebserver.MockWebServer;
import okhttp3.mockwebserver.MockWebServer;
...
server = new MockWebServer();

Related

I want to extend WebSecurityConfigurerAdapter but it had been deprecated

I'm trying to code a website using spring boot(security, jpa, web...) and i'm following this tutorial.
And in the minute : 1:05:25 , he needs to extend the WebSecurityConfigurerAdapter, but it had been deprecated in the last spring boot versions, so he changes the version in his "pom.xml" from :
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.7.3</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
To :
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.6.5</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
Then he saves all and updtaes the project. And when I do the same I get errors in my pom.xml file in the parent tag:
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.7.3</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
with the error : Coul not read maven project ...
And I get an error in this dependancy :
<dependency>
<groupId>com.mysql</groupId>
<artifactId>mysql-connector-j</artifactId>
<scope>runtime</scope>
</dependency>
The error is :
3.0.0+
The <dependency> element contains information about a dependency of the project.
Source: maven-4.0.0.xsd`
I also get this error in my console :
APPLICATION FAILED TO START
***************************
Description:
Failed to configure a DataSource: 'url' attribute is not specified and no embedded datasource could be configured.
Reason: Failed to determine a suitable driver class
Action:
Consider the following:
If you want an embedded database (H2, HSQL or Derby), please put it on the classpath.
If you have database settings to be loaded from a particular profile you may need to activate it (no profiles are currently active).
While in the video, he doesn't get errors at all.
So I would like to solve the problem by modifying something in my pom.xml and keeping that application.

What is difference between: CamelContext vs ExtendedCamelContext vs SpringCamelContext?

SpringBoot + ApacheCamel
I have problem with *CamelContext I got exception:
Cannot cast org.apache.camel.spring.SpringCamelContext to org.apache.camel.ExtendedCamelContext
during initialization some components.
parto of my configuration (pom.xml):
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.3.2.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
...
<dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-spring-boot-starter</artifactId>
<version>2.25.2</version>
</dependency>
...
Question: How to use these context / which one should be used ?
CamelContext aka DefaultCamelContext
ExtendedCamelContext
SpringCamelContext

Spring Boot 2.2.1 RELEASE build error-relative path

Am adding spring-boot parent in my pom.xml file as given below
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.2.1 RELEASE</version>
<relativePath/>
</parent>
i was change version version definition into <properties> tag as given below
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<spring-boot.version>2.2.1.RELEASE</spring-boot.version>
</properties>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>${spring-boot.version}</version>
<relativePath/>
</parent>
after this change am getting build error
Project build error: Non-resolvable parent POM for abc:abc:7.0.0.0: Failure to find org.springframework.boot:spring-boot-starter-parent:pom:${spring-boot.version} in https://repo.maven.apache.org/maven2
was cached in the local repository, resolution will not be reattempted until the update interval of central has elapsed or updates are forced and 'parent.relativePath' points at no local POM
i tried following solutions
<relativePath/> to <relativePath>/<relativePath>
<relativePath/> to <relativePath>../pom.xml/<relativePath>
Updated maven project
And also i tried following link
stackoverflow
There is no way not to inherit properties from a parent POM. Properties defined in a parent are visible in the child.

Exception in thread "main" java.lang.NoSuchMethodError: org.slf4j.impl.StaticLoggerBinder.getSingleton()

Spring Boot Application
I am making a Tag Reader Application where am keep Getting This issue
Note: i am not using any Property file input
This my Simple Spring boot application
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
#SpringBootApplication
public class RfidReaderApplication {
public static void main(String[] args) {
SpringApplication.run(RfidReaderApplication.class, args);
}
}
*Pom.xml *
This pom configursation that i am using to build project and also have one external jar for OctaneSDKJava because it not reader OctaneSDKJava jar form pom so i added externally
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.1.2.RELEASE</version>
<relativePath /> <!-- lookup parent from repository -->
</parent>
<groupId>com.Amazin.RFID.Reader</groupId>
<artifactId>RFID-Reader</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>RFID-Reader</name>
<description>Demo project for Spring Boot</description>
<properties>
<java.version>1.8</java.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>com.octane</groupId>
<artifactId>OctaneSDKJava</artifactId>
<version>1.32.0.0</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>
Error Msg that i am getting
Exception in thread "main" java.lang.NoSuchMethodError: org.slf4j.impl.StaticLoggerBinder.getSingleton()Lorg/slf4j/impl/StaticLoggerBinder;
at org.springframework.boot.logging.logback.LogbackLoggingSystem.getLoggerContext(LogbackLoggingSystem.java:285)
at org.springframework.boot.logging.logback.LogbackLoggingSystem.beforeInitialize(LogbackLoggingSystem.java:102)
at org.springframework.boot.context.logging.LoggingApplicationListener.onApplicationStartingEvent(LoggingApplicationListener.java:220)
at org.springframework.boot.context.logging.LoggingApplicationListener.onApplicationEvent(LoggingApplicationListener.java:199)
at org.springframework.context.event.SimpleApplicationEventMulticaster.doInvokeListener(SimpleApplicationEventMulticaster.java:172)
at org.springframework.context.event.SimpleApplicationEventMulticaster.invokeListener(SimpleApplicationEventMulticaster.java:165)
at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:139)
at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:127)
at org.springframework.boot.context.event.EventPublishingRunListener.starting(EventPublishingRunListener.java:69)
at org.springframework.boot.SpringApplicationRunListeners.starting(SpringApplicationRunListeners.java:48)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:302)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1260)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1248)
at com.Amazin.RFID.Reader.RfidReaderApplication.main(RfidReaderApplication.java:10)
As shown through the post linked in the comments, you are possibly missing some SLF4J dependencies. Another possibility, however, is that your dependencies actually have different versions of SLF4J, but since only one can be used there is a clash. See this SO post as well.
I would recommend explicitly using spring-boot-starter-log4j2 since you are using spring boot and going from there.

Missing #ConditionalBean on StormpathWebMvcAutoConfiguration.stormpathApplicationResolver

While trying to add Stormpath to my existing Spring-Boot application, I have the following error on startup.
java.lang.IllegalStateException: Error processing condition on com.stormpath.spring.boot.autoconfigure.StormpathWebMvcAutoConfiguration.stormpathApplicationResolver
...
Caused by: java.lang.IllegalArgumentException: #ConditionalOnMissingBean annotations must specify at least one bean (type, name or annotation)
My pom :
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.3.6.RELEASE</version>
<relativePath />
</parent>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<java.version>1.8</java.version>
<stormpath.version>1.1.1</stormpath.version>
</properties>
<dependencies>
<dependency>
<groupId>com.stormpath.spring</groupId>
<artifactId>stormpath-default-spring-boot-starter</artifactId>
<version>${stormpath.version}</version>
</dependency>
</dependencies>
The stormpath version 1.1.1 works with spring-booth 1.4. I solved the problem by changing the spring-boot-starter-parent version to 1.4.1.

Resources