title: Read .jasper file from target/jasper
body: <p>I am trying to use Jasper using the jasperreports-maven-plugin.</p>
  
  <p>So you create your .jrxml in a directory src/main/jasperreports and the plugin compiles it and creates a .jasper file in target/jasper.
  So far this is working.</p>
  
  <p>Now I would like to read this .jasper file into a Java class in order to fill the report. This is where my problem is. How do I access this .jasper file from target/jasper?</p>
  
  <p>I thought I needed to add it as additional resource directory in my pom.xml:</p>
  
  <pre><code>  &lt;build&gt;
      &lt;resources&gt;
          &lt;resource&gt;
              &lt;directory&gt;src/main/resources&lt;/directory&gt;
          &lt;/resource&gt;
          &lt;resource&gt;
              &lt;directory&gt;target/jasper&lt;/directory&gt;
          &lt;/resource&gt;
      &lt;/resources&gt;
      &lt;plugins&gt;
          &lt;plugin&gt;
              &lt;groupId&gt;org.codehaus.mojo&lt;/groupId&gt;
              &lt;artifactId&gt;jasperreports-maven-plugin&lt;/artifactId&gt;
              &lt;configuration&gt;
                &lt;outputDirectory&gt;${project.build.directory}/jasper&lt;/outputDirectory&gt;
              &lt;/configuration&gt;
              &lt;executions&gt;
                &lt;execution&gt;
                &lt;goals&gt;
                    &lt;goal&gt;compile-reports&lt;/goal&gt;
                &lt;/goals&gt;
                &lt;/execution&gt;
              &lt;/executions&gt;
          ...
  </code></pre>
  
  <p>And then get it using getResource like this:</p>
  
  <pre><code>URL resource = getClass().getResource("/target/jasper/DataSourceReport.jasper");
  </code></pre>
  
  <p>However, this returns null.
  The file DataSourceReport.jasper is inside my project under target/jasper, but it seems to be unable to find it.</p>
  
  <p>Can anyone tell me what I'm doing wrong or why this isn't working?</p>