Spring Boot Batch application failing to start in a particular environment because of environment property

Viewed 21

I ran the batch application in couple of linux environment. The application was working in one of the environment and is failing in other environment. I am getting the below failure message in that environment. The environment had some parameters which is blocking the application to start it seems. What needs to be done to change this and make the application work.

I checked the property file and found this parameter 'ENV=int'. I think this might be the once causing the issue.

Error StackTrace: {'timestamp': '2022-09-13 06:17:44,381','level':' WARN','transactionId':'','userId':'','env' :'','src_host':'','appId':'','className':'','methodName':'','messageId':'','message':'Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'btchJobLauncher': Unsatisfied dependency expressed through field 'jobs'; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'org.springframework.batch.core.configuration.annotation.SimpleBatchConfiguration': Unsatisfied dependency expressed through field 'dataSource'; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'cmnCnfg': Unsatisfied dependency expressed through field 'cnfgReader'; nested exception is org.springframework.boot.context.properties.ConfigurationPropertiesBindException: Error creating bean with name 'cnfgReader': Could not bind properties to 'CnfgReader' : prefix=, ignoreInvalidFields=false, ignoreUnknownFields=true; nested exception is org.springframework.boot.context.properties.bind.BindException: Failed to bind properties under 'env' to org.springframework.core.env.Environment'} {'timestamp': '2022-09-13 06:17:44,403','level':' INFO','transactionId':'','userId':'','env' :'','src_host':'','appId':'','className':'','methodName':'','messageId':'','message':' Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled.'} {'timestamp': '2022-09-13 06:17:44,440','level':'ERROR','transactionId':'','userId':'','env' :'','src_host':'','appId':'','className':'','methodName':'','messageId':'','message':'


APPLICATION FAILED TO START


Description: Failed to bind properties under 'env' to org.springframework.core.env.Environment: Property: env Value: int Origin: "ENV" from property source "systemEnvironment" Reason: org.springframework.core.convert.ConverterNotFoundException: No converter found capable of converting from type [java.lang.String] to type [org.springframework.core.env.Environment] Action: Update your application's configuration.

I have added the code block where the stack trace was pointing the issue.

@Configuration
@EnableConfigurationProperties
@ConfigurationProperties
@PropertySource(value = "file:${PROPS_FILE:cnfg/BtchDb.properties}")
@Component
public class CnfgReader {
    @Autowired
    private Environment envt;

    public Environment getEnvt() {
        return envt;
    }

    public void setEnvt(Environment envt) {
        this.envt = envt;
    }
}

What changes I have to make in order to make the batch application run in the environment. Thanks in advance.

0 Answers
Related