Can't make API call urlfetch.Fetch in a thread that is neither the original request thread nor a thread created by ThreadManager - google-app-engine

I am currently playing with kotlin, Spring social and Google app engine. I am trying to get back a number of followers every second.
Here is my code :
#Service
class SubscribeService {
var subscriber : Disposable? = null
var twitter : Twitter = TwitterTemplate(
"XXXAUTHXXX",
"XXXAUTHXXX",
"XXXAUTHXXX",
"XXXAUTHXXX")
fun subscribe() {
subscriber = Observable.interval(1, TimeUnit.SECONDS).subscribe {println(twitter.userOperations().getUserProfile("azeaze").followersCount)}
}
fun unsubscribe() {
subscriber?.dispose()
}
}
I get this exception when I execute subscribe function :
[INFO] io.reactivex.exceptions.OnErrorNotImplementedException: Can't make API call urlfetch.Fetch in a thread that is neither the original request thread nor a thread created by ThreadManager
[INFO] at io.reactivex.internal.functions.Functions$OnErrorMissingConsumer.accept(Functions.java:704)
[INFO] at io.reactivex.internal.functions.Functions$OnErrorMissingConsumer.accept(Functions.java:701)
[INFO] at io.reactivex.internal.observers.LambdaObserver.onError(LambdaObserver.java:74)
[INFO] at io.reactivex.internal.observers.LambdaObserver.onNext(LambdaObserver.java:64)
[INFO] at io.reactivex.internal.operators.observable.ObservableInterval$IntervalObserver.run(ObservableInterval.java:83)
[INFO] at io.reactivex.internal.schedulers.ScheduledDirectPeriodicTask.run(ScheduledDirectPeriodicTask.java:39)
[INFO] at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
[INFO] at java.util.concurrent.FutureTask.runAndReset(FutureTask.java:308)
[INFO] at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$301(ScheduledThreadPoolExecutor.java:180)
[INFO] at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:294)
[INFO] at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
[INFO] at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
[INFO] at java.lang.Thread.run(Thread.java:748)
[INFO] Caused by: com.google.apphosting.api.ApiProxy$CallNotFoundException: Can't make API call urlfetch.Fetch in a thread that is neither the original request thread nor a thread created by ThreadManager
[INFO] at com.google.apphosting.api.ApiProxy$CallNotFoundException.foreignThread(ApiProxy.java:844)
[INFO] at com.google.apphosting.api.ApiProxy.makeSyncCall(ApiProxy.java:116)
[INFO] at com.google.appengine.api.urlfetch.URLFetchServiceImpl.fetch(URLFetchServiceImpl.java:40)
[INFO] at com.google.apphosting.utils.security.urlfetch.URLFetchServiceStreamHandler$Connection.fetchResponse(URLFetchServiceStreamHandler.java:543)
[INFO] at com.google.apphosting.utils.security.urlfetch.URLFetchServiceStreamHandler$Connection.getInputStream(URLFetchServiceStreamHandler.java:422)
[INFO] at com.google.apphosting.utils.security.urlfetch.URLFetchServiceStreamHandler$Connection.getResponseCode(URLFetchServiceStreamHandler.java:275)
[INFO] at org.springframework.http.client.SimpleBufferingClientHttpRequest.executeInternal(SimpleBufferingClientHttpRequest.java:84)
[INFO] at org.springframework.http.client.AbstractBufferingClientHttpRequest.executeInternal(AbstractBufferingClientHttpRequest.java:48)
[INFO] at org.springframework.http.client.AbstractClientHttpRequest.execute(AbstractClientHttpRequest.java:53)
[INFO] at org.springframework.http.client.InterceptingClientHttpRequest$InterceptingRequestExecution.execute(InterceptingClientHttpRequest.java:99)
[INFO] at org.springframework.social.oauth1.OAuth1RequestInterceptor.intercept(OAuth1RequestInterceptor.java:48)
[INFO] at org.springframework.http.client.InterceptingClientHttpRequest$InterceptingRequestExecution.execute(InterceptingClientHttpRequest.java:86)
[INFO] at org.springframework.http.client.InterceptingClientHttpRequest.executeInternal(InterceptingClientHttpRequest.java:70)
[INFO] at org.springframework.http.client.AbstractBufferingClientHttpRequest.executeInternal(AbstractBufferingClientHttpRequest.java:48)
[INFO] at org.springframework.http.client.AbstractClientHttpRequest.execute(AbstractClientHttpRequest.java:53)
[INFO] at org.springframework.web.client.RestTemplate.doExecute(RestTemplate.java:652)
[INFO] at org.springframework.web.client.RestTemplate.execute(RestTemplate.java:628)
[INFO] at org.springframework.web.client.RestTemplate.getForObject(RestTemplate.java:303)
[INFO] at org.springframework.social.twitter.api.impl.UserTemplate.getUserProfile(UserTemplate.java:60)
[INFO] at tbetous.SubscribeService$test$1.accept(SubscribeService.kt:20)
[INFO] at tbetous.SubscribeService$test$1.accept(SubscribeService.kt:11)
[INFO] at io.reactivex.internal.observers.LambdaObserver.onNext(LambdaObserver.java:60)
[INFO] ... 9 more
[INFO] Exception in thread "RxComputationThreadPool-1" io.reactivex.exceptions.OnErrorNotImplementedException: Can't make API call urlfetch.Fetch in a thread that is neither the original request thread nor a thread created by ThreadManager
[INFO] at io.reactivex.internal.functions.Functions$OnErrorMissingConsumer.accept(Functions.java:704)
[INFO] at io.reactivex.internal.functions.Functions$OnErrorMissingConsumer.accept(Functions.java:701)
[INFO] at io.reactivex.internal.observers.LambdaObserver.onError(LambdaObserver.java:74)
[INFO] at io.reactivex.internal.observers.LambdaObserver.onNext(LambdaObserver.java:64)
[INFO] at io.reactivex.internal.operators.observable.ObservableInterval$IntervalObserver.run(ObservableInterval.java:83)
[INFO] at io.reactivex.internal.schedulers.ScheduledDirectPeriodicTask.run(ScheduledDirectPeriodicTask.java:39)
[INFO] at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
[INFO] at java.util.concurrent.FutureTask.runAndReset(FutureTask.java:308)
[INFO] at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$301(ScheduledThreadPoolExecutor.java:180)
[INFO] at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:294)
[INFO] at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
[INFO] at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
[INFO] at java.lang.Thread.run(Thread.java:748)
[INFO] Caused by: com.google.apphosting.api.ApiProxy$CallNotFoundException: Can't make API call urlfetch.Fetch in a thread that is neither the original request thread nor a thread created by ThreadManager
[INFO] at com.google.apphosting.api.ApiProxy$CallNotFoundException.foreignThread(ApiProxy.java:844)
[INFO] at com.google.apphosting.api.ApiProxy.makeSyncCall(ApiProxy.java:116)
[INFO] at com.google.appengine.api.urlfetch.URLFetchServiceImpl.fetch(URLFetchServiceImpl.java:40)
[INFO] at com.google.apphosting.utils.security.urlfetch.URLFetchServiceStreamHandler$Connection.fetchResponse(URLFetchServiceStreamHandler.java:543)
[INFO] at com.google.apphosting.utils.security.urlfetch.URLFetchServiceStreamHandler$Connection.getInputStream(URLFetchServiceStreamHandler.java:422)
[INFO] at com.google.apphosting.utils.security.urlfetch.URLFetchServiceStreamHandler$Connection.getResponseCode(URLFetchServiceStreamHandler.java:275)
[INFO] at org.springframework.http.client.SimpleBufferingClientHttpRequest.executeInternal(SimpleBufferingClientHttpRequest.java:84)
[INFO] at org.springframework.http.client.AbstractBufferingClientHttpRequest.executeInternal(AbstractBufferingClientHttpRequest.java:48)
[INFO] at org.springframework.http.client.AbstractClientHttpRequest.execute(AbstractClientHttpRequest.java:53)
[INFO] at org.springframework.http.client.InterceptingClientHttpRequest$InterceptingRequestExecution.execute(InterceptingClientHttpRequest.java:99)
[INFO] at org.springframework.social.oauth1.OAuth1RequestInterceptor.intercept(OAuth1RequestInterceptor.java:48)
[INFO] at org.springframework.http.client.InterceptingClientHttpRequest$InterceptingRequestExecution.execute(InterceptingClientHttpRequest.java:86)
[INFO] at org.springframework.http.client.InterceptingClientHttpRequest.executeInternal(InterceptingClientHttpRequest.java:70)
[INFO] at org.springframework.http.client.AbstractBufferingClientHttpRequest.executeInternal(AbstractBufferingClientHttpRequest.java:48)
[INFO] at org.springframework.http.client.AbstractClientHttpRequest.execute(AbstractClientHttpRequest.java:53)
[INFO] at org.springframework.web.client.RestTemplate.doExecute(RestTemplate.java:652)
[INFO] at org.springframework.web.client.RestTemplate.execute(RestTemplate.java:628)
[INFO] at org.springframework.web.client.RestTemplate.getForObject(RestTemplate.java:303)
[INFO] at org.springframework.social.twitter.api.impl.UserTemplate.getUserProfile(UserTemplate.java:60)
[INFO] at tbetous.SubscribeService$test$1.accept(SubscribeService.kt:20)
[INFO] at tbetous.SubscribeService$test$1.accept(SubscribeService.kt:11)
[INFO] at io.reactivex.internal.observers.LambdaObserver.onNext(LambdaObserver.java:60)
[INFO] ... 9 more
I am pretty sure it is something about google app engine. When I run my application I use mvn appengine:devserver. Can anyone help me ?

