Spring Boot failed to load property source from location 'classpath:/application.xml'

╄→尐↘猪︶ㄣ 提交于 2020-02-05 03:53:32

问题


When I deploy a Spring Boot application packaged in an ear in Jboss 7.x EAP I get the following error:

server.default-host./pepe: org.jboss.msc.service.StartException in service jboss.undertow.deployment.default-server.default-host./pepe: java.lang.RuntimeException: java.lang.IllegalStateException: Failed to load property source from location 'classpath:/application.xml'
at org.wildfly.extension.undertow.deployment.UndertowDeploymentService$1.run(UndertowDeploymentService.java:85)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)
at org.jboss.threads.JBossThread.run(JBossThread.java:320)
Caused by: java.lang.RuntimeException: java.lang.IllegalStateException: Failed to load property source from location 'classpath:/application.xml'
at io.undertow.servlet.core.DeploymentManagerImpl.deploy(DeploymentManagerImpl.java:231)
at org.wildfly.extension.undertow.deployment.UndertowDeploymentService.startContext(UndertowDeploymentService.java:100)
at org.wildfly.extension.undertow.deployment.UndertowDeploymentService$1.run(UndertowDeploymentService.java:82)
... 6 more
Caused by: java.lang.IllegalStateException: Failed to load property source from location 'classpath:/application.xml'
at org.springframework.boot.context.config.ConfigFileApplicationListener$Loader.loadIntoGroup(ConfigFileApplicationListener.java:476)
at org.springframework.boot.context.config.ConfigFileApplicationListener$Loader.load(ConfigFileApplicationListener.java:465)
at org.springframework.boot.context.config.ConfigFileApplicationListener$Loader.load(ConfigFileApplicationListener.java:386)
at org.springframework.boot.context.config.ConfigFileApplicationListener.addPropertySources(ConfigFileApplicationListener.java:225)
at org.springframework.boot.context.config.ConfigFileApplicationListener.postProcessEnvironment(ConfigFileApplicationListener.java:195)
at org.springframework.boot.context.config.ConfigFileApplicationListener.onApplicationEnvironmentPreparedEvent(ConfigFileApplicationListener.java:182)
at org.springframework.boot.context.config.ConfigFileApplicationListener.onApplicationEvent(ConfigFileApplicationListener.java:168)
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:122)
at org.springframework.boot.context.event.EventPublishingRunListener.environmentPrepared(EventPublishingRunListener.java:74)
at org.springframework.boot.SpringApplicationRunListeners.environmentPrepared(SpringApplicationRunListeners.java:54)
at org.springframework.boot.SpringApplication.prepareEnvironment(SpringApplication.java:325)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:296)
at org.springframework.boot.web.support.SpringBootServletInitializer.run(SpringBootServletInitializer.java:154)
at org.springframework.boot.web.support.SpringBootServletInitializer.createRootApplicationContext(SpringBootServletInitializer.java:134)
at org.springframework.boot.web.support.SpringBootServletInitializer.onStartup(SpringBootServletInitializer.java:87)
at org.springframework.web.SpringServletContainerInitializer.onStartup(SpringServletContainerInitializer.java:169)
at io.undertow.servlet.core.DeploymentManagerImpl.deploy(DeploymentManagerImpl.java:184)

The structure of the ear is as follows:

