7

I'm trying to run a very simple Query at the broker database. This example should get all pages from the broker.

ItemTypeCriteria criteria = new ItemTypeCriteria(64); // Page
Query query = new Query(criteria);
IItem[] results = query.ExecuteEntityQuery();
return results.Length;

When debugging this code, I see that the call to ExecuteEntityQuery throws a NullReferenceException!

If I just use ExecuteQuery:

ItemTypeCriteria criteria = new ItemTypeCriteria(64); // Page
Query query = new Query(criteria);
string[] results = query.ExecuteQuery();
return results.Length;

the result of ExecuteQuery itself is null.

In the same project on the same server I am successfully using a ComponentPresentationFactory so I would think my server is configured correctly.

Is there something wrong with my simple example? I would expect it to return the number of pages. I am wondering though why you don't seem to have to supply a publication id anywhere.

Based on Nickoli Roussakov's 1st remark, I've checked the logfile and it does show errors:

2014-08-11 12:42:24,641 ERROR Query - Unable to Configure for BrokerQuerying, query DAO could not be retrieved
com.tridion.broker.StorageException: No Data Access Object for Query
    at com.tridion.storage.filesystem.FSDAOFactory.getDAOForTypeMapping(FSDAOFactory.java:181) ~[cd_datalayer.jar:na]
    at com.tridion.storage.StorageManagerFactory.getOriginalDAO(StorageManagerFactory.java:500) ~[cd_datalayer.jar:na]
    at com.tridion.storage.StorageManagerFactory.getDAO(StorageManagerFactory.java:269) ~[cd_datalayer.jar:na]
    at com.tridion.storage.StorageManagerFactory.getDefaultDAO(StorageManagerFactory.java:176) ~[cd_datalayer.jar:na]
    at com.tridion.broker.querying.Query.<init>(Query.java:45) [cd_broker.jar:na]
    at com.tridion.broker.querying.Query.<init>(Query.java:59) [cd_broker.jar:na]
2014-08-11 12:42:24,657 ERROR Query - Unable to execute Broker Query, no QueryGenerator was initialized

So I guess the basic error is

com.tridion.broker.StorageException: No Data Access Object for Query

But what does it mean?

My complete class, including code that successfully renders a dynamic component presentation:

using Tridion.ContentDelivery.DynamicContent;
using Tridion.ContentDelivery.DynamicContent.Query;

namespace DFZ.Tridion.Mvc
{
    public static class TridionDynamicContent
    {
        public static int GetNumberOfComponents()
        {
            ItemTypeCriteria criteria1 = new ItemTypeCriteria(64); // Page
            Query query = new Query(criteria1);
            string[] results = query.ExecuteQuery();
            return results.Length;
        }

        public static ComponentPresentation GetComponentPresentation()
        {
            var cpf = new ComponentPresentationFactory(22);
            return cpf.GetComponentPresentation(16604, 16632);
        }
    }
}
  • If it is not just a typo: In the first code block, you are creating an object as query but trying to call ExecuteEntityQuery with query1 object. Check if query1 variable decalred somewhere else without being initialized? – Pankaj Gaur Aug 11 '14 at 15:12
  • 2
    Check the logs (cd_core.log). It should tell us more. – Nickoli Roussakov Aug 11 '14 at 15:41
  • @NickoliRoussakov: There are errors in the log. Updated post. – comecme Aug 12 '14 at 10:09
  • Could you supply publication id and try, if does not work, then apply one or more constraint to limit the results. it will ensure your settings, also share your storage config. – Raj Kumar Aug 12 '14 at 11:05
  • 1
    After consulting with our IT guy, it turns out the storage has been set to file based. It is not using a broker database. Appaerently this is not a problem for creating dynamic component presentations, but it does seem to prohibit query execution. – comecme Aug 12 '14 at 12:22
2

If you are quering from a local machine then it could be an issue with your license file.

Common issues are:

  1. The license file can't be found
  2. The license file doesn't contain a broker license
  3. The license file is not valid for your machine

In all cases the broker will fall back to using its built-in ItemType mappings. In other words: it will only support storing them to file system.

Best thing is to point the 'cd_storage_config.xml' to the correct location of your license file. For instance:

<License Location="/path/to/cd_licenses.xml"/>    

In case of issue 2 and/or 3 you have to contact SDL Tridion Customer Support to request a new license file.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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