XPath for web.config applicationSettings webdeploy parameters.xml file is not correct - webdeploy

I use webdeploy to deploy my web site project with a parameters.xml file I have been using a for a while. So far the parameters I've added are all element attributes and it all works well. But I am trying to get the xpath right to update an applicationSettings element value (not attributes) and am failing, badly, to work out if its my poor xpath skills to blame or a misunderstanding of the way the parameters file works.
When I do a deployment the field is not updated, it compiles fine and no errors\warnings during deployment. I want to be able to set this to True or False.
So I have following parameters field
<parameter name="ShowExceptionCallStackOnErrorView" description="Display a call stack on the UI Error view - true for debug only." defaultValue="False" tags="">
<parameterEntry kind="XmlFile" scope="\\web.config$" match="/configuration/applicationSettings/abc.123.Properties.Settings/setting[#name='ShowExceptionCallStackOnErrorView']/value" />
</parameter>
trying to match to the following application settings section
<configuration>
<applicationSettings>
<abc.123.Properties.Settings>
<setting name="ShowExceptionCallStackOnErrorView" serializeAs="String">
<value>True</value>
Any help would be much appreciated!

It's not giving you an error because it is simply not finding a match to replace. You need to add /text() to the end of your match tag if you want it to replace the contents of the value tag. As follows...
<parameter name="ShowExceptionCallStackOnErrorView" description="Display a call stack on the UI Error view - true for debug only." defaultValue="False" tags="">
<parameterEntry kind="XmlFile" scope="\\web.config$" match="/configuration/applicationSettings/abc.123.Properties.Settings/setting[#name='ShowExceptionCallStackOnErrorView']/value/text()" />
</parameter>

Related

RTI DDS creating own data types

I am working on a .Net example where I define my own data type using RTI Connext DDS.
Instead of creating the application from the beginning, I got help from the source code of the hello_world_xml_dynamic example in rti_workspace directory. I have made several changes to the USER_QOS_PROFILES.xml file to create my own data type and changes its name to MY_PROFILES.xml
But when I compile the application and run it from the command line, I get the following error:
DDS_DomainParticipantFactory_create_participant_from_config_w_paramsI:ERROR: Profile library 'MyParticipantLibrary::PublicationParticipant' not found
! Unable to create DDS domain participant
The line of code that catching the error:
if (this.participant == null)
{
this.participant = DDS.DomainParticipantFactory.get_instance().
create_participant_from_config(
"MyParticipantLibrary::PublicationParticipant");
if (this.participant == null)
{
Console.Error.WriteLine("! Unable to create DDS domain participant");
return;
}
}
this is the configuration file MY_PROFILES.xml :
<!--
RTI Data Distribution Service Deployment
-->
<dds xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="http://community.rti.com/schema/6.0.1/rti_dds_profiles.xsd">
<!-- Qos Library -->
<qos_library name="qosLibrary">
<qos_profile name="DefaultProfile">
</qos_profile>
</qos_library>
<!-- types -->
<types>
<struct name="FlightData">
<member name="Latitude" type="double"/>
<member name="Longitude" type="double"/>
<member name="Altitude" type="double"/>
</struct>
</types>
<!-- Domain Library -->
<domain_library name="MyDomainLibrary" >
<domain name="FlightDataDomain" domain_id="0">
<register_type name="FlightDataType"
type_ref="FlightData" />
<topic name="FlightDataTopic"
register_type_ref="FlightDataType">
<topic_qos name="FlightData_qos"
base_name="qosLibrary::DefaultProfile"/>
</topic>
</domain>
</domain_library>
<!-- Participant library -->
<domain_participant_library name="MyParticipantLibrary">
<domain_participant name="PublicationParticipant"
domain_ref="MyDomainLibrary::FlightDataDomain">
<publisher name="MyPublisher">
<data_writer name="FlightDataWriter"
topic_ref="FlightDataTopic"/>
</publisher>
</domain_participant>
<domain_participant name="SubscriptionParticipant"
domain_ref="MyDomainLibrary::FlightDataDomain">
<subscriber name="MySubscriber">
<data_reader name="FlightDataReader"
topic_ref="FlightDataTopic">
<datareader_qos name="FlightData_reader_qos"
base_name="qosLibrary::DefaultProfile"/>
</data_reader>
</subscriber>
</domain_participant>
</domain_participant_library>
</dds>
where am i making a mistake?
Your XML file looks correct. From the 'not found' error message, it seems that you may not have taken the right steps to instruct your application to load that profiles-file MY_PROFILES.xml to actually learn about your desired Participant. You can easily verify that this is the case by introducing an error in your XML file (for example by incorrectly renaming one tag) and rerun your application. If it does not complain about the syntax or schema of the XML, then your file did not get loaded and this hypothesis is correct.
If that turns out to be your problem indeed, then you have several options to fix that. They are listed in the User's Manual section 18.5 How to Load XML-Specified QoS Settings.

