3

I have a custom deployer extension and a configuration file with some of the parameters required for the extension. The custom extension checks if the component exists in a table in the database, if not, it is inserted, if yes then the LastUpdate date is changed.

This is what the cd_deployer_conf.xml file looks like:

<Processor Action="Deploy" Class="com.tridion.deployer.Processor">
<Module Class="com.SomeClass.tridion.deployer.CacheFlusher" Type="CacheFlusher">
    <ServerName>SomeServer</ServerName>
    <DataBaseName>SomeDB</DataBaseName>
    <UserName>SomeUser</UserName>
    <Password>Password</Password>
</Module>

In the java class, the code to get these parameters & establish the connection to the database is :

String strServerName = config.getAttribute("ServerName");
String strDataBaseName = config.getAttribute("DataBaseName");
String strUserName = config.getAttribute("UserName");
String strPassword = config.getAttribute("Password");

Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
Connection cnnConnection = DriverManager.getConnection(
    String.format("jdbc:sqlserver://%s;databaseName=%s", strServerName, strDataBaseName),
    strUserName,
    strPassword
);

However, whenever I deploy, this is the error that I get in the logs.

ERROR CacheFlusher - com.tridion.configuration.ConfigurationException: No attribute found for: ServerName.

What am I doing wrong ?

Please help.

Thanks in Advance.

2
  • Can you add some more info? I.e. which class/interface is your module extending/implementing? Which method are you implementing? What is object config? Nov 25, 2013 at 19:19
  • Thanks Mihai, Config object is configuration public CacheFlusher(Configuration config, Processor processor) throws ConfigurationException { super(config, processor); } We are trying to extend. public void process(TransportPackage data) throws ProcessingException { Did I answer your questions correctly? Nov 25, 2013 at 19:45

2 Answers 2

2

The Configuration object is context sensitive. This means it represents a certain node in your configuration file. AFAIK, the default node is the Module node itself. So you have to read a child node (e.g. ServerName) and then read some of its attributes.

You will need to use the following methods:

  • Configuration.getChild()
  • Configuration.getAttribute()

I suggest to rewrite the configuration XML to the following:

<Module Class="com.SomeClass.tridion.deployer.CacheFlusher" Type="CacheFlusher">
    <ServerName Value="SomeServer" />
    <DataBaseName Value="SomeDB" />
    <UserName Value="SomeUser" />
    <Password Value="Password" />
</Module>

then some sample code would be:

Configuration serverConfig = config.getChild("ServerName");
String serverName = serverConfig.getAttribute("Value");

For completeness you could also check for the existence of certain nodes/attribtues using methods:

  • Configuration.hasChild()
  • Configuration.hasAttribute()
1
  • 1
    Thanks for the solution Mihai! You are awesome! My log file is now error free after I made all the changes. Nov 25, 2013 at 21:36
2

Instead of:

<ServerName>SomeServer</ServerName>
<DataBaseName>SomeDB</DataBaseName>
<UserName>SomeUser</UserName>
<Password>Password</Password>

Try this to specify your custom parameters:

<Properties>
    <Property Name="ServerName" Value="SomeServer" />
    <Property Name="DataBaseName" Value="SomeDB" />
    <Property Name="UserName" Value="SomeUser" />
    <Property Name="Password" Value="Password" />
</Properties>
1
  • Thanks Nickoli. I still get the same errors after I made these config changes and restarted the deployer website. Nov 25, 2013 at 19:44

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.