I found my solution. Thanks to this link. GAE does not work with RxJava beacause It does not respect thred restriction of Google standard environnent. I had to specify how RxJava have to create thread.
Here is my code :
val scheduler : Scheduler = Schedulers.from(ScheduledThreadPoolExecutor(3, ThreadManager.backgroundThreadFactory()))
RxJavaPlugins.setComputationSchedulerHandler { scheduler }
After that I can use RxJava :
subscriber = Observable.interval(1, TimeUnit.SECONDS)
.map { twitter.userOperations().getUserProfile("azeazeaz").followersCount }
.subscribe {it -> println(it)}

Related

Akka Http read entity fails with Substream Source cannot be materialized more than once

When I am trying to consume the data on server into memory and later I want to create strict entity with it, but getting Substream Source cannot be materialized more than once error message.
As far as I know I am not consuming the data from the request more than once (from application layer not investigated akka-http library layer). Requests are successful with small chunk of data, failing with bigger (around 10 KB) chunk of data
First try:
if (!entity.isChunked()) {
entity.dataBytes.runFold(ByteString.empty)(_ ++ _).flatMap { encryptedBody =>
decrypt(encryptedBody).map { decrypted =>
HttpEntity(decrypted)
}
}
}
also tried following (suggestion in Akka http -ERROR :Substream Source cannot be materialized more than once If Payload size increased) but no luck
Second try (with strict):
entity.toStrict(4.seconds).flatMap { strictEntity =>
decrypt(strictEntity.data).map { decrypted =>
HttpEntity(decrypted)
}
}
AkkaHttp Version: 10.0.13 ( We are in the process of migrating to latest version, we are kind of stuck with older version)
Akka Version : 2.4.20
Any kind of help would be great.
Stack trace is:
[info] java.lang.IllegalStateException: Substream Source cannot be materialized more than once
[info] at akka.stream.impl.fusing.SubSource$$anon$4.setCB(StreamOfStreams.scala:725)
[info] at akka.stream.impl.fusing.SubSource$$anon$4.preStart(StreamOfStreams.scala:735)
[info] at akka.stream.impl.fusing.GraphInterpreter.init(GraphInterpreter.scala:520)
[info] at akka.stream.impl.fusing.GraphInterpreterShell.init(ActorGraphInterpreter.scala:380)
[info] at akka.stream.impl.fusing.ActorGraphInterpreter.tryInit(ActorGraphInterpreter.scala:538)
[info] at akka.stream.impl.fusing.ActorGraphInterpreter.preStart(ActorGraphInterpreter.scala:586)
[info] at akka.actor.Actor$class.aroundPreStart(Actor.scala:510)
[info] at akka.stream.impl.fusing.ActorGraphInterpreter.aroundPreStart(ActorGraphInterpreter.scala:529)
[info] at akka.actor.ActorCell.create(ActorCell.scala:590)
[info] at akka.actor.ActorCell.invokeAll$1_aroundBody2(ActorCell.scala:461)
[info] at akka.actor.ActorCell$AjcClosure3.run(ActorCell.scala:1)
[info] at org.aspectj.runtime.reflect.JoinPointImpl.proceed(JoinPointImpl.java:149)
[info] at akka.kamon.instrumentation.ActorSystemMessageInstrumentation$$anonfun$aroundSystemMessageInvoke$1.apply(ActorSystemMessageInstrumentation.scala:34)
[info] at kamon.trace.Tracer$.withContext(TracerModule.scala:58)
[info] at akka.kamon.instrumentation.ActorSystemMessageInstrumentation.aroundSystemMessageInvoke(ActorSystemMessageInstrumentation.scala:34)
[info] at akka.actor.ActorCell.invokeAll$1(ActorCell.scala:1)
[info] at akka.actor.ActorCell.systemInvoke(ActorCell.scala:483)
[info] at akka.dispatch.Mailbox.processAllSystemMessages(Mailbox.scala:282)
[info] at akka.dispatch.Mailbox.run(Mailbox.scala:223)
[info] at akka.dispatch.Mailbox.exec(Mailbox.scala:234)
[info] at scala.concurrent.forkjoin.ForkJoinTask.doExec(ForkJoinTask.java:260)
[info] at scala.concurrent.forkjoin.ForkJoinPool$WorkQueue.runTask(ForkJoinPool.java:1339)
[info] at scala.concurrent.forkjoin.ForkJoinPool.runWorker(ForkJoinPool.java:1979)
[info] at scala.concurrent.forkjoin.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:107)
Failing because the entity was read more than once.
In the beginning, I could not figure it out because the reading was happening at the time validation, and it is deeply buried in the validations. (one of the validation depends on body content)
I tried strict entity conversion after the validations, so it did not work out.