How to set boolean in xml-action script

I am trying to set a flag so I do something like this:
<set field="existingFound" value="false" type="Boolean"/>
but the following line prints "true" in the log:
<log message="storeProperty, existingFound (0): ${existingFound}"/>
What is the best way to set flags?
The set.#value attribute is interpreted as a Groovy String (GString) so any non-empty value will be interpreted as true. The set.#from attribute is interpreted as a Groovy expression, so simply using from="false" instead of value="false" will get the desired result.
To see the generated Groovy code from an XML actions block you can write code that will cause an error and then the script will be logged, or you can change the log4j.xml file to turn on "debug" level logging for the XmlActions class (the latest log4j.xml file in the GitHub repository has an example of this). Looking at the Groovy code generated from the XML elements is a good way to track down issues when what is happening just doesn't make sense.

Xpath for creating config file and sharepoint deployment

I am new to sharepoint 2010 and am trying to update the config file to look like this
<applicationSettings>
<Name.Library.Settings>
<setting name="FromAddress" serializeAs="String">
<value>tasks#munder.com</value>
</setting>
</Name.Library.Settings>
</applicationSettings>
by deploying a feature with the following code
,new ModificationEntry(
"applicationSettings/Name.Library.Settings"
,"configuration/applicationSettings"
,"<Name.Library.Settings/>"
,SPWebConfigModification.SPWebConfigModificationType.EnsureChildNode
,true)
,new ModificationEntry(
"applicationSettings/Name.Library.Settingsname='IsSharepointDeployed']"
,"configuration/applicationSettings/Name.Library.Settings"
,"<setting name='IsSharepointDeployed' serializeAs='String' />"
,SPWebConfigModification.SPWebConfigModificationType.EnsureChildNode
,true)
When I do this I'm getting the following error "Error occurred in deployment step 'Activate Features': Expression must evaluate to a node-set."
I belive this is telling me that my xpath query is wrong. It is configuration/applicationSettings/Name.Library.Settings
Any ideas what may be wrong with it?
I don't know if this solves all of your problem but:
"applicationSettings/Name.Library.Settings[#name='IsSharepointDeployed']"
Might help.

Problem with struts 2 and json plugin

