Jump to content
We've recently updated our Privacy Statement, available here ×
  • Setting data source attributes generates error "Attribute 'host' is not defined in the User Profile"


    vchiem
    • Features: Data Sources Version: v6.3 Product: JasperReports® Server

    Issue:

    The following attributes were entered when creating a new data source :
     
    Host: {attribute('host','User')}
    Port: {attribute('port','Tenant')}
    Database: {attribute('dbname','Server')}
    URL: jdbc:postgresql://{attribute('host','User')}:{attribute('port','Tenant')}/{attribute('dbname','Server')}
    User Name: {attribute('userName')}
    Password: {attribute('password')}
     
    After clicking on the Test Connection button, the following error was generated:
     
    Substitution error in resource /organizations/organization_1/datasources/AttrDSTest, field 'url'. Attribute 'host' is not defined in the User Profile.
    
     

     

     

    These attribute parameters have already been defined under Manage -> Server Settings -> Server Attributes and they also appear under the User's profile as Inherited attributes. 

    What is the reason for the error and how can this be resolved ?
     

     

     


     

    Solution:

    There are two ways to reference attribute values, Categorical and Hierarchical. Categorical references does not take into account inherited attributes at the specified level.
     
    By setting {attribute('host','User')} or {attribute('port','Tenant')} or {attribute('dbname','Server')} means it is referencing the attribute values at the respective categorical level. Therefore, by defining {attribute('host','User')}, the 'host' attribute value must be explicitly set at the User level. Doing this will override the 'host' attribute inheritance from true to false and resolve the error. Like-wise, the port attribute value must be explicitly set at the Organization level.
     

    By default, the attribute parameters at the User and Tenant level are inherited from the Server attributes and can be referenced by using Hierarchical value reference:
    {attribute('host')}
    {attribute('port')}
     

    The server searches for an attribute with the given name in the following order, stopping and returning the first value that it finds:
    • At the user level
    • At the organization level including parent organizations
    • At the server level.
     
     
    Note that the following will also resolve the error:
    {attribute('host', 'Server')}
    {attribute('port', 'Server')}

    but this is a categorical reference to the server attributes.

     

    Another thing to be mindful of is when a categorical reference is set as attribute('dbname','Tenant')} and the 'dbname' was explicitly set at the organization level, the Test Connection can fail with similar error if tested under a 'superuser' account:

    Substitution error in resource /public/Data_Sources/AttrDSTest, field 'url'. Attribute 'dbname' is not defined in the Tenant Profile.

    In order to test the attribute datasource, log out and log in to the organization level as a user, for example jasperadmin, before carrying out the Test Connection. 

    User Feedback

    Recommended Comments

    I followed the Admin guide and tested with a new user on JRS 6.4.0 and JRS 7.5.0 and I get the same error :

    "Attribute 'host' is not defined in the User Profile."

    Or if the host is defined in the Server profile :

    "Attribute 'host' is not defined in the server Profile."

    Here is the URL : jdbc:postgresql://{attribute('host','Server')}:{attribute('port','Server')}/{attribute('db','Server')}

    If anyone has an idea...

    Link to comment
    Share on other sites

    Remove the 'Server' parameter in your attribute calls. As the above wiki notes, this will tell JRS to seach the whole hierarchy (User, then Tenant, then Server) for your attributes. My guess is you didn't define 'host', 'port', 'db' at the Server level but instead at the Org or User level. Easiest solution is to not pass that second parameter.

    Link to comment
    Share on other sites



    Guest
    This is now closed for further comments

×
×
  • Create New...