BadCredentialsException: Could not obtain access token with spring boot security Oauth2 on GAE

I am currently developping a small web application with spring boot. I would like to use google oauth2 to login my user. All worked like a charm in localhost on my computer but when I deploy my app in GAE I get an error.
Here is the error stack I got from dev server on GAE. I guess the error is the same in production mode.
[INFO] 2017-08-27 17:02:31.290 DEBUG 630 --- [tp1134612201-18] g.c.AuthorizationCodeAccessTokenProvider : Retrieving token from https://www.googleapis.com/oauth2/v4/token
[INFO] 2017-08-27 17:02:31.565 DEBUG 630 --- [tp1134612201-18] o.s.web.client.RestTemplate : Created POST request for "https://www.googleapis.com/oauth2/v4/token"
[INFO] 2017-08-27 17:02:31.566 DEBUG 630 --- [tp1134612201-18] g.c.AuthorizationCodeAccessTokenProvider : Encoding and sending form: {grant_type=[authorization_code], code=[4/PmvPPmFGQF0PamafaItFDiqKT_RwZN4RkdoydpxOTD4], redirect_uri=[https://127.0.0.1:8080/login], client_id=[XXX], client_secret=[YYY]}
[INFO] 2017-08-27 17:02:32.905 DEBUG 630 --- [tp1134612201-18] o.s.web.client.RestTemplate : POST request for "https://www.googleapis.com/oauth2/v4/token" resulted in 400 (OK); invoking error handler
[INFO] 2017-08-27 17:02:33.343 DEBUG 630 --- [tp1134612201-18] o.s.b.f.s.DefaultListableBeanFactory : Returning cached instance of singleton bean 'delegatingApplicationListener'
[INFO] 2017-08-27 17:02:33.381 DEBUG 630 --- [tp1134612201-18] uth2ClientAuthenticationProcessingFilter : Authentication request failed: org.springframework.security.authentication.BadCredentialsException: Could not obtain access token
[INFO]
[INFO] org.springframework.security.authentication.BadCredentialsException: Could not obtain access token
[INFO] at org.springframework.security.oauth2.client.filter.OAuth2ClientAuthenticationProcessingFilter.attemptAuthentication(OAuth2ClientAuthenticationProcessingFilter.java:107)
[INFO] at org.springframework.security.web.authentication.AbstractAuthenticationProcessingFilter.doFilter(AbstractAuthenticationProcessingFilter.java:212)
[INFO] at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:331)
[INFO] at org.springframework.security.web.authentication.logout.LogoutFilter.doFilter(LogoutFilter.java:116)
[INFO] at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:331)
[INFO] at org.springframework.security.web.csrf.CsrfFilter.doFilterInternal(CsrfFilter.java:100)
[INFO] at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
[INFO] at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:331)
[INFO] at org.springframework.security.web.header.HeaderWriterFilter.doFilterInternal(HeaderWriterFilter.java:64)
[INFO] at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
[INFO] at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:331)
[INFO] at org.springframework.security.web.context.SecurityContextPersistenceFilter.doFilter(SecurityContextPersistenceFilter.java:105)
[INFO] at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:331)
[INFO] at org.springframework.security.web.context.request.async.WebAsyncManagerIntegrationFilter.doFilterInternal(WebAsyncManagerIntegrationFilter.java:56)
[INFO] at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
[INFO] at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:331)
[INFO] at org.springframework.security.web.FilterChainProxy.doFilterInternal(FilterChainProxy.java:214)
[INFO] at org.springframework.security.web.FilterChainProxy.doFilter(FilterChainProxy.java:177)
[INFO] at org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:346)
[INFO] at org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:262)
[INFO] at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1759)
[INFO] at org.springframework.web.filter.RequestContextFilter.doFilterInternal(RequestContextFilter.java:99)
[INFO] at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
[INFO] at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1759)
[INFO] at org.springframework.security.oauth2.client.filter.OAuth2ClientContextFilter.doFilter(OAuth2ClientContextFilter.java:60)
[INFO] at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1759)
[INFO] at org.springframework.web.filter.HttpPutFormContentFilter.doFilterInternal(HttpPutFormContentFilter.java:105)
[INFO] at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
[INFO] at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1759)
[INFO] at org.springframework.web.filter.HiddenHttpMethodFilter.doFilterInternal(HiddenHttpMethodFilter.java:81)
[INFO] at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
[INFO] at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1759)
[INFO] at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:197)
[INFO] at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
[INFO] at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1759)
[INFO] at org.springframework.boot.web.support.ErrorPageFilter.doFilter(ErrorPageFilter.java:115)
[INFO] at org.springframework.boot.web.support.ErrorPageFilter.access$000(ErrorPageFilter.java:59)
[INFO] at org.springframework.boot.web.support.ErrorPageFilter$1.doFilterInternal(ErrorPageFilter.java:90)
[INFO] at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
[INFO] at org.springframework.boot.web.support.ErrorPageFilter.doFilter(ErrorPageFilter.java:108)
[INFO] at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1759)
[INFO] at org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:582)
[INFO] at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:143)
[INFO] at org.eclipse.jetty.security.SecurityHandler.handle(SecurityHandler.java:524)
[INFO] at org.eclipse.jetty.server.session.SessionHandler.doHandle(SessionHandler.java:226)
[INFO] at org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1180)
[INFO] at org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:512)
[INFO] at org.eclipse.jetty.server.session.SessionHandler.doScope(SessionHandler.java:185)
[INFO] at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:1112)
[INFO] at com.google.appengine.tools.development.jetty9.DevAppEngineWebAppContext.doScope(DevAppEngineWebAppContext.java:94)
[INFO] at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:141)
[INFO] at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:134)
[INFO] at com.google.appengine.tools.development.jetty9.JettyContainerService$ApiProxyHandler.handle(JettyContainerService.java:597)
[INFO] at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:134)
[INFO] at org.eclipse.jetty.server.Server.handle(Server.java:534)
[INFO] at org.eclipse.jetty.server.HttpChannel.handle(HttpChannel.java:320)
[INFO] at org.eclipse.jetty.server.HttpConnection.onFillable(HttpConnection.java:251)
[INFO] at org.eclipse.jetty.io.AbstractConnection$ReadCallback.succeeded(AbstractConnection.java:283)
[INFO] at org.eclipse.jetty.io.FillInterest.fillable(FillInterest.java:108)
[INFO] at org.eclipse.jetty.io.SelectChannelEndPoint$2.run(SelectChannelEndPoint.java:93)
[INFO] at org.eclipse.jetty.util.thread.strategy.ExecuteProduceConsume.executeProduceConsume(ExecuteProduceConsume.java:303)
[INFO] at org.eclipse.jetty.util.thread.strategy.ExecuteProduceConsume.produceConsume(ExecuteProduceConsume.java:148)
[INFO] at org.eclipse.jetty.util.thread.strategy.ExecuteProduceConsume.run(ExecuteProduceConsume.java:136)
[INFO] at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:671)
[INFO] at org.eclipse.jetty.util.thread.QueuedThreadPool$2.run(QueuedThreadPool.java:589)
[INFO] at java.lang.Thread.run(Thread.java:748)
[INFO] Caused by: org.springframework.security.oauth2.client.resource.OAuth2AccessDeniedException: Access token denied.
[INFO] at org.springframework.security.oauth2.client.token.OAuth2AccessTokenSupport.retrieveToken(OAuth2AccessTokenSupport.java:142)
[INFO] at org.springframework.security.oauth2.client.token.grant.code.AuthorizationCodeAccessTokenProvider.obtainAccessToken(AuthorizationCodeAccessTokenProvider.java:209)
[INFO] at org.springframework.security.oauth2.client.OAuth2RestTemplate.acquireAccessToken(OAuth2RestTemplate.java:221)
[INFO] at org.springframework.security.oauth2.client.OAuth2RestTemplate.getAccessToken(OAuth2RestTemplate.java:173)
[INFO] at org.springframework.security.oauth2.client.filter.OAuth2ClientAuthenticationProcessingFilter.attemptAuthentication(OAuth2ClientAuthenticationProcessingFilter.java:105)
[INFO] ... 65 common frames omitted
[INFO] Caused by: org.springframework.security.oauth2.common.exceptions.RedirectMismatchException: Bad Request
[INFO] at org.springframework.security.oauth2.common.exceptions.OAuth2ExceptionJackson2Deserializer.deserialize(OAuth2ExceptionJackson2Deserializer.java:103)
[INFO] at org.springframework.security.oauth2.common.exceptions.OAuth2ExceptionJackson2Deserializer.deserialize(OAuth2ExceptionJackson2Deserializer.java:33)
[INFO] at com.fasterxml.jackson.databind.ObjectMapper._readMapAndClose(ObjectMapper.java:3798)
[INFO] at com.fasterxml.jackson.databind.ObjectMapper.readValue(ObjectMapper.java:2922)
[INFO] at org.springframework.http.converter.json.AbstractJackson2HttpMessageConverter.readJavaType(AbstractJackson2HttpMessageConverter.java:237)
[INFO] at org.springframework.http.converter.json.AbstractJackson2HttpMessageConverter.readInternal(AbstractJackson2HttpMessageConverter.java:217)
[INFO] at org.springframework.http.converter.AbstractHttpMessageConverter.read(AbstractHttpMessageConverter.java:193)
[INFO] at org.springframework.security.oauth2.client.token.OAuth2AccessTokenSupport$AccessTokenErrorHandler.handleError(OAuth2AccessTokenSupport.java:235)
[INFO] at org.springframework.web.client.RestTemplate.handleResponse(RestTemplate.java:700)
[INFO] at org.springframework.web.client.RestTemplate.doExecute(RestTemplate.java:653)
[INFO] at org.springframework.web.client.RestTemplate.execute(RestTemplate.java:621)
[INFO] at org.springframework.security.oauth2.client.token.OAuth2AccessTokenSupport.retrieveToken(OAuth2AccessTokenSupport.java:137)
[INFO] ... 69 common frames omitted
Here is my configuration :
application.yml :
security:
oauth2:
client:
clientId: XXXXX
clientSecret: XXXXX
accessTokenUri: https://www.googleapis.com/oauth2/v4/token
userAuthorizationUri: https://accounts.google.com/o/oauth2/v2/auth
clientAuthenticationScheme: form
scope:
- openid
- email
- profile
resource:
userInfoUri: https://www.googleapis.com/oauth2/v3/userinfo
preferTokenInfo: true
Spring Security configuration :
#Configuration
#EnableOAuth2Sso
#EnableWebSecurity
class WebSecurityConfig : WebSecurityConfigurerAdapter() {
#Throws(Exception::class)
override fun configure(http: HttpSecurity) {
http
.authorizeRequests()
.antMatchers("/", "/home", "/webjars/**", "/count", "/login")
.permitAll()
.anyRequest()
.authenticated()
.and()
.formLogin()
.loginPage("/login")
.permitAll()
.and()
.logout()
.logoutUrl("/logout")
.logoutSuccessUrl("/")
.permitAll()
}
}
MVC controller :
#Configuration
class MvcConfiguration : WebMvcConfigurerAdapter() {
override fun addViewControllers(registry: ViewControllerRegistry?) {
super.addViewControllers(registry)
registry?.addViewController("/home")?.setViewName("home");
registry?.addViewController("/")?.setViewName("home");
registry?.addViewController("/hello")?.setViewName("hello");
}
}
The redirection page I set in my google api console is : https://my-awesome-app.appspot.com/login. All worked when I was testing on http://localhost:8080. There is maybe something with ssl ?
By the way, I am using kotlin. But it is very similar to Java
Can anyone help me ?
It's hard to find the right answer as the full stack trace is not printed out.
Looking at the stack trace, a few key errors state:
[INFO] org.springframework.security.authentication.BadCredentialsException: Could not obtain access token
...
[INFO] Caused by: org.springframework.security.oauth2.client.resource.OAuth2AccessDeniedException: Access token denied.
This indicates that the OAuth Client for your application is not properly authenticated or that the credentials you are using are not valid.
Rather than setting your own Access Token and User Auth URIs, I recommend using the Google Java API Client which will handle this for you:
https://github.com/googleapis/google-api-java-client
We have some G Suite samples that show OAuth flows here:
https://github.com/gsuitedevs/java-samples
Perhaps this answer may be useful too:
Get user info via Google API

