Reputation: 407
I have a really weird issue with Tomcat that I can't seem to fix. My issue is that it seems that Tomcat sees the Tomcat folder (C:/Program Files/Apache Software Foundation/Tomcat 6) as the classpath. This issue comes into effect when I set my JAVA_OPTS to reference my properties file.
-Ddoiadmin.properties.file=doiadmin.properties
I have the properties file in my classpath (WEB-INF/classes) however when I start Tomcat, I get the error:
com.XXXXX.commons.servicecore.ServiceConfigurationException: Could not find main properties file (directly or on classpath): [doiadmin.properties]
The only way to get the application to properly start is to put the properties file in the Tomcat folder. This is annoying and not something I want to do in the long run.
I scoured the internet and asked a few people to no avail. Does anyone have any suggestions?
Thanks for any help -Tim
Upvotes: 1
Views: 668
Reputation: 1043
If I understand you correctly I would do this:
In you web.xml have the following:
<env-entry>
<env-entry-name>RootPathPropertyName</env-entry-name>
<env-entry-type>java.lang.String</env-entry-type>
<env-entry-value>uk.co.foo.project.path</env-entry-value>
</env-entry>
<env-entry>
<env-entry-name>RootPathPropertyValue</env-entry-name>
<env-entry-type>java.lang.String</env-entry-type>
<env-entry-value>d:/foo/bar</env-entry-value>
</env-entry>
In you context set up a PlaceHolderConfigurer as follows:
<!-- Properties Configuration -->
<bean id="propertyConfigurer"
class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<property name="order" value="1"/>
<property name="locations">
<list>
<value>file:${uk.co.foo.project.path}/config/foo.properties</value>
</list>
</property>
</bean>
In your tomcat config you can override the default location with the following in the file /conf/Catalina/localhost/foo.xml:
<Context path="foo" >
<Environment name="RootPathPropertyValue" value="c:/foo/bar" type="java.lang.String" override="false"/>
</Context>
Upvotes: 1