I'm using the json plugin that comes with struts 2 (json-lib-2.1.jar) and trying to follow the website to set it up.
Here's my struts.xml
<struts>
<package name="example" extends="json-default">
<action name="AjaxRetrieveUser" class="actions.view.RetrieveUser">
<result type="json"/>
</action>
</package>
</struts>
but I get this warning:
SEVERE: Unable to find parent packages json-default
Is there something else I'm supposed to do?
Edit:
I added this method to my RetrieveUser:
public Map<String,Object> getJsonModel()
{
return jsonModel;
}
And my struts.xml looks like this:
<struts>
<package name="example" extends="json-default">
<action name="AjaxRetrieveUser" class="actions.view.RetrieveUser">
<result type="json"/>
<param name="root">jsonModel</param>
</action>
</package>
</struts>
However, I don't think the response is going from the RetrieveUser class to the javascript. I'm using firebug and no request gets sent.
I believe that net.sf.json-lib is just a toolset you can use in your Java to build up JSON-ready objects, suitable to be returned by actions such as you describe.
Probably, you need to include struts-json-plugin - make sure its version matches your struts version.
I notice also that as written, your action will attempt to return RetrieveUser, serialized. Most implementations I've done/seen specify the root object to be returned, by adding
<param name="root">jsonUser</param>
Under the tag, and define this method in RetrieveUser
public Map<String, Object> getJsonUser()
[This is mentioned in the Sruts2 doc]. Hope that helps.
[edit] I use Map - you could also use the object structures provided by json-lib instead.
Re: Your edit. Probably need to see your calling javascript. And probably I will suggest that you make sure you have both a success and an error handler. Can you debug/log to show that the method is being called in java ? Do your logs show anything ? This is usually some sort of error....

How do I set the xmlns attribute when using XMLFile in Wix 3

I am adding elements to an XML file during installation using the XmlFile element:
<util:XmlFile Id="SetOracleDialectProperty"
Action="createElement"
ElementPath="//hibernate-configuration/session-factory"
Name="property"
Sequence="9"
File="[INSTALLLOCATION]Config\hibernate.config"
Value="NHibernate.Dialect.Oracle10gDialect"/>
The empty file I am writing to looks like this:
<hibernate-configuration xmlns="urn:nhibernate-configuration-2.2">
<session-factory>
</session-factory>
</hibernate-configuration>
After running the installer I end up with this:
<hibernate-configuration xmlns="urn:nhibernate-configuration-2.2">
<session-factory>
<property xmlns="">NHibernate.Dialect.Oracle10gDialect</property>
</session-factory>
</hibernate-configuration>
The problem is that the empty xmlns attribute is overriding the xmlns specified in the root node of the file so the property element is not recognised correctly by nhibernate.
How can I either set the value to match the root node or remove the xmlns attribute?
I have spent some time searching for an answer and the closest I've found is "do what you would do in MSXML" which doesn't help me as it doesn't say how to do it in WiX (e.g. what attribute on XmlFile to use).
EDIT
To explain Rob's answer slightly, in a place where I can use nice formatting:
You add a document fragment by setting Node="document" on the XmlConfig element.
You have to explicitly set the namespace otherwise you get the default one again.
Also although you're adding a "document" it doesn't seem to work if you specify more than one element. You get a mysterious and thoroughly unhelpful "Setup wizard ended prematurely" runtime error.
So my fixed code looks like this:
<util:XmlConfig Id="MsSqlDialect"
Action="create"
ElementPath="//hibernate-configuration/session-factory"
File="[INSTALLLOCATION]Config\hibernate.config"
Node="document">
<![CDATA[
<property xmlns="urn:nhibernate-configuration-2.2" name="dialect">NHibernate.Dialect.Oracle10gDialect</property>
]]>
</util:XmlConfig>
I know this is years later but if anyone else comes across this I think the true solution is this:
<util:XmlFile Id="SetOracleDialectProperty"
Action="createElement"
ElementPath="//hibernate-configuration/session-factory"
Name="urn:nhibernate-configuration-2.2:property"
Sequence="9"
File="[INSTALLLOCATION]Config\hibernate.config"
Value="NHibernate.Dialect.Oracle10gDialect"/>
change is from Name="property" to Name="urn:nhibernate-configuration-2.2:property" - when config is written it will apprear as just as it will recognize it is the default namespace. I had the same problem adjusting manifest files and this approach sorted it.
The problem here is that MSXML states that createElement will always give you the default namespace (just as you are seeing). I think you'll need to switch to the more complex but more powerful XmlConfig. In this case, try using a document fragment to add the entire element with correct namespace instead of depending on MSXML to create it for you.