How to use a server attribute (ServerAttribute_env_url) in json data adapter's url element

0

1. I created a server attribute with name 'env_url' and value ="http://......."

2. I want to use this in the JSON data adapter.

Is it possible to pass a server attribute like below to a JSON data adapter ?

<?xml version="1.0" encoding="UTF-8" ?>
<jsonDataAdapter class="net.sf.jasperreports.data.json.JsonDataAdapterImpl"><name>smc-per-calendar-json-adapter_2</name>
<dataFile xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="httpDataLocation">

<url>$P{ServerAttribute_env_url}+"/users"</url>
<method>GET</method>
<header>
    <name>contentType</name><value>application/json;charset=utf-8</value>    
</header>
<header>
    <name>accept</name><value>application/json;charset=utf-8</value>
</header>
<urlParameter>

......

I get :

net.sf.jasperreports.engine.JRRuntimeException: net.sf.jasperreports.engine.JRException: Error opening input stream from URL: repo:/reports/dataadapter/myJsonDataAdapter.xml.
    at net.sf.jasperreports.repo.DefaultRepositoryService.getInputStream(DefaultRepositoryService.java:116)
    at net.sf.jasperreports.repo.InputStreamPersistenceService.load(InputStreamPersistenceService.java:45)
    at net.sf.jasperreports.repo.DefaultRepositoryService.getResource(DefaultRepositoryService.java:149)

.

.

.

.

 

The data source url changes per environment (dev, qa, prod), so I would like it dynamically set. I am trying achieve it with server attributes (I may have a jasper server instance running per environment). Any other suggestions are appreciated. 

kothany's picture
Joined: Nov 16 2018 - 1:46pm
Last seen: 3 weeks 5 days ago
narcism - 5 months 6 days ago

Thank you narcism. Its working, the link you provided has solved my problem. 

kothany - 5 months 6 days ago

0 Answers:

No answers yet
Feedback
randomness