2016-11-03 8 views
0

私のアプリケーションはJasperReportsを使用してPDFファイルを生成します。 Assembly Mavenプラグインを使用してアプリケーション用のjarファイルを生成します。net.sf.jasperreports.engine.JRRuntimeException:次のフォントをロードできませんでした

問題は、私は、コマンドラインを使用してjarファイルを実行すると、私は次の例外を取得することです:、

net.sf.jasperreports.engine.JRRuntimeException: Could not load the following font: 
pdfFontName: DejaVu Sans 
pdfEncoding: Identity-H 
isPdfEmbedded : true 
    at net.sf.jasperreports.engine.export.JRPdfExporter.getFont(JRPdfExporter.java:2176) 
    at net.sf.jasperreports.engine.export.JRPdfExporter.getChunk(JRPdfExporter.java:1967) 
    at net.sf.jasperreports.engine.export.JRPdfExporter.getPhrase(JRPdfExporter.java:1936) 
    ... 

しかし、私は、コマンドラインjava -cp "jasperreports-fonts-4.0.0.jar;PrintOutCore-1.0.jar" com.soprabanking.printout.Launcherを使用してクラスパスにJasperReportsの-フォントジャーを追加するとき問題は消えて、すべてが大丈夫です。

jasperreports-fonts jarをコマンドラインでクラスパスに手動で追加せずにjarを正しく実行するにはどうすればよいですか?

これは私のpom.xmlです:

<?xml version="1.0" encoding="UTF-8"?> 
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 
    <modelVersion>4.0.0</modelVersion> 
    <groupId>com.soprabanking</groupId> 
    <version>1.0</version> 
    <packaging>jar</packaging> 
    <artifactId>PrintOutCore</artifactId> 
    <properties> 
     <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> 
    </properties> 
    <dependencies> 
     <dependency> 
      <groupId>com.soprabanking</groupId> 
      <artifactId>PrintOutDao</artifactId> 
      <version>0.0.1-SNAPSHOT</version> 
     </dependency> 
     <!-- BEGIN Junit --> 
     <dependency> 
      <groupId>junit</groupId> 
      <artifactId>junit</artifactId> 
      <version>4.9</version> 
      <exclusions> 
       <exclusion> 
        <groupId>org.hamcrest</groupId> 
        <artifactId>hamcrest-core</artifactId> 
       </exclusion> 
      </exclusions> 
     </dependency> 
     <!-- https://mvnrepository.com/artifact/xmlunit/xmlunit --> 
     <dependency> 
      <groupId>xmlunit</groupId> 
      <artifactId>xmlunit</artifactId> 
      <version>1.6</version> 
     </dependency> 
     <dependency> 
      <groupId>org.hamcrest</groupId> 
      <artifactId>hamcrest-library</artifactId> 
      <version>1.3</version> 
     </dependency> 
     <!-- FINISH Junit --> 
     <!-- START jasper dependencies --> 
     <dependency> 
      <groupId>net.sf.jasperreports</groupId> 
      <artifactId>jasperreports</artifactId> 
      <version>6.1.1</version> 
     </dependency> 
     <dependency> 
      <groupId>com.lowagie</groupId> 
      <artifactId>itext</artifactId> 
      <version>2.1.7</version> 
     </dependency> 
     <dependency> 
      <groupId>org.apache.poi</groupId> 
      <artifactId>poi</artifactId> 
      <version>3.12</version> 
     </dependency> 
     <dependency> 
      <groupId>net.sf.jasperreports</groupId> 
      <artifactId>jasperreports-fonts</artifactId> 
      <version>4.0.0</version> 
     </dependency> 
     <!-- END jasper dependencies --> 
     <!-- Begin Apache POI --> 
     <dependency> 
      <groupId>org.apache.poi</groupId> 
      <artifactId>poi</artifactId> 
      <version>3.10-FINAL</version> 
     </dependency> 
     <dependency> 
      <groupId>org.apache.poi</groupId> 
      <artifactId>poi-ooxml</artifactId> 
      <version>3.10-FINAL</version> 
     </dependency> 
     <!-- FINISH Apache POI --> 
     <!-- https://mvnrepository.com/artifact/net.contentobjects.jnotify/jnotify --> 
     <dependency> 
      <groupId>net.contentobjects.jnotify</groupId> 
      <artifactId>jnotify</artifactId> 
      <version>0.94</version> 
     </dependency> 
     <dependency> 
      <groupId>org.json</groupId> 
      <artifactId>json</artifactId> 
      <version>20090211</version> 
     </dependency> 
    </dependencies> 
    <build> 
     <plugins> 
      <plugin> 
       <groupId>org.apache.maven.plugins</groupId> 
       <artifactId>maven-compiler-plugin</artifactId> 
       <version>3.1</version> 
       <configuration> 
        <source>1.7</source> 
        <target>1.7</target> 
       </configuration> 
      </plugin> 
      <!-- Includes the runtime dependencies --> 
      <plugin> 
       <groupId>org.apache.maven.plugins</groupId> 
       <artifactId>maven-surefire-plugin</artifactId> 
       <version>2.12.4</version> 
       <configuration> 
        <skipTests>true</skipTests> 
        <includes> 
         <include>**/*Accountancy*.java</include> 
         <include>**/*AccountOfficer*.java</include> 
         <include>**/*AccountsWithout*.java</include> 
         <include>**/*AutomaticRev*.java</include> 
         <include>**/*GeneralSummary*.java</include> 
         <include>**/*GrandLivre*.java</include> 
         <include>**/*RevaluationOn*.java</include> 
         <include>**/*SyntheticGeneral*.java</include> 
         <include>**/*SyntheticBalance*.java</include> 
         <include>**/*BceaoBalance*.java</include> 
         <include>**/*DailyReport*.java</include> 
         <include>**/*DailyTransaction*.java</include> 
         <include>com.soprabanking.printout.test.utils.*.java</include> 
         <include>com.soprabanking.printout.service.reportcreators.xls.XLSUtilsTest.java</include> 
         <include>com.soprabanking.printout.test.service.ParserXmlUtilsTest.java</include> 
        </includes> 
       </configuration> 
      </plugin> 
      <plugin> 
       <artifactId>maven-assembly-plugin</artifactId> 
       <version>2.6</version> 
       <configuration> 
        <descriptorRefs> 
         <descriptorRef>jar-with-dependencies</descriptorRef> 
        </descriptorRefs> 
       </configuration> 
       <executions> 
        <execution> 
         <id>make-assembly</id> 
         <phase>package</phase> 
         <goals> 
          <goal>single</goal> 
         </goals> 
        </execution> 
       </executions> 
      </plugin> 
     </plugins> 
    </build> 
