title: Jasper: error opening input stream from url
body: <p>I'm designing a jasper report using iReport which takes a parameter and fetches an image from a given URL:</p>
  
  <p>The parameter is a user's screen name in twitter, and the url is it's profile image.</p>
  
  <pre><code>    &lt;image&gt;
         &lt;reportElement x="4" y="51" width="73" height="64"/&gt;
             &lt;imageExpression&gt;&lt;![CDATA["https://api.twitter.com/1/users/profile_image?screen_name="+$F{user_screen_name}+"&amp;size=bigger"]]&gt;&lt;/imageExpression&gt;
      &lt;/image&gt;
  </code></pre>
  
  <p>It works great when the image exists. If it doesn't the following exception is thrown:</p>
  
  <pre><code>    Error filling print... net.sf.jasperreports.engine.JRException: Error opening input stream from URL :
      https://api.twitter.com/1/users/profile_image?screen_name=CPTCurtisHervey&amp;size=bigger 
      Setting up the file resolver... net.sf.jasperreports.engine.JRRuntimeException:
      net.sf.jasperreports.engine.JRException: Error opening input stream from URL :
      https://api.twitter.com/1/users/profile_image?screen_name=CPTCurtisHervey&amp;size=bigger 
      at net.sf.jasperreports.repo.DefaultRepositoryService.getInputStream(DefaultRepositoryService.java:138)
      at net.sf.jasperreports.repo.RepositoryUtil.findInputStream(RepositoryUtil.java:186)     
      at net.sf.jasperreports.repo.RepositoryUtil.getBytes(RepositoryUtil.java:202)
      at net.sf.jasperreports.engine.JRImageRenderer.getInstance(JRImageRenderer.java:141)     
      at net.sf.jasperreports.engine.fill.JRFillImage.evaluateImage(JRFillImage.java:498)
      at net.sf.jasperreports.engine.fill.JRFillImage.evaluate(JRFillImage.java:441)
      at net.sf.jasperreports.engine.fill.JRFillElementContainer.evaluate(JRFillElementContainer.java:257)
      at net.sf.jasperreports.engine.fill.JRFillBand.evaluate(JRFillBand.java:468)
      at net.sf.jasperreports.engine.fill.JRVerticalFiller.fillColumnBand(JRVerticalFiller.java:2037)     
      at net.sf.jasperreports.engine.fill.JRVerticalFiller.fillDetail(JRVerticalFiller.java:761)     
      at net.sf.jasperreports.engine.fill.JRVerticalFiller.fillReportContent(JRVerticalFiller.java:291)
      at net.sf.jasperreports.engine.fill.JRVerticalFiller.fillReport(JRVerticalFiller.java:133)     
      at net.sf.jasperreports.engine.fill.JRBaseFiller.fill(JRBaseFiller.java:903)
      at net.sf.jasperreports.engine.fill.JRBaseFiller.fill(JRBaseFiller.java:813)
      at net.sf.jasperreports.engine.fill.JRFiller.fillReport(JRFiller.java:58)
      at net.sf.jasperreports.engine.JasperFillManager.fillReport(JasperFillManager.java:417)
      at net.sf.jasperreports.engine.JasperFillManager.fillReport(JasperFillManager.java:247)
      at com.jaspersoft.ireport.designer.compiler.IReportCompiler.run(IReportCompiler.java:878)
      at org.openide.util.RequestProcessor$Task.run(RequestProcessor.java:572)
      at org.openide.util.RequestProcessor$Processor.run(RequestProcessor.java:997) Caused by: 
      net.sf.jasperreports.engine.JRException: Error opening input stream from URL : 
      https://api.twitter.com/1/users/profile_image?screen_name=CPTCurtisHervey&amp;size=bigger     
      at net.sf.jasperreports.engine.util.JRLoader.getInputStream(JRLoader.java:314)
      at net.sf.jasperreports.repo.DefaultRepositoryService.getInputStream(DefaultRepositoryService.java:121)
      ... 19 more Caused by: java.io.FileNotFoundException: 
      https://api.twitter.com/1/users/profile_image?screen_name=CPTCurtisHervey&amp;size=bigger     
      at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1401)     
      at sun.net.www.protocol.https.HttpsURLConnectionImpl.getInputStream(HttpsURLConnectionImpl.java:254)
      at java.net.URL.openStream(URL.java:1029)     
      at net.sf.jasperreports.engine.util.JRLoader.getInputStream(JRLoader.java:310)... 20 more 
      Print not filled. Try to use an EmptyDataSource...
  </code></pre>
  
  <p>How can i handle this situation in the jrxml file?</p>
  
  <p>I would like to simply add a fixed URL address in case it can't find one.</p>
  
  <p>Anyone has any suggestions?</p>
  
  <p>Thank you!</p>