java.io.NotSerializableException With Java 8/Jetty 9 Compat App Engine Environment

When attempting to upload a file to a Google App Engine Application running in the Java 8/Jetty 9 Compatible Managed VM environment, I get the following stack trace because the org.eclipse.jetty.util.MultiPartInputStreamParser$MultiPart class does NOT implement the java.io.Serializable interface.
I get the following exception:
[INFO] java.io.NotSerializableException: org.eclipse.jetty.util.MultiPartInputStreamParser$MultiPart
[INFO] at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1184)
[INFO] at java.io.ObjectOutputStream.defaultWriteFields(ObjectOutputStream.java:1548)
[INFO] at java.io.ObjectOutputStream.writeSerialData(ObjectOutputStream.java:1509)
[INFO] at java.io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java:1432)
[INFO] at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1178)
[INFO] at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:348)
[INFO] at java.util.HashMap.internalWriteEntries(HashMap.java:1777)
[INFO] at java.util.HashMap.writeObject(HashMap.java:1354)
[INFO] at sun.reflect.GeneratedMethodAccessor24.invoke(Unknown Source)
[INFO] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
[INFO] at java.lang.reflect.Method.invoke(Method.java:498)
[INFO] at java.io.ObjectStreamClass.invokeWriteObject(ObjectStreamClass.java:1028)
[INFO] at java.io.ObjectOutputStream.writeSerialData(ObjectOutputStream.java:1496)
[INFO] at java.io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java:1432)
[INFO] at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1178)
[INFO] at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:348)
[INFO] at java.util.LinkedHashMap.internalWriteEntries(LinkedHashMap.java:333)
[INFO] at java.util.HashMap.writeObject(HashMap.java:1354)
[INFO] at sun.reflect.GeneratedMethodAccessor24.invoke(Unknown Source)
[INFO] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
[INFO] at java.lang.reflect.Method.invoke(Method.java:498)
[INFO] at java.io.ObjectStreamClass.invokeWriteObject(ObjectStreamClass.java:1028)
[INFO] at java.io.ObjectOutputStream.writeSerialData(ObjectOutputStream.java:1496)
[INFO] at java.io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java:1432)
[INFO] at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1178)
[INFO] at java.io.ObjectOutputStream.defaultWriteFields(ObjectOutputStream.java:1548)
[INFO] at java.io.ObjectOutputStream.defaultWriteObject(ObjectOutputStream.java:441)
[INFO] at java.util.Collections$SynchronizedMap.writeObject(Collections.java:2691)
[INFO] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
[INFO] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
[INFO] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
[INFO] at java.lang.reflect.Method.invoke(Method.java:498)
[INFO] at java.io.ObjectStreamClass.invokeWriteObject(ObjectStreamClass.java:1028)
[INFO] at java.io.ObjectOutputStream.writeSerialData(ObjectOutputStream.java:1496)
[INFO] at java.io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java:1432)
[INFO] at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1178)
[INFO] at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:348)
[INFO] at java.util.HashMap.internalWriteEntries(HashMap.java:1777)
[INFO] at java.util.HashMap.writeObject(HashMap.java:1354)
[INFO] at sun.reflect.GeneratedMethodAccessor24.invoke(Unknown Source)
[INFO] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
[INFO] at java.lang.reflect.Method.invoke(Method.java:498)
[INFO] at java.io.ObjectStreamClass.invokeWriteObject(ObjectStreamClass.java:1028)
[INFO] at java.io.ObjectOutputStream.writeSerialData(ObjectOutputStream.java:1496)
[INFO] at java.io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java:1432)
[INFO] at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1178)
[INFO] at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:348)
[INFO] at com.google.apphosting.runtime.SessionManagerUtil.serialize(SessionManagerUtil.java:28)
[INFO] at com.google.apphosting.runtime.DatastoreSessionStore.createEntityForSession(DatastoreSessionStore.java:73)
[INFO] at com.google.apphosting.runtime.DatastoreSessionStore.saveSession(DatastoreSessionStore.java:112)
[INFO] at com.google.apphosting.runtime.jetty9.SessionManager$AppEngineSession.save(SessionManager.java:145)
[INFO] at com.google.apphosting.runtime.jetty9.SaveSessionFilter.doFilter(SaveSessionFilter.java:43)
[INFO] at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1652)
[INFO] at com.google.apphosting.utils.servlet.TransactionCleanupFilter.doFilter(TransactionCleanupFilter.java:43)
[INFO] at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1652)
[INFO] at org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:585)
[INFO] at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:143)
[INFO] at org.eclipse.jetty.security.SecurityHandler.handle(SecurityHandler.java:553)
[INFO] at org.eclipse.jetty.server.session.SessionHandler.doHandle(SessionHandler.java:223)
[INFO] at org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1127)
[INFO] at org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:515)
[INFO] at org.eclipse.jetty.server.session.SessionHandler.doScope(SessionHandler.java:185)
[INFO] at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:1061)
[INFO] at com.google.apphosting.vmruntime.jetty9.VmRuntimeWebAppContext.doScope(VmRuntimeWebAppContext.java:299)
[INFO] at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:141)
[INFO] at org.eclipse.jetty.server.handler.ContextHandlerCollection.handle(ContextHandlerCollection.java:215)
[INFO] at org.eclipse.jetty.server.handler.HandlerCollection.handle(HandlerCollection.java:110)
[INFO] at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:97)
[INFO] at org.eclipse.jetty.server.Server.handle(Server.java:497)
[INFO] at org.eclipse.jetty.server.HttpChannel.handle(HttpChannel.java:310)
[INFO] at org.eclipse.jetty.server.HttpConnection.onFillable(HttpConnection.java:257)
[INFO] at org.eclipse.jetty.io.AbstractConnection$2.run(AbstractConnection.java:540)
[INFO] at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:635)
[INFO] at org.eclipse.jetty.util.thread.QueuedThreadPool$3.run(QueuedThreadPool.java:555)
[INFO] at java.lang.Thread.run(Thread.java:745)
As you see there:
[INFO] at com.google.apphosting.runtime.SessionManagerUtil.serialize(SessionManagerUtil.java:28)
[INFO] at com.google.apphosting.runtime.DatastoreSessionStore.createEntityForSession(DatastoreSessionStore.java:73)
[INFO] at com.google.apphosting.runtime.DatastoreSessionStore.saveSession(DatastoreSessionStore.java:112)
[INFO] at com.google.apphosting.runtime.jetty9.SessionManager$AppEngineSession.save(SessionManager.java:145)
[INFO] at com.google.apphosting.runtime.jetty9.SaveSessionFilter.doFilter(SaveSessionFilter.java:43)
server is trying to put MultiPartInputStreamParser into user Session (and save to database). You shouldn't do that.

