You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Anu Gali <an...@yahoo.com> on 2011/07/28 02:08:48 UTC

Adding reference to properties file in Tomcat context.xml or server.xml

     
        I am trying to externalize a properties file outside of the app war in the tomcat context itself.This is so that the war can be build and ported to different env without having to change the properties file in each env every time.

Lets say that the properties file is called: app.properties
1) I placed all the properties, in tomcat_home/conf/context.xml and/or
 tomcat_home/conf/Catalina/localhost/context.xml. Eg.,
 
<Context path=/app>
<Parameter  name="maxExemptions" value="10" override="false"/>
</Context>

 When I start tomcat, I get the following error:
Jul 27, 2011 4:38:38 PM org.apache.catalina.startup.HostConfig deployDescriptor
INFO: Deploying configuration descriptor context.xml
Jul 27, 2011 4:38:38 PM org.apache.tomcat.util.digester.Digester fatalError
SEVERE: Parse Fatal Error at line 45 column 43: Element type "Parameter" must be followed by either attribute 
specifications, ">" or "/>".
org.xml.sax.SAXParseException: Element type "Parameter" must be followed by either attribute specifications, "
>" or "/>".
        at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.createSAXParseException(ErrorHandlerWra
pper.java:195)
        at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.fatalError(ErrorHandlerWrapper.java:174
)
        at com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(XMLErrorReporter.java:388)
        at com.sun.org.apache.xerces.internal.impl.XMLScanner.reportFatalError(XMLScanner.java:1414)
        at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.seekCloseOfStartTag(XMLDocum
entFragmentScannerImpl.java:1395)
        at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanStartElement(XMLDocument
FragmentScannerImpl.java:1328)
        at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl$FragmentContentDriver.next(X

2) Also tried using <Environment name="maxExemptions" value="10"
         type="java.lang.Integer" override="false"/>, get the similar exception as before.

Is it possible to just provide the properties file path in server.xml or context.xml, so that tomcat would load it on startup? I have done this in JBoss using the  properties-service.xml file giving it the path to properties file which gets loaded on startup and the app can just reference those variables.

Thanks
An
 

Re: Adding reference to properties file in Tomcat context.xml or server.xml

Posted by Felix Schumacher <fe...@internetallee.de>.

Anu Gali <an...@yahoo.com> schrieb:

>     
>        I am trying to externalize a properties file outside of the app
>war in the tomcat context itself.This is so that the war can be build
>and ported to different env without having to change the properties
>file in each env every time.
>
>Lets say that the properties file is called: app.properties
>1) I placed all the properties, in tomcat_home/conf/context.xml and/or
> tomcat_home/conf/Catalina/localhost/context.xml. Eg.,
> 
><Context path=/app>
1. You are missing quotes around /app.
2. I believe the path attribute is not allowed in the files you were describing.
3. Since you are using tomcat, you could make use of one feature of the Digested, which is able to replace ${name} with Java system variables. Those can be set per tomcat instance.

Regards
 Felix
><Parameter  name="maxExemptions" value="10" override="false"/>
></Context>
>
> When I start tomcat, I get the following error:
>Jul 27, 2011 4:38:38 PM org.apache.catalina.startup.HostConfig
>deployDescriptor
>INFO: Deploying configuration descriptor context.xml
>Jul 27, 2011 4:38:38 PM org.apache.tomcat.util.digester.Digester
>fatalError
>SEVERE: Parse Fatal Error at line 45 column 43: Element type
>"Parameter" must be followed by either attribute 
>specifications, ">" or "/>".
>org.xml.sax.SAXParseException: Element type "Parameter" must be
>followed by either attribute specifications, "
>>" or "/>".
>        at
>com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.createSAXParseException(ErrorHandlerWra
>pper.java:195)
>        at
>com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.fatalError(ErrorHandlerWrapper.java:174
>)
>        at
>com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(XMLErrorReporter.java:388)
>        at
>com.sun.org.apache.xerces.internal.impl.XMLScanner.reportFatalError(XMLScanner.java:1414)
>        at
>com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.seekCloseOfStartTag(XMLDocum
>entFragmentScannerImpl.java:1395)
>        at
>com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanStartElement(XMLDocument
>FragmentScannerImpl.java:1328)
>        at
>com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl$FragmentContentDriver.next(X
>
>2) Also tried using <Environment name="maxExemptions" value="10"
>         type="java.lang.Integer" override="false"/>, get the similar
>exception as before.
>
>Is it possible to just provide the properties file path in server.xml
>or context.xml, so that tomcat would load it on startup? I have done
>this in JBoss using the  properties-service.xml file giving it the path
>to properties file which gets loaded on startup and the app can just
>reference those variables.
>
>Thanks
>An



---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org