Reputation: 215
I wrote a springboot application but it gives error before run method execution.I observed with debug it enters main method but after that it gives error immediately.I checked pom.xml file but I did not find any problem with dependencies.
Error is : org.springframework.boot.context.config.ConfigFileApplicationListener.supportsSourceType(Ljava/lang/Class;)Z
Do you have any idea?
My app class is :
@Configuration
@SpringBootApplication
public class ProcessesApplication implements CommandLineRunner {
private static Logger logger = LoggerFactory.getLogger(ProcessesApplication.class);
@Autowired
private BatchManager batchManager;
public static void main(String[] args) {
SpringApplication.run(ProcessesApplication.class, args);
}
@Override
public void run(String... args) throws Exception {
Integer threadCount = 5;
try {
if (args.length > 1 && args[1] != null && !args[1].trim().isEmpty()) {
try {
threadCount = Integer.valueOf(args[1].trim());
} catch (Exception e) {
e.getStackTrace(e));
}
}
this.batchManager.setThreadCount(threadCount);
this.batchManager.setProcessName("Process");
this.batchManager.start();
} catch (Exception e) {
e.getStackTrace(e);
}
}
}
My pom.xml is
?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-
instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.2.2.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<groupId>com.App</groupId>
<artifactId>processes</artifactId>
<version>1.0.1</version>
<name>processes</name>
<description>data sending </description>
<properties>
<java.version>1.8</java.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jdbc</artifactId>
</dependency>
<dependency>
<groupId>com.oracle</groupId>
<artifactId>ojdbc6</artifactId>
<version>11.2.0.3</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-resources-plugin</artifactId>
<version>2.6</version>
</plugin>
</plugins>
</build>
Log file :
Exception in thread "main" java.lang.AbstractMethodError: org.springframework.boot.context.config.ConfigFileApplicationListener.supportsSourceType(Ljava/lang/Class;)Z
at org.springframework.context.event.GenericApplicationListenerAdapter.supportsSourceType(GenericApplicationListenerAdapter.java:81)
at org.springframework.context.event.AbstractApplicationEventMulticaster.supportsEvent(AbstractApplicationEventMulticaster.java:304)
at org.springframework.context.event.AbstractApplicationEventMulticaster.retrieveApplicationListeners(AbstractApplicationEventMulticaster.java:225)
at org.springframework.context.event.AbstractApplicationEventMulticaster.getApplicationListeners(AbstractApplicationEventMulticaster.java:196)
at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:133)
at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:127)
at org.springframework.boot.context.event.EventPublishingRunListener.environmentPrepared(EventPublishingRunListener.java:76)
at org.springframework.boot.SpringApplicationRunListeners.environmentPrepared(SpringApplicationRunListeners.java:53)
at org.springframework.boot.SpringApplication.prepareEnvironment(SpringApplication.java:345)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:308)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1226)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1215)
at com.App.processes.ProcessesApplication.main(ProcessesApplication.java:39)
Upvotes: 1
Views: 810
Reputation: 4690
I would suggest seperating the class with main()
function from the other class.
Basically create a class that has only the main()
function inside and another class for the CommandLineRunner
.
Example:
@SpringBootApplication
@EnableAsync
public class SpringApp{
public static void main(String[] args) {
SpringApplication.run(SpringApp.class, args);
}
}
And a seperate Class for the Runner
:
@Component
public class ARunner implements ApplicationRunner {
@Override
public void run(ApplicationArguments args) throws Exception
{
// Your code...
}
}
Upvotes: 1