Jump to content
Changes to the Jaspersoft community edition download ×

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


Recommended Posts

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. 

Link to comment
Share on other sites

  • Replies 2
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...