Permission denied error in app engine code

I am getting the below error in the line 5 while executing the app engine code in localhost and in cloud.
1 HttpClient client = new HttpClient();
2 GetMethod getMethod =new GetMethod(url);
3 client.getHttpConnectionManager().getParams()
4 .setConnectionTimeout(1000);
5 int response = client.executeMethod(getMethod);
I am seeing this error while running the job in localhost and in app engine.
Please find the error logs below:
INFO] 2016-03-07 11:04:03 DEBUG HttpConnection:1215 - enter HttpConnection.closeSockedAndStreams()
[INFO] 2016-03-07 11:04:03 INFO HttpMethodDirector:439 - I/O exception (java.net.SocketException) caught when processing request: Permission denied: Not allowe
d to issue a socket bind: permission denied.
[INFO] 2016-03-07 11:04:03 DEBUG HttpMethodDirector:443 - Permission denied: Not allowed to issue a socket bind: permission denied.
[INFO] java.net.SocketException: Permission denied: Not allowed to issue a socket bind: permission denied.
[INFO] at com.google.appengine.api.socket.SocketApiHelper.translateError(SocketApiHelper.java:95)
[INFO] at com.google.appengine.api.socket.SocketApiHelper.translateError(SocketApiHelper.java:106)
[INFO] at com.google.appengine.api.socket.SocketApiHelper.makeSyncCall(SocketApiHelper.java:74)
[INFO] at com.google.appengine.api.socket.AppEngineSocketImpl.createSocket(AppEngineSocketImpl.java:470)
[INFO] at com.google.appengine.api.socket.AppEngineSocketImpl.bind(AppEngineSocketImpl.java:486)
[INFO] at java.net.Socket.bind(Socket.java:631)
[INFO] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
[INFO] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
[INFO] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
[INFO] at java.lang.reflect.Method.invoke(Method.java:606)
[INFO] at com.google.appengine.tools.development.agent.runtime.Runtime.invoke(Runtime.java:130)
[INFO] at org.apache.commons.httpclient.protocol.ReflectionSocketFactory.createSocket(ReflectionSocketFactory.java:139)
[INFO] at org.apache.commons.httpclient.protocol.DefaultProtocolSocketFactory.createSocket(DefaultProtocolSocketFactory.java:125)
[INFO] at org.apache.commons.httpclient.HttpConnection.open(HttpConnection.java:707)
[INFO] at org.apache.commons.httpclient.HttpMethodDirector.executeWithRetry(HttpMethodDirector.java:387)
[INFO] at org.apache.commons.httpclient.HttpMethodDirector.executeMethod(HttpMethodDirector.java:171)
[INFO] at org.apache.commons.httpclient.HttpClient.executeMethod(HttpClient.java:397)
[INFO] at org.apache.commons.httpclient.HttpClient.executeMethod(HttpClient.java:323)
[INFO] at com.disney.unityads.UnityAdsStats.downloadZip(UnityAdsStats.java:169)
[INFO] at com.disney.unityads.UnityAdsStats.run(UnityAdsStats.java:72)
[INFO] at com.disney.unityads.UnityAdsChannelJobWorker.doPost(UnityAdsChannelJobWorker.java:46)
[INFO] at javax.servlet.http.HttpServlet.service(HttpServlet.java:637)
[INFO] at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
[INFO] at org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:511)
[INFO] at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1166)
Check the documentation for how to make HTTP requests. AppEngine is a very limited environment, for example if you try to use an alternative HTTP client your app gets the same treatment as one that tries to use sockets directly.
https://cloud.google.com/appengine/docs/java/urlfetch/

