Search code examples
javaspring-mvctomcatspring-environment

Skipped XML bean definition file due to specified profiles [default] not matching


We have a Spring application deployed on tomcat, and it does not start.

The application error is as follows:

Caused by: org.springframework.beans.PropertyBatchUpdateException; nested 
PropertyAccessExceptions (1) are:
PropertyAccessException 1: org.springframework.beans.MethodInvocationException: Property 'driverClassName' threw exception; nested exception is java.lang.IllegalStateException: Could not load JDBC driver class [${hibernate.connection.driver_class}]
at org.springframework.beans.AbstractPropertyAccessor.setPropertyValues(AbstractPropertyAccessor.java:121)
at org.springframework.beans.AbstractPropertyAccessor.setPropertyValues(AbstractPropertyAccessor.java:75)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1564)
... 49 more

We do have a properties file defined at: /opt/tomcat/appname/tomcat8-2 with three files: config.properties, core-ws.proprties, and log4j-config.xml

We know ${TOMCAT_CONFIG_HOME} is defined to be: /opt/tomcat/appname/tomcat8-2

We know that the file permissions are correct, the user running tomcat has read permissions to the directories and files in this config directory. I can as that tomcat user edit/read the properties file. So, we know it's not a permissions issue.

From the app log, we have this error message:

Skipped XML bean definition file due to specified profiles [default] not matching: class path resource [spring/app-platform-entity-context.xml]

The Spring application context file has this for properties:

<beans profile="default">
     <context:property-placeholder location="file:${TOMCAT_CONFIG_HOME}/core-ws.properties" />
 </beans>

Finally here is what the core-ws.properties looks like:

hibernate.connection.url=jdbc:oracle:thin:@//123.456.789/APP_DB
hibernate.connection.driver_class=oracle.jdbc.driver.OracleDriver
hibernate.connection.username=some_db_user
hibernate.connection.password=some_db_password

So, I have looked into this for a coupe of days, and I am at my wits end. I can tell you we have no problem with the log4j-config.xml file. The app can find it, and read it just fine. it is just this one parameter that seems to be crashing the app ...

Any help with this matter would be much appreciated. Thanks!


Solution

  • The reason that XML file was skipped was because we had a -Dspring.profiles.active=prod in our CATALINA_OPTS setup.

    We didn't find it until we started exporting what the values were as tomcat started.

    Once we removed this line, our [default] profile tookover as it should.

    Thanks!