1

My complete application is working perfectly in Eclipse. I generated a jar file by mvn clean package command in the project directory. The jar file is generated in the target folder.

Now I am executing this jar file by java -jar ScoreExtractionApp.jar, it is giving the below exceptions:

ConfigServletWebServerApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'appStartupRunner': Unsatisfied dependency expressed through field 'scoreParserService'; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'scoreParserServiceImpl': Unsatisfied dependency expressed through field 'decisionAgentService'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'decisionAgentServiceImpl' defined in URL [jar:file:/D:/ScoreExtractionGitHub/ScoreExtraction/target/classes/ScoreExtractionApp.jar!/BOOT-INF/classes!/com/alrajhi/score/ScoreExtraction/service/impl/DecisionAgentServiceImpl.class]: Post-processing of merged bean definition failed; nested exception is java.lang.IllegalStateException: Failed to introspect Class [com.alrajhi.score.ScoreExtraction.service.impl.DecisionAgentServiceImpl] from ClassLoader [org.springframework.boot.loader.LaunchedURLClassLoader@179d3b25]

package com.alrajhi.score.ScoreExtraction;

import lombok.extern.slf4j.Slf4j;


import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.ApplicationArguments;
import org.springframework.boot.ApplicationRunner;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.stereotype.Component;
import org.springframework.stereotype.Service;

import com.alrajhi.score.ScoreExtraction.service.ScoreParserService;

@Slf4j
@ComponentScan
@Service
public class AppStartupRunner implements ApplicationRunner {
//
    @Autowired
    ScoreParserService scoreParserService;
//
    @Override
    public void run(ApplicationArguments args) throws Exception {
        log.info("Your application started with option names : {}", args.getOptionNames());
       scoreParserService.startExecution();
    }
}

Below is the ScoreParserService Interface

package com.alrajhi.score.ScoreExtraction.service;

import java.io.File;
import java.math.BigDecimal;
import java.util.Date;
import java.util.List;

import org.springframework.stereotype.Service;

@Service
public interface ScoreParserService {

    public void startExecution();

    public List<File> getInputFiles(String workingDirectory);

    public void processInputFiles(List<File> files);
    
    public void saveLogOutputToDB(Date logDate, String logLevel, String logResult, String logType, String logUser, String runStatus,BigDecimal s);

 }

Warning Messages during building Jar file

[WARNING] Some problems were encountered while building the effective model for com.alrajhi.score:ScoreExtraction:jar:0.0.1

[WARNING] 'dependencies.dependency.systemPath' for com.experian.appscore:appscore:jar should not point at files within the project directory, ${project.basedir}/src/main/resources/lib/APPSCORE.jar will be unresolvable by dependent projects @ line 133, column 25

[WARNING] 'dependencies.dependency.systemPath' for com.experian.encoder:encoder:jar should not point at files within the project directory, ${project.basedir}/src/main/resources/lib/com.experian.eda.encoder-1.2.1.EDA2-bundle.jar will be unresolvable by dependent projects @ line 142, column 25

[WARNING] 'dependencies.dependency.systemPath' for com.experian.eda.da:Decision.Agent.Bundle:jar should not point at files within the project directory, ${project.basedir}/src/main/resources/lib/DA.jar will be unresolvable by dependent projects @ line 151, column 25

[WARNING] 'dependencies.dependency.systemPath' for org.grlea.Bridge:Log.Bridge:jar should not point at files within the project directory, ${project.basedir}/src/main/resources/lib/log-bridge-1.0.jar will be unresolvable by dependent projects @ line 160, column 25
Mario Codes
  • 689
  • 8
  • 15
  • Bean creation is failing as component is not scanned. You need to add annotation @ComponentScan – Ravindra Yadav Sep 02 '20 at 12:17
  • Where i have to put it – Waleed Raza Sep 02 '20 at 12:20
  • When running from Eclipse, are you using the same version of Java as when you run the packaged JAR? – mthmulders Sep 02 '20 at 12:46
  • in eclipse it is running by JAVA "1.8.0_11" and outside i have 2 java versions "1.8.0_221" and "1.8.0_11". I executed generated jar file by java version "1.8.0_11" and it is giving same results – Waleed Raza Sep 02 '20 at 15:13
  • You need to put @ComponentScan in AppStartupRunner as you already have need to put base package reference & package reference for same. Refrence: https://springframework.guru/spring-component-scan/ – Ravindra Yadav Sep 03 '20 at 05:15
  • Dear i have already added this and tried but it did not help. check the edited code above – Waleed Raza Sep 03 '20 at 06:55
  • Please check Warning messages during building of Jar file. I think this can be a problem ? As these jar are importing on the services which are making problem – Waleed Raza Sep 03 '20 at 07:04

1 Answers1

0

As i mentioned in the comments above the problem was warining messages during build.

[WARNING] Some problems were encountered while building the effective model for com.alrajhi.score:ScoreExtraction:jar:0.0.1

[WARNING] 'dependencies.dependency.systemPath' for com.experian.appscore:appscore:jar should not point at files within the project directory, ${project.basedir}/src/main/resources/lib/APPSCORE.jar will be unresolvable by dependent projects @ line 133, column 25

[WARNING] 'dependencies.dependency.systemPath' for com.experian.encoder:encoder:jar should not point at files within the project directory, ${project.basedir}/src/main/resources/lib/com.experian.eda.encoder-1.2.1.EDA2-bundle.jar will be unresolvable by dependent projects @ line 142, column 25

[WARNING] 'dependencies.dependency.systemPath' for com.experian.eda.da:Decision.Agent.Bundle:jar should not point at files within the project directory, ${project.basedir}/src/main/resources/lib/DA.jar will be unresolvable by dependent projects @ line 151, column 25

[WARNING] 'dependencies.dependency.systemPath' for org.grlea.Bridge:Log.Bridge:jar should not point at files within the project directory, ${project.basedir}/src/main/resources/lib/log-bridge-1.0.jar will be unresolvable by dependent projects @ line 160, column 25

And the solution of these warning messages was including these jar files in my local mevan repository. I got this idea by this thread