-
1. Re: What's the right way to reference a properties file in a WAR when its packaged in an EAR?
jaikiran Feb 28, 2018 6:24 AM (in response to laredotornado)I haven't used Spring, so I don't know much of it. However:
classpath:core.properties,/WEB-INF/classes/quickbase.properties
Since it uses "classpath:", I think all you need to do is change /WEB-INF/classes/quickbase.properties to just quickbase.properties. Something like:
classpath:core.properties,quickbase.properties
The quickbase.properties if it's in the WEB-INF/classes will be available in the classpath of the war component.
-
2. Re: What's the right way to reference a properties file in a WAR when its packaged in an EAR?
laredotornado Feb 28, 2018 10:34 AM (in response to jaikiran)Hi Jaikiran, If I specify
<context:property-placeholder location="classpath:core.properties,classpath:quickbase.properties"/>
The WAR file deploys by itself (i.e. when its not within an EAR). However when that same WAR is packaged within an EAR then the file does not get recognized and the WAR artifact does not get deployed. I'm tryign to figure out how to write the above or perhaps structure something in the EAR's jboss-deployment-structure.xml file so that I can correctly deploy the WAR when it's packaged within an EAR.
Thanks, - Dave
-
3. Re: What's the right way to reference a properties file in a WAR when its packaged in an EAR?
jaikiran Mar 1, 2018 1:16 AM (in response to laredotornado)Where exactly is this spring configuration XML file located? In some jar in .ear/lib directory? If so, you'll have to move it to WEB-INF/classes folder within the .war (which itself is within the .ear). If that's not the case, can you paste the output of the following:
jar -tf yourear.ear
and then
jar -tf yourwar-within-that-ear.war
-
4. Re: What's the right way to reference a properties file in a WAR when its packaged in an EAR?
laredotornado Mar 1, 2018 9:34 AM (in response to jaikiran)Hi,
The Spring confirmation file is located in my WAR file at
WEB-INF/classes/META-INF/spring/applicationContext-sfclient-mvc.xml
The output of the other commands is below. First is the EAR
localhost:ear-project davea$ jar -tf target/myearpackage.ear
META-INF/MANIFEST.MF
META-INF/
lib/
META-INF/maven/
META-INF/maven/org.mainco.subco/
META-INF/maven/org.mainco.subco/myearpackage/
mywarfile.war
META-INF/application.xml
lib/spring-web-4.3.8.RELEASE.jar
lib/jackson-databind-2.8.8.jar
lib/spring-security-config-4.2.3.RELEASE.jar
lib/csrfguard-3.0.0.jar
lib/java-xmlbuilder-0.4.jar
lib/jsoup-1.7.2.jar
lib/jackson-annotations-2.1.1.jar
lib/csrfguard-3.0.0-sources.jar
lib/esapi-2.1.0.1.jar
lib/spring-security-jwt-1.0.4.RELEASE.jar
lib/jasypt-springsecurity3-1.9.0.jar
lib/itextpdf-5.1.0.jar
lib/spring-jdbc-4.3.8.RELEASE.jar
lib/ehcache-2.10.3.jar
lib/spring-expression-4.3.8.RELEASE.jar
lib/spring-context-4.3.8.RELEASE.jar
lib/force-wsc-uber-39.0.0.jar
lib/c3p0-0.9.1.1.jar
lib/aspectjweaver-1.8.6.jar
lib/batik-ext-1.7.jar
lib/ezmorph-1.0.6.jar
lib/spymemcached-2.12.3.jar
lib/spring-orm-4.3.8.RELEASE.jar
META-INF/maven/org.mainco.subco/myearpackage/pom.xml
META-INF/maven/org.mainco.subco/myearpackage/pom.properties
lib/hibernate-validator-4.3.0.Final.jar
lib/UserAgentUtils-1.15.jar
lib/json-lib-2.4-jdk15.jar
lib/spring-test-4.3.8.RELEASE.jar
lib/quartz-2.2.1.jar
lib/spring-aop-4.3.8.RELEASE.jar
lib/spring-security-web-4.2.3.RELEASE.jar
lib/spring-beans-4.3.8.RELEASE.jar
lib/spring-core-4.3.8.RELEASE.jar
lib/nekohtml-1.9.16.jar
lib/dwr-3.0.2-RELEASE.jar
lib/xml-apis-ext-1.3.04.jar
lib/hibernate-core-5.2.12.Final.jar
lib/jackson-core-2.1.1.jar
lib/jasypt-hibernate4-1.9.0.jar
lib/commons-httpclient-3.1.jar
lib/cglib-nodep-2.2.2.jar
lib/batik-css-1.7.jar
lib/batik-util-1.7.jar
lib/xml-apis-1.3.04.jar
lib/jasypt-1.9.0.jar
lib/slf4j-api-1.6.6.jar
lib/antisamy-1.5.3.jar
lib/aopalliance-1.0.jar
lib/knicker-2.3.3.jar
lib/hibernate-ehcache-5.2.12.Final.jar
lib/spring-security-taglibs-4.2.3.RELEASE.jar
lib/bcprov-jdk15on-1.47.jar
lib/spring-tx-4.3.8.RELEASE.jar
lib/poi-3.9.jar
lib/spring-security-core-4.2.3.RELEASE.jar
lib/byte-buddy-1.6.14.jar
META-INF/jboss-deployment-structure.xml
lib/itext-2.1.7.jar
lib/aws-java-sdk-1.8.5.jar
lib/hibernate-entitymanager-5.2.12.Final.jar
lib/bcpkix-jdk15on-1.47.jar
lib/opencsv-2.3.jar
lib/spring-aspects-4.3.8.RELEASE.jar
lib/core-105.0.0-SNAPSHOT.jar
lib/spring-security-acl-4.2.3.RELEASE.jar
lib/spring-webmvc-4.3.8.RELEASE.jar
lib/all-1.0.jar
lib/commons-fileupload-1.2.2.jar
lib/jets3t-0.9.0.jar
lib/spring-context-support-4.3.8.RELEASE.jar
lib/bcprov-jdk16-1.46.jar
lib/mysql-connector-java-5.1.22.jar
And then the WAR ...
localhost:non-ebook-wars davea$ jar -tf target/myearpackage/mywarfile.war
META-INF/MANIFEST.MF
META-INF/
META-INF/maven/
META-INF/maven/org.mainco.subco/
META-INF/maven/org.mainco.subco/mywarfile/
WEB-INF/
WEB-INF/classes/
WEB-INF/classes/org/
WEB-INF/classes/org/mainco/
WEB-INF/classes/org/mainco/subco/
WEB-INF/classes/org/mainco/subco/thirdparty/
WEB-INF/classes/org/mainco/subco/thirdparty/exceptions/
WEB-INF/classes/org/mainco/subco/thirdparty/controller/
WEB-INF/classes/org/mainco/subco/thirdparty/quartz/
WEB-INF/classes/META-INF/
WEB-INF/classes/META-INF/spring/
WEB-INF/lib/
WEB-INF/views/
META-INF/maven/org.mainco.subco/mywarfile/pom.xml
WEB-INF/classes/META-INF/spring/infrastructure.xml
WEB-INF/classes/messages.properties
WEB-INF/lib/java-xmlbuilder-1.1.jar
WEB-INF/lib/jets3t-0.9.4.jar
META-INF/maven/org.mainco.subco/mywarfile/pom.properties
WEB-INF/lib/httpclient-4.5.jar
WEB-INF/jboss-deployment-structure.xml
WEB-INF/classes/META-INF/spring/applicationContext-mywarfile-security.xml
WEB-INF/faces-config.xml
WEB-INF/lib/jackson-mapper-asl-1.9.13.jar
WEB-INF/classes/org/mainco/subco/thirdparty/exceptions/DataAccessLayerException.class
WEB-INF/classes/META-INF/spring/applicationContext-mywarfile.xml
WEB-INF/lib/slf4j-api-1.6.1.jar
WEB-INF/lib/jackson-core-asl-1.9.13.jar
WEB-INF/classes/org/mainco/subco/thirdparty/controller/IndexController$FlushThread.class
WEB-INF/classes/META-INF/spring/applicationContext-mywarfile-mvc.xml
WEB-INF/web.xml
WEB-INF/views/index.jsp
WEB-INF/classes/org/mainco/subco/thirdparty/controller/IndexController.class
WEB-INF/classes/META-INF/spring/context-component-scan.xml
WEB-INF/lib/base64-2.3.8.jar
WEB-INF/lib/enterprise-1.6.jar
WEB-INF/classes/org/mainco/subco/thirdparty/quartz/AbstractWorker.class
WEB-INF/classes/org/mainco/subco/thirdparty/quartz/ProcessPDWorker.class
WEB-INF/dispatcher-servlet.xml
WEB-INF/lib/bcprov-jdk15on-1.52.jar
WEB-INF/classes/org/mainco/subco/thirdparty/quartz/ProcessPDJob.class
WEB-INF/classes/application.properties
WEB-INF/classes/quickbase.properties
WEB-INF/lib/jackson-core-2.8.8.jar
-
5. Re: What's the right way to reference a properties file in a WAR when its packaged in an EAR?
mullaikani Nov 24, 2018 11:14 PM (in response to laredotornado)Hi
I have the same problem.i have applicationcontext.xml in ear meta-inf but its not refered in war
Please tell me if you have solution
Thanks
Mullai
-
6. Re: What's the right way to reference a properties file in a WAR when its packaged in an EAR?
mullaikani Mar 18, 2019 10:33 PM (in response to jaikiran)Hi, thanks a lot for your reply.
I have my applicatio context in METAINF of EAR. It is a common context to create spring bean for 3 wars present in ear.
Placing applicatio context in ear the bean is not created and I get nullpointer when I test the services exposed in war.
Please help me.
Regards
Mullai
-
7. Re: What's the right way to reference a properties file in a WAR when its packaged in an EAR?
zhurlik Mar 19, 2019 4:19 AM (in response to mullaikani)Hi,
A couple years ago I wrote one article about sharing Spring Context between wars within ear file
How to create Single Spring Application Context via JBoss Modules
Thnaks,
Vlad