4 Replies Latest reply on Mar 1, 2018 9:34 AM by D. Alvarado

    What's the right way to reference a properties file in a WAR when its packaged in an EAR?

    D. Alvarado Newbie

      I'm using Wildfly 11 and Spring 4.3.8.RELEASE.  I'm having a problem deploying an EAR file with a WAR module within it.  The structure of my EAR module is

       

       

      [code]

      + EAR module

        + META-INF

        + lib

        + sfclieint.war

      [/code]

       

       

      The WAR module deploys fine on its own but fails when deployed in the EAR module.  The reason it fails is because I have this in my WAR's application context, loaded by Spring

       

      [code]

       

        <context:property-placeholder location="classpath:core.properties,/WEB-INF/classes/quickbase.properties"/>

       

      [/code]

       

      The file "/WEB-INF/classes/quickbase.properties" exists within the WAR if I unzip it.  However, it does not seem to be detected when the EAR is deployed.  The specific error upon deployment is

       

      [code]

        Unsatisfied dependency expressed through field 'connection'; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type 'com.sforce.soap.enterprise.EnterpriseConnection' available: expected at least 1 bean which qualifies as autowire candidate. Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true)}

      [/code]

       

      which is normally initialized in the same application context file through teh below beans ...

       

      [code]

        <bean id="sfConfig" class="com.sforce.ws.ConnectorConfig">

        <property name="authEndpoint" value="${salesforce.auth.endpoint}" />

        <property name="username" value="${salesforce.username}" />

        <property name="password" value="${salesforce.password}" />

        </bean>

       

        <bean id="sfConnection" class="com.sforce.soap.enterprise.Connector" factory-method="newConnection">

        <constructor-arg type="com.sforce.ws.ConnectorConfig" ref="sfConfig" />

        </bean>

      [/code]

        • 1. Re: What's the right way to reference a properties file in a WAR when its packaged in an EAR?
          jaikiran pai Master

          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?
            D. Alvarado Newbie

            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 pai Master

              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?
                D. Alvarado Newbie

                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