spring-attic / spring-social

Allows you to connect your applications with SaaS providers such as Facebook and Twitter.
http://projects.spring.io/spring-social
Apache License 2.0
619 stars 351 forks source link

JdbcConnectionRepository does not work with Spring Boot DevTools #215

Closed arthurc closed 7 years ago

arthurc commented 7 years ago

JdbcConnectionRepository uses @ Transactional and thus creates a proxy using the restart class loader in Spring Boot DevTools. Because JdbcConnectionRepository is package private an exception is raised upon creation:

java.lang.IllegalAccessError: class org.springframework.social.connect.jdbc.JdbcConnectionRepository$$EnhancerBySpringCGLIB$$df73938 cannot access its superclass org.springframework.social.connect.jdbc.JdbcConnectionRepository
    at java.lang.ClassLoader.defineClass1(Native Method) ~[na:1.8.0_72]
    at java.lang.ClassLoader.defineClass(ClassLoader.java:760) ~[na:1.8.0_72]
    at sun.reflect.GeneratedMethodAccessor22.invoke(Unknown Source) ~[na:na]
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_72]
    at java.lang.reflect.Method.invoke(Method.java:498) ~[na:1.8.0_72]
    at org.springframework.cglib.core.ReflectUtils.defineClass(ReflectUtils.java:413) ~[spring-core-4.3.3.RELEASE.jar:4.3.3.RELEASE]
    at org.springframework.cglib.core.AbstractClassGenerator.generate(AbstractClassGenerator.java:336) ~[spring-core-4.3.3.RELEASE.jar:4.3.3.RELEASE]
    at org.springframework.cglib.proxy.Enhancer.generate(Enhancer.java:492) ~[spring-core-4.3.3.RELEASE.jar:4.3.3.RELEASE]
    at org.springframework.cglib.core.AbstractClassGenerator$ClassLoaderData$3.apply(AbstractClassGenerator.java:93) ~[spring-core-4.3.3.RELEASE.jar:4.3.3.RELEASE]
    at org.springframework.cglib.core.AbstractClassGenerator$ClassLoaderData$3.apply(AbstractClassGenerator.java:91) ~[spring-core-4.3.3.RELEASE.jar:4.3.3.RELEASE]
    at org.springframework.cglib.core.internal.LoadingCache$2.call(LoadingCache.java:54) ~[spring-core-4.3.3.RELEASE.jar:4.3.3.RELEASE]
    at java.util.concurrent.FutureTask.run(FutureTask.java:266) ~[na:1.8.0_72]
    at org.springframework.cglib.core.internal.LoadingCache.createEntry(LoadingCache.java:61) ~[spring-core-4.3.3.RELEASE.jar:4.3.3.RELEASE]
    at org.springframework.cglib.core.internal.LoadingCache.get(LoadingCache.java:34) ~[spring-core-4.3.3.RELEASE.jar:4.3.3.RELEASE]
    ...

If you want to use Spring Social with the JdbcConnectionRepository implementation, I see no other way than to make the ConnectionRepository implementations public. One can also argue that they should be public as they are exposed as public beans in the org.springframework.social.config.annotation.SocialConfiguration configuration class (the connectionRepository bean).

The InMemoryConnectionRepository does not create any proxies and thus does not suffer from the same issue, but I though that it should also be public for consistency.

pivotal-issuemaster commented 7 years ago

@arthurc Please sign the Contributor License Agreement!

Click here to manually synchronize the status of this Pull Request.

See the FAQ for frequently asked questions.

VadimKirilchuk commented 7 years ago

Hi, I can confirm the issue. Added spring social stuff into my application and was getting the following error on /connect/facebook:

There was an unexpected error (type=Internal Server Error, status=500). Error creating bean with name 'scopedTarget.connectionRepository' defined in class path resource [org/springframework/social/config/annotation/SocialConfiguration.class]: Initialization of bean failed; nested exception is org.springframework.aop.framework.AopConfigException: Could not generate CGLIB subclass of class [class org.springframework.social.connect.jdbc.JdbcConnectionRepository]: Common causes of this problem include using a final class or a non-visible class; nested exception is org.springframework.cglib.core.CodeGenerationException: java.lang.reflect.InvocationTargetException-->null

Tried to exclude dependencies of the project one by one and the issue was resolved by removing devtools from classpath. Bring it back and the issue reproduces again.

I was lucky enough to find this pull request. How long are you going to wait for the contributor to sign the license? (ugh, 4th of November and still not merged).

pivotal-issuemaster commented 7 years ago

@arthurc Thank you for signing the Contributor License Agreement!

arthurc commented 7 years ago

Sorry, missed the agreement. Fixed now

bshinyambalasovrn commented 7 years ago

I am still seeing this in version 1.4.5.RELEASE does anyone know which version this was fixed or point me to how I can find that out. Thanks

VadimKirilchuk commented 7 years ago

It works for me in 2.0.0.M1.

On Tue, Mar 14, 2017, 23:56 bshinyambala notifications@github.com wrote:

I am still seeing this in version 1.4.5.RELEASE does anyone know which version this was fixed or point me to how I can find that out. Thanks

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/spring-projects/spring-social/pull/215#issuecomment-286557419, or mute the thread https://github.com/notifications/unsubscribe-auth/AB35eSzRnM-luhs8tAcqyNjpSlIDTxgjks5rlv8JgaJpZM4Ko-rj .