├── META-INF
│   ├── application.xml
│   └── jboss-deployment-structure.xml
├── evaluateboot_be-web-0.0.1-SNAPSHOT.war
└── lib
    ├── asm-5.0.4.jar
    ├── aspectjweaver-1.8.13.jar
    ├── bcpkix-jdk15on-1.55.jar
    ├── bcprov-jdk15on-1.55.jar
    ├── bval-core-1.1.2.jar
    ├── cache-api-1.0.0.jar
    ├── ccf2-8.0.0.4_MAPFRE.jar  
    ├── cxf-core-3.1.12.jar
    ├── cxf-rt-bindings-soap-3.1.12.jar
    ├── cxf-rt-databinding-jaxb-3.1.12.jar
    ├── cxf-rt-frontend-jaxws-3.1.12.jar
    ├── cxf-rt-frontend-simple-3.1.12.jar
    ├── cxf-rt-security-3.1.12.jar
    ├── cxf-rt-security-saml-3.1.12.jar
    ├── cxf-rt-transports-http-3.1.12.jar
    ├── cxf-rt-ws-security-3.1.12.jar
    ├── cxf-rt-wsdl-3.1.12.jar
    ├── cxf-spring-boot-autoconfigure-3.1.12.jar
    ├── cxf-spring-boot-starter-jaxws-3.1.12.jar
    ├── dom4j-1.6.1.jar
    ├── ehcache-2.10.4.jar
    ├── evaluateboot-bo-0.0.1-SNAPSHOT.jar
    ├── evaluateboot_be-commons-0.0.1-SNAPSHOT.jar
    ├── evaluateboot_be-crud-dl-api-0.0.1-SNAPSHOT.jar
    ├── evaluateboot_be-crud-sr-api-0.0.1-SNAPSHOT.jar
    ├── evaluateboot_be-crud-sr-impl-0.0.1-SNAPSHOT.jar
    ├── evaluateboot_be.zeroConfig-0.0.1-SNAPSHOT.jar
    ├── guava-19.0.jar
    ├── hibernate-validator-5.3.6.Final.jar
    ├── httpclient-4.5.3.jar
    ├── httpcore-4.4.8.jar
    ├── jackson-annotations-2.8.0.jar
    ├── jackson-core-2.8.10.jar
    ├── jackson-databind-2.8.10.jar
    ├── jasypt-1.9.2.jar
    ├── jaxen-1.1.1_CXF_MAPFRE.jar
    ├── jboss-logging-3.3.1.Final.jar
    ├── jcl-over-slf4j-1.7.25.jar
    ├── jdom-1.1.jar
    ├── joda-time-2.9.9.jar
    ├── jul-to-slf4j-1.7.25.jar
    ├── log4j-over-slf4j-1.7.25.jar
    ├── logback-classic-1.1.11.jar
    ├── spring-aspects-4.3.13.RELEASE.jar
    ├── spring-beans-4.3.13.RELEASE.jar
    ├── spring-boot-1.5.9.RELEASE.jar
    ├── spring-boot-actuator-1.5.9.RELEASE.jar
    ├── spring-boot-autoconfigure-1.5.9.RELEASE.jar
    ├── spring-boot-starter-1.5.9.RELEASE.jar
    ...

The version of spring boot that I am using is 1.5.9.

Why is Spring Boot trying to load the ear deployment descriptor, which is in the META-INF folder?

This same ear deploys correctly in Websphere 8.5.5.x


回答1:


After carefully reviewing the generated artifacts, I have found that the problem that causes this error is because one of the artifacts has the following plugin:

<plugin>
  <groupId> org.apache.maven.plugins </ groupId>
     <artifactId> maven-jar-plugin </ artifactId>
       <configuration>
          <archive>
             <manifest>
               <addClasspath> true </ addClasspath>
             </ manifest>
            <manifestEntries>
               <Class-Path> ./ META-INF / </ Class-Path>
            </ manifestEntries>
       </ archive>
    </ configuration>
 </ plugin>

This is causing it to generate the META-INF file:

Manifest-Version: 1.0
Archiver-Version: Plexus Archiver
Built-By: jose
Class-Path: ./ META-INF/ bval-core-1.1.2.jar gaia-core-2.4.0-SNAPSHOT.
jar gaia-commons-devutils-2.4.0-SNAPSHOT.jar gaiafrontend-proxy-2.4.0
-SNAPSHOT.jar gaia-commons-2.4.0-SNAPSHOT.jar MAPFRE_ARQOS_CORE_VIDA.
 ArquitecturaCoreVidaFramework-14.1.12.jar MAPFRE_ARQOS_COMMONS_STANDA
