Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

LinkageError with Lombok, Eclipse and JasperReports Maven Plugin #1036

Closed
mkielar opened this issue Feb 29, 2016 · 25 comments
Closed

LinkageError with Lombok, Eclipse and JasperReports Maven Plugin #1036

mkielar opened this issue Feb 29, 2016 · 25 comments
Milestone

Comments

@mkielar
Copy link

mkielar commented Feb 29, 2016

I'm getting a LinkageError error when opening a Maven project that utilizes jasperreports-plugin in Eclipse Mars with Lombok.

Version: Mars.1 Release (4.5.1)
Build id: 20150924-1200
Lombok v1.16.6 "Candid Duck" is installed.

In that case, whenever project is built, it runs the Maven Plugin, the Plugin seems to run correctly (no logs in Eclipse's Maven Console) and then Eclipse reports an error in pom.xml with this exception:

Error while compiling Jasper reports (com.alexnederlof:jasperreports-plugin:1.6:jasper:default:process-sources) org.apache.maven.plugin.MojoExecutionException: Error while compiling Jasper reports
    at com.alexnederlof.jasperreport.JasperReporter.executeTasks(JasperReporter.java:238)
    at com.alexnederlof.jasperreport.JasperReporter.execute(JasperReporter.java:138)
    at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:134)
    at org.eclipse.m2e.core.internal.embedder.MavenImpl.execute(MavenImpl.java:331)
    at org.eclipse.m2e.core.internal.embedder.MavenImpl$11.call(MavenImpl.java:1362)
    at org.eclipse.m2e.core.internal.embedder.MavenImpl$11.call(MavenImpl.java:1)
    at org.eclipse.m2e.core.internal.embedder.MavenExecutionContext.executeBare(MavenExecutionContext.java:176)
    at org.eclipse.m2e.core.internal.embedder.MavenExecutionContext.execute(MavenExecutionContext.java:112)
    at org.eclipse.m2e.core.internal.embedder.MavenImpl.execute(MavenImpl.java:1360)
    at org.eclipse.m2e.core.project.configurator.MojoExecutionBuildParticipant.build(MojoExecutionBuildParticipant.java:52)
    at org.eclipse.m2e.core.internal.builder.MavenBuilderImpl.build(MavenBuilderImpl.java:137)
    at org.eclipse.m2e.core.internal.builder.MavenBuilder$1.method(MavenBuilder.java:172)
    at org.eclipse.m2e.core.internal.builder.MavenBuilder$1.method(MavenBuilder.java:1)
    at org.eclipse.m2e.core.internal.builder.MavenBuilder$BuildMethod$1$1.call(MavenBuilder.java:115) 
    at org.eclipse.m2e.core.internal.embedder.MavenExecutionContext.executeBare(MavenExecutionContext.java:176)
    at org.eclipse.m2e.core.internal.embedder.MavenExecutionContext.execute(MavenExecutionContext.java:112)
    at org.eclipse.m2e.core.internal.builder.MavenBuilder$BuildMethod$1.call(MavenBuilder.java:105)
    at org.eclipse.m2e.core.internal.embedder.MavenExecutionContext.executeBare(MavenExecutionContext.java:176)
    at org.eclipse.m2e.core.internal.embedder.MavenExecutionContext.execute(MavenExecutionContext.java:151)
    at org.eclipse.m2e.core.internal.embedder.MavenExecutionContext.execute(MavenExecutionContext.java:99)
    at org.eclipse.m2e.core.internal.builder.MavenBuilder$BuildMethod.execute(MavenBuilder.java:86)
    at org.eclipse.m2e.core.internal.builder.MavenBuilder.build(MavenBuilder.java:200)
    at org.eclipse.core.internal.events.BuildManager$2.run(BuildManager.java:734)
    at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:42)
    at org.eclipse.core.internal.events.BuildManager.basicBuild(BuildManager.java:205)
    at org.eclipse.core.internal.events.BuildManager.basicBuild(BuildManager.java:245)
    at org.eclipse.core.internal.events.BuildManager$1.run(BuildManager.java:300)
    at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:42)
    at org.eclipse.core.internal.events.BuildManager.basicBuild(BuildManager.java:303)
    at org.eclipse.core.internal.events.BuildManager.basicBuildLoop(BuildManager.java:359)
    at org.eclipse.core.internal.events.BuildManager.build(BuildManager.java:382)
    at org.eclipse.core.internal.events.AutoBuildJob.doBuild(AutoBuildJob.java:144)
    at org.eclipse.core.internal.events.AutoBuildJob.run(AutoBuildJob.java:235)
    at org.eclipse.core.internal.jobs.Worker.run(Worker.java:55) 

Caused by: java.util.concurrent.ExecutionException: java.lang.LinkageError: loader constraint violation: when resolving method "lombok.launch.PatchFixesHider$Transform.transform_swapped(Lorg/eclipse/jdt/internal/compiler/ast/CompilationUnitDeclaration;Lorg/eclipse/jdt/internal/compiler/parser/Parser;)V" the class loader (instance of org/codehaus/plexus/classworlds/realm/ClassRealm) of the current class, org/eclipse/jdt/internal/compiler/parser/Parser, and the class loader  (instance of lombok/launch/ShadowClassLoader) for the method's defining class, lombok/launch/PatchFixesHider$Transform, have different Class objects for the type org/eclipse/jdt/internal/compiler/ast/CompilationUnitDeclaration used in the signature
    at java.util.concurrent.FutureTask.report(FutureTask.java:122)
    at java.util.concurrent.FutureTask.get(FutureTask.java:192)
    at com.alexnederlof.jasperreport.JasperReporter.checkForExceptions(JasperReporter.java:245)
    at com.alexnederlof.jasperreport.JasperReporter.executeTasks(JasperReporter.java:230) 
    ... 33 more 

Caused by: java.lang.LinkageError: loader constraint violation: when resolving method "lombok.launch.PatchFixesHider$Transform.transform_swapped(Lorg/eclipse/jdt/internal/compiler/ast/CompilationUnitDeclaration;Lorg/eclipse/jdt/internal/compiler/parser/Parser;)V" the class loader (instance of org/codehaus/plexus/classworlds/realm/ClassRealm) of the current class, org/eclipse/jdt/internal/compiler/parser/Parser, and the class loader (instance of lombok/launch/ShadowClassLoader) for the method's defining class, lombok/launch/PatchFixesHider$Transform, have different Class objects for the type org/eclipse/jdt/internal/compiler/ast/CompilationUnitDeclaration used in the signature
    at org.eclipse.jdt.internal.compiler.parser.Parser.endParse(Parser.java:8681)
    at org.eclipse.jdt.internal.compiler.parser.Parser.parse(Parser.java:9715)
    at org.eclipse.jdt.internal.compiler.parser.Parser.parse(Parser.java:9933)
    at org.eclipse.jdt.internal.compiler.parser.Parser.parse(Parser.java:9890)
    at org.eclipse.jdt.internal.compiler.parser.Parser.dietParse(Parser.java:8454)
    at org.eclipse.jdt.internal.compiler.Compiler.internalBeginToCompile(Compiler.java:718)
    at org.eclipse.jdt.internal.compiler.Compiler.beginToCompile(Compiler.java:383)
    at org.eclipse.jdt.internal.compiler.Compiler.compile(Compiler.java:428)
    at net.sf.jasperreports.engine.design.JRJdtCompiler.compileUnits(JRJdtCompiler.java:173)
    at net.sf.jasperreports.engine.design.JRAbstractCompiler.compileReport(JRAbstractCompiler.java:212)
    at net.sf.jasperreports.engine.JasperCompileManager.compile(JasperCompileManager.java:357)
    at net.sf.jasperreports.engine.JasperCompileManager.compileToStream(JasperCompileManager.java:326)
    at net.sf.jasperreports.engine.JasperCompileManager.compileToStream(JasperCompileManager.java:309)
    at net.sf.jasperreports.engine.JasperCompileManager.compileReportToStream(JasperCompileManager.java:587)
    at com.alexnederlof.jasperreport.CompileTask.call(CompileTask.java:75) 
    at com.alexnederlof.jasperreport.CompileTask.call(CompileTask.java:34)
    at java.util.concurrent.FutureTask.run(FutureTask.java:266)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
    at java.lang.Thread.run(Thread.java:745)

I created a small, self contained, correct example that will allow to reproduce the problem.
The problem might be that the plugin uses ejc artifact by itself, and then classes from it are loaded with a different classloader than Eclipse's, which somehow results in LinkageError.

If I remove Lombok, the whole thing complies smoothly without errors.

@nicoschl
Copy link

Hi,

Any news / workaround for this issue?

@mhagnumdw
Copy link

Today I had the same problem.

Tested versions:

  • Eclipse 2019-03 with lombok in versions 1.18.12, 1.18.10, 1.18.8, 1.18.6, 1.18.4, 1.18.2, 1.18.0, 1.16.18 and edge.
  • Eclipse 2020-03 with lombok 1.18.12.
  • Java JDK 1.8.0_222 / Windows 10
  • Maven 3.6.3
  • maven plugin net.sf.jasperreports : jasperreports 6.4.3 and 6.12.2
  • maven pligin com.alexnederlof : jasperreports-plugin 2.3 to 2.7

Ultimately, for this case, the solution was to remove the lombok from Eclipse. In the eclipse.ini file I removed the line -javaagent:C:\xxx\eclipse\lombok.jar

@joblini
Copy link

joblini commented Sep 30, 2020

Any progress on this issue?

Removing Lombok from Eclipse (In the eclipse.ini file remove the line -javaagent:C:\xxx\eclipse\lombok.jar) is not a viable solution for us as we use Lombok in many projects.

@randakar
Copy link

Looks similar to #1281 which is also still open

@randakar
Copy link

.. and #2351

Looking at this it is very important that you update not just the lombok dependency, but also the lombok installation / plugin itself, as this may be an old (closed) bug resurfacing.

Since we're now on 1.18.12 and this report is talking about a 1.16.x version this may already be fixed and just be a setup or update problem.

@randakar
Copy link

Especially with comments like this #2454 (comment) - you may need to refresh your workspace as well to fix this.

@joblini
Copy link

joblini commented Sep 30, 2020

@randakar I tested with 1.18.12 in a fresh workspace, and the problem still occurs.
I created a simple project to reproduce the problem

@randakar
Copy link

randakar commented Oct 1, 2020 via email

@randakar
Copy link

randakar commented Oct 1, 2020 via email

@joblini
Copy link

joblini commented Oct 1, 2020

@randakar The changes in the pull request did not resolve the problem.

The error does not occur when building directly with Maven.

The error only occurs when building the project in Eclipse, via the m2e Eclipse integration
This screenshot should help to illustrate.

lombok-1036-eclipse-error

@joblini
Copy link

joblini commented Oct 1, 2020

@randakar I tested with the lombok edge release (with a fresh workspace), but the problem still occurs.

@randakar
Copy link

randakar commented Oct 1, 2020 via email

@joblini
Copy link

joblini commented Oct 1, 2020

When the project is built for the first time (via m2e) after running Eclipse with the lombok javaagent enabled, the error is :

java.lang.NoClassDefFoundError: org/eclipse/jdt/internal/compiler/parser/Parser
at lombok.launch.PatchFixesHider$Transform.(PatchFixesHider.java:177)

Here is the complete stack trace:

`Error while compiling Jasper reports (com.alexnederlof:jasperreports-plugin:2.6:jasper:default:process-sources)

org.apache.maven.plugin.MojoExecutionException: Error while compiling Jasper reports
at com.alexnederlof.jasperreport.JasperReporter.executeTasks(JasperReporter.java:416)
at com.alexnederlof.jasperreport.JasperReporter.execute(JasperReporter.java:210)
at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:137)
at org.eclipse.m2e.core.internal.embedder.MavenImpl.execute(MavenImpl.java:332)
at org.eclipse.m2e.core.internal.embedder.MavenImpl.lambda$8(MavenImpl.java:1379)
at org.eclipse.m2e.core.internal.embedder.MavenExecutionContext.executeBare(MavenExecutionContext.java:179)
at org.eclipse.m2e.core.internal.embedder.MavenExecutionContext.execute(MavenExecutionContext.java:114)
at org.eclipse.m2e.core.internal.embedder.MavenImpl.execute(MavenImpl.java:1378)
at org.eclipse.m2e.core.project.configurator.MojoExecutionBuildParticipant.build(MojoExecutionBuildParticipant.java:54)
at org.eclipse.m2e.core.internal.builder.MavenBuilderImpl.build(MavenBuilderImpl.java:135)
at org.eclipse.m2e.core.internal.builder.MavenBuilder$1.method(MavenBuilder.java:169)
at org.eclipse.m2e.core.internal.builder.MavenBuilder$1.method(MavenBuilder.java:1)
at org.eclipse.m2e.core.internal.builder.MavenBuilder$BuildMethod.lambda$1(MavenBuilder.java:114)
at org.eclipse.m2e.core.internal.embedder.MavenExecutionContext.executeBare(MavenExecutionContext.java:179)
at org.eclipse.m2e.core.internal.embedder.MavenExecutionContext.execute(MavenExecutionContext.java:114)
at org.eclipse.m2e.core.internal.builder.MavenBuilder$BuildMethod.lambda$0(MavenBuilder.java:105)
at org.eclipse.m2e.core.internal.embedder.MavenExecutionContext.executeBare(MavenExecutionContext.java:179)
at org.eclipse.m2e.core.internal.embedder.MavenExecutionContext.execute(MavenExecutionContext.java:153)
at org.eclipse.m2e.core.internal.embedder.MavenExecutionContext.execute(MavenExecutionContext.java:101)
at org.eclipse.m2e.core.internal.builder.MavenBuilder$BuildMethod.execute(MavenBuilder.java:88)
at org.eclipse.m2e.core.internal.builder.MavenBuilder.build(MavenBuilder.java:197)
at org.eclipse.core.internal.events.BuildManager$2.run(BuildManager.java:832)
at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:45)
at org.eclipse.core.internal.events.BuildManager.basicBuild(BuildManager.java:220)
at org.eclipse.core.internal.events.BuildManager.basicBuild(BuildManager.java:263)
at org.eclipse.core.internal.events.BuildManager$1.run(BuildManager.java:316)
at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:45)
at org.eclipse.core.internal.events.BuildManager.basicBuild(BuildManager.java:319)
at org.eclipse.core.internal.events.BuildManager.basicBuildLoop(BuildManager.java:371)
at org.eclipse.core.internal.events.BuildManager.build(BuildManager.java:392)
at org.eclipse.core.internal.events.AutoBuildJob.doBuild(AutoBuildJob.java:154)
at org.eclipse.core.internal.events.AutoBuildJob.run(AutoBuildJob.java:244)
at org.eclipse.core.internal.jobs.Worker.run(Worker.java:63)
Caused by: java.util.concurrent.ExecutionException: java.lang.NoClassDefFoundError: org/eclipse/jdt/internal/compiler/parser/Parser
at java.util.concurrent.FutureTask.report(FutureTask.java:122)
at java.util.concurrent.FutureTask.get(FutureTask.java:192)
at com.alexnederlof.jasperreport.JasperReporter.checkForExceptions(JasperReporter.java:423)
at com.alexnederlof.jasperreport.JasperReporter.executeTasks(JasperReporter.java:405)
... 32 more
Caused by: java.lang.NoClassDefFoundError: org/eclipse/jdt/internal/compiler/parser/Parser
at lombok.launch.PatchFixesHider$Transform.(PatchFixesHider.java:177)
at org.eclipse.jdt.internal.compiler.parser.Parser.endParse(Parser.java:9900)
at org.eclipse.jdt.internal.compiler.parser.Parser.parse(Parser.java:11077)
at org.eclipse.jdt.internal.compiler.parser.Parser.parse(Parser.java:11301)
at org.eclipse.jdt.internal.compiler.parser.Parser.parse(Parser.java:11258)
at org.eclipse.jdt.internal.compiler.parser.Parser.dietParse(Parser.java:9673)
at org.eclipse.jdt.internal.compiler.Compiler.internalBeginToCompile(Compiler.java:718)
at org.eclipse.jdt.internal.compiler.Compiler.beginToCompile(Compiler.java:383)
at org.eclipse.jdt.internal.compiler.Compiler.compile(Compiler.java:428)
at net.sf.jasperreports.engine.design.JRJdtCompiler.compileUnits(JRJdtCompiler.java:160)
at net.sf.jasperreports.engine.design.JRAbstractCompiler.compileReport(JRAbstractCompiler.java:203)
at net.sf.jasperreports.engine.JasperCompileManager.compile(JasperCompileManager.java:358)
at net.sf.jasperreports.engine.JasperCompileManager.compileToStream(JasperCompileManager.java:327)
at net.sf.jasperreports.engine.JasperCompileManager.compileToStream(JasperCompileManager.java:310)
at net.sf.jasperreports.engine.JasperCompileManager.compileReportToStream(JasperCompileManager.java:588)
at com.alexnederlof.jasperreport.CompileTask.call(CompileTask.java:63)
at com.alexnederlof.jasperreport.CompileTask.call(CompileTask.java:28)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:748)
Caused by: java.lang.ClassNotFoundException: org.eclipse.jdt.internal.compiler.parser.Parser
at java.lang.ClassLoader.findClass(ClassLoader.java:530)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at lombok.launch.ShadowClassLoader.loadClass(ShadowClassLoader.java:534)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
... 21 more
`

Subsequent builds (via m2e) produce the LinkageError as indicated in the original problem description

@mhagnumdw
Copy link

Did anyone get a workaround for this problem?

@Rawi01
Copy link
Collaborator

Rawi01 commented Feb 17, 2021

Removing the eclipse lifecycle mapping should help here. The problem is that the jasperreports plugin loads the eclipse compiler classes every time you run a m2e build and lombok does not like that.

@joblini
Copy link

joblini commented Feb 18, 2021

The purpose of the m2e lifecycle mapping is to invoke the jasperreports plugin to compile reports, as required, during the Eclipse build cycle. Removing the mapping would result in reports not being compiled, so this isn't an acceptable solution.

@Rawi01
Copy link
Collaborator

Rawi01 commented Feb 18, 2021

You can still invoke the maven goal by hand or compile the reports using your reports editor (e.g. Jaspersoft Studio). That might not be perfect but is still a better workaround than removing lombok completly.

@rolandas-karosas
Copy link

Any progress on this problem building via m2e?
Could it be any complaints to jasperreports library implementation of using eclipse jdt compiler (JRJdtCompiler.java)? But direct maven build is successful.
Or is it lombok eclipse agent any issue not able to deal when other library uses jdt compiler?

With Lombok v1.18.22 "Envious Ferret" same error

org.apache.maven.plugin.MojoExecutionException: Error while compiling Jasper reports
	at com.alexnederlof.jasperreport.JasperReporter.executeTasks(JasperReporter.java:429)
	at com.alexnederlof.jasperreport.JasperReporter.execute(JasperReporter.java:223)
	at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:137)
	at org.eclipse.m2e.core.internal.embedder.MavenImpl.execute(MavenImpl.java:336)
	at org.eclipse.m2e.core.internal.embedder.MavenImpl.lambda$8(MavenImpl.java:1423)
	at org.eclipse.m2e.core.internal.embedder.MavenExecutionContext.executeBare(MavenExecutionContext.java:182)
	at org.eclipse.m2e.core.internal.embedder.MavenExecutionContext.execute(MavenExecutionContext.java:117)
	at org.eclipse.m2e.core.internal.embedder.MavenImpl.execute(MavenImpl.java:1422)
	at org.eclipse.m2e.core.project.configurator.MojoExecutionBuildParticipant.build(MojoExecutionBuildParticipant.java:55)
	at org.eclipse.m2e.core.internal.builder.MavenBuilderImpl.build(MavenBuilderImpl.java:135)
	at org.eclipse.m2e.core.internal.builder.MavenBuilder$1.method(MavenBuilder.java:169)
	at org.eclipse.m2e.core.internal.builder.MavenBuilder$1.method(MavenBuilder.java:1)
	at org.eclipse.m2e.core.internal.builder.MavenBuilder$BuildMethod.lambda$1(MavenBuilder.java:114)
	at org.eclipse.m2e.core.internal.embedder.MavenExecutionContext.executeBare(MavenExecutionContext.java:182)
	at org.eclipse.m2e.core.internal.embedder.MavenExecutionContext.execute(MavenExecutionContext.java:117)
	at org.eclipse.m2e.core.internal.builder.MavenBuilder$BuildMethod.lambda$0(MavenBuilder.java:105)
	at org.eclipse.m2e.core.internal.embedder.MavenExecutionContext.executeBare(MavenExecutionContext.java:182)
	at org.eclipse.m2e.core.internal.embedder.MavenExecutionContext.execute(MavenExecutionContext.java:156)
	at org.eclipse.m2e.core.internal.embedder.MavenExecutionContext.execute(MavenExecutionContext.java:103)
	at org.eclipse.m2e.core.internal.builder.MavenBuilder$BuildMethod.execute(MavenBuilder.java:88)
	at org.eclipse.m2e.core.internal.builder.MavenBuilder.build(MavenBuilder.java:198)
	at org.eclipse.core.internal.events.BuildManager$2.run(BuildManager.java:853)
	at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:45)
	at org.eclipse.core.internal.events.BuildManager.basicBuild(BuildManager.java:232)
	at org.eclipse.core.internal.events.BuildManager.basicBuild(BuildManager.java:281)
	at org.eclipse.core.internal.events.BuildManager$1.run(BuildManager.java:334)
	at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:45)
	at org.eclipse.core.internal.events.BuildManager.basicBuild(BuildManager.java:337)
	at org.eclipse.core.internal.events.BuildManager.basicBuildLoop(BuildManager.java:389)
	at org.eclipse.core.internal.events.BuildManager.build(BuildManager.java:410)
	at org.eclipse.core.internal.events.AutoBuildJob.doBuild(AutoBuildJob.java:160)
	at org.eclipse.core.internal.events.AutoBuildJob.run(AutoBuildJob.java:251)
	at org.eclipse.core.internal.jobs.Worker.run(Worker.java:63)
Caused by: java.util.concurrent.ExecutionException: java.lang.NoClassDefFoundError: org/eclipse/jdt/internal/compiler/parser/Parser
	at java.base/java.util.concurrent.FutureTask.report(FutureTask.java:122)
	at java.base/java.util.concurrent.FutureTask.get(FutureTask.java:191)
	at com.alexnederlof.jasperreport.JasperReporter.checkForExceptions(JasperReporter.java:436)
	at com.alexnederlof.jasperreport.JasperReporter.executeTasks(JasperReporter.java:418)
	... 32 more
Caused by: java.lang.NoClassDefFoundError: org/eclipse/jdt/internal/compiler/parser/Parser
	at java.base/java.lang.Class.getDeclaredMethods0(Native Method)
	at java.base/java.lang.Class.privateGetDeclaredMethods(Class.java:3325)
	at java.base/java.lang.Class.getDeclaredMethods(Class.java:2466)
	at lombok.launch.PatchFixesHider$Util.findMethodAnyArgs(PatchFixesHider.java:123)
	at lombok.launch.PatchFixesHider$Transform.init(PatchFixesHider.java:202)
	at lombok.launch.PatchFixesHider$Transform.transform_swapped(PatchFixesHider.java:212)
	at org.eclipse.jdt.internal.compiler.parser.Parser.endParse(Parser.java:9900)
	at org.eclipse.jdt.internal.compiler.parser.Parser.parse(Parser.java:11077)
	at org.eclipse.jdt.internal.compiler.parser.Parser.parse(Parser.java:11301)
	at org.eclipse.jdt.internal.compiler.parser.Parser.parse(Parser.java:11258)
	at org.eclipse.jdt.internal.compiler.parser.Parser.dietParse(Parser.java:9673)
	at org.eclipse.jdt.internal.compiler.Compiler.internalBeginToCompile(Compiler.java:718)
	at org.eclipse.jdt.internal.compiler.Compiler.beginToCompile(Compiler.java:383)
	at org.eclipse.jdt.internal.compiler.Compiler.compile(Compiler.java:428)
	at net.sf.jasperreports.engine.design.JRJdtCompiler.compileUnits(JRJdtCompiler.java:160)
	at net.sf.jasperreports.engine.design.JRAbstractCompiler.compileReport(JRAbstractCompiler.java:203)
	at net.sf.jasperreports.engine.JasperCompileManager.compile(JasperCompileManager.java:358)
	at net.sf.jasperreports.engine.JasperCompileManager.compileToStream(JasperCompileManager.java:327)
	at net.sf.jasperreports.engine.JasperCompileManager.compileToStream(JasperCompileManager.java:310)
	at net.sf.jasperreports.engine.JasperCompileManager.compileReportToStream(JasperCompileManager.java:588)
	at com.alexnederlof.jasperreport.CompileTask.call(CompileTask.java:58)
	at com.alexnederlof.jasperreport.CompileTask.call(CompileTask.java:28)
	at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
	at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1130)
	at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:630)
	at java.base/java.lang.Thread.run(Thread.java:832)
Caused by: java.lang.ClassNotFoundException: org.eclipse.jdt.internal.compiler.parser.Parser
	at java.base/java.lang.ClassLoader.findClass(ClassLoader.java:719)
	at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:589)
	at lombok.launch.ShadowClassLoader.loadClass(ShadowClassLoader.java:555)
	at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:522)
	... 26 more

@Rawi01
Copy link
Collaborator

Rawi01 commented Dec 18, 2021

As I already mentioned there are some classloading issues because the plugin and eclipse load the eclipse compiler classes in different classloaders. Lombok assumes that there is only one instance of these classes... There already is a list of classloaders that lombok ignores, it might be a good solution to add the plugin loader to that list.

As a workaround you can use the JRJavacCompiler instead of JRJdtCompiler. Unfortunately the plugin support for it does not work properly so instead of using the <compiler> property you have to add the relevant property and the classpath by hand:

<additionalProperties>
	<net.sf.jasperreports.compiler.class>net.sf.jasperreports.engine.design.JRJavacCompiler</net.sf.jasperreports.compiler.class>
	<net.sf.jasperreports.compiler.classpath>/path/to/jasperreports-6.15.0.jar</net.sf.jasperreports.compiler.classpath>
</additionalProperties>

@rolandas-karosas
Copy link

I have already tried JRJavacCompiler before asking here. Unfortunetely JRJavacCompiler is hundred times slower than JRJdtCompiler. Especially painful when u have hundreds of reports to compile.

@ghost
Copy link

ghost commented Dec 30, 2021

I have confirmed that excluding the classloader org.codehaus.plexus.classworlds.realm.ClassRealm, similar to what is done in #2351, does resolve the issue in that the errors no longer occur. However, org.codehaus.plexus.classworlds.realm.ClassRealm is the classloader used by Maven plugins, so excluding this classloader will affect more than just the JasperReports plugin.

I'm not sure if each maven plugin gets its own classloader instance or if they all share the same one.

@rzwitserloot would it break too much by excluding the plexus-classworlds classloader? If each plugin gets its own classloader instance, in theory it could be possible to identify which one loads the JasperReports plugin and exclude it. If they all share the same classloader, then this strategy won't work at all because there would be no way to isolate ECJ.

What are your thoughts?

@Rawi01
Copy link
Collaborator

Rawi01 commented Dec 31, 2021

It is also possible to detect the plugin classloader using toString()

if (loader != null && loader.toString().contains("jasperreports-plugin")) return false; // Relevant to bug #1036

@ghost
Copy link

ghost commented Jan 1, 2022

Excellent point @Rawi01! Normally ClassLoader.toString() inherits from java.lang.Object, so usually not very useful. But the implementation in org.codehaus.plexus.classworlds.realm.ClassRealm includes the Maven plugin ID. The plugin ID is set in org.apache.maven.classrealm.DefaultClassRealmManager which includes the Maven group ID and artifact ID.

To be absolutely safe, the final version should be:

if (loader != null && loader.toString().contains("com.alexnederlof:jasperreports-plugin")) return false; // Relevant to bug #1036

@nicoschl
Copy link

Thank you for an excellent project! Can you please include it in an edge release? I would really like to test it. I see there are other fixes for eclipse in the release notes, that is of interest to me. Thank you!

@rzwitserloot
Copy link
Collaborator

Just pushed an edge release with this fix included.

@rzwitserloot rzwitserloot added this to the next-version milestone Mar 17, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

8 participants