Cute Happy Ghost
본문 바로가기
JAVA/JasperStudio

[jasperstudio] #4 JasperReports 라이브러리 추가, 종속성 에러문제 해결(collections4,openPDF,jfreechart)

by JENN_tech7 2023. 10. 31.
728x90
SMALL
  • maven프로젝트의 경우 pom.xml에 디펜던시를 추가해준다
<!-- https://mvnrepository.com/artifact/net.sf.jasperreports/jasperreports -->
<dependency>
    <groupId>net.sf.jasperreports</groupId>
    <artifactId>jasperreports</artifactId>
    <version>6.20.6</version>
</dependency>

다른 버전을 원한다면

https://mvnrepository.com/artifact/net.sf.jasperreports/jasperreports

여기서 찾아서 해주면 된다

 

 

 

  • maven아닐 경우에도 위의 링크에 들어가서 jar파일을 다운로드 받아주면된다
    혹은 아래 링크의 sourceforge에 들어가서 다운로드 받아도 된다

https://sourceforge.net/projects/jasperreports/files/jasperreports/JasperReports%206.20.6/

 

JasperReports Library - Browse /jasperreports/JasperReports 6.20.6 at SourceForge.net

PBRS™ and CRD®, our standalone report scheduling solutions for Power BI, Microsoft SQL Server Reporting Services® (SSRS) and SAP Crystal Reports®, are designed to supplement and strengthen your current Business intelligence infrastructure by automatin

sourceforge.net

 

 

 

 

 

나는 안타깝게도 maven 프로젝트가 아니었다

maven으로 변환할 수 있었지만 프로젝트 구조가 달라지고, 리스크가 꽤나 컸다

jar파일을 넣어주는게 시간이 얼마 안걸리기때문에 다운로드 받아줬다

아래 jasper관련 jar파일 다 다운로드 받아서 WEB-INF/lib에 넣어주면된다

 

 

 

 

 

 

라이브러리 수동으로 넣어주는 것은 험난한 길을 걷는거임

maven같은 빌드도구를 통해 의존성관리하는 것이 최고임

하지만 의존성충돌이 원인이 되는 에러들은 꽤나 많다 

나는 여기서 일어났던 종속성 문제를 수동주입하여 해결했고 그 방법을 써보겠다

 

 

 

 

 

  • collections4 
    현재 이 프로젝트는 collections3을 쓰고 있는데 jasper 어딘가에서 collections4를 쓰고 있겠지
    NoClassDefFoundError는 말 그대로 클래스를 찾을 수 없다는 뜻이고 친절하게 클래스 경로까지 알려준다
    그럼 해당 라이브러리를 다운로드 받아주면 해결된다
Handler dispatch failed; nested exception is java.lang.NoClassDefFoundError: org/apache/commons/collections4/map/ReferenceMap

https://commons.apache.org/proper/commons-collections/download_collections.cgi

 

Collections – Download Apache Commons Collections

Download Apache Commons Collections Using a Mirror We recommend you use a mirror to download our release builds, but you must verify the integrity of the downloaded files using signatures downloaded from our main distribution directories. Recent releases (

commons.apache.org

 

 

 

 

  • opdnPDF
    'com/lowagie/text/DocumentException'클래스는 jasper에서 쓰는 구버전itext의 클래스라고 해서
    itext 라이브러리를 다운받아 넣어줬다
    하지만 그와 종속된 에러들이 계속 떠서 아니라고 생각해서 다시 찾아봤고 openPDF jar만 다운받아주면됐었다
java.lang.NoClassDefFoundError: com/lowagie/text/DocumentException

https://javadoc.io/doc/com.github.librepdf/openpdf/1.3.26/com/lowagie/text/pdf/package-summary.html

 

com.lowagie.text.pdf package summary - openpdf 1.3.26 javadoc

Latest version of com.github.librepdf:openpdf https://javadoc.io/doc/com.github.librepdf/openpdf Current version 1.3.26 https://javadoc.io/doc/com.github.librepdf/openpdf/1.3.26 package-list path (used for javadoc generation -link option) https://javadoc.i

javadoc.io

 

 

 

 

 

  • jfreechart
    해당 에러는 jfree 클래스가 없어서 나는 에러지만 차트를 쓰지않으면 상관없다 
    리포트표출에는 문제없는 에러지만 나는 차트를 쓰기 때문에 jfreechart jar를 다운받아서 넣어준다
java.lang.NoClassDefFoundError: Lorg/jfree/chart/plot/PlotOrientation

https://sourceforge.net/projects/jfreechart/

 

JFreeChart

Download JFreeChart for free. JFreeChart is a free (LGPL) chart library for the Java(tm) platform. It supports bar charts, pie charts, line charts, time series charts, scatter plots, histograms, simple Gantt charts, Pareto charts, bubble plots, dials, ther

sourceforge.net

다운로드 받아서 lib폴더를 확인해보면 여러개의 jar파일이 있는 것을 볼 수 있다

하지만 얘네가 다 필요한 것은 아니라고한다

각각의 JAR 파일이 어떤 용도로 사용되는지 궁금해서 찾아봤다

  • jfreechart: JFreeChart의 핵심 클래스들을 포함하고 있으며, 차트를 생성하는 데 필요
  • jcommon: JFreeChart가 의존하는 공통 유틸리티 라이브러리
  • jfreechart-experimental: 실험적인 기능을 포함하고 있는 라이브러리로, 필수는 아님
  • jfreechart-swt: SWT(Standard Widget Toolkit)를 이용하여 JFreeChart를 표시할 때 사용. SWT 기반의 애플리케이션에서 필요
  • jfreesvg: SVG 포맷으로 차트를 출력할 때 사용
  • junit: 자바 단위 테스트 프레임워크로, 프로덕션 환경에서는 필요하지 않음
  • hamcrest-core: JUnit과 함께 사용되는 매처 라이브러리로, 테스트를 위한 것
  • orsonchart: 다른 차트 라이브러리로, JFreeChart와 별개
  • orsonpdf: 차트를 PDF 형식으로 내보낼 때 사용하는 라이브러리
  • servlet: 웹 애플리케이션에서 차트를 서블릿을 통해 제공할 때 사용
  • swtgraphics3d: 3D 그래픽을 SWT로 표시할 때 사용하는 라이브러리로, 일반적인 차트 생성에는 필요하지 않음

 

따라서 기본 차트 기능만 필요하다면 jfreechartjcommon만 프로젝트에 추가하면 된다

이렇게 하면 리포트기능에 필요한 모든 라이브러리들이 구동된다

728x90
LIST

댓글