</project> 
+0

可能な複製(http://stackoverflow.com/questions/40388856/maven-assembly-plugin-is-missing-something-at-packaging-time [Mavenのアセンブリのプラグインは、パッケージング時に何かが欠けています] ) –

+0

質問を再投稿するのは悪い習慣です –

+0

私は古い質問を説明していませんでした。 –

答えて

1

検索の長い時間の後、私は、問題の根本を発見しました。

は実際には、パッケージング時にアセンブリプラグインは、二回ファイルにjasperreports_extension.propertiesを見つけるので、1を削除し、他を保ちます。

ソリューションは、のMaven-シェード - プラグインMavenのアセンブリ・プラグインを交換し、それに変圧器を追加することです。

<plugin> 
    <groupId>org.apache.maven.plugins</groupId> 
    <artifactId>maven-shade-plugin</artifactId> 
    <version>2.4.3</version> 
    <executions> 
     <execution> 
      <phase>package</phase> 
      <goals> 
       <goal>shade</goal> 
      </goals> 
      <configuration> 
       <transformers> 
        <transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer"> 
         <resource>jasperreports_extension.properties</resource> 
        </transformer> 
        <transformer 
         implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer"> 
         <mainClass>org.springframework.batch.core.launch.support.CommandLineJobRunner</mainClass> 
        </transformer> 
        <transformer 
         implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer"> 
         <resource>META-INF/spring.handlers</resource> 
        </transformer> 
        <transformer 
         implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer"> 
         <resource>META-INF/spring.schemas</resource> 
        </transformer> 
       </transformers> 
       <filters> 
        <filter> 
         <artifact>junit:junit</artifact> 
         <includes> 
          <include>junit/framework/**</include> 
          <include>org/junit/**</include> 
         </includes> 
         <excludes> 
          <exclude>org/junit/experimental/**</exclude> 
          <exclude>org/junit/runners/**</exclude> 
         </excludes> 
        </filter> 
        <filter> 
         <artifact>*:*</artifact> 
         <excludes> 
          <exclude>META-INF/*.SF</exclude> 
          <exclude>META-INF/*.DSA</exclude> 
          <exclude>META-INF/*.RSA</exclude> 
         </excludes> 
        </filter> 
       </filters> 
      </configuration> 
     </execution> 
    </executions> 
</plugin> 
関連する問題