如何解决LinkageError与JasperReports(6. *)? [英] How to resolve LinkageError with JasperReports (6.*)?

查看:299
本文介绍了如何解决LinkageError与JasperReports(6. *)?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

e.g。我们得到:

  net.sf.jasperreports.engine.JRException:... 
导致:net.sf .jasperreports.engine.fill.JRExpressionEvalException:
评估源文本的表达式的错误:
$ P {REPORT_SCRIPTLET} .setTestRaw_LogOn_TstMsgOn(true,true)
导致:java.lang.LinkageError:loader约束违反:loader
(java / net / FactoryURLClassLoader的实例)先前为不同类型加载
,名称为org / slf4j / Logger
pre>

运行在具有JR插件v6.1.0 的 Eclipse(Kepler)预览中,但不与另一个使用5.5.1的Eclipse一起运行



显然,我们正在使用一些本身正在使用slf4j api进行日志记录的构建路径引用的自定义报告脚本。



似乎与同一类的另一个不同版本冲突(对于相同的底层加载隔离)。

解决方案例

我遇到同样的问题,我通过在项目中的Build路径中添加Jars来解决问题:




  • slf4j-api-1.7.12.jar

  • slf4j-log4j12-1.7.12.jar

  • slf4j-simple-1.7.12.jar



并添加 JasperReports库 JasperReports图书馆依赖关系到项目



这些步骤


  1. 右键单击项目

  2. 构建Cath>配置构建路径

  3. 转到库并使用添加添加jar外部JAR

  4. 使用添加库添加JasperReport库和JasperReport库依赖关系

  5. 然后转到订单和导出并检查新添加的库和Jars,然后单击确定

您将得到如下结果:




e.g. we got:

net.sf.jasperreports.engine.JRException: ...
Caused by: net.sf.jasperreports.engine.fill.JRExpressionEvalException: 
  Error evaluating expression for source text: 
    $P{REPORT_SCRIPTLET}.setTestRaw_LogOn_TstMsgOn(true, true)
Caused by: java.lang.LinkageError: loader constraint violation: loader 
  (instance of java/net/FactoryURLClassLoader) previously initiated loading 
  for a different type with name "org/slf4j/Logger"

running in Eclipse (Kepler) Preview with JR plugin v6.1.0, but not with another Eclipse running with 5.5.1.final

Obviously we are using some build-path-referenced custom report scriptlet which itself is using the slf4j api for logging.

It seems to be conflicting with another different version of the same class (for the same underlying class loading isolation).

解决方案

I got the same problem and I solved it by adding those Jars in Build path in my project:

  • slf4j-api-1.7.12.jar
  • slf4j-log4j12-1.7.12.jar
  • slf4j-simple-1.7.12.jar

and add also the JasperReports Library and the JasperReports Library Dependencies to the project

with these steps

  1. Right click in the project
  2. Build Cath > Configure Build Path
  3. go to libraries and add the jars using Add External JARs
  4. Add the JasperReport Library and JasperReport Library Dependencies using Add Library
  5. and then go to Order and Export and check the new added Libraries and Jars and click OK

you will get a result like that :

这篇关于如何解决LinkageError与JasperReports(6. *)?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