Failed to create proxy for classes marked with #Transactional annotation on App Engine

I am trying sample app on App Engine. Here I am trying JPA Transaction manager as follows.
<context:component-scan base-package="com.pokuri.havasay"/>
<context:annotation-config/>
<bean id="entityManagerFactory" class="org.springframework.orm.jpa.LocalEntityManagerFactoryBean">
<property name="persistenceUnitName" value="pokuri-havasay"/>
</bean>
<bean id="transactionManager" class="org.springframework.orm.jpa.JpaTransactionManager">
<property name="entityManagerFactory" ref="entityManagerFactory" />
</bean>
<bean class="org.springframework.orm.jpa.support.PersistenceAnnotationBeanPostProcessor"/>
<tx:annotation-driven transaction-manager="transactionManager" proxy-target-class="true"/>
And I have annotated my service without interface with org.springframework.transaction.annotation.Transactional as follows
#Service
#Transactional
public class UserManagementService {
}
Now I see that on starting app on App Engine getting following proxy creation exception
[INFO] org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'userManagementService' defined in file [E:\workspace\pokuri-havasay\target\pokuri-havasay-1.0-SNAPSHOT\WEB-INF\classes\com\pokuri\havasay\user\services\UserManagementService.class]: Initialization of bean failed; nested exception is org.springframework.aop.framework.AopConfigException: Could
[INFO] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:547)
[INFO] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:476)
[INFO] at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:303)
[INFO] at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230)
[INFO] at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:299)
[INFO] at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:194)
[INFO] at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:755)
[INFO] at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:757)
[INFO] at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:480)
[INFO] at org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(ContextLoader.java:403)
[INFO] at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:306)
[INFO] at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:106)
[INFO] at org.mortbay.jetty.handler.ContextHandler.startContext(ContextHandler.java:548)
[INFO] at org.mortbay.jetty.servlet.Context.startContext(Context.java:136)
[INFO] at org.mortbay.jetty.webapp.WebAppContext.startContext(WebAppContext.java:1250)
[INFO] at org.mortbay.jetty.handler.ContextHandler.doStart(ContextHandler.java:517)
[INFO] at org.mortbay.jetty.webapp.WebAppContext.doStart(WebAppContext.java:467)
[INFO] at org.mortbay.component.AbstractLifeCycle.start(AbstractLifeCycle.java:50)
[INFO] at org.mortbay.jetty.handler.HandlerWrapper.doStart(HandlerWrapper.java:130)
[INFO] at org.mortbay.component.AbstractLifeCycle.start(AbstractLifeCycle.java:50)
[INFO] at com.google.appengine.tools.development.JettyContainerService.reloadWebApp(JettyContainerService.java:422)
[INFO] at com.google.appengine.tools.development.JettyContainerService$2.filesChanged(JettyContainerService.java:380)
[INFO] at org.mortbay.util.Scanner.reportBulkChanges(Scanner.java:486)
[INFO] at org.mortbay.util.Scanner.reportDifferences(Scanner.java:352)
[INFO] at org.mortbay.util.Scanner.scan(Scanner.java:280)
[INFO] at org.mortbay.util.Scanner$1.run(Scanner.java:232)
[INFO] at java.util.TimerThread.mainLoop(Timer.java:555)
[INFO] at java.util.TimerThread.run(Timer.java:505)
[INFO] Caused by: org.springframework.aop.framework.AopConfigException: Could not generate CGLIB subclass of class [class com.pokuri.havasay.user.services.UserManagementService]: 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
[INFO] at org.springframework.aop.framework.CglibAopProxy.getProxy(CglibAopProxy.java:206)
[INFO] at org.springframework.aop.framework.ProxyFactory.getProxy(ProxyFactory.java:109)
[INFO] at org.springframework.aop.framework.autoproxy.AbstractAutoProxyCreator.createProxy(AbstractAutoProxyCreator.java:447)
[INFO] at org.springframework.aop.framework.autoproxy.AbstractAutoProxyCreator.wrapIfNecessary(AbstractAutoProxyCreator.java:333)
[INFO] at org.springframework.aop.framework.autoproxy.AbstractAutoProxyCreator.postProcessAfterInitialization(AbstractAutoProxyCreator.java:293)
[INFO] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyBeanPostProcessorsAfterInitialization(AbstractAutowireCapableBeanFactory.java:422)
[INFO] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1571)
[INFO] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:539)
[INFO] ... 27 more
[INFO] Caused by: org.springframework.cglib.core.CodeGenerationException: java.lang.reflect.InvocationTargetException-->null
[INFO] at org.springframework.cglib.core.AbstractClassGenerator.create(AbstractClassGenerator.java:237)
[INFO] at org.springframework.cglib.proxy.Enhancer.createHelper(Enhancer.java:377)
[INFO] at org.springframework.cglib.proxy.Enhancer.create(Enhancer.java:285)
[INFO] at org.springframework.aop.framework.CglibAopProxy.createProxyClassAndInstance(CglibAopProxy.java:227)
[INFO] at org.springframework.aop.framework.ObjenesisCglibAopProxy.createProxyClassAndInstance(ObjenesisCglibAopProxy.java:66)
[INFO] at org.springframework.aop.framework.CglibAopProxy.getProxy(CglibAopProxy.java:202)
[INFO] ... 34 more
[INFO] Caused by: java.lang.reflect.InvocationTargetException
[INFO] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
[INFO] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
[INFO] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
[INFO] at java.lang.reflect.Method.invoke(Method.java:483)
[INFO] at com.google.appengine.tools.development.agent.runtime.Runtime.invoke(Runtime.java:130)
[INFO] at org.springframework.cglib.core.ReflectUtils.defineClass(ReflectUtils.java:384)
[INFO] at org.springframework.cglib.core.AbstractClassGenerator.create(AbstractClassGenerator.java:219)
[INFO] ... 39 more
[INFO] Caused by: java.lang.LinkageError: loader (instance of com/google/appengine/tools/development/IsolatedAppClassLoader): attempted duplicate class definition for name: "com/pokuri/havasay/user/services/UserManagementService$$EnhancerBySpringCGLIB$$5f9cad7d"
[INFO] at java.lang.ClassLoader.defineClass1(Native Method)
[INFO] at java.lang.ClassLoader.defineClass(ClassLoader.java:760)
[INFO] ... 46 more
[INFO]
But when I deploy the same war on tomcat I don't see any issue and spring able to create proxy for the services. And no issue if I have implemented interfaces. When I don't have interfaces then only I see this issue.
Please guide me in fixing this

Resources