-
Jul 8th, 2012, 05:51 PM
#1
error creating tc Server instance using custom template with user supplied properties
Hi,
I am getting an error when trying to create tc Server instance using tcruntime-instance.bat script with --template that need some property value to be passed from properties file.
So, for example, if I want to create an instance using the 'diagnostic' template, execute the following command and got this output;
.................................................. .................................................. .....................
>tcruntime-instance.bat create testDiagnosticServer -t diagnostics
Creating instance 'testDiagnosticServer' ...
Using separate layout
Creating bin\setenv.bat
Creating conf\wrapper.conf
Applying template 'base'
Copying template's contents
Applying fragment 'context-fragment.xml' to 'conf/context.xml'
Applying fragment 'server-fragment.xml' to 'conf/server.xml'
Applying fragment 'web-fragment.xml' to 'conf/web.xml'
Applying fragment 'tomcat-users-fragment.xml' to 'conf/tomcat-users.xml'
Applying fragment 'catalina-fragment.properties' to 'conf/catalina.properties'
Applying template 'base-tomcat-7'
Copying template's contents
Applying fragment 'server-fragment.xml' to 'conf/server.xml'
Applying fragment 'web-fragment.xml' to 'conf/web.xml'
Applying fragment 'catalina-fragment.properties' to 'conf/catalina.properties'
Applying template 'diagnostics'
Copying template's contents
Applying fragment 'server-fragment.xml' to 'conf/server.xml'
Applying template 'bio'
Copying template's contents
Applying fragment 'server-fragment.xml' to 'conf/server.xml'
create failed. A value for the property 'diagnostics.jdbc.driverClassName' is required but was not provided. A value can be provided using --property diagnostics.jdbc.driverClassName=<value>
.................................................. .................................................. ......................................
In the ..\templates\diagnostics\configuration-prompts.properties file, I added the following entry;
jdbc.resource.name=mySqlDataSource
jdbc.username=root
jdbc.password=password
jdbc.driverClassName=com.mysql.jdbc.Driver
jdbc.url=jdbc:mysql://localhost/dbname
But that did not help; I don't want to use the --property option in the parameter, as I want to have those in separate properties file and use it to configure the server.
Could you please let me know, what is the correct way of setting the property value for variables like {jdbc.username} etc, using the properties file with the template option?
Thanks,
Mohan
-
Jul 31st, 2012, 02:58 PM
#2
Hi Mohan,
You would need to specify the template name before the property name.
If you want to specify "jdbc.driverClassName", you would need to pass it in like this:
> tcruntime-instance.bat create testDiagnosticServer -t diagnostics -p diagnostics.jdbc.driverClassName=com.mysql.jdbc.Dr iver
-Jason
-
Jul 31st, 2012, 03:03 PM
#3
Sorry, just noticed you wanted to use the properties file.
You would do it like this:
> tcruntime-instance.bat create testDiagnosticServer -t diagnostics -f <my properties file>
The properties file needs to have the template name before the properties too.
i.e.
----- In File -----------
diagnostics.jdbc.resource.name=mySqlDataSource
diagnostics.jdbc.username=root
diagnostics.jdbc.password=password
diagnostics.jdbc.driverClassName=com.mysql.jdbc.Dr iver
diagnostics.jdbc.url=jdbc:mysql://localhost/dbname
-
Aug 6th, 2012, 09:36 PM
#4
Hi Jason,
Thanks for your reply.
I tried the way you have suggested to use the properties file (using -f option and by having the template name before the properties). It worked this time, by creating the server using the diagnostics template, but the strange thing is in the server.xml file of the server instance, the /conf/server.xml the {jdbc.driverClassName} values are not replaced with its value from the properties file,
here is what /testDiagnosticsServer/conf/server.xml contents looks like (marked in red font are the unchanged values);
..................................................
<GlobalNamingResources>
<Resource auth="Container"
description="User database that can be updated and saved"
factory="org.apache.catalina.users.MemoryUserDatab aseFactory"
name="UserDatabase"
pathname="conf/tomcat-users.xml"
type="org.apache.catalina.UserDatabase"/>
<Resource auth="Container"
driverClassName="${diagnostics.jdbc.driverClassName}"
factory="com.springsource.tcserver.serviceability. request.DataSourceFactory"
initialSize="10"
jdbcInterceptors="ConnectionState;StatementFinaliz er;SlowQueryReportJmx(threshold=10000)"
jmxEnabled="true"
logAbandoned="true"
maxActive="100"
maxWait="10000"
minEvictableIdleTimeMillis="30000"
minIdle="10"
name="${diagnostics.jdbc.resource.name}"
password="${diagnostics.jdbc.password}"
removeAbandoned="true"
removeAbandonedTimeout="60"
testOnBorrow="true"
testOnReturn="false"
testWhileIdle="true"
timeBetweenEvictionRunsMillis="5000"
type="javax.sql.DataSource"
url="${diagnostics.jdbc.url}"
username="${diagnostics.jdbc.username}"
validationInterval="30000"
validationQuery="SELECT 1"/>
</GlobalNamingResources>
.....................................
-
Aug 6th, 2012, 10:35 PM
#5
Values in ${...} are located in the conf/catalina.properties file.
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules