question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

IllegalAccessError when creating CGLIB proxies for package-private classes using Spring DevTools

See original GitHub issue

I hit this error using gradle bootRun when spring-boot-devtools is on the classpath:

o.s.aop.framework.CglibAopProxy : Unable to proxy method [...] because it is package-visible across different ClassLoaders: All calls to this method via a proxy will NOT be routed to the target instance.
<snip>
java.lang.IllegalAccessError: class Foo$$EnhancerBySpringCGLIB$$8345c360 cannot access its superclass Foo

If I remove spring-boot-devtools, the application starts fine. I’m guessing this is due to the classloader architecture of spring-boot-devtools

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:13 (4 by maintainers)

github_iconTop GitHub Comments

6reactions
wilkinsonacommented, Jun 21, 2017

@kartoffelsup In your case the problem is because your application is split into multiple modules which can cause problems with DevTools’ restart class loader.

The proxy for BarServiceImpl is loaded by the restart class loader but BarServiceImpl itself is loaded by the app class loader. A package is scoped to the class loader that defined it so, in this case, we end up with two different org.bar.devtools.autoconfig.demo packages and a package-private type in one of those package is not visible to a type in the other of those packages.

You can fix the problem by adding bar to the restart class loader using META-INF/spring-devtools.properties:

restart.include.bar=/bar-.+\.jar
0reactions
kartoffelsupcommented, Jun 21, 2017

Ahh, thank you @wilkinsona 😃! Sorry for the inconvenience.

Read more comments on GitHub >

github_iconTop Results From Across the Web

IllegalAccessError when creating CGLIB proxies for package ...
I hit this error using gradle bootRun when spring-boot-devtools is on the classpath: o.s.aop.framework.CglibAopProxy : Unable to proxy ...
Read more >
CGLIB with spring throws IllegalAccessError - Stack Overflow
The issue is basically that Spring is instructing CGLIB to create the proxy class (subclass, com.company.int.components.core.registration.
Read more >
ClassCastException occured on Solver.solve in spring boot
Now that I know that this error is related to spring-boot-devtools, and that the error will not occur if ... at org.springframework.cglib.proxy.
Read more >
Bug List - Bugs - Eclipse
Let's make it more convenient to use. 2017-03-23 ... AJDT 2.2.3 (AJ 1.7.3) does not weaves classes in Kepler Java EE project with...
Read more >
Difference between JDK dynamic proxy and CGLib proxy in ...
It can create proxy by subclassing. Spring uses CGLIB for proxy if class is not implementing interface. Sr. No. Key, JDK dynamic proxy,...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found