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.
Related
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
I'm trying asynchronous processing support in servlet 3.1 with GAE J8 standard environment (no extensible environment).
Basically I have a servlet annotated with
#WebServlet(name = "MyServletName", urlPatterns = {"/dosomething"}, asyncSupported = true)
and to obtain an instance of AsyncContext I call (in doPost method)
final AsyncContext asyncContext = httpServletRequest.startAsync(httpServletRequest, httpServletResponse);
But asynchronous processing support seems to have some problems in GAE
Local development server says:
[INFO] GCLOUD: java.lang.IllegalStateException: !asyncSupported: _ah_DevAppServerModulesFilter
[INFO] GCLOUD: at org.eclipse.jetty.server.Request.startAsync(Request.java:2262)
[INFO] GCLOUD: at javax.servlet.ServletRequestWrapper.startAsync(ServletRequestWrapper.java:464)
[INFO] GCLOUD: at <my-servlet>.doPost
[INFO] GCLOUD: at javax.servlet.http.HttpServlet.service(HttpServlet.java:707)
[INFO] GCLOUD: at javax.servlet.http.HttpServlet.service(HttpServlet.java:790)
[INFO] GCLOUD: at org.eclipse.jetty.servlet.ServletHolder.handle(ServletHolder.java:848)
[INFO] GCLOUD: at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1772)
[INFO] GCLOUD: at com.google.appengine.api.socket.dev.DevSocketFilter.doFilter(DevSocketFilter.java:74)
[INFO] GCLOUD: at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1759)
[INFO] GCLOUD: at com.google.appengine.tools.development.ResponseRewriterFilter.doFilter(ResponseRewriterFilter.java:134)
[INFO] GCLOUD: at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1759)
[INFO] GCLOUD: at com.google.appengine.tools.development.HeaderVerificationFilter.doFilter(HeaderVerificationFilter.java:34)
[INFO] GCLOUD: at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1759)
[INFO] GCLOUD: at com.google.appengine.api.blobstore.dev.ServeBlobFilter.doFilter(ServeBlobFilter.java:63)
[INFO] GCLOUD: at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1759)
[INFO] GCLOUD: at com.google.apphosting.utils.servlet.TransactionCleanupFilter.doFilter(TransactionCleanupFilter.java:48)
[INFO] GCLOUD: at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1759)
[INFO] GCLOUD: at com.google.appengine.tools.development.jetty9.StaticFileFilter.doFilter(StaticFileFilter.java:122)
[INFO] GCLOUD: at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1759)
[INFO] GCLOUD: at com.google.appengine.tools.development.DevAppServerModulesFilter.doDirectRequest(DevAppServerModulesFilter.java:366)
[INFO] GCLOUD: at com.google.appengine.tools.development.DevAppServerModulesFilter.doDirectModuleRequest(DevAppServerModulesFilter.java:349)
[INFO] GCLOUD: at com.google.appengine.tools.development.DevAppServerModulesFilter.doFilter(DevAppServerModulesFilter.java:116)
[INFO] GCLOUD: at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1751)
[INFO] GCLOUD: at org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:582)
[INFO] GCLOUD: at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:143)
[INFO] GCLOUD: at org.eclipse.jetty.security.SecurityHandler.handle(SecurityHandler.java:524)
[INFO] GCLOUD: at org.eclipse.jetty.server.session.SessionHandler.doHandle(SessionHandler.java:226)
[INFO] GCLOUD: at org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1180)
[INFO] GCLOUD: at org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:512)
[INFO] GCLOUD: at org.eclipse.jetty.server.session.SessionHandler.doScope(SessionHandler.java:185)
[INFO] GCLOUD: at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:1112)
[INFO] GCLOUD: at com.google.appengine.tools.development.jetty9.DevAppEngineWebAppContext.doScope(DevAppEngineWebAppContext.java:94)
[INFO] GCLOUD: at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:141)
[INFO] GCLOUD: at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:134)
[INFO] GCLOUD: at com.google.appengine.tools.development.jetty9.JettyContainerService$ApiProxyHandler.handle(JettyContainerService.java:597)
[INFO] GCLOUD: at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:134)
[INFO] GCLOUD: at org.eclipse.jetty.server.Server.handle(Server.java:534)
[INFO] GCLOUD: at org.eclipse.jetty.server.HttpChannel.handle(HttpChannel.java:320)
[INFO] GCLOUD: at org.eclipse.jetty.server.HttpConnection.onFillable(HttpConnection.java:251)
[INFO] GCLOUD: at org.eclipse.jetty.io.AbstractConnection$ReadCallback.succeeded(AbstractConnection.java:283)
[INFO] GCLOUD: at org.eclipse.jetty.io.FillInterest.fillable(FillInterest.java:108)
[INFO] GCLOUD: at org.eclipse.jetty.io.SelectChannelEndPoint$2.run(SelectChannelEndPoint.java:93)
[INFO] GCLOUD: at org.eclipse.jetty.util.thread.strategy.ExecuteProduceConsume.executeProduceConsume(ExecuteProduceConsume.java:303)
[INFO] GCLOUD: at org.eclipse.jetty.util.thread.strategy.ExecuteProduceConsume.produceConsume(ExecuteProduceConsume.java:148)
[INFO] GCLOUD: at org.eclipse.jetty.util.thread.strategy.ExecuteProduceConsume.run(ExecuteProduceConsume.java:136)
[INFO] GCLOUD: at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:671)
[INFO] GCLOUD: at org.eclipse.jetty.util.thread.QueuedThreadPool$2.run(QueuedThreadPool.java:589)
[INFO] GCLOUD: at java.lang.Thread.run(Thread.java:745)
Once the app is deployed to cloud, the error is:
java.lang.IllegalStateException: !asyncSupported: unknown
at org.eclipse.jetty.server.Request.startAsync (Request.java:2262)
at <my-servlet>.doPost
at javax.servlet.http.HttpServlet.service (HttpServlet.java:707)
at javax.servlet.http.HttpServlet.service (HttpServlet.java:790)
at org.eclipse.jetty.servlet.ServletHolder.handle (ServletHolder.java:848)
at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter (ServletHandler.java:1772)
at com.google.apphosting.utils.servlet.ParseBlobUploadFilter.doFilter (ParseBlobUploadFilter.java:125)
at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter (ServletHandler.java:1759)
at com.google.apphosting.runtime.jetty9.SaveSessionFilter.doFilter (SaveSessionFilter.java:37)
at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter (ServletHandler.java:1759)
at com.google.apphosting.utils.servlet.JdbcMySqlConnectionCleanupFilter.doFilter (JdbcMySqlConnectionCleanupFilter.java:60)
at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter (ServletHandler.java:1759)
at com.google.apphosting.utils.servlet.TransactionCleanupFilter.doFilter (TransactionCleanupFilter.java:48)
at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter (ServletHandler.java:1759)
at org.eclipse.jetty.servlet.ServletHandler.doHandle (ServletHandler.java:582)
at org.eclipse.jetty.server.handler.ScopedHandler.handle (ScopedHandler.java:143)
at org.eclipse.jetty.security.SecurityHandler.handle (SecurityHandler.java:524)
at org.eclipse.jetty.server.session.SessionHandler.doHandle (SessionHandler.java:226)
at org.eclipse.jetty.server.handler.ContextHandler.doHandle (ContextHandler.java:1180)
at org.eclipse.jetty.servlet.ServletHandler.doScope (ServletHandler.java:512)
at org.eclipse.jetty.server.session.SessionHandler.doScope (SessionHandler.java:185)
at org.eclipse.jetty.server.handler.ContextHandler.doScope (ContextHandler.java:1112)
at org.eclipse.jetty.server.handler.ScopedHandler.handle (ScopedHandler.java:141)
at com.google.apphosting.runtime.jetty9.AppVersionHandlerMap.handle (AppVersionHandlerMap.java:297)
at org.eclipse.jetty.server.handler.HandlerWrapper.handle (HandlerWrapper.java:134)
at org.eclipse.jetty.server.Server.handle (Server.java:534)
at org.eclipse.jetty.server.HttpChannel.handle (HttpChannel.java:320)
at com.google.apphosting.runtime.jetty9.RpcConnection.handle (RpcConnection.java:219)
at com.google.apphosting.runtime.jetty9.RpcConnector.serviceRequest (RpcConnector.java:81)
at com.google.apphosting.runtime.jetty9.JettyServletEngineAdapter.serviceRequest (JettyServletEngineAdapter.java:108)
at com.google.apphosting.runtime.JavaRuntime$RequestRunnable.dispatchServletRequest (JavaRuntime.java:657)
at com.google.apphosting.runtime.JavaRuntime$RequestRunnable.dispatchRequest (JavaRuntime.java:619)
at com.google.apphosting.runtime.JavaRuntime$RequestRunnable.run (JavaRuntime.java:589)
at com.google.apphosting.runtime.JavaRuntime$NullSandboxRequestRunnable.run (JavaRuntime.java:783)
at com.google.apphosting.runtime.ThreadGroupPool$PoolEntry.run (ThreadGroupPool.java:263)
at java.lang.Thread.run (Thread.java:745)
Have I missed something?
Thank you!
According to https://cloud.google.com/appengine/docs/standard/java/release-notes#june_28_2017, async servlet 3.1 is not supported.
I created a feature request on Google's public issue tracker, hope the App Engine team can implement this.
I am using google-endpoint V2 on app engine standard, with firebase authentication.
When deploying locally, the server starts and runs fine. When a query is issued to access one of the endpointV2, I get an inconsistent behavior:
it works well for a bit (the endpoint returns with the expected payload), but sometimes gets stuck trying to contact https://servicecontrol.googleapis.com/v1/services/my-project-id.appspot.com:check.
It takes about a minute to timeout, then the next query may timeout or return properly...
Any idea of how to resolve that would be appreciated!
The logs in the devserver, for a failed query:
[INFO] GCLOUD: failed because of java.net.SocketTimeoutException: Timeout while fetching: https://servicecontrol.googleapis.com/v1/services/my-project-id.appspot.com:check
[INFO] GCLOUD: Aug 02, 2017 12:27:06 AM com.google.api.control.Client check
[INFO] GCLOUD: SEVERE: direct send of a check request service_name: "my-project-id.appspot.com"
[INFO] GCLOUD: operation {
[INFO] GCLOUD: operation_id: "7453fb02-56e3-48ec-856c-e25d09ccc792"
[INFO] GCLOUD: operation_name: "1.recipes_groceries_appspot_com.ApiadminPop"
[INFO] GCLOUD: consumer_id: "project:my-project-id"
[INFO] GCLOUD: start_time {
[INFO] GCLOUD: seconds: 1501658786
[INFO] GCLOUD: nanos: 76000000
[INFO] GCLOUD: }
[INFO] GCLOUD: end_time {
[INFO] GCLOUD: seconds: 1501658786
[INFO] GCLOUD: nanos: 76000000
[INFO] GCLOUD: }
[INFO] GCLOUD: labels {
[INFO] GCLOUD: key: "servicecontrol.googleapis.com/referer"
[INFO] GCLOUD: value: "http://localhost:4200/_ah/api/static/proxy.html?jsh=m%3B%2F_%2Fscs%2Fapps-static%2F_%2Fjs%2Fk%3Doz.gapi.en.4KxLsUEUJCA.O%2Fm%3D__features__%2Fam%3DAQ%2Frt%3Dj%2Fd%3D1%2Frs%3DAGLTcCOh765ksalVtUgJb_uys4PUTu6HZA"
[INFO] GCLOUD: }
[INFO] GCLOUD: labels {
[INFO] GCLOUD: key: "servicecontrol.googleapis.com/caller_ip"
[INFO] GCLOUD: value: "127.0.0.1"
[INFO] GCLOUD: }
[INFO] GCLOUD: labels {
[INFO] GCLOUD: key: "servicecontrol.googleapis.com/user_agent"
[INFO] GCLOUD: value: "ESP"
[INFO] GCLOUD: }
[INFO] GCLOUD: labels {
[INFO] GCLOUD: key: "servicecontrol.googleapis.com/service_agent"
[INFO] GCLOUD: value: "EF_JAVA/1.0.4"
[INFO] GCLOUD: }
[INFO] GCLOUD: }
[INFO] GCLOUD: failed because of java.net.SocketTimeoutException: Timeout while fetching: https://servicecontrol.googleapis.com/v1/services/my-project-id.appspot.com:check
[INFO] GCLOUD: Aug 02, 2017 12:27:06 AM com.google.api.control.ControlFilter doFilter
[INFO] GCLOUD: WARNING: the check did not succeed; the response null
[INFO] GCLOUD: Aug 02, 2017 12:27:06 AM com.google.api.server.spi.auth.GoogleAppEngineAuthenticator authenticate
[INFO] GCLOUD: INFO: appEngineUser = example#example.com
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)}
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