Spring boot property injection failed

RonPringadi :

I'm trying to add a property which uses injection on a spring boot project. Please see the token variable. If I hard coded the token, without @Value it works and managed to be deployed on Wildfly Server (JBoss).

I have verified that lms.token exist in the application.properties lms.token=sometokenvalue. I'm using:

  • spring-boot-2.1.2.RELEASE.jar
  • spring-core-5.1.2.RELEASE.jar
@Service
@Transactional
public class VaultLMSImpl implements LMSService {
    protected final Log logger = LogFactory.getLog(VaultLMSImpl.class);

    @Value("${lms.token}")
    private String token;

    @Autowired
    private Endpoint endpoint;
}
{"WFLYCTL0080: Failed services" => {"jboss.undertow.deployment.default-server.default-host./lms" => "org.jboss.msc.service.StartException in service jboss.undertow.deployment.default-server.default-host./lms: java.lang.RuntimeException: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'LMSAPI': Unsatisfied dependency expressed through field 'lmsService';
 nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'vaultLMSImpl': Injection of autowired dependencies failed;
 nested exception is java.lang.IllegalAccessError: tried to access method org.springframework.core.convert.TypeDescriptor.<init>(Lorg/springframework/core/ResolvableType;
Ljava/lang/Class;
[Ljava/lang/annotation/Annotation;
)V from class org.springframework.beans.factory.config.DependencyDescriptor
    Caused by: java.lang.RuntimeException: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'LMSAPI': Unsatisfied dependency expressed through field 'lmsService';
 nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'vaultLMSImpl': Injection of autowired dependencies failed;
 nested exception is java.lang.IllegalAccessError: tried to access method org.springframework.core.convert.TypeDescriptor.<init>(Lorg/springframework/core/ResolvableType;
Ljava/lang/Class;
[Ljava/lang/annotation/Annotation;
)V from class org.springframework.beans.factory.config.DependencyDescriptor
    Caused by: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'LMSAPI': Unsatisfied dependency expressed through field 'lmsService';
 nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'vaultLMSImpl': Injection of autowired dependencies failed;
 nested exception is java.lang.IllegalAccessError: tried to access method org.springframework.core.convert.TypeDescriptor.<init>(Lorg/springframework/core/ResolvableType;
Ljava/lang/Class;
[Ljava/lang/annotation/Annotation;
)V from class org.springframework.beans.factory.config.DependencyDescriptor
    Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'vaultLMSImpl': Injection of autowired dependencies failed;
 nested exception is java.lang.IllegalAccessError: tried to access method org.springframework.core.convert.TypeDescriptor.<init>(Lorg/springframework/core/ResolvableType;
Ljava/lang/Class;
[Ljava/lang/annotation/Annotation;
)V from class org.springframework.beans.factory.config.DependencyDescriptor
    Caused by: java.lang.IllegalAccessError: tried to access method org.springframework.core.convert.TypeDescriptor.<init>(Lorg/springframework/core/ResolvableType;
Ljava/lang/Class;
[Ljava/lang/annotation/Annotation;
)V from class org.springframework.beans.factory.config.DependencyDescriptor"},
"WFLYCTL0412: Required services that are not installed:" => ["jboss.undertow.deployment.default-server.default-host./lms"],
"WFLYCTL0180: Services with missing/unavailable dependencies" => undefined}

What am I missing here?

Pom file as follows:

<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/maven-v4_0_0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <groupId>com.ramen.maple</groupId>
    <artifactId>kms</artifactId>
    <version>2018.arch</version>
    <packaging>war</packaging>
    <name>LMS Webapp</name>
    <parent>
        <groupId>com.ramen.maple</groupId>
        <artifactId>services</artifactId>
        <version>2018.arch</version>
    </parent>
    <profiles>
        <!-- Profile for excluding local confs -->
        <profile>
            <id>exclusions</id>
            <activation>
                <activeByDefault>true</activeByDefault>
            </activation>
            <build>
                <resources>
                    <resource>
                        <directory>src/main/resources/</directory>
                        <excludes>
                            <exclude>local-conf/**</exclude>
                        </excludes>
                    </resource>
                </resources>
            </build>
        </profile>
        <profile>
            <id>integration</id>
            <activation>
                <activeByDefault>true</activeByDefault>
            </activation>
            <dependencies>
                <dependency>
                    <groupId>org.wildfly.arquillian</groupId>
                    <artifactId>wildfly-arquillian-container-managed</artifactId>
                    <version>${wildfly-arquillian-container-managed.version}</version>
                    <scope>test</scope>
                </dependency>
            </dependencies>
            <!-- This optional build configuration downloads and extracts JBoss AS 
                automatically -->
            <!-- Remove it if you want to use an existing installation defined by 
                the JBOSS_HOME environment variable -->
            <build>
                <plugins>
                    <plugin>
                        <artifactId>maven-dependency-plugin</artifactId>
                        <executions>
                            <execution>
                                <id>unpack</id>
                                <phase>process-resources</phase>
                                <goals>
                                    <goal>unpack</goal>
                                </goals>
                                <configuration>
                                    <artifactItems>
                                        <artifactItem>
                                            <groupId>org.wildfly</groupId>
                                            <artifactId>wildfly-dist</artifactId>
                                            <version>${wildfly.version}</version>
                                            <type>zip</type>
                                            <overWrite>false</overWrite>
                                            <outputDirectory>target</outputDirectory>
                                        </artifactItem>
                                    </artifactItems>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>
                    <plugin>
                        <artifactId>maven-resources-plugin</artifactId>
                        <version>3.0.2</version>
                        <executions>
                            <execution>
                                <id>copy-configurations</id>
                                <phase>process-test-sources</phase>
                                <goals>
                                    <goal>copy-resources</goal>
                                </goals>
                                <configuration>
                                    <outputDirectory>target/wildfly-10.1.0.Final/standalone/configuration</outputDirectory>
                                    <resources>
                                        <resource>
                                            <directory>src/test/resources</directory>
                                            <includes>
                                                <include>standalone-full.xml</include>
                                                <include>application-roles.properties</include>
                                                <include>application-users.properties</include>
                                            </includes>
                                            <filtering>true</filtering>
                                        </resource>
                                    </resources>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>
                </plugins>
            </build>
        </profile>
    </profiles>
    <dependencyManagement>
        <dependencies>
            <dependency>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-dependencies</artifactId>
                <version>${spring.boot.version}</version>
                <type>pom</type>
                <scope>import</scope>
            </dependency>
            <dependency>
                <groupId>org.jboss.arquillian</groupId>
                <artifactId>arquillian-bom</artifactId>
                <version>1.1.11.Final</version>
                <scope>import</scope>
                <type>pom</type>
            </dependency>
            <dependency>
                <groupId>org.jboss.shrinkwrap.resolver</groupId>
                <artifactId>shrinkwrap-resolver-bom</artifactId>
                <version>3.0.0-beta-2</version>
                <type>pom</type>
                <scope>import</scope>
            </dependency>

        </dependencies>
    </dependencyManagement>
    <properties>
        <!-- For spring vault we'll need to use 5.1.2.RELEASE while our parent 
            project (see services/pom.xml) is still using version 5.0.7.RELEASE https://docs.spring.io/spring-vault/docs/current/reference/html/#preface -->
        <spring.version>5.1.3.RELEASE</spring.version>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
        <java.version>1.8</java.version>

    </properties>
    <dependencies>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
            <exclusions>
                <exclusion>
                    <groupId>org.apache.tomcat.embed</groupId>
                    <artifactId>tomcat-embed-websocket</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>com.fasterxml.jackson.core</groupId>
                    <artifactId>jackson-databind</artifactId>
                </exclusion>
            </exclusions>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-test</artifactId>
            <scope>test</scope>
            <exclusions>
                <exclusion>
                    <groupId>dom4j</groupId>
                    <artifactId>dom4j</artifactId>
                </exclusion>
            </exclusions>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-core</artifactId>
            <version>${spring.version}</version>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-web</artifactId>
            <version>${spring.version}</version>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-webmvc</artifactId>
            <version>${spring.version}</version>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-oxm</artifactId>
            <version>${spring.version}</version>
        </dependency>

        <dependency>
            <groupId>com.fasterxml.jackson.core</groupId>
            <artifactId>jackson-databind</artifactId>
            <version>${jackson.version}</version>
        </dependency>
        <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>slf4j-api</artifactId>
            <version>${slf4j-api.version}</version>
            <scope>provided</scope>
        </dependency>

        <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>slf4j-log4j12</artifactId>
            <version>${slf4j-log4j.version}</version>
            <scope>test</scope>
        </dependency>

        <dependency>
            <groupId>org.springframework.vault</groupId>
            <artifactId>spring-vault-core</artifactId>
            <version>2.1.1.RELEASE</version>
        </dependency>
        <dependency>
            <groupId>org.springframework.vault</groupId>
            <artifactId>spring-vault-dependencies</artifactId>
            <version>2.1.1.RELEASE</version>
            <type>pom</type>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-tx</artifactId>
            <version>${spring.version}</version>
        </dependency>

        <dependency>
            <groupId>org.apache.httpcomponents</groupId>
            <artifactId>httpmime</artifactId>
            <version>${httpmime.version}</version> <!-- was 4.1 -->
        </dependency>
        <dependency>
            <groupId>org.apache.httpcomponents</groupId>
            <artifactId>httpcore</artifactId>
            <version>${httpcore.version}</version> <!-- was 4.4 -->
        </dependency>
        <dependency>
            <groupId>org.apache.httpcomponents</groupId>
            <artifactId>httpclient</artifactId>
            <version>${httpclient.version}</version> <!-- was 4.1 -->
        </dependency>
        <dependency>
            <groupId>org.apache.commons</groupId>
            <artifactId>commons-crypto</artifactId>
            <version>1.0.0</version>
        </dependency>
        <dependency>
            <groupId>org.apache.commons</groupId>
            <artifactId>commons-lang3</artifactId>
            <version>3.8.1</version>
        </dependency>
        <dependency>
            <groupId>javax.validation</groupId>
            <artifactId>validation-api</artifactId>
            <version>${validation-api.version}</version>
        </dependency>
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>${junit.version}</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.hibernate</groupId>
            <artifactId>hibernate-validator</artifactId>
            <version>${hibernate-validator.version}</version> <!-- was 4.3.1.Final -->
        </dependency>
        <dependency>
            <groupId>javax.servlet</groupId>
            <artifactId>javax.servlet-api</artifactId>
            <version>${javax.servlet-api.version}</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>com.nimbusds</groupId>
            <artifactId>nimbus-jose-jwt</artifactId>
            <version>${nimbus-jose-jwt.version}</version>
        </dependency>
        <dependency>
            <groupId>org.bouncycastle</groupId>
            <artifactId>bcprov-jdk15on</artifactId>
            <version>${bcprov-jdk15on.version}</version>
        </dependency>
        <dependency>
            <groupId>commons-fileupload</groupId>
            <artifactId>commons-fileupload</artifactId>
            <version>${commons-fileupload.version}</version> <!-- was 1.3.1 -->
        </dependency>
        <dependency>
            <groupId>com.google.guava</groupId>
            <artifactId>guava</artifactId>
            <version>${guava.version}</version>
        </dependency>
        <dependency>
            <groupId>org.apache.logging.log4j</groupId>
            <artifactId>log4j-core</artifactId>
            <version>${log4j.version}</version>
        </dependency>
        <dependency>
            <groupId>log4j</groupId>
            <artifactId>apache-log4j-extras</artifactId>
            <version>${log4j-extras.version}</version>
        </dependency>
        <dependency>
            <groupId>org.jboss.logging</groupId>
            <artifactId>jboss-logging</artifactId>
            <version>3.3.2.Final</version>
        </dependency>
        <dependency>
            <groupId>com.google.code.gson</groupId>
            <artifactId>gson</artifactId>
            <version>${gson.version}</version>
        </dependency>

        <dependency>
            <groupId>com.ramen.maple</groupId>
            <artifactId>derrick</artifactId>
            <version>${project.version}</version>
        </dependency>
        <dependency>
            <groupId>org.jboss.spec.javax.servlet</groupId>
            <artifactId>jboss-servlet-api_3.0_spec</artifactId>
            <version>${jboss-servlet-api_3.0_spec.version}</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>org.jboss.arquillian.junit</groupId>
            <artifactId>arquillian-junit-container</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.wildfly.arquillian</groupId>
            <artifactId>wildfly-arquillian-container-managed</artifactId>
            <version>${wildfly-arquillian-container-managed.version}</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.jboss.shrinkwrap.resolver</groupId>
            <artifactId>shrinkwrap-resolver-impl-maven</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>net.sf.json-lib</groupId>
            <artifactId>json-lib</artifactId>
            <version>${json-lib.version}</version>
            <exclusions>
                <exclusion>
                    <groupId>commons-beanutils</groupId>
                    <artifactId>commons-beanutils</artifactId>
                </exclusion>
            </exclusions>
        </dependency>
        <dependency>
            <groupId>org.json</groupId>
            <artifactId>json</artifactId>
            <version>${json.version}</version>
        </dependency>
        <!-- resteasy - start -->
        <dependency>
            <groupId>org.jboss.resteasy</groupId>
            <artifactId>resteasy-jaxb-provider</artifactId>
            <version>${resteasy-jaxb-provider.version}</version>
            <scope>provided</scope>
            <exclusions>
                <exclusion>
                    <artifactId>servlet-api</artifactId>
                    <groupId>javax.servlet</groupId>
                </exclusion>
            </exclusions>
        </dependency>
        <dependency>
            <groupId>org.jboss.resteasy</groupId>
            <artifactId>resteasy-jettison-provider</artifactId>
            <version>${resteasy-jettison-provider.version}</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>org.jboss.resteasy</groupId>
            <artifactId>resteasy-jackson-provider</artifactId>
            <version>${resteasy-jackson-provider.version}</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>org.jboss.resteasy</groupId>
            <artifactId>resteasy-jaxrs</artifactId>
            <version>${resteasy-jaxrs.version}</version>
            <scope>provided</scope>
            <exclusions>
                <exclusion>
                    <artifactId>commons-logging</artifactId>
                    <groupId>commons-logging</groupId>
                </exclusion>
                <exclusion>
                    <artifactId>commons-codec</artifactId>
                    <groupId>commons-codec</groupId>
                </exclusion>
            </exclusions>
        </dependency>
        <!-- resteasy - end -->
    </dependencies>
    <build>
        <finalName>kms</finalName>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
                <version>${spring.boot.version}</version>
            </plugin>
            <plugin>
                <groupId>org.jacoco</groupId>
                <artifactId>jacoco-maven-plugin</artifactId>
                <version>0.8.0</version>
                <executions>
                    <execution>
                        <id>default-prepare-agent</id>
                        <goals>
                            <goal>prepare-agent</goal>
                        </goals>
                    </execution>
                    <execution>
                        <id>default-report</id>
                        <phase>prepare-package</phase>
                        <goals>
                            <goal>report</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-war-plugin</artifactId>
                <version>${maven.war.plugin.version}</version>
                <configuration>
                    <archive>
                        <manifestEntries>
                            <dependencies>com.fasterxml.jackson.core.jackson-databind export,org.slf4j export,org.jboss.remote-naming export</dependencies>
                        </manifestEntries>
                    </archive>
                </configuration>
            </plugin>
            <plugin>
                <artifactId>maven-assembly-plugin</artifactId>
                <version>${maven.assembly.plugin.version}</version>
                <executions>
                    <execution>
                        <id>prepare kms zip for local</id>
                        <configuration>
                            <finalName>local-conf</finalName>
                            <descriptors>
                                <descriptor>src/main/assembly/local-prepare-conf-zip.xml</descriptor>
                            </descriptors>
                            <appendAssemblyId>false</appendAssemblyId>
                        </configuration>
                        <phase>package</phase>
                        <goals>
                            <goal>single</goal>
                        </goals>
                    </execution>
                    <execution>
                        <id>prepare kms zip</id>
                        <configuration>
                            <finalName>${project.artifactId}-conf</finalName>
                            <descriptors>
                                <descriptor>src/main/assembly/prepare-conf-zip.xml</descriptor>
                            </descriptors>
                            <appendAssemblyId>false</appendAssemblyId>
                        </configuration>
                        <phase>package</phase>
                        <goals>
                            <goal>single</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <artifactId>maven-war-plugin</artifactId>
                <version>${maven.war.plugin.version}</version>
                <configuration>
                    <failOnMissingWebXml>false</failOnMissingWebXml>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-surefire-plugin</artifactId>
                <version>${maven-surefire-plugin.version}</version>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <configuration>
                    <source>${java.version}</source>
                    <target>${java.version}</target>
                    <compilerArgument>-parameters</compilerArgument>
                </configuration>
            </plugin>
        </plugins>
    </build>

    <distributionManagement>
        <repository>
            <id>deployment</id>
            <name>maple</name>
            <url>http://nexus.ramen.com/repository/releases</url>
        </repository>
        <snapshotRepository>
            <id>deployment</id>
            <name>maple</name>
            <url>http://nexus.ramen.com/repository/snapshots</url>
        </snapshotRepository>
    </distributionManagement>
</project>
Karol Dowbecki :

Spring Boot 2.1.2.RELEASE requires Spring Framework 5.1.4.RELEASE as per docs:

Spring Boot 2.1.2.RELEASE requires Java 8 and is compatible up to Java 11 (included). Spring Framework 5.1.4.RELEASE or above is also required.

You should upgrade spring-core and other framework dependencies to 5.1.4.RELEASE. Better, to avoid that kind of problems, you should let Spring Boot manage the version of Spring Framework dependencies e.g. through BOM.

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=87462&siteId=1