LONE.CommonsExceptions-14.1.12.jar MAPFRE_ARQOS_COMMONS_STANDALONE.En
cryptionServiceProvider-14.1.12.jar MAPFRE_ARQOS_COMMONS_STANDALONE.U
tils-14.1.12.jar MAPFRE_ARQOS_COMMONS_STANDALONE.Log4M-14.1.12.jar MA
PFRE_ARQOS_COMMONS_STANDALONE.CacheServiceProvider-14.1.12.jar MAPFRE
_ARQOS_COMMONS_STANDALONE.Tron21ConnectorErrorExchange-14.1.12.jar do
m4j-1.6.1.jar jaxen-1.1.1_CXF_MAPFRE.jar xercesImpl-2.8.0.jar jdom-1.
1.jar ctgclient-8.0.0.4_MAPFRE.jar ctgserver-8.0.0.4_MAPFRE.jar ccf2-
8.0.0.4_MAPFRE.jar cicseci-8.0.0.4_MAPFRE.jar cicsecitools-8.0.0.4_MA
PFRE.jar cicsframe-8.0.0.4_MAPFRE.jar security-8.0.0.4_MAPFRE.jar spr
ing-aspects-4.3.13.RELEASE.jar spring-core-4.3.13.RELEASE.jar commons
-logging-1.2.jar spring-context-4.3.13.RELEASE.jar spring-context-sup
port-4.3.13.RELEASE.jar spring-beans-4.3.13.RELEASE.jar spring-expres
sion-4.3.13.RELEASE.jar spring-aop-4.3.13.RELEASE.jar spring-oxm-4.3.
13.RELEASE.jar spring-tx-4.3.13.RELEASE.jar spring-web-4.3.13.RELEASE
.jar spring-webmvc-4.3.13.RELEASE.jar spring-security-core-4.2.3.RELE
ASE.jar aopalliance-1.0.jar spring-security-ldap-4.2.3.RELEASE.jar sp
ring-ldap-core-2.3.2.RELEASE.jar spring-security-config-4.2.3.RELEASE
.jar spring-security-web-4.2.3.RELEASE.jar spring-boot-1.5.9.RELEASE.
jar spring-boot-autoconfigure-1.5.9.RELEASE.jar jackson-core-2.8.10.j
ar jackson-databind-2.8.10.jar jackson-annotations-2.8.0.jar cxf-core
-3.1.12.jar woodstox-core-asl-4.4.1.jar stax2-api-3.1.4.jar xmlschema
-core-2.2.2.jar cxf-rt-bindings-soap-3.1.12.jar cxf-rt-databinding-ja
xb-3.1.12.jar cxf-rt-frontend-simple-3.1.12.jar cxf-rt-frontend-jaxws
-3.1.12.jar asm-5.0.4.jar cxf-rt-transports-http-3.1.12.jar cxf-rt-ws
-security-3.1.12.jar cxf-rt-security-saml-3.1.12.jar cxf-rt-security-
3.1.12.jar wss4j-policy-2.1.10.jar neethi-3.0.3.jar wss4j-ws-security
-stax-2.1.10.jar wss4j-bindings-2.1.10.jar wss4j-ws-security-policy-s
tax-2.1.10.jar cxf-rt-wsdl-3.1.12.jar wsdl4j-1.6.3.jar logback-core-1
.1.11.jar logback-classic-1.1.11.jar slf4j-api-1.7.25.jar commons-io-
2.4.jar commons-codec-1.10.jar commons-pool-1.6.jar commons-lang-2.6.
jar commons-lang3-3.3.2.jar commons-collections-3.2.2.jar commons-bea
nutils-1.9.3.jar validation-api-1.1.0.Final.jar cache-api-1.0.0.jar j
oda-time-2.9.9.jar swagger-annotations-1.5.10.jar lombok-1.16.18.jar 
guava-19.0.jar aspectjweaver-1.8.13.jar coherence-12.1.2.0.jar ehcach
e-2.10.4.jar wss4j-1.6.7.jar wss4j-ws-security-common-2.0.9.jar xmlse
c-2.0.7.jar jasypt-1.9.2.jar wss4j-ws-security-dom-2.0.9.jar gaiaback
end-core-2.4.0-SNAPSHOT.jar gaia-context-2.4.0-SNAPSHOT.jar spring-jd
bc-4.3.13.RELEASE.jar springfox-swagger2-2.6.1.jar swagger-models-1.5
.10.jar springfox-spi-2.6.1.jar springfox-core-2.6.1.jar springfox-sc
hema-2.6.1.jar springfox-swagger-common-2.6.1.jar springfox-spring-we
b-2.6.1.jar classmate-1.3.4.jar spring-plugin-core-1.2.0.RELEASE.jar 
spring-plugin-metadata-1.2.0.RELEASE.jar mapstruct-1.0.0.Final.jar sp
ringfox-swagger-ui-2.6.1.jar gaiabackend-remote-2.4.0-SNAPSHOT.jar ga
ia-plinvoker-2.4.0-SNAPSHOT.jar plinvoker-1.0.0-20180208.232239-4.jar
cxf-spring-boot-starter-jaxws-3.1.12.jar spring-boot-starter-1.5.9.R
ELEASE.jar spring-boot-starter-logging-1.5.9.RELEASE.jar jul-to-slf4j
-1.7.25.jar log4j-over-slf4j-1.7.25.jar snakeyaml-1.17.jar spring-boo
t-starter-web-1.5.9.RELEASE.jar spring-boot-starter-tomcat-1.5.9.RELE
ASE.jar tomcat-embed-core-8.5.23.jar tomcat-annotations-api-8.5.23.ja
r tomcat-embed-el-8.5.23.jar tomcat-embed-websocket-8.5.23.jar hibern
ate-validator-5.3.6.Final.jar jboss-logging-3.3.1.Final.jar cxf-sprin
g-boot-autoconfigure-3.1.12.jar jcl-over-slf4j-1.7.25.jar
Created-By: Apache Maven 3.5.0
Build-Jdk: 1.8.0_20

Removing the entry from the plugin:

<manifestEntries>
    <Class-Path> ./ META-INF / </ Class-Path>
</ manifestEntries>

The application.xml file of the ear device is no longer scanned




回答2:


Actually the application.xml and jboss-deployment-structure.xml file should be present inside the WEB-INF. Could you please check the project structure. If it is a new project, you can use this URL (https://start.spring.io/) to create the project structure. Can you refer the below URL:

https://docs.jboss.org/jbossas/docs/Server_Configuration_Guide/4/html/ch01s04s02.html

verify the complete structure including the war packaging.



来源:https://stackoverflow.com/questions/48955035/spring-boot-failed-to-load-property-source-from-location-classpath-application

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!